@@ -57,7 +57,7 @@ class SettingsFragment(private val mActivity: AppCompatActivity) :
5757 5 -> {
5858 // Open the GitHub repository in a browser when "Git Repo" is selected
5959 val uri: Uri =
60- Uri .parse(Constants .gitRepo ) // missing 'http://' will cause crashed
60+ Uri .parse(Constants .GIT_REPO_LINK ) // missing 'http://' will cause crashed
6161
6262 val intent = Intent (Intent .ACTION_VIEW , uri)
6363 startActivity(intent)
@@ -84,6 +84,17 @@ class SettingsFragment(private val mActivity: AppCompatActivity) :
8484 binding.logoutBtn.setOnClickListener { openLogoutDialog() }
8585 }
8686
87+
88+ /* *
89+ Opens the logout dialog.
90+ The dialog is created using a custom Dialog class and inflated with the logout_dialog.xml layout.
91+ The layout parameters are set to match the parent view.
92+ The dialog is set to be non-cancelable to prevent dismissing it by clicking outside.
93+ Click listeners are set for the "Logout" button, "Cancel" button, and "Close" button.
94+ When the "Logout" button is clicked, the user preferences are cleared, and the user is redirected to the LoginActivity.
95+ The finishAffinity() method is called to finish all activities in the current task.
96+ When the "Cancel" or "Close" button is clicked, the dialog is dismissed.
97+ */
8798 private fun openLogoutDialog () {
8899 // Create and show the logout dialog
89100 val logoutDialog = Dialog (mActivity)
@@ -104,6 +115,15 @@ class SettingsFragment(private val mActivity: AppCompatActivity) :
104115 logoutDialog.show()
105116 }
106117
118+
119+ /* *
120+ Adds data to the menu list in the drawer.
121+ The existing drawerItemList is cleared.
122+ DrawerMenu objects representing the menu items are created and added to the drawerItemList.
123+ Each menu item consists of a title, subtitle, and icon.
124+ The titles and icons are retrieved from resources using string resource IDs and drawable resource IDs.
125+ The subtitle for the "Change Language" menu item is dynamically set based on the language code stored in preferences.
126+ */
107127 private fun addDataInMenu () {
108128 drawerItemList.clear()
109129 drawerItemList.add(
@@ -151,6 +171,13 @@ class SettingsFragment(private val mActivity: AppCompatActivity) :
151171 drawerItemList.add(DrawerMenu (resources.getString(R .string.more), " " , R .drawable.ic_more))
152172 }
153173
174+ /* *
175+ Refreshes the drawer menu.
176+ Resets the isChangeLanguageSelected flag to false.
177+ Adds data to the menu items in the drawer.
178+ Notifies the drawerAdapter that the data set has changed.
179+ Updates the text of the logout, deactivate, and delete account TextViews with the corresponding string resources.
180+ */
154181 private fun refreshDrawer () {
155182 isChangeLanguageSelected = false
156183 addDataInMenu()
0 commit comments