Merge "Update battery states text to support battery feature(1/2)" into sc-dev
diff --git a/res/layout/more_settings_button.xml b/res/layout/more_settings_button.xml
index 84ef75a..7140d79 100644
--- a/res/layout/more_settings_button.xml
+++ b/res/layout/more_settings_button.xml
@@ -23,11 +23,13 @@
<Button
android:id="@+id/button"
style="@style/ActionPrimaryButton"
+ android:theme="@style/RoundedCornerThemeOverlay"
+ android:paddingHorizontal="16dp"
+ android:drawablePadding="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="8dp"
android:layout_marginHorizontal="16dp"
- android:theme="@style/RoundedCornerThemeOverlay"
settings:allowDividerBelow="true"/>
</FrameLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ce266e2..edabf61 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7176,9 +7176,9 @@
<!-- Preference summary for app not supporting always-on VPN [CHAR LIMIT=40] -->
<string name="vpn_always_on_summary_not_supported">Not supported by this app</string>
<!-- Preference summary for a VPN app that is set to be always-on. [CHAR LIMIT=40] -->
- <string name="vpn_always_on_summary_active">Always-on active</string>
+ <string name="vpn_always_on_summary_active">Always on</string>
<!-- Preference summary for a VPN app that has an insecure type. [CHAR LIMIT=40] -->
- <string name="vpn_insecure_summary">not secure VPN</string>
+ <string name="vpn_insecure_summary">Not secure</string>
<!-- Preference title for the toggle that controls whether to force all network connections to
go through VPN. [CHAR LIMIT=40] -->
<string name="vpn_require_connection">Block connections without VPN</string>
@@ -10532,9 +10532,9 @@
<!-- Media management apps settings title [CHAR LIMIT=40] -->
<string name="media_management_apps_title">Media management apps</string>
<!-- Label for a setting which controls whether an app can manage media files [CHAR LIMIT=45] -->
- <string name="media_management_apps_toggle_label">Allow app to manage media files</string>
+ <string name="media_management_apps_toggle_label">Allow app to manage media</string>
<!-- Description for a setting which controls whether an app can manage media files [CHAR LIMIT=NONE] -->
- <string name="media_management_apps_description">If allowed, this app can modify or delete media files on this device or connected storage device without asking you. App must have permission to access files and media.</string>
+ <string name="media_management_apps_description">If allowed, this app can modify or delete media files created with other apps without asking you. App must have permission to access files and media.</string>
<!-- Search keywords for media management apps settings [CHAR_LIMIT=NONE] -->
<string name="keywords_media_management_apps">Media, File, Management, Manager, Manage, Edit, Editor, App, Application, Program</string>
diff --git a/src/com/android/settings/emergency/MoreSettingsPreferenceController.java b/src/com/android/settings/emergency/MoreSettingsPreferenceController.java
index 34c11c7..3c9ae6e 100644
--- a/src/com/android/settings/emergency/MoreSettingsPreferenceController.java
+++ b/src/com/android/settings/emergency/MoreSettingsPreferenceController.java
@@ -25,9 +25,15 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
+import android.util.DisplayMetrics;
import android.util.Log;
+import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
@@ -35,6 +41,7 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.widget.LayoutPreference;
@@ -77,7 +84,17 @@
super.displayPreference(screen);
final LayoutPreference pref = screen.findPreference(getPreferenceKey());
final Button button = pref.findViewById(R.id.button);
+ final Drawable icon = getIcon();
button.setText(getButtonText());
+ if (icon != null) {
+ button.setCompoundDrawablesWithIntrinsicBounds(
+ /* left= */ icon,
+ /* top= */null,
+ /* right= */ null,
+ /* bottom= */ null);
+ button.setVisibility(View.VISIBLE);
+ }
+
button.setOnClickListener(this);
}
@@ -100,6 +117,21 @@
mContext.startActivity(intent, bundle);
}
+ private Drawable getIcon() {
+ final String packageName = mContext.getResources().getString(
+ R.string.config_emergency_package_name);
+ try {
+ final PackageManager pm = mContext.getPackageManager();
+ final ApplicationInfo appInfo = pm.getApplicationInfo(
+ packageName, MATCH_DISABLED_COMPONENTS
+ | MATCH_DISABLED_UNTIL_USED_COMPONENTS);
+ return getScaledDrawable(mContext, Utils.getBadgedIcon(mContext, appInfo), 24, 24);
+ } catch (Exception e) {
+ Log.d(TAG, "Failed to get open app button icon", e);
+ return null;
+ }
+ }
+
private CharSequence getButtonText() {
final String packageName = mContext.getResources().getString(
R.string.config_emergency_package_name);
@@ -114,4 +146,29 @@
return "";
}
}
+
+ private static Drawable getScaledDrawable(Context context, Drawable icon, int width,
+ int height) {
+ DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
+ int widthInDp =
+ (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, width, displayMetrics);
+ int heightInDp =
+ (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, height,
+ displayMetrics);
+
+ return new BitmapDrawable(context.getResources(),
+ convertToBitmap(icon, widthInDp, heightInDp));
+ }
+
+ private static Bitmap convertToBitmap(Drawable icon, int width, int height) {
+ if (icon == null) {
+ return null;
+ }
+ Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bitmap);
+ icon.setBounds(0, 0, width, height);
+ icon.draw(canvas);
+ return bitmap;
+ }
+
}
diff --git a/src/com/android/settings/vpn2/ManageablePreference.java b/src/com/android/settings/vpn2/ManageablePreference.java
index c65073f..b785186 100644
--- a/src/com/android/settings/vpn2/ManageablePreference.java
+++ b/src/com/android/settings/vpn2/ManageablePreference.java
@@ -107,21 +107,20 @@
final Resources res = getContext().getResources();
final String[] states = res.getStringArray(R.array.vpn_states);
String summary = (mState == STATE_NONE ? "" : states[mState]);
- if (mIsAlwaysOn) {
- final String alwaysOnString = res.getString(R.string.vpn_always_on_summary_active);
- summary = TextUtils.isEmpty(summary) ? alwaysOnString : res.getString(
- R.string.join_two_unrelated_items, summary, alwaysOnString);
- }
if (mIsInsecureVpn) {
final String insecureString = res.getString(R.string.vpn_insecure_summary);
- summary = TextUtils.isEmpty(summary) ? insecureString : res.getString(
- R.string.join_two_unrelated_items, summary, insecureString);
+ summary = TextUtils.isEmpty(summary) ? insecureString : summary + " / "
+ + insecureString;
SpannableString summarySpan = new SpannableString(summary);
final int colorError = Utils.getColorErrorDefaultColor(getContext());
summarySpan.setSpan(new ForegroundColorSpan(colorError), 0, summary.length(),
SPAN_EXCLUSIVE_INCLUSIVE);
setSummary(summarySpan);
+ } else if (mIsAlwaysOn) {
+ final String alwaysOnString = res.getString(R.string.vpn_always_on_summary_active);
+ summary = TextUtils.isEmpty(summary) ? alwaysOnString : summary + " / "
+ + alwaysOnString;
} else {
setSummary(summary);
}