1
0
Fork 0

Issue #5233: Minor modifications suggested in code review.

master
bswe 2019-10-10 14:26:34 -07:00
parent 7ec714552f
commit 052695ffa1
3 changed files with 10 additions and 7 deletions

View File

@ -23,13 +23,15 @@ import android.os.Build.VERSION.SDK_INT
*/ */
object PrivateShortcutCreateManager { object PrivateShortcutCreateManager {
fun doesPrivateBrowsingPinnedShortcutExist(context: Context) : Boolean { fun doesPrivateBrowsingPinnedShortcutExist(context: Context): Boolean {
return if (SDK_INT >= Build.VERSION_CODES.N_MR1) { return if (SDK_INT >= Build.VERSION_CODES.N_MR1) {
val pinnedShortcuts = context.getSystemService(ShortcutManager::class.java).pinnedShortcuts val pinnedShortcuts = context.getSystemService(ShortcutManager::class.java).pinnedShortcuts
for (s in pinnedShortcuts) { if (pinnedShortcuts.any()) {
if (s.intent?.extras?.getString(HomeActivity.OPEN_TO_SEARCH) == for (s in pinnedShortcuts) {
StartSearchIntentProcessor.PRIVATE_BROWSING_PINNED_SHORTCUT) { if (s.intent?.extras?.getString(HomeActivity.OPEN_TO_SEARCH) ==
return true StartSearchIntentProcessor.PRIVATE_BROWSING_PINNED_SHORTCUT) {
return true
}
} }
} }
false false

View File

@ -349,7 +349,8 @@ class HomeFragment : Fragment() {
}, owner = this) }, owner = this)
if (context.settings().showPrivateModeContextualFeatureRecommender && if (context.settings().showPrivateModeContextualFeatureRecommender &&
browsingModeManager.mode.isPrivate && !PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(requireContext())) { browsingModeManager.mode.isPrivate &&
!PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(context)) {
recommendPrivateBrowsingShortcut() recommendPrivateBrowsingShortcut()
} }
} }

View File

@ -133,7 +133,7 @@ class SettingsFragment : PreferenceFragmentCompat(), AccountObserver {
} }
findPreference<Preference>(getPreferenceKey(R.string.pref_key_add_private_browsing_shortcut))?.apply { findPreference<Preference>(getPreferenceKey(R.string.pref_key_add_private_browsing_shortcut))?.apply {
isVisible = !PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(requireContext()) isVisible = !PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(context)
} }
setupPreferences() setupPreferences()