com.android.internal.R Java Examples

The following examples show how to use com.android.internal.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: ImmersiveModeConfirmation.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public WindowManager.LayoutParams getClingWindowLayoutParams() {
    final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL,
            0
                    | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                    | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
                    | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
            ,
            PixelFormat.TRANSLUCENT);
    lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
    lp.setTitle("ImmersiveModeConfirmation");
    lp.windowAnimations = com.android.internal.R.style.Animation_ImmersiveModeConfirmation;
    lp.token = getWindowToken();
    return lp;
}
 
Example #2
Source File: AnimatorInflater.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private static int inferValueTypeOfKeyframe(Resources res, Theme theme, AttributeSet attrs) {
    int valueType;
    TypedArray a;
    if (theme != null) {
        a = theme.obtainStyledAttributes(attrs, R.styleable.Keyframe, 0, 0);
    } else {
        a = res.obtainAttributes(attrs, R.styleable.Keyframe);
    }

    TypedValue keyframeValue = a.peekValue(R.styleable.Keyframe_value);
    boolean hasValue = (keyframeValue != null);
    // When no value type is provided, check whether it's a color type first.
    // If not, fall back to default value type (i.e. float type).
    if (hasValue && isColorType(keyframeValue.type)) {
        valueType = VALUE_TYPE_COLOR;
    } else {
        valueType = VALUE_TYPE_FLOAT;
    }
    a.recycle();
    return valueType;
}
 
Example #3
Source File: RemoteViews.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private static void loadTransitionOverride(Context context,
        RemoteViews.OnClickHandler handler) {
    if (handler != null && context.getResources().getBoolean(
            com.android.internal.R.bool.config_overrideRemoteViewsActivityTransition)) {
        TypedArray windowStyle = context.getTheme().obtainStyledAttributes(
                com.android.internal.R.styleable.Window);
        int windowAnimations = windowStyle.getResourceId(
                com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
        TypedArray windowAnimationStyle = context.obtainStyledAttributes(
                windowAnimations, com.android.internal.R.styleable.WindowAnimation);
        handler.setEnterAnimationId(windowAnimationStyle.getResourceId(
                com.android.internal.R.styleable.
                        WindowAnimation_activityOpenRemoteViewsEnterAnimation, 0));
        windowStyle.recycle();
        windowAnimationStyle.recycle();
    }
}
 
Example #4
Source File: AppTransition.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an overlay with a background color and a thumbnail for the cross profile apps
 * animation.
 */
GraphicBuffer createCrossProfileAppsThumbnail(
        @DrawableRes int thumbnailDrawableRes, Rect frame) {
    final int width = frame.width();
    final int height = frame.height();

    final Picture picture = new Picture();
    final Canvas canvas = picture.beginRecording(width, height);
    canvas.drawColor(Color.argb(0.6f, 0, 0, 0));
    final int thumbnailSize = mService.mContext.getResources().getDimensionPixelSize(
            com.android.internal.R.dimen.cross_profile_apps_thumbnail_size);
    final Drawable drawable = mService.mContext.getDrawable(thumbnailDrawableRes);
    drawable.setBounds(
            (width - thumbnailSize) / 2,
            (height - thumbnailSize) / 2,
            (width + thumbnailSize) / 2,
            (height + thumbnailSize) / 2);
    drawable.setTint(mContext.getColor(android.R.color.white));
    drawable.draw(canvas);
    picture.endRecording();

    return Bitmap.createBitmap(picture).createGraphicBufferHandle();
}
 
Example #5
Source File: DatePickerDialog.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private DatePickerDialog(@NonNull Context context, @StyleRes int themeResId,
        @Nullable OnDateSetListener listener, @Nullable Calendar calendar, int year,
        int monthOfYear, int dayOfMonth) {
    super(context, resolveDialogTheme(context, themeResId));

    final Context themeContext = getContext();
    final LayoutInflater inflater = LayoutInflater.from(themeContext);
    final View view = inflater.inflate(R.layout.date_picker_dialog, null);
    setView(view);

    setButton(BUTTON_POSITIVE, themeContext.getString(R.string.ok), this);
    setButton(BUTTON_NEGATIVE, themeContext.getString(R.string.cancel), this);
    setButtonPanelLayoutHint(LAYOUT_HINT_SIDE);

    if (calendar != null) {
        year = calendar.get(Calendar.YEAR);
        monthOfYear = calendar.get(Calendar.MONTH);
        dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
    }

    mDatePicker = (DatePicker) view.findViewById(R.id.datePicker);
    mDatePicker.init(year, monthOfYear, dayOfMonth, this);
    mDatePicker.setValidationCallback(mValidationCallback);

    mDateSetListener = listener;
}
 
Example #6
Source File: BluetoothManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Retrieve the Bluetooth Adapter's name and address and save it in
 * in the local cache
 */
private void loadStoredNameAndAddress() {
    if (DBG) {
        Slog.d(TAG, "Loading stored name and address");
    }
    if (mContext.getResources()
            .getBoolean(com.android.internal.R.bool.config_bluetooth_address_validation)
            && Settings.Secure.getInt(mContentResolver, SECURE_SETTINGS_BLUETOOTH_ADDR_VALID, 0)
            == 0) {
        // if the valid flag is not set, don't load the address and name
        if (DBG) {
            Slog.d(TAG, "invalid bluetooth name and address stored");
        }
        return;
    }
    mName = Settings.Secure.getString(mContentResolver, SECURE_SETTINGS_BLUETOOTH_NAME);
    mAddress = Settings.Secure.getString(mContentResolver, SECURE_SETTINGS_BLUETOOTH_ADDRESS);
    if (DBG) {
        Slog.d(TAG, "Stored bluetooth Name=" + mName + ",Address=" + mAddress);
    }
}
 
Example #7
Source File: LockdownVpnTracker.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void showNotification(int titleRes, int iconRes) {
    final Notification.Builder builder =
            new Notification.Builder(mContext, SystemNotificationChannels.VPN)
                    .setWhen(0)
                    .setSmallIcon(iconRes)
                    .setContentTitle(mContext.getString(titleRes))
                    .setContentText(mContext.getString(R.string.vpn_lockdown_config))
                    .setContentIntent(mConfigIntent)
                    .setOngoing(true)
                    .addAction(R.drawable.ic_menu_refresh, mContext.getString(R.string.reset),
                            mResetIntent)
                    .setColor(mContext.getColor(
                            com.android.internal.R.color.system_notification_accent_color));

    NotificationManager.from(mContext).notify(null, SystemMessage.NOTE_VPN_STATUS,
            builder.build());
}
 
Example #8
Source File: ShareActionProvider.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public View onCreateActionView() {
    // Create the view and set its data model.
    ActivityChooserView activityChooserView = new ActivityChooserView(mContext);
    if (!activityChooserView.isInEditMode()) {
        ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
        activityChooserView.setActivityChooserModel(dataModel);
    }

    // Lookup and set the expand action icon.
    TypedValue outTypedValue = new TypedValue();
    mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true);
    Drawable drawable = mContext.getDrawable(outTypedValue.resourceId);
    activityChooserView.setExpandActivityOverflowButtonDrawable(drawable);
    activityChooserView.setProvider(this);

    // Set content description.
    activityChooserView.setDefaultActionButtonContentDescription(
            R.string.shareactionprovider_share_with_application);
    activityChooserView.setExpandActivityOverflowButtonContentDescription(
            R.string.shareactionprovider_share_with);

    return activityChooserView;
}
 
Example #9
Source File: FontResourcesParser.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private static FontFileResourceEntry readFont(XmlPullParser parser, Resources resources)
        throws XmlPullParserException, IOException {
    AttributeSet attrs = Xml.asAttributeSet(parser);
    TypedArray array = resources.obtainAttributes(attrs, R.styleable.FontFamilyFont);
    int weight = array.getInt(R.styleable.FontFamilyFont_fontWeight,
            Typeface.RESOLVE_BY_FONT_TABLE);
    int italic = array.getInt(R.styleable.FontFamilyFont_fontStyle,
            Typeface.RESOLVE_BY_FONT_TABLE);
    String variationSettings = array.getString(
            R.styleable.FontFamilyFont_fontVariationSettings);
    int ttcIndex = array.getInt(R.styleable.FontFamilyFont_ttcIndex, 0);
    String filename = array.getString(R.styleable.FontFamilyFont_font);
    array.recycle();
    while (parser.next() != XmlPullParser.END_TAG) {
        skip(parser);
    }
    if (filename == null) {
        return null;
    }
    return new FontFileResourceEntry(filename, weight, italic, variationSettings, ttcIndex);
}
 
