org.chromium.content.R源码实例Demo

android.widget.NumberPicker.OnValueChangeListener#org.chromium.content.R源码实例Demo

下面列出了android.widget.NumberPicker.OnValueChangeListener#org.chromium.content.R 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: 365browser   文件: TracingControllerAndroid.java
/**
 * Start profiling to the specified file. Returns true on success.
 *
 * Only one TracingControllerAndroid can be running at the same time. If another profiler
 * is running when this method is called, it will be cancelled. If this
 * profiler is already running, this method does nothing and returns false.
 *
 * @param filename The name of the file to output the profile data to.
 * @param showToasts Whether or not we want to show toasts during this profiling session.
 * When we are timing the profile run we might not want to incur extra draw overhead of showing
 * notifications about the profiling system.
 * @param categories Which categories to trace. See TracingControllerAndroid::BeginTracing()
 * (in content/public/browser/trace_controller.h) for the format.
 * @param traceOptions Which trace options to use. See
 * TraceOptions::TraceOptions(const std::string& options_string)
 * (in base/trace_event/trace_event_impl.h) for the format.
 */
public boolean startTracing(String filename, boolean showToasts, String categories,
        String traceOptions) {
    mShowToasts = showToasts;
    if (isTracing()) {
        // Don't need a toast because this shouldn't happen via the UI.
        Log.e(TAG, "Received startTracing, but we're already tracing");
        return false;
    }
    // Lazy initialize the native side, to allow construction before the library is loaded.
    initializeNativeControllerIfNeeded();
    if (!nativeStartTracing(mNativeTracingControllerAndroid, categories,
            traceOptions.toString())) {
        logAndToastError(mContext.getString(R.string.profiler_error_toast));
        return false;
    }

    logForProfiler(String.format(PROFILER_STARTED_FMT, categories));
    showToast(mContext.getString(R.string.profiler_started_toast) + ": " + categories);
    mFilename = filename;
    mIsTracing = true;
    return true;
}
 
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View layout = convertView;
    if (convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        layout = inflater.inflate(R.layout.date_time_suggestion, parent, false);
    }
    TextView labelView = (TextView) layout.findViewById(R.id.date_time_suggestion_value);
    TextView sublabelView = (TextView) layout.findViewById(R.id.date_time_suggestion_label);

    if (position == getCount() - 1) {
        labelView.setText(mContext.getText(R.string.date_picker_dialog_other_button_label));
        sublabelView.setText("");
    } else {
        labelView.setText(getItem(position).localizedValue());
        sublabelView.setText(getItem(position).label());
    }

    return layout;
}
 
源代码3 项目: 365browser   文件: MonthPicker.java
public MonthPicker(Context context, double minValue, double maxValue) {
    super(context, minValue, maxValue);

    getPositionInYearSpinner().setContentDescription(
            getResources().getString(R.string.accessibility_date_picker_month));

    // initialization based on locale
    mShortMonths =
            DateFormatSymbols.getInstance(Locale.getDefault()).getShortMonths();

    // logic duplicated from android.widget.DatePicker
    if (usingNumericMonths()) {
        // We're in a locale where a date should either be all-numeric, or all-text.
        // All-text would require custom NumberPicker formatters for day and year.
        for (int i = 0; i < mShortMonths.length; ++i) {
            mShortMonths[i] = String.format("%d", i + 1);
        }
    }

    // initialize to current date
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    init(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), null);
}
 
源代码4 项目: 365browser   文件: TwoFieldDatePickerDialog.java
/**
 * @param context The context the dialog is to run in.
 * @param theme the theme to apply to this dialog
 * @param callBack How the parent is notified that the date is set.
 * @param year The initial year of the dialog.
 * @param weekOfYear The initial week of the dialog.
 */
public TwoFieldDatePickerDialog(Context context,
        int theme,
         OnValueSetListener callBack,
        int year,
        int positionInYear,
        double minValue,
        double maxValue) {
    super(context, theme);

    mCallBack = callBack;

    setButton(BUTTON_POSITIVE, context.getText(
            R.string.date_picker_dialog_set), this);
    setButton(BUTTON_NEGATIVE, context.getText(android.R.string.cancel),
            (OnClickListener) null);
    setIcon(0);

    mPicker = createPicker(context, minValue, maxValue);
    setView(mPicker);
    mPicker.init(year, positionInYear, this);
}
 
