Merge "Add indicator for system dialer in Settings" into nyc-dev
This commit is contained in:
@@ -69,4 +69,26 @@
|
|||||||
android:paddingEnd="7dip"
|
android:paddingEnd="7dip"
|
||||||
android:duplicateParentState="true"
|
android:duplicateParentState="true"
|
||||||
/>
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/system_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="@string/system_app"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:paddingEnd="7dip"
|
||||||
|
android:duplicateParentState="true"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/system_default_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="@string/system_default_app"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:paddingEnd="7dip"
|
||||||
|
android:duplicateParentState="true"
|
||||||
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -6607,6 +6607,12 @@
|
|||||||
<!-- Label of default app for current setting [CHAR LIMIT=40] -->
|
<!-- Label of default app for current setting [CHAR LIMIT=40] -->
|
||||||
<string name="default_app">(Default)</string>
|
<string name="default_app">(Default)</string>
|
||||||
|
|
||||||
|
<!-- Label of system app for current setting -->
|
||||||
|
<string name="system_app">(System)</string>
|
||||||
|
|
||||||
|
<!-- Label of system and default app for current setting -->
|
||||||
|
<string name="system_default_app">(System default)</string>
|
||||||
|
|
||||||
<!-- Title of app storage screen [CHAR LIMIT=30] -->
|
<!-- Title of app storage screen [CHAR LIMIT=30] -->
|
||||||
<string name="apps_storage">Apps storage</string>
|
<string name="apps_storage">Apps storage</string>
|
||||||
|
|
||||||
|
@@ -56,6 +56,7 @@ public class AppListPreference extends CustomListPreference {
|
|||||||
private Drawable[] mEntryDrawables;
|
private Drawable[] mEntryDrawables;
|
||||||
private boolean mShowItemNone = false;
|
private boolean mShowItemNone = false;
|
||||||
private CharSequence[] mSummaries;
|
private CharSequence[] mSummaries;
|
||||||
|
private int mSystemAppIndex = -1;
|
||||||
|
|
||||||
public class AppArrayAdapter extends ArrayAdapter<CharSequence> {
|
public class AppArrayAdapter extends ArrayAdapter<CharSequence> {
|
||||||
private Drawable[] mImageDrawables = null;
|
private Drawable[] mImageDrawables = null;
|
||||||
@@ -79,8 +80,12 @@ public class AppListPreference extends CustomListPreference {
|
|||||||
View view = inflater.inflate(R.layout.app_preference_item, parent, false);
|
View view = inflater.inflate(R.layout.app_preference_item, parent, false);
|
||||||
TextView textView = (TextView) view.findViewById(android.R.id.title);
|
TextView textView = (TextView) view.findViewById(android.R.id.title);
|
||||||
textView.setText(getItem(position));
|
textView.setText(getItem(position));
|
||||||
if (position == mSelectedIndex) {
|
if (position == mSelectedIndex && position == mSystemAppIndex) {
|
||||||
|
view.findViewById(R.id.system_default_label).setVisibility(View.VISIBLE);
|
||||||
|
} else if (position == mSelectedIndex) {
|
||||||
view.findViewById(R.id.default_label).setVisibility(View.VISIBLE);
|
view.findViewById(R.id.default_label).setVisibility(View.VISIBLE);
|
||||||
|
} else if (position == mSystemAppIndex) {
|
||||||
|
view.findViewById(R.id.system_label).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
|
ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
|
||||||
imageView.setImageDrawable(mImageDrawables[position]);
|
imageView.setImageDrawable(mImageDrawables[position]);
|
||||||
@@ -122,6 +127,11 @@ public class AppListPreference extends CustomListPreference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPackageNames(CharSequence[] packageNames, CharSequence defaultPackageName) {
|
public void setPackageNames(CharSequence[] packageNames, CharSequence defaultPackageName) {
|
||||||
|
setPackageNames(packageNames, defaultPackageName, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackageNames(CharSequence[] packageNames, CharSequence defaultPackageName,
|
||||||
|
CharSequence systemPackageName) {
|
||||||
// Look up all package names in PackageManager. Skip ones we can't find.
|
// Look up all package names in PackageManager. Skip ones we can't find.
|
||||||
PackageManager pm = getContext().getPackageManager();
|
PackageManager pm = getContext().getPackageManager();
|
||||||
final int entryCount = packageNames.length + (mShowItemNone ? 1 : 0);
|
final int entryCount = packageNames.length + (mShowItemNone ? 1 : 0);
|
||||||
@@ -129,6 +139,7 @@ public class AppListPreference extends CustomListPreference {
|
|||||||
List<CharSequence> validatedPackageNames = new ArrayList<>(entryCount);
|
List<CharSequence> validatedPackageNames = new ArrayList<>(entryCount);
|
||||||
List<Drawable> entryDrawables = new ArrayList<>(entryCount);
|
List<Drawable> entryDrawables = new ArrayList<>(entryCount);
|
||||||
int selectedIndex = -1;
|
int selectedIndex = -1;
|
||||||
|
mSystemAppIndex = -1;
|
||||||
for (int i = 0; i < packageNames.length; i++) {
|
for (int i = 0; i < packageNames.length; i++) {
|
||||||
try {
|
try {
|
||||||
ApplicationInfo appInfo = pm.getApplicationInfoAsUser(packageNames[i].toString(), 0,
|
ApplicationInfo appInfo = pm.getApplicationInfoAsUser(packageNames[i].toString(), 0,
|
||||||
@@ -140,6 +151,10 @@ public class AppListPreference extends CustomListPreference {
|
|||||||
appInfo.packageName.contentEquals(defaultPackageName)) {
|
appInfo.packageName.contentEquals(defaultPackageName)) {
|
||||||
selectedIndex = i;
|
selectedIndex = i;
|
||||||
}
|
}
|
||||||
|
if (appInfo.packageName != null && systemPackageName != null &&
|
||||||
|
appInfo.packageName.contentEquals(systemPackageName)) {
|
||||||
|
mSystemAppIndex = i;
|
||||||
|
}
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
// Skip unknown packages.
|
// Skip unknown packages.
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ import android.content.Context;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.telecom.DefaultDialerManager;
|
import android.telecom.DefaultDialerManager;
|
||||||
|
import android.telecom.TelecomManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@@ -56,13 +57,18 @@ public class DefaultPhonePreference extends AppListPreference implements SelfAva
|
|||||||
for (int i = 0; i < dialerPackages.size(); i++) {
|
for (int i = 0; i < dialerPackages.size(); i++) {
|
||||||
dialers[i] = dialerPackages.get(i);
|
dialers[i] = dialerPackages.get(i);
|
||||||
}
|
}
|
||||||
setPackageNames(dialers, getDefaultPackage());
|
setPackageNames(dialers, getDefaultPackage(), getSystemPackage());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDefaultPackage() {
|
private String getDefaultPackage() {
|
||||||
return DefaultDialerManager.getDefaultDialerApplication(getContext(), mUserId);
|
return DefaultDialerManager.getDefaultDialerApplication(getContext(), mUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getSystemPackage() {
|
||||||
|
TelecomManager tm = TelecomManager.from(getContext());
|
||||||
|
return tm.getSystemDialerPackage();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable(Context context) {
|
public boolean isAvailable(Context context) {
|
||||||
final TelephonyManager tm =
|
final TelephonyManager tm =
|
||||||
|
Reference in New Issue
Block a user