Example #10
Source File: RadioGroup.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public RadioGroup(Context context, AttributeSet attrs) {
    super(context, attrs);

    // RadioGroup is important by default, unless app developer overrode attribute.
    if (getImportantForAutofill() == IMPORTANT_FOR_AUTOFILL_AUTO) {
        setImportantForAutofill(IMPORTANT_FOR_AUTOFILL_YES);
    }

    // retrieve selected radio button as requested by the user in the
    // XML layout file
    TypedArray attributes = context.obtainStyledAttributes(
            attrs, com.android.internal.R.styleable.RadioGroup, com.android.internal.R.attr.radioButtonStyle, 0);

    int value = attributes.getResourceId(R.styleable.RadioGroup_checkedButton, View.NO_ID);
    if (value != View.NO_ID) {
        mCheckedId = value;
        mInitialCheckedId = value;
    }
    final int index = attributes.getInt(com.android.internal.R.styleable.RadioGroup_orientation, VERTICAL);
    setOrientation(index);

    attributes.recycle();
    init();
}
 
Example #11
Source File: PreloadsFileCacheExpirationJobService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public static void schedule(Context context) {
    int keepPreloadsMinDays = Resources.getSystem().getInteger(
            R.integer.config_keepPreloadsMinDays); // Default is 1 week
    long keepPreloadsMinTimeoutMs = DEBUG ? TimeUnit.MINUTES.toMillis(2)
            : TimeUnit.DAYS.toMillis(keepPreloadsMinDays);
    long keepPreloadsMaxTimeoutMs = DEBUG ? TimeUnit.MINUTES.toMillis(3)
            : TimeUnit.DAYS.toMillis(keepPreloadsMinDays + 1);

    if (DEBUG) {
        StringBuilder sb = new StringBuilder("Scheduling expiration job to run in ");
        TimeUtils.formatDuration(keepPreloadsMinTimeoutMs, sb);
        Slog.i(TAG, sb.toString());
    }
    JobInfo expirationJob = new JobInfo.Builder(JOB_ID,
            new ComponentName(context, PreloadsFileCacheExpirationJobService.class))
            .setPersisted(true)
            .setMinimumLatency(keepPreloadsMinTimeoutMs)
            .setOverrideDeadline(keepPreloadsMaxTimeoutMs)
            .build();

    JobScheduler jobScheduler = context.getSystemService(JobScheduler.class);
    jobScheduler.schedule(expirationJob);
}
 
Example #12
Source File: ProgressBar.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Should only be called if we've already verified that mProgressDrawable
 * and mProgressTintInfo are non-null.
 */
private void applyPrimaryProgressTint() {
    if (mProgressTintInfo.mHasProgressTint
            || mProgressTintInfo.mHasProgressTintMode) {
        final Drawable target = getTintTarget(R.id.progress, true);
        if (target != null) {
            if (mProgressTintInfo.mHasProgressTint) {
                target.setTintList(mProgressTintInfo.mProgressTintList);
            }
            if (mProgressTintInfo.mHasProgressTintMode) {
                target.setTintMode(mProgressTintInfo.mProgressTintMode);
            }

            // The drawable (or one of its children) may not have been
            // stateful before applying the tint, so let's try again.
            if (target.isStateful()) {
                target.setState(getDrawableState());
            }
        }
    }
}
 
Example #13
Source File: AbsSeekBar.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
void onVisualProgressChanged(int id, float scale) {
    super.onVisualProgressChanged(id, scale);

    if (id == R.id.progress) {
        final Drawable thumb = mThumb;
        if (thumb != null) {
            setThumbPos(getWidth(), thumb, scale, Integer.MIN_VALUE);

            // Since we draw translated, the drawable's bounds that it signals
            // for invalidation won't be the actual bounds we want invalidated,
            // so just invalidate this whole view.
            invalidate();
        }
    }
}
 
Example #14
Source File: LingerMonitor.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
public boolean isNotificationEnabled(NetworkAgentInfo fromNai, NetworkAgentInfo toNai) {
    // TODO: Evaluate moving to CarrierConfigManager.
    String[] notifySwitches =
            mContext.getResources().getStringArray(R.array.config_networkNotifySwitches);

    if (VDBG) {
        Log.d(TAG, "Notify on network switches: " + Arrays.toString(notifySwitches));
    }

    for (String notifySwitch : notifySwitches) {
        if (TextUtils.isEmpty(notifySwitch)) continue;
        String[] transports = notifySwitch.split("-", 2);
        if (transports.length != 2) {
            Log.e(TAG, "Invalid network switch notification configuration: " + notifySwitch);
            continue;
        }
        int fromTransport = TRANSPORT_NAMES.get("TRANSPORT_" + transports[0]);
        int toTransport = TRANSPORT_NAMES.get("TRANSPORT_" + transports[1]);
        if (hasTransport(fromNai, fromTransport) && hasTransport(toNai, toTransport)) {
            return true;
        }
    }

    return false;
}
 