源代码5 项目: 365browser   文件: SelectionPopupController.java
/**
 * Intialize the menu items for processing text, if there is any.
 */
private void initializeTextProcessingMenu(Menu menu) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
            || !isSelectActionModeAllowed(MENU_ITEM_PROCESS_TEXT)) {
        return;
    }

    PackageManager packageManager = mContext.getPackageManager();
    List<ResolveInfo> supportedActivities =
            packageManager.queryIntentActivities(createProcessTextIntent(), 0);
    for (int i = 0; i < supportedActivities.size(); i++) {
        ResolveInfo resolveInfo = supportedActivities.get(i);
        CharSequence label = resolveInfo.loadLabel(mContext.getPackageManager());
        menu.add(R.id.select_action_menu_text_processing_menus, Menu.NONE,
                MENU_ITEM_ORDER_TEXT_PROCESS_START + i, label)
                .setIntent(createProcessTextIntentForResolveInfo(resolveInfo))
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
}
 
源代码6 项目: 365browser   文件: SelectionPopupController.java
/**
 * Perform a share action.
 */
@VisibleForTesting
void share() {
    RecordUserAction.record("MobileActionMode.Share");
    String query = sanitizeQuery(getSelectedText(), MAX_SHARE_QUERY_LENGTH);
    if (TextUtils.isEmpty(query)) return;

    Intent send = new Intent(Intent.ACTION_SEND);
    send.setType("text/plain");
    send.putExtra(Intent.EXTRA_TEXT, query);
    try {
        Intent i = Intent.createChooser(send, mContext.getString(R.string.actionbar_share));
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mContext.startActivity(i);
    } catch (android.content.ActivityNotFoundException ex) {
        // If no app handles it, do nothing.
    }
}
 
源代码7 项目: 365browser   文件: FloatingPastePopupMenu.java
private void createPasteMenu(ActionMode mode, Menu menu) {
    mode.setTitle(DeviceFormFactor.isTablet()
                    ? mContext.getString(R.string.actionbar_textselection_title)
                    : null);
    mode.setSubtitle(null);
    SelectionPopupController.initializeMenu(mContext, mode, menu);
    if (!mDelegate.canPaste()) menu.removeItem(R.id.select_action_menu_paste);
    if (!mDelegate.canSelectAll()) menu.removeItem(R.id.select_action_menu_select_all);
    if (!mDelegate.canPasteAsPlainText()) {
        menu.removeItem(R.id.select_action_menu_paste_as_plain_text);
    }
    // TODO(ctzsm): Remove runtime title set after O SDK rolls.
    MenuItem item = menu.findItem(R.id.select_action_menu_paste_as_plain_text);
    if (item != null) {
        item.setTitle(mContext.getResources().getIdentifier(
                "paste_as_plain_text", "string", "android"));
    }
    menu.removeItem(R.id.select_action_menu_cut);
    menu.removeItem(R.id.select_action_menu_copy);
    menu.removeItem(R.id.select_action_menu_share);
    menu.removeItem(R.id.select_action_menu_web_search);
}
 
源代码8 项目: 365browser   文件: FloatingPastePopupMenu.java
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.select_action_menu_paste) {
        mDelegate.paste();
        mode.finish();
    }
    if (id == R.id.select_action_menu_paste_as_plain_text) {
        mDelegate.pasteAsPlainText();
        mode.finish();
    }
    if (id == R.id.select_action_menu_select_all) {
        mDelegate.selectAll();
        mode.finish();
    }
    return true;
}
 
/**
 * Start profiling to a new file in the Downloads directory.
 *
 * Calls #startTracing(String, boolean, String, boolean) with a new timestamped filename.
 * @see #startTracing(String, boolean, String, boolean)
 */
