本文整理汇总了Java中org.chromium.chrome.browser.preferences.ChromePreferenceManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ChromePreferenceManager.getInstance方法的具体用法?Java ChromePreferenceManager.getInstance怎么用?Java ChromePreferenceManager.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.chromium.chrome.browser.preferences.ChromePreferenceManager
的用法示例。
在下文中一共展示了ChromePreferenceManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: launchSigninPromoIfNeeded
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* Launches the signin promo if it needs to be displayed.
* @param activity The parent activity.
* @return Whether the signin promo is shown.
*/
public static boolean launchSigninPromoIfNeeded(final Activity activity) {
// The promo is displayed if Chrome is launched directly (i.e., not with the intent to
// navigate to and view a URL on startup), the instance is part of the field trial,
// and the promo has been marked to display.
ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance(activity);
if (MultiWindowUtils.getInstance().isLegacyMultiWindow(activity)) return false;
if (!preferenceManager.getShowSigninPromo()) return false;
preferenceManager.setShowSigninPromo(false);
String lastSyncName = PrefServiceBridge.getInstance().getSyncLastAccountName();
if (ChromeSigninController.get(activity).isSignedIn() || !TextUtils.isEmpty(lastSyncName)) {
return false;
}
AccountSigninActivity.startIfAllowed(activity, SigninAccessPoint.SIGNIN_PROMO);
preferenceManager.setSigninPromoShown();
return true;
}
示例2: onSnippetBound
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* To be triggered when a snippet is bound to a ViewHolder.
*/
public void onSnippetBound(View cardView) {
// We only run if the feature is enabled and once per NTP.
if (!SnippetsConfig.isIncreasedCardVisibilityEnabled() || mFirstCardAnimationRun) return;
mFirstCardAnimationRun = true;
// We only want an animation to run if we are not scrolled.
if (computeVerticalScrollOffset() != 0) return;
// We only show the animation a certain number of times to a user.
ChromePreferenceManager manager = ChromePreferenceManager.getInstance(getContext());
int animCount = manager.getNewTabPageFirstCardAnimationRunCount();
if (animCount > CardsVariationParameters.getFirstCardAnimationMaxRuns()) return;
manager.setNewTabPageFirstCardAnimationRunCount(animCount + 1);
// We do not show the animation if the user has previously seen it then scrolled.
if (manager.getCardsImpressionAfterAnimation()) return;
// The peeking card bounces up twice from its position.
ObjectAnimator animator = ObjectAnimator.ofFloat(cardView, View.TRANSLATION_Y,
0f, -mPeekingCardBounceDistance, 0f, -mPeekingCardBounceDistance, 0f);
animator.setStartDelay(PEEKING_CARD_ANIMATION_START_DELAY_MS);
animator.setDuration(PEEKING_CARD_ANIMATION_TIME_MS);
animator.setInterpolator(PEEKING_CARD_INTERPOLATOR);
animator.start();
}
示例3: cacheEnabledStateForNextLaunch
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* Once native is loaded we can consult the command-line (set via about:flags) and also finch
* state to see if we should enable WebAPKs.
*/
public static void cacheEnabledStateForNextLaunch() {
ChromePreferenceManager preferenceManager =
ChromePreferenceManager.getInstance(ContextUtils.getApplicationContext());
boolean wasCommandLineEnabled = preferenceManager.getCachedWebApkCommandLineEnabled();
boolean isCommandLineEnabled = isCommandLineFlagSet();
if (isCommandLineEnabled != wasCommandLineEnabled) {
// {@link launchWebApkRequirementsDialogIfNeeded()} is skipped the first time Chrome is
// launched so do caching here instead.
preferenceManager.setCachedWebApkCommandLineEnabled(isCommandLineEnabled);
}
boolean wasEnabled = isEnabledInPrefs();
boolean isEnabled = computeEnabled();
if (isEnabled != wasEnabled) {
Log.d(TAG, "WebApk setting changed (%s => %s)", wasEnabled, isEnabled);
preferenceManager.setCachedWebApkRuntimeEnabled(isEnabled);
}
}
示例4: cacheChromeHomeEnabled
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* Cache whether or not Chrome Home is enabled.
*/
public static void cacheChromeHomeEnabled() {
Context context = ContextUtils.getApplicationContext();
// Chrome Home doesn't work with tablets.
if (DeviceFormFactor.isTablet(context)) return;
boolean isChromeHomeEnabled = ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME);
ChromePreferenceManager manager = ChromePreferenceManager.getInstance(context);
boolean valueChanged = isChromeHomeEnabled != manager.isChromeHomeEnabled();
manager.setChromeHomeEnabled(isChromeHomeEnabled);
sChromeHomeEnabled = isChromeHomeEnabled;
// If the cached value changed, restart chrome.
if (valueChanged) ApplicationLifetime.terminate(true);
}
示例5: launchSigninPromoIfNeeded
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* Launches the signin promo if it needs to be displayed.
* @param activity The parent activity.
* @return Whether the signin promo is shown.
*/
public static boolean launchSigninPromoIfNeeded(final Activity activity) {
// The promo is displayed if Chrome is launched directly (i.e., not with the intent to
// navigate to and view a URL on startup), the instance is part of the field trial,
// and the promo has been marked to display.
ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance(activity);
if (MultiWindowUtils.getInstance().isMultiWindow(activity)) return false;
if (!preferenceManager.getShowSigninPromo()) return false;
preferenceManager.setShowSigninPromo(false);
String lastSyncName = PrefServiceBridge.getInstance().getSyncLastAccountName();
if (SigninManager.getAndroidSigninPromoExperimentGroup() < 0
|| ChromeSigninController.get(activity).isSignedIn()
|| !TextUtils.isEmpty(lastSyncName)) {
return false;
}
SigninPromoScreen promoScreen = new SigninPromoScreen(activity);
promoScreen.show();
preferenceManager.setSigninPromoShown();
return true;
}
示例6: launchSigninPromoIfNeeded
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* Launches the signin promo if it needs to be displayed.
* @param activity The parent activity.
* @return Whether the signin promo is shown.
*/
public static boolean launchSigninPromoIfNeeded(final Activity activity) {
// The promo is displayed if Chrome is launched directly (i.e., not with the intent to
// navigate to and view a URL on startup), the instance is part of the field trial,
// and the promo has been marked to display.
ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance();
if (MultiWindowUtils.getInstance().isLegacyMultiWindow(activity)) return false;
if (!preferenceManager.getShowSigninPromo()) return false;
preferenceManager.setShowSigninPromo(false);
String lastSyncName = PrefServiceBridge.getInstance().getSyncLastAccountName();
if (ChromeSigninController.get().isSignedIn() || !TextUtils.isEmpty(lastSyncName)) {
return false;
}
AccountSigninActivity.startIfAllowed(activity, SigninAccessPoint.SIGNIN_PROMO);
preferenceManager.setSigninPromoShown();
return true;
}
示例7: ContextualSearchPolicy
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* @param context The Android Context.
*/
public ContextualSearchPolicy(Context context,
ContextualSearchSelectionController selectionController,
ContextualSearchNetworkCommunicator networkCommunicator) {
mPreferenceManager = ChromePreferenceManager.getInstance(context);
mSelectionController = selectionController;
mNetworkCommunicator = networkCommunicator;
}
示例8: CtrSuppression
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* Constructs an object that tracks impressions and clicks per user to produce CTR and
* impression metrics.
* @param context An Android Context.
*/
CtrSuppression(Context context) {
mPreferenceManager = ChromePreferenceManager.getInstance(context);
// This needs to be done last in this constructor because the native code may call
// into this object.
mNativePointer = nativeInit();
}
示例9: isChromeHomeEnabled
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* @return Whether or not chrome should attach the toolbar to the bottom of the screen.
*/
public static boolean isChromeHomeEnabled() {
if (sChromeHomeEnabled == null) {
ChromePreferenceManager manager =
ChromePreferenceManager.getInstance(ContextUtils.getApplicationContext());
sChromeHomeEnabled = manager.isChromeHomeEnabled();
}
return sChromeHomeEnabled;
}
示例10: ContextualSearchPolicy
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* ContextualSearchPolicy constructor.
*/
public ContextualSearchPolicy(ContextualSearchSelectionController selectionController,
ContextualSearchNetworkCommunicator networkCommunicator) {
mPreferenceManager = ChromePreferenceManager.getInstance();
mSelectionController = selectionController;
mNetworkCommunicator = networkCommunicator;
}
示例11: handleShouldSuppressTap
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* Handles Tap suppression by making a callback to either the handler's #handleSuppressedTap()
* or #handleNonSuppressedTap() after a possible delay.
* This should be called when the context is fully built (by gathering surrounding text
* if needed, etc) but before showing any UX.
*/
void handleShouldSuppressTap() {
int x = (int) mX;
int y = (int) mY;
// TODO(donnd): add a policy method to get adjusted tap count.
ChromePreferenceManager prefs = ChromePreferenceManager.getInstance();
int adjustedTapsSinceOpen = prefs.getContextualSearchTapCount()
- prefs.getContextualSearchTapQuickAnswerCount();
TapSuppressionHeuristics tapHeuristics =
new TapSuppressionHeuristics(this, mLastTapState, x, y, adjustedTapsSinceOpen);
// TODO(donnd): Move to be called when the panel closes to work with states that change.
tapHeuristics.logConditionState();
// Tell the manager what it needs in order to log metrics on whether the tap would have
// been suppressed if each of the heuristics were satisfied.
mHandler.handleMetricsForWouldSuppressTap(tapHeuristics);
boolean shouldSuppressTap = tapHeuristics.shouldSuppressTap();
if (mTapTimeNanoseconds != 0) {
// Remember the tap state for subsequent tap evaluation.
mLastTapState =
new ContextualSearchTapState(x, y, mTapTimeNanoseconds, shouldSuppressTap);
} else {
mLastTapState = null;
}
if (shouldSuppressTap) {
mHandler.handleSuppressedTap();
} else {
mHandler.handleNonSuppressedTap();
}
}
示例12: CtrSuppression
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* Constructs an object that tracks impressions and clicks per user to produce CTR and
* impression metrics.
*/
CtrSuppression() {
mPreferenceManager = ChromePreferenceManager.getInstance();
// This needs to be done last in this constructor because the native code may call
// into this object.
mNativePointer = nativeInit();
}
示例13: onCardBound
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
@Override
public void onCardBound(CardViewHolder cardViewHolder) {
if (cardViewHolder.getAdapterPosition() == getNewTabPageAdapter().getFirstCardPosition()) {
updatePeekingCard(cardViewHolder);
} else {
cardViewHolder.setNotPeeking();
}
// Animate the peeking card.
// We only run if the feature is enabled and once per NTP.
if (!shouldAnimateFirstCard()) return;
mFirstCardAnimationRun = true;
// We only want an animation to run if we are not scrolled.
if (computeVerticalScrollOffset() != 0) return;
// We only show the animation a certain number of times to a user.
ChromePreferenceManager manager = ChromePreferenceManager.getInstance();
int animCount = manager.getNewTabPageFirstCardAnimationRunCount();
if (animCount > CardsVariationParameters.getFirstCardAnimationMaxRuns()) return;
manager.setNewTabPageFirstCardAnimationRunCount(animCount + 1);
// We do not show the animation if the user has previously seen it then scrolled.
if (manager.getCardsImpressionAfterAnimation()) return;
// The peeking card bounces up twice from its position.
ObjectAnimator animator =
ObjectAnimator.ofFloat(cardViewHolder.itemView, View.TRANSLATION_Y, 0f,
-mPeekingCardBounceDistance, 0f, -mPeekingCardBounceDistance, 0f);
animator.setStartDelay(PEEKING_CARD_ANIMATION_START_DELAY_MS);
animator.setDuration(PEEKING_CARD_ANIMATION_TIME_MS);
animator.setInterpolator(PEEKING_CARD_INTERPOLATOR);
animator.start();
}
示例14: cacheEnabledStateForNextLaunch
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* Once native is loaded we can consult the command-line (set via about:flags) and also finch
* state to see if we should enable WebAPKs.
*/
public static void cacheEnabledStateForNextLaunch() {
ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance();
boolean wasEnabled = isEnabledInPrefs();
boolean isEnabled = ChromeFeatureList.isEnabled(ChromeFeatureList.IMPROVED_A2HS);
if (isEnabled != wasEnabled) {
Log.d(TAG, "WebApk setting changed (%s => %s)", wasEnabled, isEnabled);
preferenceManager.setCachedWebApkRuntimeEnabled(isEnabled);
}
}
示例15: cacheChromeHomeEnabled
import org.chromium.chrome.browser.preferences.ChromePreferenceManager; //导入方法依赖的package包/类
/**
* Cache whether or not Chrome Home is enabled.
*/
public static void cacheChromeHomeEnabled() {
// Chrome Home doesn't work with tablets.
if (DeviceFormFactor.isTablet()) return;
boolean isChromeHomeEnabled = ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME);
ChromePreferenceManager manager = ChromePreferenceManager.getInstance();
boolean valueChanged = isChromeHomeEnabled != manager.isChromeHomeEnabled();
manager.setChromeHomeEnabled(isChromeHomeEnabled);
sChromeHomeEnabled = isChromeHomeEnabled;
// If the cached value changed, restart chrome.
if (valueChanged) ApplicationLifetime.terminate(true);
}