Example #15
Source File: LegacyGlobalActions.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private Action getLockdownAction() {
    return new SinglePressAction(com.android.internal.R.drawable.ic_lock_lock,
            R.string.global_action_lockdown) {

        @Override
        public void onPress() {
            new LockPatternUtils(mContext).requireCredentialEntry(UserHandle.USER_ALL);
            try {
                WindowManagerGlobal.getWindowManagerService().lockNow(null);
            } catch (RemoteException e) {
                Log.e(TAG, "Error while trying to lock device.", e);
            }
        }

        @Override
        public boolean showDuringKeyguard() {
            return true;
        }

        @Override
        public boolean showBeforeProvisioning() {
            return false;
        }
    };
}
 
Example #16
Source File: YearPickerView.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public YearPickerView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    final LayoutParams frame = new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    setLayoutParams(frame);

    final Resources res = context.getResources();
    mViewSize = res.getDimensionPixelOffset(R.dimen.datepicker_view_animator_height);
    mChildSize = res.getDimensionPixelOffset(R.dimen.datepicker_year_label_height);

    setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final int year = mAdapter.getYearForPosition(position);
            mAdapter.setSelection(year);

            if (mOnYearSelectedListener != null) {
                mOnYearSelectedListener.onYearChanged(YearPickerView.this, year);
            }
        }
    });

    mAdapter = new YearAdapter(getContext());
    setAdapter(mAdapter);
}
 
Example #17
Source File: ProgressBar.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Should only be called if we've already verified that mProgressDrawable
 * and mProgressTintInfo are non-null.
 */
private void applySecondaryProgressTint() {
    if (mProgressTintInfo.mHasSecondaryProgressTint
            || mProgressTintInfo.mHasSecondaryProgressTintMode) {
        final Drawable target = getTintTarget(R.id.secondaryProgress, false);
        if (target != null) {
            if (mProgressTintInfo.mHasSecondaryProgressTint) {
                target.setTintList(mProgressTintInfo.mSecondaryProgressTintList);
            }
            if (mProgressTintInfo.mHasSecondaryProgressTintMode) {
                target.setTintMode(mProgressTintInfo.mSecondaryProgressTintMode);
            }

            // The drawable (or one of its children) may not have been
            // stateful before applying the tint, so let's try again.
            if (target.isStateful()) {
                target.setState(getDrawableState());
            }
        }
    }
}
 
Example #18
Source File: AlertDialog.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
static @StyleRes int resolveDialogTheme(Context context, @StyleRes int themeResId) {
    if (themeResId == THEME_TRADITIONAL) {
        return R.style.Theme_Dialog_Alert;
    } else if (themeResId == THEME_HOLO_DARK) {
        return R.style.Theme_Holo_Dialog_Alert;
    } else if (themeResId == THEME_HOLO_LIGHT) {
        return R.style.Theme_Holo_Light_Dialog_Alert;
    } else if (themeResId == THEME_DEVICE_DEFAULT_DARK) {
        return R.style.Theme_DeviceDefault_Dialog_Alert;
    } else if (themeResId == THEME_DEVICE_DEFAULT_LIGHT) {
        return R.style.Theme_DeviceDefault_Light_Dialog_Alert;
    } else if (ResourceId.isValid(themeResId)) {
        // start of real resource IDs.
        return themeResId;
    } else {
        final TypedValue outValue = new TypedValue();
        context.getTheme().resolveAttribute(R.attr.alertDialogTheme, outValue, true);
        return outValue.resourceId;
    }
}
 
Example #19
Source File: TimePickerClockDelegate.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void onFocusChange(View v, boolean focused) {
    if (focused) {
        switch (v.getId()) {
            case R.id.am_label:
                setAmOrPm(AM);
                break;
            case R.id.pm_label:
                setAmOrPm(PM);
                break;
            case R.id.hours:
                setCurrentItemShowing(HOUR_INDEX, true, true);
                break;
            case R.id.minutes:
                setCurrentItemShowing(MINUTE_INDEX, true, true);
                break;
            default:
                // Failed to handle this click, don't vibrate.
                return;
        }

        tryVibrate();
    }
}
 