public boolean startTracing(boolean showToasts, String categories,
        boolean recordContinuously) {
    mShowToasts = showToasts;
    String state = Environment.getExternalStorageState();
    if (!Environment.MEDIA_MOUNTED.equals(state)) {
        logAndToastError(
                mContext.getString(R.string.profiler_no_storage_toast));
        return false;
    }

    // Generate a hopefully-unique filename using the UTC timestamp.
    // (Not a huge problem if it isn't unique, we'll just append more data.)
    SimpleDateFormat formatter = new SimpleDateFormat(
            "yyyy-MM-dd-HHmmss", Locale.US);
    formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
    File dir = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_DOWNLOADS);
    File file = new File(
            dir, "chrome-profile-results-" + formatter.format(new Date()));

    return startTracing(file.getPath(), showToasts, categories, recordContinuously);
}
 
/**
 * Start profiling to the specified file. Returns true on success.
 *
 * Only one TracingControllerAndroid can be running at the same time. If another profiler
 * is running when this method is called, it will be cancelled. If this
 * profiler is already running, this method does nothing and returns false.
 *
 * @param filename The name of the file to output the profile data to.
 * @param showToasts Whether or not we want to show toasts during this profiling session.
 * When we are timing the profile run we might not want to incur extra draw overhead of showing
 * notifications about the profiling system.
 * @param categories Which categories to trace. See TracingControllerAndroid::BeginTracing()
 * (in content/public/browser/trace_controller.h) for the format.
 * @param recordContinuously Record until the user ends the trace. The trace buffer is fixed
 * size and we use it as a ring buffer during recording.
 */
public boolean startTracing(String filename, boolean showToasts, String categories,
        boolean recordContinuously) {
    mShowToasts = showToasts;
    if (isTracing()) {
        // Don't need a toast because this shouldn't happen via the UI.
        Log.e(TAG, "Received startTracing, but we're already tracing");
        return false;
    }
    // Lazy initialize the native side, to allow construction before the library is loaded.
    if (mNativeTracingControllerAndroid == 0) {
        mNativeTracingControllerAndroid = nativeInit();
    }
    if (!nativeStartTracing(mNativeTracingControllerAndroid, filename, categories,
            recordContinuously)) {
        logAndToastError(mContext.getString(R.string.profiler_error_toast));
        return false;
    }

    logAndToastInfo(mContext.getString(R.string.profiler_started_toast) + ": " + categories);
    TraceEvent.setEnabledToMatchNative();
    mFilename = filename;
    mIsTracing = true;
    return true;
}
 
/**
 * @param context The context the dialog is to run in.
 * @param theme the theme to apply to this dialog
 * @param callBack How the parent is notified that the date is set.
 * @param year The initial year of the dialog.
 * @param weekOfYear The initial week of the dialog.
 */
public TwoFieldDatePickerDialog(Context context,
        int theme,
         OnValueSetListener callBack,
        int year,
        int positionInYear,
        long minValue,
        long maxValue) {
    super(context, theme);

    mCallBack = callBack;

    setButton(BUTTON_POSITIVE, context.getText(
            R.string.date_picker_dialog_set), this);
    setButton(BUTTON_NEGATIVE, context.getText(android.R.string.cancel),
            (OnClickListener) null);
    setIcon(0);

    mPicker = createPicker(context, minValue, maxValue);
    setView(mPicker);
    mPicker.init(year, positionInYear, this);
}
 
private void createActionMenu(ActionMode mode, Menu menu) {
    mode.getMenuInflater().inflate(R.menu.select_action_menu, menu);
    if (!mEditable || !canPaste()) {
        menu.removeItem(R.id.select_action_menu_paste);
    }

    if (!mEditable) {
        menu.removeItem(R.id.select_action_menu_cut);
    }

    if (mEditable || !mActionHandler.isShareAvailable()) {
        menu.removeItem(R.id.select_action_menu_share);
    }

    if (mEditable || mIncognito || !mActionHandler.isWebSearchAvailable()) {
        menu.removeItem(R.id.select_action_menu_web_search);
    }
}
 
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.select_action_menu_select_all) {
        mActionHandler.selectAll();
    } else if (id == R.id.select_action_menu_cut) {
        mActionHandler.cut();
    } else if (id == R.id.select_action_menu_copy) {
        mActionHandler.copy();
        mode.finish();
    } else if (id == R.id.select_action_menu_paste) {
        mActionHandler.paste();
    } else if (id == R.id.select_action_menu_share) {
        mActionHandler.share();
        mode.finish();
    } else if (id == R.id.select_action_menu_web_search) {
        mActionHandler.search();
        mode.finish();
    } else {
        return false;
    }
    return true;
}
 
