Use app name as summary in default home app setting.

Bug: 27834147

Condition: Only use app name as summary if there is only 1 launcher app
installed.

Change-Id: Idb9b55d5618bbdbea6446758f2fcd09d0d6309af
This commit is contained in:
Fan Zhang
2016-07-11 15:25:03 -07:00
parent 68d65abaaa
commit 233daf469d
3 changed files with 73 additions and 30 deletions

View File

@@ -32,6 +32,7 @@ import android.os.Parcelable;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@@ -265,6 +266,24 @@ public class AppListPreference extends CustomListPreference {
}
}
/**
* Sets app label as summary if there is only 1 app applicable to this preference.
*/
protected void setSoleAppLabelAsSummary() {
final CharSequence soleLauncherLabel = getSoleAppLabel();
if (!TextUtils.isEmpty(soleLauncherLabel)) {
setSummary(soleLauncherLabel);
}
}
/**
* Returns app label if there is only 1 app applicable to this preference.
*/
protected CharSequence getSoleAppLabel() {
// Intentionally left empty so subclasses can override with necessary logic.
return null;
}
private static class SavedState implements Parcelable {
public final CharSequence[] entryValues;