Skip to content

Commit

Permalink
Merge pull request #241 from WideChat/ear_settings_fix
Browse files Browse the repository at this point in the history
Fix 'Preferences' and 'About' click listeners when in spanish
  • Loading branch information
ear-dev authored Feb 14, 2019
2 parents fa6c14a + a6e218b commit 64efacd
Showing 1 changed file with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ class SettingsFragment : Fragment(), SettingsView, AdapterView.OnItemClickListen
}

override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
if (Constants.WIDECHAT) {
widechatOnItemClick(parent, view, position, id)
} else {
rocketChatOnItemClick(parent, view, position, id)
}
}

private fun rocketChatOnItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
when (parent?.getItemAtPosition(position).toString()) {
resources.getStringArray(R.array.settings_actions)[0] -> {
(activity as AppCompatActivity).addFragmentBackStack(
Expand Down Expand Up @@ -114,13 +122,35 @@ class SettingsFragment : Fragment(), SettingsView, AdapterView.OnItemClickListen
AboutFragment.newInstance()
}
}
// WIDECHAT
resources.getString(R.string.log_out) -> {
showLogoutDialog()
}
}
}

private fun widechatOnItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
when (parent?.getItemAtPosition(position).toString()) {
resources.getStringArray(R.array.widechat_settings_actions)[0] -> {
(activity as AppCompatActivity).addFragmentBackStack(
TAG_PREFERENCES_FRAGMENT,
R.id.fragment_container
) {
PreferencesFragment.newInstance()
}
}

resources.getStringArray(R.array.widechat_settings_actions)[1] -> {
(activity as AppCompatActivity).addFragmentBackStack(
TAG_ABOUT_FRAGMENT,
R.id.fragment_container
) {
AboutFragment.newInstance()
}
}

resources.getStringArray(R.array.widechat_settings_actions)[2] -> {
showLogoutDialog()
}
}
}

private fun showLogoutDialog() {
context?.let {
AlertDialog.Builder(it)
Expand Down

0 comments on commit 64efacd

Please sign in to comment.