Issue #5233: Minor modifications suggested in code review.
parent
7ec714552f
commit
052695ffa1
|
@ -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
|
||||||
|
|
|
@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue