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);
}
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();
}
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();
}
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);
}
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;
}
Aggregations