Java Code Examples for org.chromium.ui.base.DeviceFormFactor#isTablet()
The following examples show how to use
org.chromium.ui.base.DeviceFormFactor#isTablet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SuggestionView.java From 365browser with Apache License 2.0 | 6 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (DeviceFormFactor.isTablet()) { // Use the same image transform matrix as the navigation icon to ensure the same // scaling, which requires centering vertically based on the height of the // navigation icon view and not the image itself. canvas.save(); mSuggestionIconLeft = getSuggestionIconLeftPosition(); canvas.translate( mSuggestionIconLeft, (getMeasuredHeight() - mNavigationButton.getMeasuredHeight()) / 2f); canvas.concat(mNavigationButton.getImageMatrix()); mSuggestionIcon.draw(canvas); canvas.restore(); } }
Example 2
Source File: FeatureUtilities.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * 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); }
Example 3
Source File: CustomTabToolbar.java From delion with Apache License 2.0 | 6 votes |
@Override public void updateSecurityIcon(int securityLevel) { if (mState == STATE_TITLE_ONLY) return; mSecurityIconType = securityLevel; if (securityLevel == ConnectionSecurityLevel.NONE) { mAnimDelegate.hideSecurityButton(); } else { boolean isSmallDevice = !DeviceFormFactor.isTablet(getContext()); int id = LocationBarLayout.getSecurityIconResource(securityLevel, isSmallDevice); if (id == 0) { mSecurityButton.setImageDrawable(null); } else { // ImageView#setImageResource is no-op if given resource is the current one. mSecurityButton.setImageResource(id); mSecurityButton.setTint(LocationBarLayout.getColorStateList( securityLevel, getToolbarDataProvider(), getResources())); } mAnimDelegate.showSecurityButton(); } mUrlBar.emphasizeUrl(); mUrlBar.invalidate(); }
Example 4
Source File: SnackbarView.java From 365browser with Apache License 2.0 | 6 votes |
/** * Creates an instance of the {@link SnackbarView}. * @param activity The activity that displays the snackbar. * @param listener An {@link OnClickListener} that will be called when the action button is * clicked. * @param snackbar The snackbar to be displayed. * @param parentView The ViewGroup used to display this snackbar. If this is null, this class * will determine where to attach the snackbar. */ SnackbarView(Activity activity, OnClickListener listener, Snackbar snackbar, @Nullable ViewGroup parentView) { mActivity = activity; mIsTablet = DeviceFormFactor.isTablet(); if (parentView == null) { mOriginalParent = findParentView(activity); if (activity instanceof ChromeActivity) mAnimateOverWebContent = true; } else { mOriginalParent = parentView; } mParent = mOriginalParent; mView = (ViewGroup) LayoutInflater.from(activity).inflate( R.layout.snackbar, mParent, false); mAnimationDuration = mView.getResources() .getInteger(android.R.integer.config_mediumAnimTime); mMessageView = (TemplatePreservingTextView) mView.findViewById(R.id.snackbar_message); mActionButtonView = (TextView) mView.findViewById(R.id.snackbar_button); mActionButtonView.setOnClickListener(listener); mProfileImageView = (ImageView) mView.findViewById(R.id.snackbar_profile_image); updateInternal(snackbar, false); }
Example 5
Source File: SnackbarView.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Creates an instance of the {@link SnackbarView}. * @param activity The activity that displays the snackbar. * @param listener An {@link OnClickListener} that will be called when the action button is * clicked. * @param snackbar The snackbar to be displayed. */ SnackbarView(Activity activity, OnClickListener listener, Snackbar snackbar) { mActivity = activity; mIsTablet = DeviceFormFactor.isTablet(activity); mOriginalParent = findParentView(activity); mParent = mOriginalParent; mView = (ViewGroup) LayoutInflater.from(activity).inflate( R.layout.snackbar, mParent, false); mAnimationDuration = mView.getResources() .getInteger(android.R.integer.config_mediumAnimTime); mMessageView = (TemplatePreservingTextView) mView.findViewById(R.id.snackbar_message); mActionButtonView = (TextView) mView.findViewById(R.id.snackbar_button); mActionButtonView.setOnClickListener(listener); mProfileImageView = (ImageView) mView.findViewById(R.id.snackbar_profile_image); updateInternal(snackbar, false); }
Example 6
Source File: SuggestionView.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (DeviceFormFactor.isTablet(getContext())) { // Use the same image transform matrix as the navigation icon to ensure the same // scaling, which requires centering vertically based on the height of the // navigation icon view and not the image itself. canvas.save(); mSuggestionIconLeft = getSuggestionIconLeftPosition(); canvas.translate( mSuggestionIconLeft, (getMeasuredHeight() - mNavigationButton.getMeasuredHeight()) / 2f); canvas.concat(mNavigationButton.getImageMatrix()); mSuggestionIcon.draw(canvas); canvas.restore(); } }
Example 7
Source File: LocationBarLayout.java From 365browser with Apache License 2.0 | 5 votes |
/** * Updates the security icon displayed in the LocationBar. */ @Override public void updateSecurityIcon(int securityLevel) { boolean isSmallDevice = !DeviceFormFactor.isTablet(); boolean isOfflinePage = getCurrentTab() != null && OfflinePageUtils.isOfflinePage(getCurrentTab()); int id = getSecurityIconResource(securityLevel, isSmallDevice, isOfflinePage); if (id == 0) { mSecurityButton.setImageDrawable(null); } else { // ImageView#setImageResource is no-op if given resource is the current one. mSecurityButton.setImageResource(id); mSecurityButton.setTint(getColorStateList(securityLevel, getToolbarDataProvider(), getResources(), ColorUtils.shouldUseOpaqueTextboxBackground( getToolbarDataProvider().getPrimaryColor()))); } updateVerboseStatusVisibility(); boolean shouldEmphasizeHttpsScheme = shouldEmphasizeHttpsScheme(); if (mSecurityIconResource == id && mIsEmphasizingHttpsScheme == shouldEmphasizeHttpsScheme) { return; } mSecurityIconResource = id; changeLocationBarIcon(); updateLocationBarIconContainerVisibility(); // Since we emphasize the scheme of the URL based on the security type, we need to // refresh the emphasis. mUrlBar.deEmphasizeUrl(); emphasizeUrl(); mIsEmphasizingHttpsScheme = shouldEmphasizeHttpsScheme; }
Example 8
Source File: LayerTitleCache.java From delion with Apache License 2.0 | 5 votes |
private String getUpdatedTitleInternal(Tab tab, String titleString, boolean fetchFaviconFromHistory) { final int tabId = tab.getId(); Bitmap originalFavicon = tab.getFavicon(); boolean isDarkTheme = tab.isIncognito(); // If theme colors are enabled in the tab switcher, the theme might require lighter text. if (FeatureUtilities.areTabSwitcherThemeColorsEnabled() && !DeviceFormFactor.isTablet(mContext)) { isDarkTheme |= ColorUtils.shouldUseLightForegroundOnBackground(tab.getThemeColor()); } ColorUtils.shouldUseLightForegroundOnBackground(tab.getThemeColor()); boolean isRtl = tab.isTitleDirectionRtl(); TitleBitmapFactory titleBitmapFactory = isDarkTheme ? mDarkTitleBitmapFactory : mStandardTitleBitmapFactory; Title title = mTitles.get(tabId); if (title == null) { title = new Title(); mTitles.put(tabId, title); title.register(); } title.set(titleBitmapFactory.getTitleBitmap(mContext, titleString), titleBitmapFactory.getFaviconBitmap(mContext, originalFavicon), fetchFaviconFromHistory); if (mNativeLayerTitleCache != 0) { nativeUpdateLayer(mNativeLayerTitleCache, tabId, title.getTitleResId(), title.getFaviconResId(), isDarkTheme, isRtl); } return titleString; }
Example 9
Source File: ToolbarManager.java From delion with Apache License 2.0 | 5 votes |
private boolean shouldShowCusrsorInLocationBar() { Tab tab = mToolbarModel.getTab(); if (tab == null) return false; NativePage nativePage = tab.getNativePage(); if (!(nativePage instanceof NewTabPage) && !(nativePage instanceof IncognitoNewTabPage)) { return false; } Context context = mToolbar.getContext(); return DeviceFormFactor.isTablet(context) && context.getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY; }
Example 10
Source File: DeviceClassManager.java From delion with Apache License 2.0 | 5 votes |
/** * The {@link DeviceClassManager} constructor should be self contained and * rely on system information and command line flags. */ private DeviceClassManager() { // Device based configurations. if (SysUtils.isLowEndDevice()) { mEnableSnapshots = false; mEnableLayerDecorationCache = true; mEnableAccessibilityLayout = true; mEnableAnimations = false; mEnablePrerendering = false; mEnableToolbarSwipe = false; mDisableDomainReliability = true; } else { mEnableSnapshots = true; mEnableLayerDecorationCache = true; mEnableAccessibilityLayout = false; mEnableAnimations = true; mEnablePrerendering = true; mEnableToolbarSwipe = true; mDisableDomainReliability = false; } if (DeviceFormFactor.isTablet(ContextUtils.getApplicationContext())) { mEnableAccessibilityLayout = false; } // Flag based configurations. CommandLine commandLine = CommandLine.getInstance(); mEnableAccessibilityLayout |= commandLine .hasSwitch(ChromeSwitches.ENABLE_ACCESSIBILITY_TAB_SWITCHER); mEnableFullscreen = !commandLine.hasSwitch(ChromeSwitches.DISABLE_FULLSCREEN); mEnableToolbarSwipeInDocumentMode = commandLine.hasSwitch(ChromeSwitches.ENABLE_TOOLBAR_SWIPE_IN_DOCUMENT_MODE); // Related features. if (mEnableAccessibilityLayout) { mEnableAnimations = false; } }
Example 11
Source File: TabContentViewParent.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public boolean layoutDependsOn(CoordinatorLayout parent, TabContentViewParent child, View dependency) { // Disable coordination on tablet as they appear at different location on tablet. return dependency.getId() == R.id.snackbar && !DeviceFormFactor.isTablet(child.getContext()); }
Example 12
Source File: DownloadManagerToolbar.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void initialize(SelectionDelegate<DownloadHistoryItemWrapper> delegate, int titleResId, @Nullable DrawerLayout drawerLayout, int normalGroupResId, int selectedGroupResId) { if (DeviceFormFactor.isTablet(getContext())) { getMenu().removeItem(R.id.close_menu_id); } super.initialize(delegate, titleResId, drawerLayout, normalGroupResId, selectedGroupResId); mNumberRollView.setContentDescriptionString(R.plurals.accessibility_selected_items); }
Example 13
Source File: DownloadManagerUi.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == R.id.close_menu_id && !DeviceFormFactor.isTablet(mActivity)) { mActivity.finish(); return true; } else if (item.getItemId() == R.id.selection_mode_delete_menu_id) { deleteSelectedItems(); return true; } else if (item.getItemId() == R.id.selection_mode_share_menu_id) { shareSelectedItems(); return true; } return false; }
Example 14
Source File: RecentTabsRowAdapter.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void notifyDataSetChanged() { mGroups.clear(); List<CurrentlyOpenTab> tabList = mRecentTabsManager.getCurrentlyOpenTabs(); if (tabList != null && !tabList.isEmpty()) { addGroup(new CurrentlyOpenTabsGroup(tabList)); } addGroup(mRecentlyClosedTabsGroup); for (ForeignSession session : mRecentTabsManager.getForeignSessions()) { if (!mHasForeignDataRecorded) { RecordHistogram.recordEnumeratedHistogram("HistoryPage.OtherDevicesMenu", OtherSessionsActions.HAS_FOREIGN_DATA, OtherSessionsActions.LIMIT); mHasForeignDataRecorded = true; } addGroup(new ForeignSessionGroup(session)); } if (mRecentTabsManager.shouldDisplaySyncPromo()) { addGroup(new SyncPromoGroup()); } // Add separator line after the recently closed tabs group. int recentlyClosedIndex = mGroups.indexOf(mRecentlyClosedTabsGroup); if (DeviceFormFactor.isTablet(mActivity)) { if (recentlyClosedIndex != mGroups.size() - 2) { mGroups.set(recentlyClosedIndex + 1, mVisibleSeparatorGroup); } } else if (recentlyClosedIndex != mGroups.size() - 1) { mGroups.add(recentlyClosedIndex + 1, mVisibleSeparatorGroup); } super.notifyDataSetChanged(); }
Example 15
Source File: RecentTabsRowAdapter.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void notifyDataSetChanged() { mGroups.clear(); addGroup(mRecentlyClosedTabsGroup); for (ForeignSession session : mRecentTabsManager.getForeignSessions()) { if (!mHasForeignDataRecorded) { RecordHistogram.recordEnumeratedHistogram("HistoryPage.OtherDevicesMenu", OtherSessionsActions.HAS_FOREIGN_DATA, OtherSessionsActions.LIMIT); mHasForeignDataRecorded = true; } addGroup(new ForeignSessionGroup(session)); } if (mRecentTabsManager.shouldDisplaySyncPromo()) { addGroup(new SyncPromoGroup()); } // Add separator line after the recently closed tabs group. int recentlyClosedIndex = mGroups.indexOf(mRecentlyClosedTabsGroup); if (DeviceFormFactor.isTablet()) { if (recentlyClosedIndex != mGroups.size() - 2) { mGroups.set(recentlyClosedIndex + 1, mVisibleSeparatorGroup); } } else if (recentlyClosedIndex != mGroups.size() - 1) { mGroups.add(recentlyClosedIndex + 1, mVisibleSeparatorGroup); } super.notifyDataSetChanged(); }
Example 16
Source File: ToolbarManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
private boolean shouldShowCusrsorInLocationBar() { Tab tab = mToolbarModel.getTab(); if (tab == null) return false; NativePage nativePage = tab.getNativePage(); if (!(nativePage instanceof NewTabPage) && !(nativePage instanceof IncognitoNewTabPage)) { return false; } Context context = mToolbar.getContext(); return DeviceFormFactor.isTablet(context) && context.getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY; }
Example 17
Source File: TabContentManager.java From delion with Apache License 2.0 | 4 votes |
/** * @param context The context that this cache is created in. * @param contentOffsetProvider The provider of content parameter. */ public TabContentManager(Context context, ContentOffsetProvider contentOffsetProvider, boolean snapshotsEnabled) { mContext = context; mContentOffsetProvider = contentOffsetProvider; mSnapshotsEnabled = snapshotsEnabled; // Override the cache size on the command line with --thumbnails=100 int defaultCacheSize = getIntegerResourceWithOverride(mContext, R.integer.default_thumbnail_cache_size, ChromeSwitches.THUMBNAILS); mFullResThumbnailsMaxSize = defaultCacheSize; int compressionQueueMaxSize = mContext.getResources().getInteger( R.integer.default_compression_queue_size); int writeQueueMaxSize = mContext.getResources().getInteger( R.integer.default_write_queue_size); // Override the cache size on the command line with // --approximation-thumbnails=100 int approximationCacheSize = getIntegerResourceWithOverride(mContext, R.integer.default_approximation_thumbnail_cache_size, ChromeSwitches.APPROXIMATION_THUMBNAILS); float thumbnailScale = 1.f; boolean useApproximationThumbnails; float deviceDensity = mContext.getResources().getDisplayMetrics().density; if (DeviceFormFactor.isTablet(mContext)) { // Scale all tablets to MDPI. thumbnailScale = 1.f / deviceDensity; useApproximationThumbnails = false; } else { // For phones, reduce the amount of memory usage by capturing a lower-res thumbnail for // devices with resolution higher than HDPI (crbug.com/357740). if (deviceDensity > 1.5f) { thumbnailScale = 1.5f / deviceDensity; } useApproximationThumbnails = true; } mThumbnailScale = thumbnailScale; mPriorityTabIds = new int[mFullResThumbnailsMaxSize]; mNativeTabContentManager = nativeInit(defaultCacheSize, approximationCacheSize, compressionQueueMaxSize, writeQueueMaxSize, useApproximationThumbnails); }
Example 18
Source File: StaticResourcePreloads.java From 365browser with Apache License 2.0 | 4 votes |
public static int[] getSynchronousResources(Context context) { return DeviceFormFactor.isTablet() ? sSynchronousResources : sEmptyList; }
Example 19
Source File: NewTabPage.java From 365browser with Apache License 2.0 | 4 votes |
private boolean isInSingleUrlBarMode(Context context) { if (DeviceFormFactor.isTablet()) return false; if (FeatureUtilities.isChromeHomeEnabled()) return false; return mSearchProviderHasLogo; }
Example 20
Source File: FeatureUtilities.java From delion with Apache License 2.0 | 2 votes |
/** * Whether the device could possibly run in Document mode (may return true even if the document * mode is turned off). * * This function can't be changed to return false (even if document mode is deleted) because we * need to know whether a user needs to be migrated away. * * @param context The context to use for checking configuration. * @return Whether the device could possibly run in Document mode. */ public static boolean isDocumentModeEligible(Context context) { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !DeviceFormFactor.isTablet(context); }