Permalink
Browse files

DevelopmentSettings: Add dynamic dashboard summary

Dashboard summary changes with ADB toggle's value

Change-Id: I4daf82f3258562a5a54a30f2094f1793d41757e4
  • Loading branch information...
MSF-Jarvis authored and akhilnarang committed May 26, 2017
1 parent 3ec6e93 commit b1b7deb41ba7ec9e2b99331993855295116c6904
Showing with 39 additions and 2 deletions.
  1. +4 −1 res/values/aosip_strings.xml
  2. +35 −1 src/com/android/settings/DevelopmentSettings.java
@@ -257,7 +257,10 @@
<string name="camera_sounds_summary">Enable camera shutter sound</string>
<string name="camera_sound_warning_dialog_text">Disabling the camera shutter sound is illegal in some areas! Please check the applicable law in your country</string>
<!-- Volume settings - Volume adjustment sound -->
<!-- Volume settings - Volume adjustment sound -->
<string name="volume_adjust_sounds_title">Volume adjustment sounds</string>
<!-- Development Settings summary-->
<string name="adb_enabled">ADB Enabled</string>
<string name="adb_disabled">ADB Disabled</string>
</resources>
@@ -84,6 +84,7 @@
import com.android.internal.app.LocalePicker;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settings.applications.BackgroundCheckSummary;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.fuelgauge.InactiveApps;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
@@ -94,7 +95,6 @@
import com.android.settings.util.Helpers;
import dalvik.system.VMRuntime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@@ -2478,4 +2478,38 @@ private boolean isOemUnlockAllowed() {
return !(mUm.hasBaseUserRestriction(UserManager.DISALLOW_OEM_UNLOCK, userHandle)
|| mUm.hasBaseUserRestriction(UserManager.DISALLOW_FACTORY_RESET, userHandle));
}
private static class SummaryProvider implements SummaryLoader.SummaryProvider {
private final Context mContext;
private final SummaryLoader mSummaryLoader;
private ContentResolver resolver;
public SummaryProvider(Context context, SummaryLoader summaryLoader) {
mContext = context;
mSummaryLoader = summaryLoader;
resolver = mContext.getContentResolver();
}
@Override
public void setListening(boolean listening) {
if (listening) {
boolean adbEnabled = Settings.Global.getInt(resolver,
Settings.Global.ADB_ENABLED, 0) != 0;
String newSummary = adbEnabled ? mContext.getString(R.string.adb_enabled)
: mContext.getString(R.string.adb_disabled);
mSummaryLoader.setSummary(this, newSummary);
}
}
}
public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
= new SummaryLoader.SummaryProviderFactory() {
@Override
public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
SummaryLoader summaryLoader) {
return new SummaryProvider(activity, summaryLoader);
}
};
}

0 comments on commit b1b7deb

Please sign in to comment.