Issue #5233: Minor modifications suggested in code review.
This commit is contained in:
parent
7ec714552f
commit
052695ffa1
|
@ -23,13 +23,15 @@ import android.os.Build.VERSION.SDK_INT
|
|||
*/
|
||||
object PrivateShortcutCreateManager {
|
||||
|
||||
fun doesPrivateBrowsingPinnedShortcutExist(context: Context) : Boolean {
|
||||
fun doesPrivateBrowsingPinnedShortcutExist(context: Context): Boolean {
|
||||
return if (SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
val pinnedShortcuts = context.getSystemService(ShortcutManager::class.java).pinnedShortcuts
|
||||
for (s in pinnedShortcuts) {
|
||||
if (s.intent?.extras?.getString(HomeActivity.OPEN_TO_SEARCH) ==
|
||||
StartSearchIntentProcessor.PRIVATE_BROWSING_PINNED_SHORTCUT) {
|
||||
return true
|
||||
if (pinnedShortcuts.any()) {
|
||||
for (s in pinnedShortcuts) {
|
||||
if (s.intent?.extras?.getString(HomeActivity.OPEN_TO_SEARCH) ==
|
||||
StartSearchIntentProcessor.PRIVATE_BROWSING_PINNED_SHORTCUT) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
|
|
|
@ -349,7 +349,8 @@ class HomeFragment : Fragment() {
|
|||
}, owner = this)
|
||||
|
||||
if (context.settings().showPrivateModeContextualFeatureRecommender &&
|
||||
browsingModeManager.mode.isPrivate && !PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(requireContext())) {
|
||||
browsingModeManager.mode.isPrivate &&
|
||||
!PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(context)) {
|
||||
recommendPrivateBrowsingShortcut()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ class SettingsFragment : PreferenceFragmentCompat(), AccountObserver {
|
|||
}
|
||||
|
||||
findPreference<Preference>(getPreferenceKey(R.string.pref_key_add_private_browsing_shortcut))?.apply {
|
||||
isVisible = !PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(requireContext())
|
||||
isVisible = !PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(context)
|
||||
}
|
||||
|
||||
setupPreferences()
|
||||
|
|
Loading…
Reference in New Issue
Block a user