1
0
Fork 0

For #7730 - always show "Add private browsing shortcut" in sett… (#7943)

master
Sören Hentzschel 2020-01-27 17:44:28 +01:00 committed by Tiger Oakes
parent 154e11841a
commit 8a7c7fd06f
3 changed files with 2 additions and 22 deletions

View File

@ -14,26 +14,12 @@ import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.home.intent.StartSearchIntentProcessor
import java.util.UUID
import android.content.pm.ShortcutManager
import android.os.Build
import android.os.Build.VERSION.SDK_INT
/**
* Handles the creation and existence of pinned shortcuts.
* Handles the creation of pinned shortcuts.
*/
object PrivateShortcutCreateManager {
fun doesPrivateBrowsingPinnedShortcutExist(context: Context): Boolean {
return if (SDK_INT >= Build.VERSION_CODES.N_MR1) {
val pinnedShortcuts = context.getSystemService(ShortcutManager::class.java).pinnedShortcuts
pinnedShortcuts.any {
it.intent?.extras?.getString(HomeActivity.OPEN_TO_SEARCH) ==
StartSearchIntentProcessor.PRIVATE_BROWSING_PINNED_SHORTCUT
}
} else
false
}
fun createPrivateShortcut(context: Context) {
if (!ShortcutManagerCompat.isRequestPinShortcutSupported(context)) return

View File

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

View File

@ -173,11 +173,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
}
}
findPreference<Preference>(getPreferenceKey(pref_key_add_private_browsing_shortcut))?.apply {
isVisible =
!PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(context)
}
setupPreferences()
updateAccountUIState(