Skip to content

Commit

Permalink
Design review: open AppIconDialog after clicking on "Take me there"
Browse files Browse the repository at this point in the history
  • Loading branch information
cooltey committed Nov 14, 2024
1 parent 912d515 commit 2cf85a1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
7 changes: 4 additions & 3 deletions app/src/main/java/org/wikipedia/settings/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SettingsActivity : SingleFragmentActivity<SettingsFragment>() {
private val app = WikipediaApp.instance

public override fun createFragment(): SettingsFragment {
return SettingsFragment.newInstance()
return SettingsFragment.newInstance(intent.getBooleanExtra(Constants.ARG_BOOLEAN, false))
}

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -42,8 +42,9 @@ class SettingsActivity : SingleFragmentActivity<SettingsFragment>() {
const val ACTIVITY_RESULT_FEED_CONFIGURATION_CHANGED = 2
const val ACTIVITY_RESULT_LOG_OUT = 3

fun newIntent(ctx: Context): Intent {
return Intent(ctx, SettingsActivity::class.java)
fun newIntent(ctx: Context, showAppIconDialog: Boolean = false): Intent {
return Intent(ctx, SettingsActivity::class.java).
putExtra(Constants.ARG_BOOLEAN, showAppIconDialog)
}
}
}
11 changes: 9 additions & 2 deletions app/src/main/java/org/wikipedia/settings/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import androidx.core.os.bundleOf
import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.preference.SwitchPreferenceCompat
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import org.wikipedia.Constants
import org.wikipedia.R
import org.wikipedia.concurrency.FlowEventBus
import org.wikipedia.events.ReadingListsEnableSyncStatusEvent
Expand Down Expand Up @@ -51,6 +53,9 @@ class SettingsFragment : PreferenceLoaderFragment(), MenuProvider {
override fun loadPreferences() {
preferenceLoader = SettingsPreferenceLoader(this)
preferenceLoader.loadPreferences()
if (requireArguments().getBoolean(Constants.ARG_BOOLEAN, false)) {
preferenceLoader.showAppIconDialog()
}
}

override fun onResume() {
Expand Down Expand Up @@ -96,8 +101,10 @@ class SettingsFragment : PreferenceLoaderFragment(), MenuProvider {
}

companion object {
fun newInstance(): SettingsFragment {
return SettingsFragment()
fun newInstance(showAppIconDialog: Boolean = false): SettingsFragment {
return SettingsFragment().apply {
arguments = bundleOf(Constants.ARG_BOOLEAN to showAppIconDialog)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ internal class SettingsPreferenceLoader(fragment: PreferenceFragmentCompat) : Ba
}
}

if (ContributionsDashboardHelper.contributionsDashboardEnabled && DonorStatus.donorStatus() == DonorStatus.DONOR) {
findPreference(R.string.preference_key_app_icon).onPreferenceClickListener = Preference.OnPreferenceClickListener {
ExclusiveBottomSheetPresenter.show(fragment.parentFragmentManager, AppIconDialog.newInstance())
true
}
} else {
findPreference(R.string.preference_key_app_icon).isVisible = false
findPreference(R.string.preference_key_app_icon).isVisible = shouldShowAppIconPreference

findPreference(R.string.preference_key_app_icon).onPreferenceClickListener = Preference.OnPreferenceClickListener {
showAppIconDialog()
true
}

findPreference(R.string.preference_key_about_wikipedia_app).onPreferenceClickListener = Preference.OnPreferenceClickListener {
Expand All @@ -84,6 +82,14 @@ internal class SettingsPreferenceLoader(fragment: PreferenceFragmentCompat) : Ba
return "\n\nVersion: ${BuildConfig.VERSION_NAME} \nDevice: ${Build.BRAND} ${Build.MODEL} (SDK: ${Build.VERSION.SDK_INT})\n"
}

private val shouldShowAppIconPreference get() = ContributionsDashboardHelper.contributionsDashboardEnabled && DonorStatus.donorStatus() == DonorStatus.DONOR

fun showAppIconDialog() {
if (shouldShowAppIconPreference) {
ExclusiveBottomSheetPresenter.show(fragment.parentFragmentManager, AppIconDialog.newInstance())
}
}

fun updateLanguagePrefSummary() {
// TODO: resolve RTL vs LTR with multiple languages (e.g. list contains English and Hebrew)
findPreference(R.string.preference_key_language).summary = WikipediaApp.instance.languageState.appLanguageLocalizedNames
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class ContributionsDashboardHelper {
return surveyUrls[WikipediaApp.instance.languageState.appLanguageCode].orEmpty()
}

// Temporarily value for different access from either entry dialogs, overflow menu or the contribute tab.
var shouldShowDonorHistorySnackbar = false

var shouldShowThankYouDialog = false
Expand Down Expand Up @@ -74,7 +73,7 @@ class ContributionsDashboardHelper {
.setMessage(R.string.contributions_dashboard_donor_icon_dialog_message)
.setIcon(R.drawable.ic_heart_24)
.setPositiveButton(R.string.contributions_dashboard_donor_icon_dialog_ok) { _, _ ->
context.startActivity(SettingsActivity.newIntent(context))
context.startActivity(SettingsActivity.newIntent(context, showAppIconDialog = true))
}
.setNegativeButton(R.string.contributions_dashboard_donor_icon_dialog_cancel, null)
.show()
Expand Down

0 comments on commit 2cf85a1

Please sign in to comment.