Search in sources :

Example 6 with CalledByNative

use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.

the class ConnectionInfoPopup method addResetCertDecisionsButton.

@CalledByNative
private void addResetCertDecisionsButton(String label) {
    assert mNativeConnectionInfoPopup != 0;
    assert mResetCertDecisionsButton == null;
    mResetCertDecisionsButton = new Button(mContext);
    mResetCertDecisionsButton.setText(label);
    mResetCertDecisionsButton.setBackgroundResource(R.drawable.connection_info_reset_cert_decisions);
    mResetCertDecisionsButton.setTextColor(ApiCompatibilityUtils.getColor(mContext.getResources(), R.color.connection_info_popup_reset_cert_decisions_button));
    mResetCertDecisionsButton.setTextSize(DESCRIPTION_TEXT_SIZE_SP);
    mResetCertDecisionsButton.setOnClickListener(this);
    LinearLayout container = new LinearLayout(mContext);
    container.setOrientation(LinearLayout.VERTICAL);
    container.addView(mResetCertDecisionsButton);
    container.setPadding(0, 0, 0, mPaddingWide);
    mContainer.addView(container);
}
Also used : Button(android.widget.Button) LinearLayout(android.widget.LinearLayout) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 7 with CalledByNative

use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.

the class WebsiteSettingsPopup method showDialog.

/**
     * Displays the WebsiteSettingsPopup.
     */
@CalledByNative
private void showDialog() {
    if (!DeviceFormFactor.isTablet(mContext)) {
        // On smaller screens, make the dialog fill the width of the screen.
        ScrollView scrollView = new ScrollView(mContext);
        scrollView.addView(mContainer);
        mDialog.addContentView(scrollView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
        // This must be called after addContentView, or it won't fully fill to the edge.
        Window window = mDialog.getWindow();
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    } else {
        // On larger screens, make the dialog centered in the screen and have a maximum width.
        ScrollView scrollView = new ScrollView(mContext) {

            @Override
            protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                final int maxDialogWidthInPx = (int) (MAX_TABLET_DIALOG_WIDTH_DP * mContext.getResources().getDisplayMetrics().density);
                if (MeasureSpec.getSize(widthMeasureSpec) > maxDialogWidthInPx) {
                    widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxDialogWidthInPx, MeasureSpec.EXACTLY);
                }
                super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            }
        };
        scrollView.addView(mContainer);
        mDialog.addContentView(scrollView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
    }
    mDialog.show();
}
Also used : Window(android.view.Window) ScrollView(android.widget.ScrollView) LinearLayout(android.widget.LinearLayout) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 8 with CalledByNative

use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.

the class ShortcutHelper method getScopeFromUrl.

/**
     * Generates a scope URL based on the passed in URL. It should be used if the Web Manifest
     * does not specify a scope URL.
     * @param url The url to convert to a scope.
     * @return The scope.
     */
@CalledByNative
public static String getScopeFromUrl(String url) {
    // Scope URL is generated by:
    // - Removing last component of the URL.
    // - Clearing the URL's query and fragment.
    Uri uri = Uri.parse(url);
    List<String> path = uri.getPathSegments();
    int endIndex = path.size();
    // If there is at least one path element, remove the last one.
    if (endIndex > 0) {
        endIndex -= 1;
    }
    // Make sure the path starts and ends with a slash (or is only a slash if there is no path).
    Uri.Builder builder = uri.buildUpon();
    String scope_path = "/" + TextUtils.join("/", path.subList(0, endIndex));
    if (scope_path.length() > 1) {
        scope_path += "/";
    }
    builder.path(scope_path);
    builder.fragment("");
    builder.query("");
    return builder.build().toString();
}
Also used : Uri(android.net.Uri) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 9 with CalledByNative

use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.

the class TtsPlatformImpl method speak.

/**
     * Attempt to start speaking an utterance. If it returns true, will call back on
     * start and end.
     *
     * @param utteranceId A unique id for this utterance so that callbacks can be tied
     *     to a particular utterance.
     * @param text The text to speak.
     * @param lang The language code for the text (e.g., "en-US").
     * @param rate The speech rate, in the units expected by Android TextToSpeech.
     * @param pitch The speech pitch, in the units expected by Android TextToSpeech.
     * @param volume The speech volume, in the units expected by Android TextToSpeech.
     * @return true on success.
     */
@CalledByNative
private boolean speak(int utteranceId, String text, String lang, float rate, float pitch, float volume) {
    if (!mInitialized) {
        mPendingUtterance = new PendingUtterance(this, utteranceId, text, lang, rate, pitch, volume);
        return true;
    }
    if (mPendingUtterance != null)
        mPendingUtterance = null;
    if (!lang.equals(mCurrentLanguage)) {
        mTextToSpeech.setLanguage(new Locale(lang));
        mCurrentLanguage = lang;
    }
    mTextToSpeech.setSpeechRate(rate);
    mTextToSpeech.setPitch(pitch);
    int result = callSpeak(text, volume, utteranceId);
    return (result == TextToSpeech.SUCCESS);
}
Also used : Locale(java.util.Locale) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 10 with CalledByNative

use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.

the class UsbChooserDialog method create.

@CalledByNative
private static UsbChooserDialog create(WindowAndroid windowAndroid, String origin, int securityLevel, long nativeUsbChooserDialogPtr) {
    Activity activity = windowAndroid.getActivity().get();
    if (activity == null) {
        return null;
    }
    UsbChooserDialog dialog = new UsbChooserDialog(nativeUsbChooserDialogPtr);
    dialog.show(activity, origin, securityLevel);
    return dialog;
}
Also used : Activity(android.app.Activity) CalledByNative(org.chromium.base.annotations.CalledByNative)

Aggregations

CalledByNative (org.chromium.base.annotations.CalledByNative)74 Activity (android.app.Activity)11 Context (android.content.Context)11 Intent (android.content.Intent)10 CastMediaRouteProvider (org.chromium.chrome.browser.media.router.cast.CastMediaRouteProvider)8 DownloadNotifier (org.chromium.chrome.browser.download.DownloadNotifier)6 View (android.view.View)5 TextView (android.widget.TextView)5 DownloadInfo (org.chromium.chrome.browser.download.DownloadInfo)5 SuppressLint (android.annotation.SuppressLint)4 PackageManager (android.content.pm.PackageManager)4 Bitmap (android.graphics.Bitmap)4 Paint (android.graphics.Paint)4 ScrollView (android.widget.ScrollView)4 ActivityManager (android.app.ActivityManager)3 ImageView (android.widget.ImageView)3 LinearLayout (android.widget.LinearLayout)3 VisibleForTesting (org.chromium.base.VisibleForTesting)3 Account (android.accounts.Account)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2