当前位置: 首页>>代码示例>>Java>>正文


Java UiUtils类代码示例

本文整理汇总了Java中org.chromium.ui.UiUtils的典型用法代码示例。如果您正苦于以下问题:Java UiUtils类的具体用法?Java UiUtils怎么用?Java UiUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UiUtils类属于org.chromium.ui包,在下文中一共展示了UiUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareScreenshot

import org.chromium.ui.UiUtils; //导入依赖的package包/类
/**
 * Prepares a given screenshot for sending with a feedback.
 * If no screenshot is given it creates one from the activity View if an activity is provided.
 * @param activity An activity or null
 * @param bitmap A screenshot or null
 * @return A feedback-ready screenshot or null
 */
private static Bitmap prepareScreenshot(@Nullable Activity activity, @Nullable Bitmap bitmap) {
    if (bitmap == null) {
        if (activity == null) return null;
        return UiUtils.generateScaledScreenshot(
                activity.getWindow().getDecorView().getRootView(),
                MAX_FEEDBACK_SCREENSHOT_DIMENSION, Bitmap.Config.ARGB_8888);
    }

    int screenshotMaxDimension = Math.max(bitmap.getWidth(), bitmap.getHeight());
    if (screenshotMaxDimension <= MAX_FEEDBACK_SCREENSHOT_DIMENSION) return bitmap;

    float screenshotScale = (float) MAX_FEEDBACK_SCREENSHOT_DIMENSION / screenshotMaxDimension;
    int destWidth = (int) (bitmap.getWidth() * screenshotScale);
    int destHeight = (int) (bitmap.getHeight() * screenshotScale);
    return Bitmap.createScaledBitmap(bitmap, destWidth, destHeight, true);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:ScreenshotTask.java

示例2: onVisibilityChanged

import org.chromium.ui.UiUtils; //导入依赖的package包/类
@Override
protected void onVisibilityChanged(View changedView, int visibility) {
    super.onVisibilityChanged(changedView, visibility);
    // This method might be called very early. Null check on bookmark model here.
    if (mBookmarkModel == null) return;

    if (visibility == View.VISIBLE) {
        mBookmarkModel.addObserver(mModelObserver);
        updateHistoryList();
        mSearchText.requestFocus();
        UiUtils.showKeyboard(mSearchText);
    } else {
        UiUtils.hideKeyboard(mSearchText);
        mBookmarkModel.removeObserver(mModelObserver);
        resetUI();
        clearFocus();
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:BookmarkSearchView.java

示例3: hideKeyboard

import org.chromium.ui.UiUtils; //导入依赖的package包/类
@Override
public void hideKeyboard(Runnable postHideTask) {
    // When this is called we actually want to hide the keyboard whatever owns it.
    // This includes hiding the keyboard, and dropping focus from the URL bar.
    // See http://crbug/236424
    // TODO(aberent) Find a better place to put this, possibly as part of a wider
    // redesign of focus control.
    if (mUrlBar != null) mUrlBar.clearFocus();
    boolean wasVisible = false;
    if (hasFocus()) {
        wasVisible = UiUtils.hideKeyboard(this);
    }
    if (wasVisible) {
        mPostHideKeyboardTask = postHideTask;
    } else {
        postHideTask.run();
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:CompositorViewHolder.java

示例4: clearSharedImages

import org.chromium.ui.UiUtils; //导入依赖的package包/类
/**
 * Clears all shared image files.
 */
public static void clearSharedImages() {
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            try {
                File imagePath = UiUtils.getDirectoryForImageCapture(
                        ContextUtils.getApplicationContext());
                deleteShareImageFiles(new File(imagePath, SHARE_IMAGES_DIRECTORY_NAME));
            } catch (IOException ie) {
                // Ignore exception.
            }
            return null;
        }
    }.execute();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:ShareHelper.java

示例5: onWindowFocusChanged

import org.chromium.ui.UiUtils; //导入依赖的package包/类
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
    super.onWindowFocusChanged(hasWindowFocus);
    if (hasWindowFocus) {
        if (mShowKeyboardOnWindowFocus && isFocused()) {
            // Without the call to post(..), the keyboard was not getting shown when the
            // window regained focus despite this being the final call in the view system
            // flow.
            post(new Runnable() {
                @Override
                public void run() {
                    UiUtils.showKeyboard(UrlBar.this);
                }
            });
        }
        mShowKeyboardOnWindowFocus = false;
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:UrlBar.java

示例6: revertChanges

import org.chromium.ui.UiUtils; //导入依赖的package包/类
@Override
public void revertChanges() {
    if (!mUrlHasFocus) {
        setUrlToPageUrl();
    } else {
        Tab tab = mToolbarDataProvider.getTab();
        if (NativePageFactory.isNativePageUrl(tab.getUrl(), tab.isIncognito())) {
            setUrlBarText("", null);
        } else {
            setUrlBarText(
                    mToolbarDataProvider.getText(), getCurrentTabUrl());
            selectAll();
        }
        hideSuggestions();
        UiUtils.hideKeyboard(mUrlBar);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:18,代码来源:LocationBarLayout.java

示例7: getProficientLanguages

import org.chromium.ui.UiUtils; //导入依赖的package包/类
/**
 * Similar to {@link #getProficientLanguageList} except the the result is provided in
 * a {@link LinkedHashSet} to provide access to a unique ordered list.
 * @return a {@link LinkedHashSet} of languages the user is proficient using.
 */
private LinkedHashSet<String> getProficientLanguages() {
    LinkedHashSet<String> uniqueLanguages = new LinkedHashSet<String>();
    // The primary language, according to the translation-service, always comes first.
    String primaryLanguage = getNativeTranslateServiceTargetLanguage();
    if (isValidLocale(primaryLanguage)) {
        uniqueLanguages.add(trimLocaleToLanguage(primaryLanguage));
    }
    // Merge in the IME locales, if possible.
    if (!ContextualSearchFieldTrial.isKeyboardLanguagesForTranslationDisabled()) {
        Context context = mActivity.getApplicationContext();
        if (context != null) {
            for (String locale : UiUtils.getIMELocales(context)) {
                if (isValidLocale(locale)) uniqueLanguages.add(trimLocaleToLanguage(locale));
            }
        }
    }
    return uniqueLanguages;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:ContextualSearchTranslateController.java

示例8: onContentChanged

import org.chromium.ui.UiUtils; //导入依赖的package包/类
@Override
public void onContentChanged(Tab tab) {
    // If the tab is frozen, both native page and content view are not ready.
    if (tab.isFrozen()) return;

    View viewToShow = getViewToShow(tab);
    if (isShowing(viewToShow)) return;

    removeCurrentContent();
    LayoutParams lp = (LayoutParams) viewToShow.getLayoutParams();
    if (lp == null) {
        lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    }
    // Weirdly enough, if gravity is not top, top_margin is not respected by FrameLayout.
    // Yet for many native pages on tablet, top_margin is necessary to not overlap the tab
    // switcher.
    lp.gravity = Gravity.TOP;
    UiUtils.removeViewFromParent(viewToShow);
    addView(viewToShow, CONTENT_INDEX, lp);
    viewToShow.requestFocus();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:TabContentViewParent.java

示例9: onLayout

import org.chromium.ui.UiUtils; //导入依赖的package包/类
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    // Hide the View when the keyboard is showing.
    boolean isShowing = (getVisibility() == View.VISIBLE);
    if (UiUtils.isKeyboardShowing(getContext(), InfoBarContainer.this)) {
        if (isShowing) {
            // Set to invisible (instead of gone) so that onLayout() will be called when the
            // keyboard is dismissed.
            setVisibility(View.INVISIBLE);
        }
    } else {
        if (!isShowing && !mIsObscured) {
            setVisibility(View.VISIBLE);
        }
    }

    super.onLayout(changed, l, t, r, b);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:InfoBarContainer.java

示例10: setEmptyContainerState

import org.chromium.ui.UiUtils; //导入依赖的package包/类
public void setEmptyContainerState(boolean shouldShow) {
    Animator nextAnimator = null;

    if (shouldShow && getVisibility() != View.VISIBLE
            && mCurrentTransitionAnimation != mAnimateInAnimation) {
        nextAnimator = mAnimateInAnimation;
        UiUtils.hideKeyboard(this);
    } else if (!shouldShow && getVisibility() != View.GONE
            && mCurrentTransitionAnimation != mAnimateOutAnimation) {
        nextAnimator = mAnimateOutAnimation;
    }

    if (nextAnimator != null) {
        if (mCurrentTransitionAnimation != null) mCurrentTransitionAnimation.cancel();
        mCurrentTransitionAnimation = nextAnimator;
        mCurrentTransitionAnimation.start();
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:EmptyBackgroundViewTablet.java

示例11: showKeyboard

import org.chromium.ui.UiUtils; //导入依赖的package包/类
private void showKeyboard() {
    if (!mFindQuery.hasWindowFocus()) {
        // HACK: showKeyboard() is normally called from activate() which is
        // triggered by an options menu item. Unfortunately, because the
        // options menu is still focused at this point, that means our
        // window doesn't actually have focus when this first gets called,
        // and hence it isn't the target of the Input Method, and in
        // practice that means the soft keyboard never shows up (whatever
        // flags you pass). So as a workaround we postpone asking for the
        // keyboard to be shown until just after the window gets refocused.
        // See onWindowFocusChanged(boolean hasFocus).
        mShowKeyboardOnceWindowIsFocused = true;
        return;
    }
    UiUtils.showKeyboard(mFindQuery);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:17,代码来源:FindToolbar.java

示例12: hideKeyboard

import org.chromium.ui.UiUtils; //导入依赖的package包/类
/**
 * Hides the the keyboard if it was opened for the ContentView.
 * @param postHideTask A task to run after the keyboard is done hiding and the view's
 *         layout has been updated.  If the keyboard was not shown, the task will run
 *         immediately.
 */
public void hideKeyboard(Runnable postHideTask) {
    // When this is called we actually want to hide the keyboard whatever owns it.
    // This includes hiding the keyboard, and dropping focus from the URL bar.
    // See http://crbug/236424
    // TODO(aberent) Find a better place to put this, possibly as part of a wider
    // redesign of focus control.
    if (mUrlBar != null) mUrlBar.clearFocus();
    boolean wasVisible = false;
    if (hasFocus()) {
        wasVisible = UiUtils.hideKeyboard(this);
    }
    if (wasVisible) {
        mPostHideKeyboardTask = postHideTask;
    } else {
        postHideTask.run();
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:24,代码来源:CompositorViewHolder.java

示例13: showPopupAtBottom

import org.chromium.ui.UiUtils; //导入依赖的package包/类
private void showPopupAtBottom() {
    // When the keyboard is showing, translating the snackbar upwards looks bad because it
    // overlaps the keyboard. In this case, use an alternative animation without translation.
    boolean isKeyboardShowing = UiUtils.isKeyboardShowing(mDecor.getContext(), mDecor);
    mPopup.setAnimationStyle(isKeyboardShowing ? R.style.SnackbarAnimationWithKeyboard
            : R.style.SnackbarAnimation);

    mDecor.getLocationInWindow(mTempDecorPosition);
    mDecor.getWindowVisibleDisplayFrame(mTempVisibleDisplayFrame);
    int decorBottom = mTempDecorPosition[1] + mDecor.getHeight();
    int visibleBottom = Math.min(mTempVisibleDisplayFrame.bottom, decorBottom);
    int margin = mIsTablet ? mDecor.getResources().getDimensionPixelSize(
            R.dimen.snackbar_tablet_margin) : 0;

    mPopup.showAtLocation(mDecor, Gravity.START | Gravity.BOTTOM, margin,
            decorBottom - visibleBottom + margin);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:18,代码来源:SnackbarManager.java

示例14: onVisibilityChanged

import org.chromium.ui.UiUtils; //导入依赖的package包/类
@Override
protected void onVisibilityChanged(View changedView, int visibility) {
    super.onVisibilityChanged(changedView, visibility);
    // This method might be called very early. Null check on bookmark model here.
    if (mEnhancedBookmarksModel == null) return;

    if (visibility == View.VISIBLE) {
        mEnhancedBookmarksModel.addObserver(mModelObserver);
        updateHistoryList();
        mSearchText.requestFocus();
        UiUtils.showKeyboard(mSearchText);
    } else {
        UiUtils.hideKeyboard(mSearchText);
        mEnhancedBookmarksModel.removeObserver(mModelObserver);
        resetUI();
        clearFocus();
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:19,代码来源:EnhancedBookmarkSearchView.java

示例15: deactivate

import org.chromium.ui.UiUtils; //导入依赖的package包/类
/** Call this just before closing the find toolbar. */
public void deactivate() {
    if (!mActive) return;

    if (mObserver != null) mObserver.onFindToolbarHidden();

    setResultsBarVisibility(false);

    mTabModelSelector.removeObserver(mTabModelSelectorObserver);
    for (TabModel model : mTabModelSelector.getModels()) {
        model.removeObserver(mTabModelObserver);
    }

    mCurrentTab.getChromeWebContentsDelegateAndroid().setFindResultListener(null);
    mCurrentTab.getChromeWebContentsDelegateAndroid().setFindMatchRectsListener(null);
    mCurrentTab.removeObserver(mTabObserver);

    UiUtils.hideKeyboard(mFindQuery);
    if (mFindQuery.getText().length() > 0) {
        clearResults();
        mFindInPageBridge.stopFinding();
    }

    mFindInPageBridge.destroy();
    mActive = false;
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:27,代码来源:FindToolbar.java


注:本文中的org.chromium.ui.UiUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。