/**
 * Start profiling to a new file in the Downloads directory.
 *
 * Calls #startTracing(String, boolean, String, boolean) with a new timestamped filename.
 * @see #startTracing(String, boolean, String, boolean)
 */
public boolean startTracing(boolean showToasts, String categories,
        boolean recordContinuously) {
    mShowToasts = showToasts;
    String state = Environment.getExternalStorageState();
    if (!Environment.MEDIA_MOUNTED.equals(state)) {
        logAndToastError(
                mContext.getString(R.string.profiler_no_storage_toast));
        return false;
    }

    // Generate a hopefully-unique filename using the UTC timestamp.
    // (Not a huge problem if it isn't unique, we'll just append more data.)
    SimpleDateFormat formatter = new SimpleDateFormat(
            "yyyy-MM-dd-HHmmss", Locale.US);
    formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
    File dir = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_DOWNLOADS);
    File file = new File(
            dir, "chrome-profile-results-" + formatter.format(new Date()));

    return startTracing(file.getPath(), showToasts, categories, recordContinuously);
}
 
/**
 * Start profiling to the specified file. Returns true on success.
 *
 * Only one TracingControllerAndroid can be running at the same time. If another profiler
 * is running when this method is called, it will be cancelled. If this
 * profiler is already running, this method does nothing and returns false.
 *
 * @param filename The name of the file to output the profile data to.
 * @param showToasts Whether or not we want to show toasts during this profiling session.
 * When we are timing the profile run we might not want to incur extra draw overhead of showing
 * notifications about the profiling system.
 * @param categories Which categories to trace. See TracingControllerAndroid::BeginTracing()
 * (in content/public/browser/trace_controller.h) for the format.
 * @param recordContinuously Record until the user ends the trace. The trace buffer is fixed
 * size and we use it as a ring buffer during recording.
 */
public boolean startTracing(String filename, boolean showToasts, String categories,
        boolean recordContinuously) {
    mShowToasts = showToasts;
    if (isTracing()) {
        // Don't need a toast because this shouldn't happen via the UI.
        Log.e(TAG, "Received startTracing, but we're already tracing");
        return false;
    }
    // Lazy initialize the native side, to allow construction before the library is loaded.
    if (mNativeTracingControllerAndroid == 0) {
        mNativeTracingControllerAndroid = nativeInit();
    }
    if (!nativeStartTracing(mNativeTracingControllerAndroid, filename, categories,
            recordContinuously)) {
        logAndToastError(mContext.getString(R.string.profiler_error_toast));
        return false;
    }

    logAndToastInfo(mContext.getString(R.string.profiler_started_toast) + ": " + categories);
    TraceEvent.setEnabledToMatchNative();
    mFilename = filename;
    mIsTracing = true;
    return true;
}
 
/**
 * @param context The context the dialog is to run in.
 * @param theme the theme to apply to this dialog
 * @param callBack How the parent is notified that the date is set.
 * @param year The initial year of the dialog.
 * @param weekOfYear The initial week of the dialog.
 */
public TwoFieldDatePickerDialog(Context context,
        int theme,
         OnValueSetListener callBack,
        int year,
        int positionInYear,
        long minValue,
        long maxValue) {
    super(context, theme);

    mCallBack = callBack;

    setButton(BUTTON_POSITIVE, context.getText(
            R.string.date_picker_dialog_set), this);
    setButton(BUTTON_NEGATIVE, context.getText(android.R.string.cancel),
            (OnClickListener) null);
    setIcon(0);

    mPicker = createPicker(context, minValue, maxValue);
    setView(mPicker);
    mPicker.init(year, positionInYear, this);
}
 
