diff --git a/app/src/main/java/org/wikipedia/settings/SettingsActivity.kt b/app/src/main/java/org/wikipedia/settings/SettingsActivity.kt index 8bec26e0b44..90071313e09 100644 --- a/app/src/main/java/org/wikipedia/settings/SettingsActivity.kt +++ b/app/src/main/java/org/wikipedia/settings/SettingsActivity.kt @@ -15,7 +15,7 @@ class SettingsActivity : SingleFragmentActivity() { 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?) { @@ -42,8 +42,9 @@ class SettingsActivity : SingleFragmentActivity() { 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) } } } diff --git a/app/src/main/java/org/wikipedia/settings/SettingsFragment.kt b/app/src/main/java/org/wikipedia/settings/SettingsFragment.kt index da129a86650..5abacc629fb 100644 --- a/app/src/main/java/org/wikipedia/settings/SettingsFragment.kt +++ b/app/src/main/java/org/wikipedia/settings/SettingsFragment.kt @@ -5,6 +5,7 @@ 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 @@ -12,6 +13,7 @@ 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 @@ -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() { @@ -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) + } } } } diff --git a/app/src/main/java/org/wikipedia/settings/SettingsPreferenceLoader.kt b/app/src/main/java/org/wikipedia/settings/SettingsPreferenceLoader.kt index 55e454f866f..b0980b3c602 100644 --- a/app/src/main/java/org/wikipedia/settings/SettingsPreferenceLoader.kt +++ b/app/src/main/java/org/wikipedia/settings/SettingsPreferenceLoader.kt @@ -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 { @@ -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 diff --git a/app/src/main/java/org/wikipedia/usercontrib/ContributionsDashboardHelper.kt b/app/src/main/java/org/wikipedia/usercontrib/ContributionsDashboardHelper.kt index f0d07324c3c..d43ab93afda 100644 --- a/app/src/main/java/org/wikipedia/usercontrib/ContributionsDashboardHelper.kt +++ b/app/src/main/java/org/wikipedia/usercontrib/ContributionsDashboardHelper.kt @@ -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 @@ -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()