Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2bddc68 authored by Hai Zhang's avatar Hai Zhang
Browse files

Implement new request role UI.

Bug: 128713569
Test: manual
Change-Id: I24cd7e7f06622a4887e320da5caa59483bf57063
parent 75e3e174
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
  ~ Copyright (C) 2019 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<com.android.packageinstaller.role.ui.CheckableLinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:listPreferredItemHeight"
    android:paddingStart="?android:listPreferredItemPaddingStart"
    android:paddingEnd="?android:listPreferredItemPaddingEnd"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/icon"
        android:layout_width="32dp"
        android:layout_height="32dp" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginStart="16dp"
        android:orientation="vertical">

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:textAppearanceListItem"
            android:textColor="?android:textColorAlertDialogListItem"
            android:singleLine="true"
            android:ellipsize="marquee" />

        <TextView
            android:id="@+id/subtitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:textAppearanceListItemSecondary"
            android:textColor="?android:textColorSecondary" />
    </LinearLayout>

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:clickable="false"
        android:duplicateParentState="true"
        android:focusable="false" />
</com.android.packageinstaller.role.ui.CheckableLinearLayout>
+41 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
  ~ Copyright (C) 2019 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingStart="?android:dialogPreferredPadding"
    android:paddingEnd="?android:dialogPreferredPadding"
    android:paddingTop="18dp"
    android:gravity="center_horizontal"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/icon"
        android:layout_width="32dp"
        android:layout_height="32dp" />

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:gravity="center_horizontal"
        android:textAppearance="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle" />
</LinearLayout>
+9 −11
Original line number Diff line number Diff line
@@ -436,17 +436,6 @@
        <item quantity="other"><xliff:g id="number" example="7">%s</xliff:g> seconds</item>
    </plurals>

    <!-- Template for the message when an app requests a role and will be added to the role holding apps. [CHAR LIMIT=100] -->
    <string name="role_request_message_add">Use
        &lt;b><xliff:g id="app_name" example="Super Duper SMS">%1$s</xliff:g>&lt;/b> as your
        <xliff:g id="role_name" example="SMS app">%2$s</xliff:g>?</string>

    <!-- Template for the message when an app requests a role and will be replacing the current role holding app. [CHAR LIMIT=100] -->
    <string name="role_request_message_replace">Use
        &lt;b><xliff:g id="new_app_name" example="Super Duper SMS">%1$s</xliff:g>&lt;/b> instead of
        &lt;b><xliff:g id="current_app_name" example="Messages">%1$s</xliff:g>&lt;/b> as your
        <xliff:g id="role_name" example="SMS app">%2$s</xliff:g>?</string>

    <!-- The name of the notification channel containing reminders about permission [CHAR LIMIT=60]-->
    <string name="permission_reminders">Permission reminders</string>

@@ -486,6 +475,15 @@
    <!-- Text for the dialog listing the enabled accessibility services when there are more than one [CHAR LIMIT=none] -->
    <string name="accessibility_service_dialog_bottom_text_multiple">These apps can view your screen, actions, and inputs, perform actions, and control the display.</string>

    <!-- Template for the title when an app requests to become a default application. [CHAR LIMIT=100] -->
    <string name="request_role_title">Set <xliff:g id="app_name" example="Super Duper SMS">%1$s</xliff:g> as your default <xliff:g id="role_name" example="SMS app">%2$s</xliff:g>?</string>

    <!-- Subtitle for the application that is the current default application [CHAR LIMIT=30] -->
    <string name="request_role_current_default">Current default</string>

    <!-- Label for the button to set an application as the default application [CHAR LIMIT=20] -->
    <string name="request_role_set_as_default">Set as default</string>

    <!-- Keyword in the Settings app's search functionality that can be used to find links to the default app management screens [CHAR LIMIT=none] -->
    <string name="default_app_search_keyword">default apps</string>

+12 −2
Original line number Diff line number Diff line
@@ -46,8 +46,18 @@
            parent="@android:style/Theme.DeviceDefault.Settings">
    </style>

    <style name="RequestRole" parent="android:Theme.DeviceDefault.Light.NoActionBar.TranslucentDecor">
    <!-- TODO: STOPSHIP: Make themeable? -->
    <style name="RequestRole" parent="android:Theme.DeviceDefault.Settings">
        <item name="android:colorBackgroundCacheHint">@null</item>
        <item name="android:navigationBarColor">@android:color/transparent</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:windowActionBar">false</item>
        <item name="android:windowAnimationStyle">@null</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowDisablePreview">true</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowNoTitle">true</item>
    </style>

    <style name="Theme.PermissionGrantDialog"
+90 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.packageinstaller.role.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.LinearLayout;

import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;

/**
 * This is a simple wrapper for {@link android.widget.LinearLayout} that implements the
 * {@link android.widget.Checkable} interface by keeping an internal 'checked' state flag.
 * <p>
 * This can be used as the root view for a custom list item layout for
 * {@link android.widget.AbsListView} elements with a
 * {@link android.widget.AbsListView#setChoiceMode(int) choiceMode} set.
 */
public class CheckableLinearLayout extends LinearLayout implements Checkable {

    private static final int[] CHECKED_STATE_SET = { android.R.attr.state_checked };

    private boolean mChecked = false;

    public CheckableLinearLayout(@NonNull Context context) {
        super(context);
    }

    public CheckableLinearLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CheckableLinearLayout(@NonNull Context context, @Nullable AttributeSet attrs,
            @AttrRes int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public CheckableLinearLayout(@NonNull Context context, @Nullable AttributeSet attrs,
            @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    public boolean isChecked() {
        return mChecked;
    }

    @Override
    public void setChecked(boolean checked) {
        if (mChecked == checked) {
            return;
        }

        mChecked = checked;
        refreshDrawableState();
    }

    @Override
    public void toggle() {
        setChecked(!mChecked);
    }

    @NonNull
    @Override
    public int[] onCreateDrawableState(int extraSpace) {
        int[] state = super.onCreateDrawableState(extraSpace + 1);
        if (isChecked()) {
            mergeDrawableStates(state, CHECKED_STATE_SET);
        }
        return state;
    }
}
Loading