org.chromium.content.R Java Examples

The following examples show how to use org.chromium.content.R. 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: SelectActionModeCallback.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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;
}
 
Example #2
Source File: TracingControllerAndroid.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * 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;
}
 
Example #3
Source File: TracingControllerAndroid.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * 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);
}
 
Example #4
Source File: TwoFieldDatePickerDialog.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @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);
}
 
Example #5
Source File: FloatingPastePopupMenu.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #6
Source File: FloatingPastePopupMenu.java    From 365browser with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #7
Source File: SelectionPopupController.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * 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.
    }
}
 
Example #8
Source File: SelectActionModeCallback.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
    }
}
 
Example #9
Source File: SelectionPopupController.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #10
Source File: SelectActionModeCallback.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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;
}
 
Example #11
Source File: TracingControllerAndroid.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * 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);
}
 
Example #12
Source File: TracingControllerAndroid.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source File: TwoFieldDatePickerDialog.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * @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);
}
 
Example #14
Source File: DateTimeSuggestionListAdapter.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #15
Source File: MonthPicker.java    From 365browser with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #16
Source File: SelectActionModeCallback.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
    }
}
 
Example #17
Source File: TwoFieldDatePickerDialog.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @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);
}
 
Example #18
Source File: TracingControllerAndroid.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #19
Source File: SelectPopupDialog.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private int getSelectDialogLayout(boolean isMultiChoice) {
    int resource_id;
    TypedArray styledAttributes = mContentViewCore.getContext().obtainStyledAttributes(
            R.style.SelectPopupDialog, SELECT_DIALOG_ATTRS);
    resource_id = styledAttributes.getResourceId(isMultiChoice ? 0 : 1, 0);
    styledAttributes.recycle();
    return resource_id;
}
 
Example #20
Source File: DateTimePickerDialog.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @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,
        long min, long max) {
    super(context, 0);

    mMinTimeMillis = min;
    mMaxTimeMillis = 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));

    LayoutInflater inflater =
            (LayoutInflater) context.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, hourOfDay, minute, min, max);

    mTimePicker = (TimePicker) view.findViewById(R.id.time_picker);
    mTimePicker.setIs24HourView(is24HourView);
    mTimePicker.setCurrentHour(hourOfDay);
    mTimePicker.setCurrentMinute(minute);
    mTimePicker.setOnTimeChangedListener(this);
    onTimeChanged(mTimePicker, mTimePicker.getCurrentHour(),
            mTimePicker.getCurrentMinute());
}
 
Example #21
Source File: WeekPicker.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public WeekPicker(Context context, long minValue, long maxValue) {
    super(context, minValue, maxValue);

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

    // initialize to current date
    Calendar cal = Calendar.getInstance();
    cal.setFirstDayOfWeek(Calendar.MONDAY);
    cal.setMinimalDaysInFirstWeek(4);
    cal.setTimeInMillis(System.currentTimeMillis());
    init(getISOWeekYearForDate(cal), getWeekForDate(cal), null);
}
 
Example #22
Source File: WeekPickerDialog.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @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,
        long minValue, long maxValue) {
    super(context, theme, callBack, year, weekOfYear, minValue, maxValue);
    setTitle(R.string.week_picker_dialog_title);
}
 
Example #23
Source File: TracingControllerAndroid.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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;
    }

    logAndToastInfo(
            mContext.getString(R.string.profiler_stopped_toast, mFilename));
    TraceEvent.setEnabledToMatchNative();
    mIsTracing = false;
    mFilename = null;
}
 
Example #24
Source File: MonthPicker.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public MonthPicker(Context context, long minValue, long 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();

    // initialize to current date
    Calendar cal = Calendar.getInstance();
    init(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), null);
}
 
Example #25
Source File: MonthPicker.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public MonthPicker(Context context, long minValue, long 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();

    // initialize to current date
    Calendar cal = Calendar.getInstance();
    init(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), null);
}
 
Example #26
Source File: WeekPickerDialog.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @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,
        long minValue, long maxValue) {
    super(context, theme, callBack, year, weekOfYear, minValue, maxValue);
    setTitle(R.string.week_picker_dialog_title);
}
 
Example #27
Source File: WeekPicker.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public WeekPicker(Context context, long minValue, long maxValue) {
    super(context, minValue, maxValue);

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

    // initialize to current date
    Calendar cal = Calendar.getInstance();
    cal.setFirstDayOfWeek(Calendar.MONDAY);
    cal.setMinimalDaysInFirstWeek(4);
    cal.setTimeInMillis(System.currentTimeMillis());
    init(getISOWeekYearForDate(cal), getWeekForDate(cal), null);
}
 
Example #28
Source File: DateTimePickerDialog.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @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,
        long min, long max) {
    super(context, 0);

    mMinTimeMillis = min;
    mMaxTimeMillis = 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));

    LayoutInflater inflater =
            (LayoutInflater) context.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, hourOfDay, minute, min, max);

    mTimePicker = (TimePicker) view.findViewById(R.id.time_picker);
    mTimePicker.setIs24HourView(is24HourView);
    mTimePicker.setCurrentHour(hourOfDay);
    mTimePicker.setCurrentMinute(minute);
    mTimePicker.setOnTimeChangedListener(this);
    onTimeChanged(mTimePicker, mTimePicker.getCurrentHour(),
            mTimePicker.getCurrentMinute());
}
 
Example #29
Source File: SelectPopupDialog.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private int getSelectDialogLayout(boolean isMultiChoice) {
    int resource_id;
    TypedArray styledAttributes = mContentViewCore.getContext().obtainStyledAttributes(
            R.style.SelectPopupDialog, SELECT_DIALOG_ATTRS);
    resource_id = styledAttributes.getResourceId(isMultiChoice ? 0 : 1, 0);
    styledAttributes.recycle();
    return resource_id;
}
 
Example #30
Source File: PopupZoomer.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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(LOGTAG, "No corner radius resource for PopupZoomer overlay found.");
            sOverlayCornerRadius = 1.0f;
        }
    }
    return sOverlayCornerRadius;
}