private void createActionMenu(ActionMode mode, Menu menu) {
    mode.getMenuInflater().inflate(R.menu.select_action_menu, menu);
    if (!mEditable || !canPaste()) {
        menu.removeItem(R.id.select_action_menu_paste);
    }

    if (!mEditable) {
        menu.removeItem(R.id.select_action_menu_cut);
    }

    if (mEditable || !mActionHandler.isShareAvailable()) {
        menu.removeItem(R.id.select_action_menu_share);
    }

    if (mEditable || mIncognito || !mActionHandler.isWebSearchAvailable()) {
        menu.removeItem(R.id.select_action_menu_web_search);
    }
}
 
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.select_action_menu_select_all) {
        mActionHandler.selectAll();
    } else if (id == R.id.select_action_menu_cut) {
        mActionHandler.cut();
    } else if (id == R.id.select_action_menu_copy) {
        mActionHandler.copy();
        mode.finish();
    } else if (id == R.id.select_action_menu_paste) {
        mActionHandler.paste();
    } else if (id == R.id.select_action_menu_share) {
        mActionHandler.share();
        mode.finish();
    } else if (id == R.id.select_action_menu_web_search) {
        mActionHandler.search();
        mode.finish();
    } else {
        return false;
    }
    return true;
}
 
源代码19 项目: AndroidChromium   文件: ChromeActionModeCallback.java
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    if (!mHelper.isActionModeValid()) return true;

    if (item.getItemId() == R.id.select_action_menu_web_search) {
        search();
        mHelper.finishActionMode();
    } else {
        return mHelper.onActionItemClicked(mode, item);
    }
    return true;
}
 
源代码20 项目: 365browser   文件: ChromeActionModeCallback.java
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    if (!mHelper.isActionModeValid()) return true;

    if (item.getItemId() == R.id.select_action_menu_web_search) {
        search();
        mHelper.finishActionMode();
    } else {
        return mHelper.onActionItemClicked(mode, item);
    }
    return true;
}
 
源代码21 项目: 365browser   文件: PopupZoomer.java
private static float getOverlayCornerRadius(Context context) {
    if (sOverlayCornerRadius == 0) {
        try {
            sOverlayCornerRadius = context.getResources().getDimension(
                    R.dimen.link_preview_overlay_radius);
        } catch (Resources.NotFoundException e) {
            Log.w(TAG, "No corner radius resource for PopupZoomer overlay found.");
            sOverlayCornerRadius = 1.0f;
        }
    }
    return sOverlayCornerRadius;
}
 
源代码22 项目: 365browser   文件: TracingControllerAndroid.java
/**
 * Start profiling to a new file in the Downloads directory.
 *
 * Calls #startTracing(String, boolean, String, String) with a new timestamped filename.
 * @see #startTracing(String, boolean, String, String)
 */
public boolean startTracing(boolean showToasts, String categories, String traceOptions) {
    mShowToasts = showToasts;

    String filePath = generateTracingFilePath();
    if (filePath == null) {
        logAndToastError(mContext.getString(R.string.profiler_no_storage_toast));
    }
    return startTracing(filePath, showToasts, categories, traceOptions);
}
 
源代码23 项目: 365browser   文件: TracingControllerAndroid.java
/**
 * Called by native code when the profiler's output file is closed.
 */
@CalledByNative
protected void onTracingStopped() {
    if (!isTracing()) {
        // Don't need a toast because this shouldn't happen via the UI.
        Log.e(TAG, "Received onTracingStopped, but we aren't tracing");
        return;
    }

    logForProfiler(String.format(PROFILER_FINISHED_FMT, mFilename));
    showToast(mContext.getString(R.string.profiler_stopped_toast, mFilename));
    mIsTracing = false;
    mFilename = null;
}
 
源代码24 项目: 365browser   文件: DateTimePickerDialog.java
/**
 * @param context The context the dialog is to run in.
 * @param callBack How the parent is notified that the date is set.
 * @param year The initial year of the dialog.
 * @param monthOfYear The initial month of the dialog.
 * @param dayOfMonth The initial day of the dialog.
 */