Example #20
Source File: TransitionSet.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public TransitionSet(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TransitionSet);
    int ordering = a.getInt(R.styleable.TransitionSet_transitionOrdering,
            TransitionSet.ORDERING_TOGETHER);
    setOrdering(ordering);
    a.recycle();
}
 
Example #21
Source File: Visibility.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public Visibility(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.VisibilityTransition);
    int mode = a.getInt(R.styleable.VisibilityTransition_transitionVisibilityMode, 0);
    a.recycle();
    if (mode != 0) {
        setMode(mode);
    }
}
 
Example #22
Source File: GestureOverlayView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public GestureOverlayView(
        Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    final TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.GestureOverlayView, defStyleAttr, defStyleRes);

    mGestureStrokeWidth = a.getFloat(R.styleable.GestureOverlayView_gestureStrokeWidth,
            mGestureStrokeWidth);
    mInvalidateExtraBorder = Math.max(1, ((int) mGestureStrokeWidth) - 1);
    mCertainGestureColor = a.getColor(R.styleable.GestureOverlayView_gestureColor,
            mCertainGestureColor);
    mUncertainGestureColor = a.getColor(R.styleable.GestureOverlayView_uncertainGestureColor,
            mUncertainGestureColor);
    mFadeDuration = a.getInt(R.styleable.GestureOverlayView_fadeDuration, (int) mFadeDuration);
    mFadeOffset = a.getInt(R.styleable.GestureOverlayView_fadeOffset, (int) mFadeOffset);
    mGestureStrokeType = a.getInt(R.styleable.GestureOverlayView_gestureStrokeType,
            mGestureStrokeType);
    mGestureStrokeLengthThreshold = a.getFloat(
            R.styleable.GestureOverlayView_gestureStrokeLengthThreshold,
            mGestureStrokeLengthThreshold);
    mGestureStrokeAngleThreshold = a.getFloat(
            R.styleable.GestureOverlayView_gestureStrokeAngleThreshold,
            mGestureStrokeAngleThreshold);
    mGestureStrokeSquarenessTreshold = a.getFloat(
            R.styleable.GestureOverlayView_gestureStrokeSquarenessThreshold,
            mGestureStrokeSquarenessTreshold);
    mInterceptEvents = a.getBoolean(R.styleable.GestureOverlayView_eventsInterceptionEnabled,
            mInterceptEvents);
    mFadeEnabled = a.getBoolean(R.styleable.GestureOverlayView_fadeEnabled,
            mFadeEnabled);
    mOrientation = a.getInt(R.styleable.GestureOverlayView_orientation, mOrientation);

    a.recycle();

    init();
}
 
Example #23
Source File: ZenModeHelper.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
protected Notification createZenUpgradeNotification() {
    final Bundle extras = new Bundle();
    extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
            mContext.getResources().getString(R.string.global_action_settings));
    int title = R.string.zen_upgrade_notification_title;
    int content = R.string.zen_upgrade_notification_content;
    int drawable = R.drawable.ic_zen_24dp;
    if (NotificationManager.Policy.areAllVisualEffectsSuppressed(
            getNotificationPolicy().suppressedVisualEffects)) {
        title = R.string.zen_upgrade_notification_visd_title;
        content = R.string.zen_upgrade_notification_visd_content;
        drawable = R.drawable.ic_dnd_block_notifications;
    }

    Intent onboardingIntent = new Intent(Settings.ZEN_MODE_ONBOARDING);
    onboardingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    return new Notification.Builder(mContext, SystemNotificationChannels.DO_NOT_DISTURB)
            .setAutoCancel(true)
            .setSmallIcon(R.drawable.ic_settings_24dp)
            .setLargeIcon(Icon.createWithResource(mContext, drawable))
            .setContentTitle(mContext.getResources().getString(title))
            .setContentText(mContext.getResources().getString(content))
            .setContentIntent(PendingIntent.getActivity(mContext, 0, onboardingIntent,
                    PendingIntent.FLAG_UPDATE_CURRENT))
            .setAutoCancel(true)
            .setLocalOnly(true)
            .addExtras(extras)
            .setStyle(new Notification.BigTextStyle())
            .build();
}
 
