parent
154e11841a
commit
8a7c7fd06f
|
@ -14,26 +14,12 @@ import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.home.intent.StartSearchIntentProcessor
|
import org.mozilla.fenix.home.intent.StartSearchIntentProcessor
|
||||||
import java.util.UUID
|
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 {
|
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) {
|
fun createPrivateShortcut(context: Context) {
|
||||||
if (!ShortcutManagerCompat.isRequestPinShortcutSupported(context)) return
|
if (!ShortcutManagerCompat.isRequestPinShortcutSupported(context)) return
|
||||||
|
|
||||||
|
|
|
@ -340,8 +340,7 @@ class HomeFragment : Fragment() {
|
||||||
}, owner = this)
|
}, owner = this)
|
||||||
|
|
||||||
if (context.settings().showPrivateModeContextualFeatureRecommender &&
|
if (context.settings().showPrivateModeContextualFeatureRecommender &&
|
||||||
browsingModeManager.mode.isPrivate &&
|
browsingModeManager.mode.isPrivate) {
|
||||||
!PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(context)) {
|
|
||||||
recommendPrivateBrowsingShortcut()
|
recommendPrivateBrowsingShortcut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,11 +173,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
findPreference<Preference>(getPreferenceKey(pref_key_add_private_browsing_shortcut))?.apply {
|
|
||||||
isVisible =
|
|
||||||
!PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
setupPreferences()
|
setupPreferences()
|
||||||
|
|
||||||
updateAccountUIState(
|
updateAccountUIState(
|
||||||
|
|
Loading…
Reference in New Issue