Snap for 9921839 from 211b544ea8
to udc-release
Change-Id: I82ad73ddf5f8b13b7b256743c479d974a4d6deb7
This commit is contained in:
@@ -4204,7 +4204,6 @@
|
|||||||
<action android:name="android.settings.SYNC_SETTINGS" />
|
<action android:name="android.settings.SYNC_SETTINGS" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<data android:scheme="package" />
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter android:priority="1">
|
<intent-filter android:priority="1">
|
||||||
<action android:name="android.settings.CREDENTIAL_PROVIDER" />
|
<action android:name="android.settings.CREDENTIAL_PROVIDER" />
|
||||||
@@ -4826,6 +4825,22 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".notetask.shortcut.CreateNoteTaskShortcutActivity"
|
||||||
|
android:enabled="false"
|
||||||
|
android:exported="true"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
|
android:resizeableActivity="false"
|
||||||
|
android:theme="@android:style/Theme.NoDisplay"
|
||||||
|
android:label="@string/note_task_button_label"
|
||||||
|
android:icon="@drawable/ic_note_task_shortcut_widget">
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.CREATE_SHORTCUT" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.android.settings.bluetooth.QrCodeScanModeActivity"
|
android:name="com.android.settings.bluetooth.QrCodeScanModeActivity"
|
||||||
android:permission="android.permission.BLUETOOTH_CONNECT"
|
android:permission="android.permission.BLUETOOTH_CONNECT"
|
||||||
|
1
OWNERS
1
OWNERS
@@ -3,6 +3,7 @@ android-settings-core-eng+gerrit@google.com
|
|||||||
|
|
||||||
# People who can approve changes for submission
|
# People who can approve changes for submission
|
||||||
arcwang@google.com
|
arcwang@google.com
|
||||||
|
cantol@google.com
|
||||||
chaohuiw@google.com
|
chaohuiw@google.com
|
||||||
chiujason@google.com
|
chiujason@google.com
|
||||||
cyl@google.com
|
cyl@google.com
|
||||||
|
31
res/drawable/ic_note_task_shortcut_widget.xml
Normal file
31
res/drawable/ic_note_task_shortcut_widget.xml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
~ Copyright (C) 2023 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.
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24">
|
||||||
|
<path
|
||||||
|
android:fillAlpha="1"
|
||||||
|
android:fillColor="#636C6F"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M17.6258,4.96L19.0358,6.37L7.4058,18.01L5.9958,16.6L17.6258,4.96ZM16.1358,3.62L4.1258,15.63L3.0158,19.83C2.9058,20.45 3.3858,21 3.9958,21C4.0558,21 4.1058,21 4.1658,20.99L8.3658,19.88L20.3758,7.86C20.7758,7.46 20.9958,6.93 20.9958,6.37C20.9958,5.81 20.7758,5.28 20.3758,4.88L19.1058,3.61C18.7158,3.22 18.1858,3 17.6258,3C17.0658,3 16.5358,3.22 16.1358,3.62Z" />
|
||||||
|
<path
|
||||||
|
android:fillAlpha="1"
|
||||||
|
android:fillColor="#636C6F"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M20.1936,15.3369C20.3748,16.3837 19.9151,17.5414 18.8846,18.7597C19.1546,18.872 19.4576,18.9452 19.7724,18.9867C20.0839,19.0278 20.3683,19.0325 20.5749,19.0266C20.6772,19.0236 20.7578,19.0181 20.8101,19.0138C20.8362,19.0116 20.855,19.0097 20.8657,19.0085L20.8754,19.0074L20.875,19.0075C21.4217,18.9385 21.9214,19.325 21.9918,19.8718C22.0624,20.4195 21.6756,20.9208 21.1279,20.9914L21,19.9996C21.1279,20.9914 21.1265,20.9916 21.1265,20.9916L21.1249,20.9918L21.1211,20.9923L21.1107,20.9935L21.0795,20.997C21.0542,20.9998 21.0199,21.0032 20.9775,21.0067C20.8929,21.0138 20.7753,21.0216 20.6323,21.0257C20.3481,21.0339 19.9533,21.0279 19.5109,20.9695C18.873,20.8854 18.0393,20.6793 17.3106,20.1662C16.9605,20.3559 16.5876,20.4952 16.2299,20.6003C15.5742,20.7927 14.8754,20.8968 14.2534,20.9534C13.6801,21.0055 13.4553,21.0037 13.1015,21.0008C13.0689,21.0005 13.0352,21.0002 13,21H12.8594C12.8214,21.0002 12.785,21.0006 12.7504,21.0009C12.6524,21.0019 12.5683,21.0027 12.5,21H12.0562C12.0277,21.0003 12.0054,21.0006 11.9926,21.001L11.9751,21H9L11,19H11.9795C11.9929,18.9997 12.0064,18.9997 12.0199,19H12.4117C12.4534,18.9996 12.4864,18.9995 12.5,19H12.9675C12.977,18.9999 12.9878,18.9999 13,19C13.0446,19.0003 13.0859,19.0007 13.1249,19.0011C13.4259,19.0038 13.591,19.0054 14.0723,18.9616C14.6201,18.9118 15.1795,18.8242 15.6665,18.6813C15.753,18.6559 15.8346,18.6295 15.9114,18.6022C15.0315,17.2981 14.7125,16.1044 15.015,15.0829C15.4095,13.7511 16.6784,13.2418 17.7026,13.2864C18.7262,13.3309 19.954,13.9529 20.1936,15.3369ZM16.9327,15.6508C16.873,15.8523 16.8651,16.3878 17.4697,17.334C18.2007,16.4284 18.2585,15.8839 18.2229,15.6781C18.1939,15.5108 18.0297,15.3025 17.6157,15.2845C17.2025,15.2665 16.9885,15.4626 16.9327,15.6508Z" />
|
||||||
|
</vector>
|
@@ -34,7 +34,7 @@
|
|||||||
android:id="@android:id/title"
|
android:id="@android:id/title"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="start|center_vertical"
|
||||||
android:paddingVertical="@dimen/settingslib_switch_title_margin"
|
android:paddingVertical="@dimen/settingslib_switch_title_margin"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||||
|
@@ -21,7 +21,9 @@
|
|||||||
android:paddingStart="@dimen/admin_details_dialog_padding"
|
android:paddingStart="@dimen/admin_details_dialog_padding"
|
||||||
android:paddingEnd="@dimen/admin_details_dialog_padding"
|
android:paddingEnd="@dimen/admin_details_dialog_padding"
|
||||||
android:paddingBottom="@dimen/admin_details_dialog_padding_bottom"
|
android:paddingBottom="@dimen/admin_details_dialog_padding_bottom"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:layoutDirection="locale"
|
||||||
|
android:textDirection="locale">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -41,7 +43,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textAppearance="@style/TextAppearance.AdminDialogTitle"/>
|
android:textAppearance="@style/TextAppearance.AdminDialogTitle"
|
||||||
|
android:textAlignment="textStart"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
@@ -51,15 +54,16 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/dialog_msg"
|
android:id="@+id/dialog_msg"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxLength="200"
|
android:maxLength="200"
|
||||||
android:gravity="left"
|
|
||||||
android:autoLink="email|phone|web"
|
android:autoLink="email|phone|web"
|
||||||
android:textColor="?android:attr/textColorSecondary"/>
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textAlignment="textStart"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -427,6 +427,12 @@
|
|||||||
<string name="friday_first_day_of_week">Friday</string>
|
<string name="friday_first_day_of_week">Friday</string>
|
||||||
<!-- The title of saturday for preference of first day of week. [CHAR LIMIT=50] -->
|
<!-- The title of saturday for preference of first day of week. [CHAR LIMIT=50] -->
|
||||||
<string name="saturday_first_day_of_week">Saturday</string>
|
<string name="saturday_first_day_of_week">Saturday</string>
|
||||||
|
<!-- Title for regional preference footer. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="title_regional_pref_footer">If an app doesn’t support regional preferences, the app will use its default locale settings.</string>
|
||||||
|
<!-- Description for text in regional preference footer. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="desc_regional_pref_footer_learn_more">Learn more about language preferences.</string>
|
||||||
|
<!-- TODO(b/277573274): Update the learn more url in the regional preference. -->
|
||||||
|
<string name="regional_pref_footer_learn_more_link" translatable="false">https://support.google.com/android</string>
|
||||||
|
|
||||||
<!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] -->
|
<!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] -->
|
||||||
<string name="dlg_remove_locales_title">{count, plural,
|
<string name="dlg_remove_locales_title">{count, plural,
|
||||||
@@ -12041,4 +12047,7 @@
|
|||||||
|
|
||||||
<!-- Warning message when we try to dock an app not supporting multiple instances split into multiple sides [CHAR LIMIT=NONE] -->
|
<!-- Warning message when we try to dock an app not supporting multiple instances split into multiple sides [CHAR LIMIT=NONE] -->
|
||||||
<string name="dock_multi_instances_not_supported_text">"This app can only be opened in 1 window"</string>
|
<string name="dock_multi_instances_not_supported_text">"This app can only be opened in 1 window"</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=30] Label used to open Note Task -->
|
||||||
|
<string name="note_task_button_label">Notetaking</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -66,4 +66,11 @@
|
|||||||
android:value="arg_value_language_select" />
|
android:value="arg_value_language_select" />
|
||||||
</Preference>
|
</Preference>
|
||||||
|
|
||||||
|
<com.android.settingslib.widget.FooterPreference
|
||||||
|
android:key="regional_pref_footer"
|
||||||
|
android:title="@string/title_regional_pref_footer"
|
||||||
|
android:selectable="false"
|
||||||
|
settings:searchable="false"
|
||||||
|
settings:controller="com.android.settings.regionalpreferences.RegionalFooterPreferenceController"/>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -986,17 +986,6 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the resource id to represent the install status for an app
|
|
||||||
*/
|
|
||||||
@StringRes
|
|
||||||
public static int getInstallationStatus(ApplicationInfo info) {
|
|
||||||
if ((info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
|
|
||||||
return R.string.not_installed;
|
|
||||||
}
|
|
||||||
return info.enabled ? R.string.installed : R.string.disabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isVolumeValid(VolumeInfo volume) {
|
private static boolean isVolumeValid(VolumeInfo volume) {
|
||||||
return (volume != null) && (volume.getType() == VolumeInfo.TYPE_PRIVATE)
|
return (volume != null) && (volume.getType() == VolumeInfo.TYPE_PRIVATE)
|
||||||
&& volume.isMountedReadable();
|
&& volume.isMountedReadable();
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
|
import static android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED;
|
||||||
import static android.service.quicksettings.TileService.ACTION_QS_TILE_PREFERENCES;
|
import static android.service.quicksettings.TileService.ACTION_QS_TILE_PREFERENCES;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
@@ -27,12 +28,18 @@ import android.bluetooth.BluetoothCodecStatus;
|
|||||||
import android.bluetooth.BluetoothProfile;
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.database.ContentObserver;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -173,10 +180,47 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final Uri mDevelopEnabled = Settings.Global.getUriFor(DEVELOPMENT_SETTINGS_ENABLED);
|
||||||
|
private final ContentObserver mDeveloperSettingsObserver = new ContentObserver(new Handler(
|
||||||
|
Looper.getMainLooper())) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChange(boolean selfChange, Uri uri) {
|
||||||
|
super.onChange(selfChange, uri);
|
||||||
|
final boolean developmentEnabledState =
|
||||||
|
DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext());
|
||||||
|
final boolean switchState = mSwitchBar.isChecked();
|
||||||
|
|
||||||
|
// when developer options is enabled, but it is disabled by other privilege apps like:
|
||||||
|
// adb command, we should disable all items and finish the activity.
|
||||||
|
if (developmentEnabledState != switchState) {
|
||||||
|
if (developmentEnabledState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
disableDeveloperOptions();
|
||||||
|
getActivity().runOnUiThread(() -> finishFragment());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public DevelopmentSettingsDashboardFragment() {
|
public DevelopmentSettingsDashboardFragment() {
|
||||||
super(UserManager.DISALLOW_DEBUGGING_FEATURES);
|
super(UserManager.DISALLOW_DEBUGGING_FEATURES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
final ContentResolver cr = getContext().getContentResolver();
|
||||||
|
cr.registerContentObserver(mDevelopEnabled, false, mDeveloperSettingsObserver);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
final ContentResolver cr = getContext().getContentResolver();
|
||||||
|
cr.unregisterContentObserver(mDeveloperSettingsObserver);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
@@ -18,6 +18,7 @@ package com.android.settings.inputmethod;
|
|||||||
|
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
|
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -52,11 +53,13 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
|
static final String DEFAULT_KEY = "default_key";
|
||||||
|
static final String SELECTION_KEY = "delection_key";
|
||||||
|
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
private String mKeyDefaultName;
|
private String mKeyDefaultName;
|
||||||
private String mKeyFocus;
|
private String mKeyFocus;
|
||||||
private Context mContext;
|
private Activity mActivity;
|
||||||
private InputManager mIm;
|
|
||||||
|
|
||||||
private List<int[]> mRemappableKeyList =
|
private List<int[]> mRemappableKeyList =
|
||||||
new ArrayList<>(Arrays.asList(
|
new ArrayList<>(Arrays.asList(
|
||||||
@@ -67,36 +70,41 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
|||||||
|
|
||||||
private Map<String, int[]> mRemappableKeyMap = new HashMap<>();
|
private Map<String, int[]> mRemappableKeyMap = new HashMap<>();
|
||||||
|
|
||||||
public ModifierKeysPickerDialogFragment() {
|
public ModifierKeysPickerDialogFragment() {}
|
||||||
}
|
|
||||||
|
|
||||||
public ModifierKeysPickerDialogFragment(Preference preference, InputManager inputManager) {
|
@Override
|
||||||
mPreference = preference;
|
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||||
mKeyDefaultName = preference.getTitle().toString();
|
savedInstanceState.putString(SELECTION_KEY, mKeyFocus);
|
||||||
mKeyFocus = preference.getSummary().toString();
|
super.onSaveInstanceState(savedInstanceState);
|
||||||
mIm = inputManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
super.onCreateDialog(savedInstanceState);
|
super.onCreateDialog(savedInstanceState);
|
||||||
mContext = getActivity();
|
|
||||||
|
mActivity = getActivity();
|
||||||
|
InputManager inputManager = mActivity.getSystemService(InputManager.class);
|
||||||
|
mKeyDefaultName = getArguments().getString(DEFAULT_KEY);
|
||||||
|
mKeyFocus = getArguments().getString(SELECTION_KEY);
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
mKeyFocus = savedInstanceState.getString(SELECTION_KEY);
|
||||||
|
}
|
||||||
List<String> modifierKeys = new ArrayList<String>(Arrays.asList(
|
List<String> modifierKeys = new ArrayList<String>(Arrays.asList(
|
||||||
mContext.getString(R.string.modifier_keys_caps_lock),
|
mActivity.getString(R.string.modifier_keys_caps_lock),
|
||||||
mContext.getString(R.string.modifier_keys_ctrl),
|
mActivity.getString(R.string.modifier_keys_ctrl),
|
||||||
mContext.getString(R.string.modifier_keys_meta),
|
mActivity.getString(R.string.modifier_keys_meta),
|
||||||
mContext.getString(R.string.modifier_keys_alt)));
|
mActivity.getString(R.string.modifier_keys_alt)));
|
||||||
for (int i = 0; i < modifierKeys.size(); i++) {
|
for (int i = 0; i < modifierKeys.size(); i++) {
|
||||||
mRemappableKeyMap.put(modifierKeys.get(i), mRemappableKeyList.get(i));
|
mRemappableKeyMap.put(modifierKeys.get(i), mRemappableKeyList.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
View dialoglayout =
|
View dialoglayout =
|
||||||
LayoutInflater.from(mContext).inflate(R.layout.modifier_key_picker_dialog, null);
|
LayoutInflater.from(mActivity).inflate(R.layout.modifier_key_picker_dialog, null);
|
||||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext);
|
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mActivity);
|
||||||
dialogBuilder.setView(dialoglayout);
|
dialogBuilder.setView(dialoglayout);
|
||||||
|
|
||||||
TextView summary = dialoglayout.findViewById(R.id.modifier_key_picker_summary);
|
TextView summary = dialoglayout.findViewById(R.id.modifier_key_picker_summary);
|
||||||
CharSequence summaryText = mContext.getString(
|
CharSequence summaryText = mActivity.getString(
|
||||||
R.string.modifier_keys_picker_summary, mKeyDefaultName);
|
R.string.modifier_keys_picker_summary, mKeyDefaultName);
|
||||||
summary.setText(summaryText);
|
summary.setText(summaryText);
|
||||||
|
|
||||||
@@ -119,14 +127,14 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
|||||||
Spannable itemSummary;
|
Spannable itemSummary;
|
||||||
if (selectedItem.equals(mKeyDefaultName)) {
|
if (selectedItem.equals(mKeyDefaultName)) {
|
||||||
itemSummary = new SpannableString(
|
itemSummary = new SpannableString(
|
||||||
mContext.getString(R.string.modifier_keys_default_summary));
|
mActivity.getString(R.string.modifier_keys_default_summary));
|
||||||
itemSummary.setSpan(
|
itemSummary.setSpan(
|
||||||
new ForegroundColorSpan(getColorOfTextColorSecondary()),
|
new ForegroundColorSpan(getColorOfTextColorSecondary()),
|
||||||
0, itemSummary.length(), 0);
|
0, itemSummary.length(), 0);
|
||||||
// Set keys to default.
|
// Set keys to default.
|
||||||
int[] keys = mRemappableKeyMap.get(mKeyDefaultName);
|
int[] keys = mRemappableKeyMap.get(mKeyDefaultName);
|
||||||
for (int i = 0; i < keys.length; i++) {
|
for (int i = 0; i < keys.length; i++) {
|
||||||
mIm.remapModifierKey(keys[i], keys[i]);
|
inputManager.remapModifierKey(keys[i], keys[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
itemSummary = new SpannableString(selectedItem);
|
itemSummary = new SpannableString(selectedItem);
|
||||||
@@ -136,29 +144,29 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
|||||||
int[] fromKeys = mRemappableKeyMap.get(mKeyDefaultName);
|
int[] fromKeys = mRemappableKeyMap.get(mKeyDefaultName);
|
||||||
int[] toKeys = mRemappableKeyMap.get(selectedItem);
|
int[] toKeys = mRemappableKeyMap.get(selectedItem);
|
||||||
// CAPS_LOCK only one key, so always choose the left key for remapping.
|
// CAPS_LOCK only one key, so always choose the left key for remapping.
|
||||||
if (isKeyCapsLock(mContext, mKeyDefaultName)) {
|
if (isKeyCapsLock(mActivity, mKeyDefaultName)) {
|
||||||
mIm.remapModifierKey(fromKeys[0], toKeys[0]);
|
inputManager.remapModifierKey(fromKeys[0], toKeys[0]);
|
||||||
}
|
}
|
||||||
// Remap KEY_LEFT and KEY_RIGHT to CAPS_LOCK.
|
// Remap KEY_LEFT and KEY_RIGHT to CAPS_LOCK.
|
||||||
if (!isKeyCapsLock(mContext, mKeyDefaultName)
|
if (!isKeyCapsLock(mActivity, mKeyDefaultName)
|
||||||
&& isKeyCapsLock(mContext, selectedItem)) {
|
&& isKeyCapsLock(mActivity, selectedItem)) {
|
||||||
mIm.remapModifierKey(fromKeys[0], toKeys[0]);
|
inputManager.remapModifierKey(fromKeys[0], toKeys[0]);
|
||||||
mIm.remapModifierKey(fromKeys[1], toKeys[0]);
|
inputManager.remapModifierKey(fromKeys[1], toKeys[0]);
|
||||||
}
|
}
|
||||||
// Auto handle left and right keys remapping.
|
// Auto handle left and right keys remapping.
|
||||||
if (!isKeyCapsLock(mContext, mKeyDefaultName)
|
if (!isKeyCapsLock(mActivity, mKeyDefaultName)
|
||||||
&& !isKeyCapsLock(mContext, selectedItem)) {
|
&& !isKeyCapsLock(mActivity, selectedItem)) {
|
||||||
mIm.remapModifierKey(fromKeys[0], toKeys[0]);
|
inputManager.remapModifierKey(fromKeys[0], toKeys[0]);
|
||||||
mIm.remapModifierKey(fromKeys[1], toKeys[1]);
|
inputManager.remapModifierKey(fromKeys[1], toKeys[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mPreference.setSummary(itemSummary);
|
dismiss();
|
||||||
modifierKeyDialog.dismiss();
|
mActivity.recreate();
|
||||||
});
|
});
|
||||||
|
|
||||||
Button cancelButton = dialoglayout.findViewById(R.id.modifier_key_cancel_button);
|
Button cancelButton = dialoglayout.findViewById(R.id.modifier_key_cancel_button);
|
||||||
cancelButton.setOnClickListener(v -> {
|
cancelButton.setOnClickListener(v -> {
|
||||||
modifierKeyDialog.dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
final Window window = modifierKeyDialog.getWindow();
|
final Window window = modifierKeyDialog.getWindow();
|
||||||
@@ -207,16 +215,17 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = LayoutInflater.from(mContext).inflate(R.layout.modifier_key_item, null);
|
view = LayoutInflater.from(mActivity).inflate(R.layout.modifier_key_item, null);
|
||||||
}
|
}
|
||||||
TextView textView = view.findViewById(R.id.modifier_key_text);
|
TextView textView = view.findViewById(R.id.modifier_key_text);
|
||||||
ImageView checkIcon = view.findViewById(R.id.modifier_key_check_icon);
|
ImageView checkIcon = view.findViewById(R.id.modifier_key_check_icon);
|
||||||
textView.setText(mList.get(i));
|
textView.setText(mList.get(i));
|
||||||
if (mCurrentItem == i) {
|
if (mCurrentItem == i) {
|
||||||
|
mKeyFocus = mList.get(i);
|
||||||
textView.setTextColor(getColorOfColorAccentPrimaryVariant());
|
textView.setTextColor(getColorOfColorAccentPrimaryVariant());
|
||||||
checkIcon.setImageAlpha(255);
|
checkIcon.setImageAlpha(255);
|
||||||
view.setBackground(
|
view.setBackground(
|
||||||
mContext.getDrawable(R.drawable.modifier_key_lisetview_background));
|
mActivity.getDrawable(R.drawable.modifier_key_lisetview_background));
|
||||||
} else {
|
} else {
|
||||||
textView.setTextColor(getColorOfTextColorPrimary());
|
textView.setTextColor(getColorOfTextColorPrimary());
|
||||||
checkIcon.setImageAlpha(0);
|
checkIcon.setImageAlpha(0);
|
||||||
@@ -235,15 +244,15 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getColorOfTextColorPrimary() {
|
private int getColorOfTextColorPrimary() {
|
||||||
return Utils.getColorAttrDefaultColor(mContext, android.R.attr.textColorPrimary);
|
return Utils.getColorAttrDefaultColor(mActivity, android.R.attr.textColorPrimary);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getColorOfTextColorSecondary() {
|
private int getColorOfTextColorSecondary() {
|
||||||
return Utils.getColorAttrDefaultColor(mContext, android.R.attr.textColorSecondary);
|
return Utils.getColorAttrDefaultColor(mActivity, android.R.attr.textColorSecondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getColorOfColorAccentPrimaryVariant() {
|
private int getColorOfColorAccentPrimaryVariant() {
|
||||||
return Utils.getColorAttrDefaultColor(
|
return Utils.getColorAttrDefaultColor(
|
||||||
mContext, com.android.internal.R.attr.materialColorPrimaryContainer);
|
mActivity, com.android.internal.R.attr.materialColorPrimaryContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,12 +18,12 @@ package com.android.settings.inputmethod;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.input.InputManager;
|
import android.hardware.input.InputManager;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
|
||||||
import androidx.fragment.app.DialogFragment;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -41,8 +41,8 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class ModifierKeysPreferenceController extends BasePreferenceController {
|
public class ModifierKeysPreferenceController extends BasePreferenceController {
|
||||||
|
|
||||||
private static String KEY_TAG = "modifier_keys_dialog_tag";
|
private static final String KEY_TAG = "modifier_keys_dialog_tag";
|
||||||
private static String KEY_RESTORE_PREFERENCE = "modifier_keys_restore";
|
private static final String KEY_RESTORE_PREFERENCE = "modifier_keys_restore";
|
||||||
|
|
||||||
private static final String KEY_PREFERENCE_CAPS_LOCK = "modifier_keys_caps_lock";
|
private static final String KEY_PREFERENCE_CAPS_LOCK = "modifier_keys_caps_lock";
|
||||||
private static final String KEY_PREFERENCE_CTRL = "modifier_keys_ctrl";
|
private static final String KEY_PREFERENCE_CTRL = "modifier_keys_ctrl";
|
||||||
@@ -52,6 +52,7 @@ public class ModifierKeysPreferenceController extends BasePreferenceController {
|
|||||||
private Fragment mParent;
|
private Fragment mParent;
|
||||||
private FragmentManager mFragmentManager;
|
private FragmentManager mFragmentManager;
|
||||||
private final InputManager mIm;
|
private final InputManager mIm;
|
||||||
|
private PreferenceScreen mScreen;
|
||||||
|
|
||||||
private final List<Integer> mRemappableKeys = new ArrayList<>(
|
private final List<Integer> mRemappableKeys = new ArrayList<>(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
@@ -82,40 +83,39 @@ public class ModifierKeysPreferenceController extends BasePreferenceController {
|
|||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
|
|
||||||
if (mParent == null) {
|
if (mParent == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mScreen = screen;
|
||||||
|
refreshUi();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshUi() {
|
||||||
for (Map.Entry<Integer, Integer> entry : mIm.getModifierKeyRemapping().entrySet()) {
|
for (Map.Entry<Integer, Integer> entry : mIm.getModifierKeyRemapping().entrySet()) {
|
||||||
int fromKey = entry.getKey();
|
int fromKey = entry.getKey();
|
||||||
int toKey = entry.getValue();
|
int toKey = entry.getValue();
|
||||||
int index = mRemappableKeys.indexOf(toKey);
|
int index = mRemappableKeys.indexOf(toKey);
|
||||||
|
|
||||||
if (isCtrl(fromKey) && mRemappableKeys.contains(toKey)) {
|
if (isCtrl(fromKey) && mRemappableKeys.contains(toKey)) {
|
||||||
Preference preference = screen.findPreference(KEY_PREFERENCE_CTRL);
|
Preference preference = mScreen.findPreference(KEY_PREFERENCE_CTRL);
|
||||||
preference.setSummary(changeSummaryColor(mKeyNames[index]));
|
preference.setSummary(changeSummaryColor(mKeyNames[index]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMeta(fromKey) && mRemappableKeys.contains(toKey)) {
|
if (isMeta(fromKey) && mRemappableKeys.contains(toKey)) {
|
||||||
Preference preference = screen.findPreference(KEY_PREFERENCE_META);
|
Preference preference = mScreen.findPreference(KEY_PREFERENCE_META);
|
||||||
preference.setSummary(changeSummaryColor(mKeyNames[index]));
|
preference.setSummary(changeSummaryColor(mKeyNames[index]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAlt(fromKey) && mRemappableKeys.contains(toKey)) {
|
if (isAlt(fromKey) && mRemappableKeys.contains(toKey)) {
|
||||||
Preference preference = screen.findPreference(KEY_PREFERENCE_ALT);
|
Preference preference = mScreen.findPreference(KEY_PREFERENCE_ALT);
|
||||||
preference.setSummary(changeSummaryColor(mKeyNames[index]));
|
preference.setSummary(changeSummaryColor(mKeyNames[index]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCapLock(fromKey) && mRemappableKeys.contains(toKey)) {
|
if (isCapLock(fromKey) && mRemappableKeys.contains(toKey)) {
|
||||||
Preference preference = screen.findPreference(KEY_PREFERENCE_CAPS_LOCK);
|
Preference preference = mScreen.findPreference(KEY_PREFERENCE_CAPS_LOCK);
|
||||||
preference.setSummary(changeSummaryColor(mKeyNames[index]));
|
preference.setSummary(changeSummaryColor(mKeyNames[index]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The dialog screen depends on the previous selected key's fragment.
|
|
||||||
// In the rotation scenario, we should remove the previous dialog screen first.
|
|
||||||
clearPreviousDialog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -133,19 +133,18 @@ public class ModifierKeysPreferenceController extends BasePreferenceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showModifierKeysDialog(Preference preference) {
|
private void showModifierKeysDialog(Preference preference) {
|
||||||
ModifierKeysPickerDialogFragment fragment =
|
|
||||||
new ModifierKeysPickerDialogFragment(preference, mIm);
|
|
||||||
fragment.setTargetFragment(mParent, 0);
|
|
||||||
fragment.show(mFragmentManager, KEY_TAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clearPreviousDialog() {
|
|
||||||
mFragmentManager = mParent.getFragmentManager();
|
mFragmentManager = mParent.getFragmentManager();
|
||||||
DialogFragment preKeysDialogFragment =
|
ModifierKeysPickerDialogFragment fragment = new ModifierKeysPickerDialogFragment();
|
||||||
(DialogFragment) mFragmentManager.findFragmentByTag(KEY_TAG);
|
fragment.setTargetFragment(mParent, 0);
|
||||||
if (preKeysDialogFragment != null) {
|
Bundle bundle = new Bundle();
|
||||||
preKeysDialogFragment.dismiss();
|
bundle.putString(
|
||||||
}
|
ModifierKeysPickerDialogFragment.DEFAULT_KEY,
|
||||||
|
preference.getTitle().toString());
|
||||||
|
bundle.putString(
|
||||||
|
ModifierKeysPickerDialogFragment.SELECTION_KEY,
|
||||||
|
preference.getSummary().toString());
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
fragment.show(mFragmentManager, KEY_TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Spannable changeSummaryColor(String summary) {
|
private Spannable changeSummaryColor(String summary) {
|
||||||
|
@@ -18,25 +18,19 @@ package com.android.settings.inputmethod;
|
|||||||
|
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
|
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.hardware.input.InputManager;
|
import android.hardware.input.InputManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Spannable;
|
|
||||||
import android.text.SpannableString;
|
|
||||||
import android.text.style.ForegroundColorSpan;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settingslib.Utils;
|
|
||||||
|
|
||||||
public class ModifierKeysResetDialogFragment extends DialogFragment {
|
public class ModifierKeysResetDialogFragment extends DialogFragment {
|
||||||
private static final String MODIFIER_KEYS_CAPS_LOCK = "modifier_keys_caps_lock";
|
private static final String MODIFIER_KEYS_CAPS_LOCK = "modifier_keys_caps_lock";
|
||||||
@@ -44,41 +38,36 @@ public class ModifierKeysResetDialogFragment extends DialogFragment {
|
|||||||
private static final String MODIFIER_KEYS_META = "modifier_keys_meta";
|
private static final String MODIFIER_KEYS_META = "modifier_keys_meta";
|
||||||
private static final String MODIFIER_KEYS_ALT = "modifier_keys_alt";
|
private static final String MODIFIER_KEYS_ALT = "modifier_keys_alt";
|
||||||
|
|
||||||
private PreferenceScreen mScreen;
|
|
||||||
private InputManager mIm;
|
|
||||||
private String[] mKeys = {
|
private String[] mKeys = {
|
||||||
MODIFIER_KEYS_CAPS_LOCK,
|
MODIFIER_KEYS_CAPS_LOCK,
|
||||||
MODIFIER_KEYS_CTRL,
|
MODIFIER_KEYS_CTRL,
|
||||||
MODIFIER_KEYS_META,
|
MODIFIER_KEYS_META,
|
||||||
MODIFIER_KEYS_ALT};
|
MODIFIER_KEYS_ALT};
|
||||||
|
|
||||||
public ModifierKeysResetDialogFragment() {
|
public ModifierKeysResetDialogFragment() {}
|
||||||
}
|
|
||||||
|
|
||||||
public ModifierKeysResetDialogFragment(PreferenceScreen screen, InputManager inputManager) {
|
|
||||||
mScreen = screen;
|
|
||||||
mIm = inputManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
super.onCreateDialog(savedInstanceState);
|
super.onCreateDialog(savedInstanceState);
|
||||||
Context mContext = getActivity();
|
|
||||||
|
Activity activity = getActivity();
|
||||||
|
InputManager inputManager = activity.getSystemService(InputManager.class);
|
||||||
View dialoglayout =
|
View dialoglayout =
|
||||||
LayoutInflater.from(mContext).inflate(R.layout.modifier_key_reset_dialog, null);
|
LayoutInflater.from(activity).inflate(R.layout.modifier_key_reset_dialog, null);
|
||||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext);
|
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity);
|
||||||
dialogBuilder.setView(dialoglayout);
|
dialogBuilder.setView(dialoglayout);
|
||||||
AlertDialog modifierKeyResetDialog = dialogBuilder.create();
|
AlertDialog modifierKeyResetDialog = dialogBuilder.create();
|
||||||
|
|
||||||
Button restoreButton = dialoglayout.findViewById(R.id.modifier_key_reset_restore_button);
|
Button restoreButton = dialoglayout.findViewById(R.id.modifier_key_reset_restore_button);
|
||||||
restoreButton.setOnClickListener(v -> {
|
restoreButton.setOnClickListener(v -> {
|
||||||
resetToDefault();
|
inputManager.clearAllModifierKeyRemappings();
|
||||||
modifierKeyResetDialog.dismiss();
|
dismiss();
|
||||||
|
activity.recreate();
|
||||||
});
|
});
|
||||||
|
|
||||||
Button cancelButton = dialoglayout.findViewById(R.id.modifier_key_reset_cancel_button);
|
Button cancelButton = dialoglayout.findViewById(R.id.modifier_key_reset_cancel_button);
|
||||||
cancelButton.setOnClickListener(v -> {
|
cancelButton.setOnClickListener(v -> {
|
||||||
modifierKeyResetDialog.dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
final Window window = modifierKeyResetDialog.getWindow();
|
final Window window = modifierKeyResetDialog.getWindow();
|
||||||
@@ -86,25 +75,4 @@ public class ModifierKeysResetDialogFragment extends DialogFragment {
|
|||||||
|
|
||||||
return modifierKeyResetDialog;
|
return modifierKeyResetDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetToDefault() {
|
|
||||||
Context mContext = getActivity();
|
|
||||||
for (int i = 0; i < mKeys.length; i++) {
|
|
||||||
Preference preference = mScreen.findPreference(mKeys[i]);
|
|
||||||
Spannable title = new SpannableString(
|
|
||||||
mContext.getString(R.string.modifier_keys_default_summary));
|
|
||||||
title.setSpan(
|
|
||||||
new ForegroundColorSpan(getColorOfTextColorSecondary()),
|
|
||||||
0, title.length(), 0);
|
|
||||||
preference.setSummary(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mIm != null) {
|
|
||||||
mIm.clearAllModifierKeyRemappings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getColorOfTextColorSecondary() {
|
|
||||||
return Utils.getColorAttrDefaultColor(getActivity(), android.R.attr.textColorSecondary);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -17,12 +17,10 @@
|
|||||||
package com.android.settings.inputmethod;
|
package com.android.settings.inputmethod;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.input.InputManager;
|
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
|
|
||||||
import androidx.fragment.app.DialogFragment;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -34,16 +32,14 @@ import com.android.settingslib.Utils;
|
|||||||
|
|
||||||
public class ModifierKeysRestorePreferenceController extends BasePreferenceController {
|
public class ModifierKeysRestorePreferenceController extends BasePreferenceController {
|
||||||
|
|
||||||
private static String KEY_TAG = "modifier_keys_dialog_tag";
|
private static final String KEY_TAG = "modifier_keys_restore_dialog_tag";
|
||||||
|
|
||||||
private Fragment mParent;
|
private Fragment mParent;
|
||||||
private FragmentManager mFragmentManager;
|
private FragmentManager mFragmentManager;
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
private final InputManager mIm;
|
|
||||||
|
|
||||||
public ModifierKeysRestorePreferenceController(Context context, String key) {
|
public ModifierKeysRestorePreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mIm = context.getSystemService(InputManager.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFragment(Fragment parent) {
|
public void setFragment(Fragment parent) {
|
||||||
@@ -57,9 +53,6 @@ public class ModifierKeysRestorePreferenceController extends BasePreferenceContr
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mScreen = screen;
|
mScreen = screen;
|
||||||
// The dialog screen depends on the previous selected key's fragment.
|
|
||||||
// In the rotation scenario, we should remove the previous dialog first.
|
|
||||||
clearPreviousDialog();
|
|
||||||
setResetKeyColor();
|
setResetKeyColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,8 +71,8 @@ public class ModifierKeysRestorePreferenceController extends BasePreferenceContr
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showResetDialog() {
|
private void showResetDialog() {
|
||||||
ModifierKeysResetDialogFragment fragment =
|
mFragmentManager = mParent.getFragmentManager();
|
||||||
new ModifierKeysResetDialogFragment(mScreen, mIm);
|
ModifierKeysResetDialogFragment fragment = new ModifierKeysResetDialogFragment();
|
||||||
fragment.setTargetFragment(mParent, 0);
|
fragment.setTargetFragment(mParent, 0);
|
||||||
fragment.show(mFragmentManager, KEY_TAG);
|
fragment.show(mFragmentManager, KEY_TAG);
|
||||||
}
|
}
|
||||||
@@ -98,13 +91,4 @@ public class ModifierKeysRestorePreferenceController extends BasePreferenceContr
|
|||||||
return Utils.getColorAttrDefaultColor(
|
return Utils.getColorAttrDefaultColor(
|
||||||
mParent.getActivity(), com.android.internal.R.attr.materialColorPrimaryContainer);
|
mParent.getActivity(), com.android.internal.R.attr.materialColorPrimaryContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearPreviousDialog() {
|
|
||||||
mFragmentManager = mParent.getFragmentManager();
|
|
||||||
DialogFragment preResetDialogFragment =
|
|
||||||
(DialogFragment) mFragmentManager.findFragmentByTag(KEY_TAG);
|
|
||||||
if (preResetDialogFragment != null) {
|
|
||||||
preResetDialogFragment.dismiss();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,8 @@
|
|||||||
package com.android.settings.localepicker;
|
package com.android.settings.localepicker;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
@@ -65,10 +67,14 @@ public class LocaleHelperPreferenceController extends AbstractPreferenceControll
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void openLocaleLearnMoreLink() {
|
private void openLocaleLearnMoreLink() {
|
||||||
mContext.startActivity(
|
Intent intent = HelpUtils.getHelpIntent(
|
||||||
HelpUtils.getHelpIntent(
|
|
||||||
mContext,
|
mContext,
|
||||||
mContext.getString(R.string.link_locale_picker_footer_learn_more),
|
mContext.getString(R.string.link_locale_picker_footer_learn_more),
|
||||||
/*backupContext=*/""));
|
mContext.getClass().getName());
|
||||||
|
if (intent != null) {
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "HelpIntent is null");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 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.settings.notetask.shortcut
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.role.RoleManager
|
||||||
|
import android.app.role.RoleManager.ROLE_NOTES
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.pm.ShortcutInfo
|
||||||
|
import android.content.pm.ShortcutManager
|
||||||
|
import android.graphics.drawable.Icon
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.PersistableBundle
|
||||||
|
import android.os.UserHandle
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.core.content.getSystemService
|
||||||
|
import com.android.settings.R
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activity responsible for create a shortcut for notes action. If the shortcut is enabled, a new
|
||||||
|
* shortcut will appear in the widget picker. If the shortcut is selected, the Activity here will be
|
||||||
|
* launched, creating a new shortcut for [CreateNoteTaskShortcutActivity], and will finish.
|
||||||
|
*
|
||||||
|
* @see <a
|
||||||
|
* href="https://developer.android.com/develop/ui/views/launch/shortcuts/creating-shortcuts#custom-pinned">Creating
|
||||||
|
* a custom shortcut activity</a>
|
||||||
|
*/
|
||||||
|
internal class CreateNoteTaskShortcutActivity : ComponentActivity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
val roleManager = requireNotNull(getSystemService<RoleManager>())
|
||||||
|
val shortcutManager = requireNotNull(getSystemService<ShortcutManager>())
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
val shortcutInfo = roleManager.createNoteShortcutInfoAsUser(context = this, user)
|
||||||
|
val shortcutIntent = shortcutManager.createShortcutResultIntent(shortcutInfo)
|
||||||
|
setResult(Activity.RESULT_OK, shortcutIntent)
|
||||||
|
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
|
||||||
|
private const val SHORTCUT_ID = "note_task_shortcut_id"
|
||||||
|
private const val EXTRA_SHORTCUT_BADGE_OVERRIDE_PACKAGE =
|
||||||
|
"extra_shortcut_badge_override_package"
|
||||||
|
private const val ACTION_LAUNCH_NOTE_TASK = "com.android.systemui.action.LAUNCH_NOTE_TASK"
|
||||||
|
|
||||||
|
private fun RoleManager.createNoteShortcutInfoAsUser(
|
||||||
|
context: Context,
|
||||||
|
user: UserHandle,
|
||||||
|
): ShortcutInfo? {
|
||||||
|
val systemUiComponent = context.getSystemUiComponent() ?: return null
|
||||||
|
|
||||||
|
val extras = PersistableBundle()
|
||||||
|
getDefaultRoleHolderAsUser(ROLE_NOTES, user)?.let { packageName ->
|
||||||
|
// Set custom app badge using the icon from ROLES_NOTES default app.
|
||||||
|
extras.putString(EXTRA_SHORTCUT_BADGE_OVERRIDE_PACKAGE, packageName)
|
||||||
|
}
|
||||||
|
|
||||||
|
val icon = Icon.createWithResource(context, R.drawable.ic_note_task_shortcut_widget)
|
||||||
|
|
||||||
|
val intent = Intent(ACTION_LAUNCH_NOTE_TASK).apply {
|
||||||
|
setPackage(systemUiComponent.packageName)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ShortcutInfo.Builder(context, SHORTCUT_ID)
|
||||||
|
.setIntent(intent)
|
||||||
|
.setShortLabel(context.getString(R.string.note_task_button_label))
|
||||||
|
.setLongLived(true)
|
||||||
|
.setIcon(icon)
|
||||||
|
.setExtras(extras)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun RoleManager.getDefaultRoleHolderAsUser(
|
||||||
|
role: String,
|
||||||
|
user: UserHandle,
|
||||||
|
): String? = getRoleHoldersAsUser(role, user).firstOrNull()
|
||||||
|
|
||||||
|
private fun Context.getSystemUiComponent(): ComponentName? {
|
||||||
|
val flattenName = getString(
|
||||||
|
com.android.internal.R.string.config_systemUIServiceComponent)
|
||||||
|
check(flattenName.isNotEmpty()) {
|
||||||
|
"No 'com.android.internal.R.string.config_systemUIServiceComponent' resource"
|
||||||
|
}
|
||||||
|
return try {
|
||||||
|
ComponentName.unflattenFromString(flattenName)
|
||||||
|
} catch (e: RuntimeException) {
|
||||||
|
val message = "Invalid component name defined by 'com.android.internal.R.string." +
|
||||||
|
"config_systemUIServiceComponent' resource: $flattenName"
|
||||||
|
throw IllegalStateException(message, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,74 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2023 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.settings.regionalpreferences;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settingslib.HelpUtils;
|
||||||
|
import com.android.settingslib.widget.FooterPreference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preference controller for regional preference footer.
|
||||||
|
*/
|
||||||
|
public class RegionalFooterPreferenceController extends BasePreferenceController {
|
||||||
|
|
||||||
|
private static final String TAG = "RegionalFooterPreferenceController";
|
||||||
|
|
||||||
|
public RegionalFooterPreferenceController(Context context, String preferenceKey) {
|
||||||
|
super(context, preferenceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
return AVAILABLE_UNSEARCHABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
|
super.displayPreference(screen);
|
||||||
|
FooterPreference footerPreference = screen.findPreference(getPreferenceKey());
|
||||||
|
setupFooterPreference(footerPreference);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void setupFooterPreference(FooterPreference footerPreference) {
|
||||||
|
if (footerPreference != null) {
|
||||||
|
footerPreference.setLearnMoreAction(v -> openLocaleLearnMoreLink());
|
||||||
|
footerPreference.setLearnMoreText(mContext.getString(
|
||||||
|
R.string.desc_regional_pref_footer_learn_more));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openLocaleLearnMoreLink() {
|
||||||
|
Intent intent = HelpUtils.getHelpIntent(
|
||||||
|
mContext,
|
||||||
|
mContext.getString(R.string.regional_pref_footer_learn_more_link),
|
||||||
|
mContext.getClass().getName());
|
||||||
|
if (intent != null) {
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "HelpIntent is null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -38,6 +38,7 @@ import com.android.settingslib.spa.widget.preference.PreferenceModel
|
|||||||
import com.android.settingslib.spa.widget.ui.SpinnerOption
|
import com.android.settingslib.spa.widget.ui.SpinnerOption
|
||||||
import com.android.settingslib.spaprivileged.model.app.AppListModel
|
import com.android.settingslib.spaprivileged.model.app.AppListModel
|
||||||
import com.android.settingslib.spaprivileged.model.app.AppRecord
|
import com.android.settingslib.spaprivileged.model.app.AppRecord
|
||||||
|
import com.android.settingslib.spaprivileged.model.app.installed
|
||||||
import com.android.settingslib.spaprivileged.template.app.AppList
|
import com.android.settingslib.spaprivileged.template.app.AppList
|
||||||
import com.android.settingslib.spaprivileged.template.app.AppListInput
|
import com.android.settingslib.spaprivileged.template.app.AppListInput
|
||||||
import com.android.settingslib.spaprivileged.template.app.AppListItem
|
import com.android.settingslib.spaprivileged.template.app.AppListItem
|
||||||
@@ -75,6 +76,7 @@ fun AllAppListPage(
|
|||||||
title = stringResource(R.string.all_apps),
|
title = stringResource(R.string.all_apps),
|
||||||
listModel = rememberContext(::AllAppListModel),
|
listModel = rememberContext(::AllAppListModel),
|
||||||
showInstantApps = true,
|
showInstantApps = true,
|
||||||
|
matchAnyUserForAdmin = true,
|
||||||
moreOptions = { ResetAppPreferences(resetAppDialogPresenter::open) },
|
moreOptions = { ResetAppPreferences(resetAppDialogPresenter::open) },
|
||||||
appList = appList,
|
appList = appList,
|
||||||
)
|
)
|
||||||
@@ -133,8 +135,13 @@ class AllAppListModel(
|
|||||||
return remember {
|
return remember {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
storageSummary.value +
|
storageSummary.value +
|
||||||
when (isDisabled(record)) {
|
when {
|
||||||
true -> System.lineSeparator() + context.getString(R.string.disabled)
|
!record.app.installed -> {
|
||||||
|
System.lineSeparator() + context.getString(R.string.not_installed)
|
||||||
|
}
|
||||||
|
isDisabled(record) -> {
|
||||||
|
System.lineSeparator() + context.getString(R.string.disabled)
|
||||||
|
}
|
||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,8 +30,10 @@ import com.android.settings.notification.app.AppNotificationSettings
|
|||||||
import com.android.settings.spa.notification.AppNotificationRepository
|
import com.android.settings.spa.notification.AppNotificationRepository
|
||||||
import com.android.settings.spa.notification.IAppNotificationRepository
|
import com.android.settings.spa.notification.IAppNotificationRepository
|
||||||
import com.android.settingslib.spa.framework.compose.rememberContext
|
import com.android.settingslib.spa.framework.compose.rememberContext
|
||||||
|
import com.android.settingslib.spa.framework.compose.stateOf
|
||||||
import com.android.settingslib.spa.widget.preference.Preference
|
import com.android.settingslib.spa.widget.preference.Preference
|
||||||
import com.android.settingslib.spa.widget.preference.PreferenceModel
|
import com.android.settingslib.spa.widget.preference.PreferenceModel
|
||||||
|
import com.android.settingslib.spaprivileged.model.app.installed
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.flow
|
import kotlinx.coroutines.flow.flow
|
||||||
import kotlinx.coroutines.flow.flowOn
|
import kotlinx.coroutines.flow.flowOn
|
||||||
@@ -53,6 +55,7 @@ fun AppNotificationPreference(
|
|||||||
override val summary = summaryFlow.collectAsStateWithLifecycle(
|
override val summary = summaryFlow.collectAsStateWithLifecycle(
|
||||||
initialValue = stringResource(R.string.summary_placeholder)
|
initialValue = stringResource(R.string.summary_placeholder)
|
||||||
)
|
)
|
||||||
|
override val enabled = stateOf(app.installed)
|
||||||
override val onClick = { navigateToAppNotificationSettings(context, app) }
|
override val onClick = { navigateToAppNotificationSettings(context, app) }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -141,7 +141,9 @@ class PackageInfoPresenter(
|
|||||||
private fun getPackageInfo() =
|
private fun getPackageInfo() =
|
||||||
packageManagers.getPackageInfoAsUser(
|
packageManagers.getPackageInfoAsUser(
|
||||||
packageName = packageName,
|
packageName = packageName,
|
||||||
flags = PackageManager.MATCH_DISABLED_COMPONENTS or PackageManager.GET_PERMISSIONS,
|
flags = PackageManager.MATCH_ANY_USER or
|
||||||
|
PackageManager.MATCH_DISABLED_COMPONENTS or
|
||||||
|
PackageManager.GET_PERMISSIONS,
|
||||||
userId = userId,
|
userId = userId,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,7 @@ import androidx.compose.runtime.livedata.observeAsState
|
|||||||
import com.android.settings.R
|
import com.android.settings.R
|
||||||
import com.android.settingslib.spaprivileged.model.app.AppOpsController
|
import com.android.settingslib.spaprivileged.model.app.AppOpsController
|
||||||
import com.android.settingslib.spaprivileged.model.app.AppRecord
|
import com.android.settingslib.spaprivileged.model.app.AppRecord
|
||||||
|
import com.android.settingslib.spaprivileged.model.app.installed
|
||||||
import com.android.settingslib.spaprivileged.model.app.userId
|
import com.android.settingslib.spaprivileged.model.app.userId
|
||||||
import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListModel
|
import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListModel
|
||||||
import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider
|
import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider
|
||||||
@@ -67,11 +68,12 @@ class PictureInPictureListModel(private val context: Context) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun transformItem(app: ApplicationInfo): PictureInPictureRecord {
|
override fun transformItem(app: ApplicationInfo): PictureInPictureRecord {
|
||||||
val packageInfo =
|
|
||||||
packageManager.getPackageInfoAsUser(app.packageName, GET_ACTIVITIES_FLAGS, app.userId)
|
|
||||||
return createPictureInPictureRecord(
|
return createPictureInPictureRecord(
|
||||||
app = app,
|
app = app,
|
||||||
isSupport = packageInfo.supportsPictureInPicture(),
|
isSupport = app.installed &&
|
||||||
|
packageManager
|
||||||
|
.getPackageInfoAsUser(app.packageName, GET_ACTIVITIES_FLAGS, app.userId)
|
||||||
|
.supportsPictureInPicture(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -160,30 +160,6 @@ public class UtilsTest {
|
|||||||
Utils.maybeInitializeVolume(storageManager, new Bundle());
|
Utils.maybeInitializeVolume(storageManager, new Bundle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getInstallationStatus_notInstalled_shouldReturnUninstalled() {
|
|
||||||
assertThat(Utils.getInstallationStatus(new ApplicationInfo()))
|
|
||||||
.isEqualTo(R.string.not_installed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getInstallationStatus_enabled_shouldReturnInstalled() {
|
|
||||||
final ApplicationInfo info = new ApplicationInfo();
|
|
||||||
info.flags = ApplicationInfo.FLAG_INSTALLED;
|
|
||||||
info.enabled = true;
|
|
||||||
|
|
||||||
assertThat(Utils.getInstallationStatus(info)).isEqualTo(R.string.installed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getInstallationStatus_disabled_shouldReturnDisabled() {
|
|
||||||
final ApplicationInfo info = new ApplicationInfo();
|
|
||||||
info.flags = ApplicationInfo.FLAG_INSTALLED;
|
|
||||||
info.enabled = false;
|
|
||||||
|
|
||||||
assertThat(Utils.getInstallationStatus(info)).isEqualTo(R.string.disabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isProfileOrDeviceOwner_deviceOwnerApp_returnTrue() {
|
public void isProfileOrDeviceOwner_deviceOwnerApp_returnTrue() {
|
||||||
when(mDevicePolicyManager.isDeviceOwnerAppOnAnyUser(PACKAGE_NAME)).thenReturn(true);
|
when(mDevicePolicyManager.isDeviceOwnerAppOnAnyUser(PACKAGE_NAME)).thenReturn(true);
|
||||||
|
@@ -147,6 +147,7 @@ class AllAppListTest {
|
|||||||
val listModel = AllAppListModel(context) { stateOf(SUMMARY) }
|
val listModel = AllAppListModel(context) { stateOf(SUMMARY) }
|
||||||
val disabledApp = ApplicationInfo().apply {
|
val disabledApp = ApplicationInfo().apply {
|
||||||
packageName = PACKAGE_NAME
|
packageName = PACKAGE_NAME
|
||||||
|
flags = ApplicationInfo.FLAG_INSTALLED
|
||||||
enabled = false
|
enabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +160,23 @@ class AllAppListTest {
|
|||||||
assertThat(summaryState.value).isEqualTo("$SUMMARY${System.lineSeparator()}Disabled")
|
assertThat(summaryState.value).isEqualTo("$SUMMARY${System.lineSeparator()}Disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun allAppListModel_getSummaryWhenNotInstalled() {
|
||||||
|
val listModel = AllAppListModel(context) { stateOf(SUMMARY) }
|
||||||
|
val notInstalledApp = ApplicationInfo().apply {
|
||||||
|
packageName = PACKAGE_NAME
|
||||||
|
}
|
||||||
|
|
||||||
|
lateinit var summaryState: State<String>
|
||||||
|
composeTestRule.setContent {
|
||||||
|
summaryState =
|
||||||
|
listModel.getSummary(option = 0, record = AppRecordWithSize(app = notInstalledApp))
|
||||||
|
}
|
||||||
|
|
||||||
|
assertThat(summaryState.value)
|
||||||
|
.isEqualTo("$SUMMARY${System.lineSeparator()}Not installed for this user")
|
||||||
|
}
|
||||||
|
|
||||||
private fun getAppListInput(): AppListInput<AppRecordWithSize> {
|
private fun getAppListInput(): AppListInput<AppRecordWithSize> {
|
||||||
lateinit var input: AppListInput<AppRecordWithSize>
|
lateinit var input: AppListInput<AppRecordWithSize>
|
||||||
composeTestRule.setContent {
|
composeTestRule.setContent {
|
||||||
@@ -192,6 +210,7 @@ class AllAppListTest {
|
|||||||
const val SUMMARY = "Summary"
|
const val SUMMARY = "Summary"
|
||||||
val APP = ApplicationInfo().apply {
|
val APP = ApplicationInfo().apply {
|
||||||
packageName = PACKAGE_NAME
|
packageName = PACKAGE_NAME
|
||||||
|
flags = ApplicationInfo.FLAG_INSTALLED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ import android.content.pm.ApplicationInfo
|
|||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.test.assertIsDisplayed
|
import androidx.compose.ui.test.assertIsDisplayed
|
||||||
|
import androidx.compose.ui.test.assertIsNotEnabled
|
||||||
import androidx.compose.ui.test.junit4.createComposeRule
|
import androidx.compose.ui.test.junit4.createComposeRule
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.onRoot
|
import androidx.compose.ui.test.onRoot
|
||||||
@@ -72,7 +73,7 @@ class AppNotificationPreferenceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun title_displayed() {
|
fun title_displayed() {
|
||||||
setContent()
|
setContent(APP)
|
||||||
|
|
||||||
composeTestRule.onNodeWithText(context.getString(R.string.notifications_label))
|
composeTestRule.onNodeWithText(context.getString(R.string.notifications_label))
|
||||||
.assertIsDisplayed()
|
.assertIsDisplayed()
|
||||||
@@ -80,14 +81,25 @@ class AppNotificationPreferenceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun summary_displayed() {
|
fun summary_displayed() {
|
||||||
setContent()
|
setContent(APP)
|
||||||
|
|
||||||
composeTestRule.onNodeWithText(SUMMARY).assertIsDisplayed()
|
composeTestRule.onNodeWithText(SUMMARY).assertIsDisplayed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun whenNotInstalled_disable() {
|
||||||
|
setContent(ApplicationInfo().apply {
|
||||||
|
packageName = PACKAGE_NAME
|
||||||
|
uid = UID
|
||||||
|
})
|
||||||
|
|
||||||
|
composeTestRule.onNodeWithText(context.getString(R.string.notifications_label))
|
||||||
|
.assertIsNotEnabled()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onClick_startActivity() {
|
fun onClick_startActivity() {
|
||||||
setContent()
|
setContent(APP)
|
||||||
|
|
||||||
composeTestRule.onRoot().performClick()
|
composeTestRule.onRoot().performClick()
|
||||||
composeTestRule.delay()
|
composeTestRule.delay()
|
||||||
@@ -102,10 +114,10 @@ class AppNotificationPreferenceTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setContent() {
|
private fun setContent(app: ApplicationInfo) {
|
||||||
composeTestRule.setContent {
|
composeTestRule.setContent {
|
||||||
CompositionLocalProvider(LocalContext provides context) {
|
CompositionLocalProvider(LocalContext provides context) {
|
||||||
AppNotificationPreference(app = APP, repository = repository)
|
AppNotificationPreference(app = app, repository = repository)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,6 +128,7 @@ class AppNotificationPreferenceTest {
|
|||||||
val APP = ApplicationInfo().apply {
|
val APP = ApplicationInfo().apply {
|
||||||
packageName = PACKAGE_NAME
|
packageName = PACKAGE_NAME
|
||||||
uid = UID
|
uid = UID
|
||||||
|
flags = ApplicationInfo.FLAG_INSTALLED
|
||||||
}
|
}
|
||||||
const val SUMMARY = "Summary"
|
const val SUMMARY = "Summary"
|
||||||
}
|
}
|
||||||
|
@@ -167,6 +167,7 @@ class PictureInPictureTest {
|
|||||||
const val PICTURE_IN_PICTURE_PACKAGE_NAME = "picture.in.picture.package.name"
|
const val PICTURE_IN_PICTURE_PACKAGE_NAME = "picture.in.picture.package.name"
|
||||||
val PICTURE_IN_PICTURE_APP = ApplicationInfo().apply {
|
val PICTURE_IN_PICTURE_APP = ApplicationInfo().apply {
|
||||||
packageName = PICTURE_IN_PICTURE_PACKAGE_NAME
|
packageName = PICTURE_IN_PICTURE_PACKAGE_NAME
|
||||||
|
flags = ApplicationInfo.FLAG_INSTALLED
|
||||||
}
|
}
|
||||||
val PICTURE_IN_PICTURE_PACKAGE_INFO = PackageInfo().apply {
|
val PICTURE_IN_PICTURE_PACKAGE_INFO = PackageInfo().apply {
|
||||||
packageName = PICTURE_IN_PICTURE_PACKAGE_NAME
|
packageName = PICTURE_IN_PICTURE_PACKAGE_NAME
|
||||||
|
@@ -0,0 +1,62 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2023 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.settings.regionalpreferences;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.anyString;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.settingslib.widget.FooterPreference;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class RegionalFooterPreferenceControllerTest {
|
||||||
|
|
||||||
|
private static String KEY_FOOTER_PREFERENCE = "regional_pref_footer";
|
||||||
|
private Context mContext;
|
||||||
|
private RegionalFooterPreferenceController mRegionalFooterPreferenceController;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private FooterPreference mMockFooterPreference;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
if (Looper.myLooper() == null) {
|
||||||
|
Looper.prepare();
|
||||||
|
}
|
||||||
|
mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
mRegionalFooterPreferenceController = new RegionalFooterPreferenceController(mContext,
|
||||||
|
KEY_FOOTER_PREFERENCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setupFooterPreference_shouldSetAsTextInLearnMore() {
|
||||||
|
mRegionalFooterPreferenceController.setupFooterPreference(mMockFooterPreference);
|
||||||
|
verify(mMockFooterPreference).setLearnMoreText(anyString());
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user