public DateTimePickerDialog(Context context,
        OnDateTimeSetListener callBack,
        int year,
        int monthOfYear,
        int dayOfMonth,
        int hourOfDay, int minute, boolean is24HourView,
        double min, double max) {
    super(context, 0);

    mMinTimeMillis = (long) min;
    mMaxTimeMillis = (long) max;

    mCallBack = callBack;

    setButton(BUTTON_POSITIVE, context.getText(
            R.string.date_picker_dialog_set), this);
    setButton(BUTTON_NEGATIVE, context.getText(android.R.string.cancel),
            (OnClickListener) null);
    setIcon(0);
    setTitle(context.getText(R.string.date_time_picker_dialog_title));

    Context dialogContext = getDialogContext(context);
    LayoutInflater inflater =
            (LayoutInflater) dialogContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.date_time_picker_dialog, null);
    setView(view);
    mDatePicker = (DatePicker) view.findViewById(R.id.date_picker);
    DateDialogNormalizer.normalize(mDatePicker, this,
            year, monthOfYear, dayOfMonth, mMinTimeMillis, mMaxTimeMillis);

    mTimePicker = (TimePicker) view.findViewById(R.id.time_picker);
    mTimePicker.setIs24HourView(is24HourView);
    setHour(mTimePicker, hourOfDay);
    setMinute(mTimePicker, minute);
    mTimePicker.setOnTimeChangedListener(this);
    onTimeChanged(mTimePicker, getHour(mTimePicker), getMinute(mTimePicker));
}
 
源代码25 项目: 365browser   文件: WeekPicker.java
public WeekPicker(Context context, double minValue, double maxValue) {
    super(context, minValue, maxValue);

    getPositionInYearSpinner().setContentDescription(
            getResources().getString(R.string.accessibility_date_picker_week));

    // initialize to current date
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    cal.setFirstDayOfWeek(Calendar.MONDAY);
    cal.setMinimalDaysInFirstWeek(4);
    cal.setTimeInMillis(System.currentTimeMillis());
    init(getISOWeekYearForDate(cal), getWeekForDate(cal), null);
}
 
源代码26 项目: 365browser   文件: WeekPickerDialog.java
/**
 * @param context The context the dialog is to run in.
 * @param theme the theme to apply to this dialog
 * @param callBack How the parent is notified that the date is set.
 * @param year The initial year of the dialog.
 * @param weekOfYear The initial week of the dialog.
 */
public WeekPickerDialog(Context context,
        int theme,
         OnValueSetListener callBack,
        int year,
        int weekOfYear,
        double minValue, double maxValue) {
    super(context, theme, callBack, year, weekOfYear, minValue, maxValue);
    setTitle(R.string.week_picker_dialog_title);
}
 
源代码27 项目: 365browser   文件: SelectionPopupController.java
@Override
public void onCreateActionMode(ActionMode mode, Menu menu) {
    mode.setTitle(DeviceFormFactor.isTablet()
                    ? mContext.getString(R.string.actionbar_textselection_title)
                    : null);
    mode.setSubtitle(null);
    createActionMenu(mode, menu);
}
 
源代码28 项目: 365browser   文件: SelectionPopupController.java
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
    menu.removeGroup(R.id.select_action_menu_default_items);
    menu.removeGroup(R.id.select_action_menu_assist_items);
    menu.removeGroup(R.id.select_action_menu_text_processing_menus);
    createActionMenu(mode, menu);
    return true;
}
 
源代码29 项目: 365browser   文件: SelectionPopupController.java
/**
 * Initialize the menu by populating all the available items. Embedders should remove
 * the items that are not relevant to the input text being edited.
 */
public static void initializeMenu(Context context, ActionMode mode, Menu menu) {
    try {
        mode.getMenuInflater().inflate(R.menu.select_action_menu, menu);
    } catch (Resources.NotFoundException e) {
        // TODO(tobiasjs) by the time we get here we have already
        // caused a resource loading failure to be logged. WebView
        // resource access needs to be improved so that this
        // logspam can be avoided.
        new MenuInflater(context).inflate(R.menu.select_action_menu, menu);
    }
}
 
源代码30 项目: 365browser   文件: SelectionPopupController.java
private void updateAssistMenuItem(MenuDescriptor descriptor) {
    // There is no Assist functionality before Android O.
    if (!BuildInfo.isAtLeastO() || mAssistMenuItemId == 0) return;

    // The assist menu item ID has to be equal to android.R.id.textAssist. Until we compile
    // with Android O SDK where this ID is defined we replace the corresponding inflated
    // item with an item with the proper ID.
    // TODO(timav): Use android.R.id.textAssist for the Assist item id once we switch to
    // Android O SDK and remove |mAssistMenuItemId|.

    if (mClassificationResult != null && mClassificationResult.hasNamedAction()) {
        descriptor.addItem(R.id.select_action_menu_assist_items, mAssistMenuItemId, 1,
                mClassificationResult.label, mClassificationResult.icon);
    }
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。