Example #24
Source File: RemoteViews.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
    final View target = root.findViewById(viewId);
    if (target == null) return;

    target.setTagInternal(R.id.remote_input_tag, remoteInputs);
}
 
Example #25
Source File: CharacterPickerDialog.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
    Button b = (Button)
        mInflater.inflate(R.layout.character_picker_button, null);
    b.setText(String.valueOf(mOptions.charAt(position)));
    b.setOnClickListener(CharacterPickerDialog.this);
    return b;
}
 
Example #26
Source File: GradientColor.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void applyRootAttrsTheme(Theme t) {
    final TypedArray a = t.resolveAttributes(mThemeAttrs, R.styleable.GradientColor);
    // mThemeAttrs will be set to null if if there are no theme attributes in the
    // typed array.
    mThemeAttrs = a.extractThemeAttrs(mThemeAttrs);
    // merging the attributes update inside the updateRootElementState().
    updateRootElementState(a);

    // Account for any configuration changes.
    mChangingConfigurations |= a.getChangingConfigurations();
    a.recycle();
}
 
Example #27
Source File: CheckedTextView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public CheckedTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    final TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.CheckedTextView, defStyleAttr, defStyleRes);

    final Drawable d = a.getDrawable(R.styleable.CheckedTextView_checkMark);
    if (d != null) {
        setCheckMarkDrawable(d);
    }

    if (a.hasValue(R.styleable.CheckedTextView_checkMarkTintMode)) {
        mCheckMarkTintMode = Drawable.parseTintMode(a.getInt(
                R.styleable.CheckedTextView_checkMarkTintMode, -1), mCheckMarkTintMode);
        mHasCheckMarkTintMode = true;
    }

    if (a.hasValue(R.styleable.CheckedTextView_checkMarkTint)) {
        mCheckMarkTintList = a.getColorStateList(R.styleable.CheckedTextView_checkMarkTint);
        mHasCheckMarkTint = true;
    }

    mCheckMarkGravity = a.getInt(R.styleable.CheckedTextView_checkMarkGravity, Gravity.END);

    final boolean checked = a.getBoolean(R.styleable.CheckedTextView_checked, false);
    setChecked(checked);

    a.recycle();

    applyCheckMarkTint();
}
 
Example #28
Source File: ZenModeConfig.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private static String getConditionLine(Context context, ZenModeConfig config,
        int userHandle, boolean useLine1, boolean shortVersion) {
    if (config == null) return "";
    String summary = "";
    if (config.manualRule != null) {
        final Uri id = config.manualRule.conditionId;
        if (config.manualRule.enabler != null) {
            summary = getOwnerCaption(context, config.manualRule.enabler);
        } else {
            if (id == null) {
                summary = context.getString(com.android.internal.R.string.zen_mode_forever);
            } else {
                final long time = tryParseCountdownConditionId(id);
                Condition c = config.manualRule.condition;
                if (time > 0) {
                    final long now = System.currentTimeMillis();
                    final long span = time - now;
                    c = toTimeCondition(context, time, Math.round(span / (float) MINUTES_MS),
                            userHandle, shortVersion);
                }
                final String rt = c == null ? "" : useLine1 ? c.line1 : c.summary;
                summary = TextUtils.isEmpty(rt) ? "" : rt;
            }
        }
    }
    for (ZenRule automaticRule : config.automaticRules.values()) {
        if (automaticRule.isAutomaticActive()) {
            if (summary.isEmpty()) {
                summary = automaticRule.name;
            } else {
                summary = context.getResources()
                        .getString(R.string.zen_mode_rule_name_combination, summary,
                                automaticRule.name);
            }

        }
    }
    return summary;
}
 
Example #29
Source File: Magnifier.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * @return the size of the magnifier window in dp
 *
 * @hide
 */
@TestApi
public static PointF getMagnifierDefaultSize() {
    final Resources resources = Resources.getSystem();
    final float density = resources.getDisplayMetrics().density;
    final PointF size = new PointF();
    size.x = resources.getDimension(R.dimen.magnifier_width) / density;
    size.y = resources.getDimension(R.dimen.magnifier_height) / density;
    return size;
}
 
Example #30
Source File: ChangeTransform.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public ChangeTransform(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ChangeTransform);
    mUseOverlay = a.getBoolean(R.styleable.ChangeTransform_reparentWithOverlay, true);
    mReparent = a.getBoolean(R.styleable.ChangeTransform_reparent, true);
    a.recycle();
}