Loading packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java +21 −11 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.provider.Settings; import android.provider.Settings.Global; import android.view.LayoutInflater; Loading @@ -46,20 +47,17 @@ public class DndTile extends QSTile<QSTile.BooleanState> { private final DndDetailAdapter mDetailAdapter; private boolean mListening; private boolean mVisible; private boolean mShowingDetail; public DndTile(Host host) { super(host); mController = host.getZenModeController(); mDetailAdapter = new DndDetailAdapter(); mVisible = isVisible(host.getContext()); mContext.registerReceiver(mReceiver, new IntentFilter(ACTION_SET_VISIBLE)); } public static void setVisible(Context context, boolean visible) { context.sendBroadcast(new Intent(DndTile.ACTION_SET_VISIBLE) .putExtra(DndTile.EXTRA_VISIBLE, visible)); getSharedPrefs(context).edit().putBoolean(PREF_KEY_VISIBLE, visible).commit(); } public static boolean isVisible(Context context) { Loading Loading @@ -98,7 +96,7 @@ public class DndTile extends QSTile<QSTile.BooleanState> { protected void handleUpdateState(BooleanState state, Object arg) { final int zen = arg instanceof Integer ? (Integer) arg : mController.getZen(); state.value = zen != Global.ZEN_MODE_OFF; state.visible = mVisible; state.visible = isVisible(mContext); switch (zen) { case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS: state.icon = ResourceIcon.get(R.drawable.ic_qs_dnd_on); Loading Loading @@ -145,26 +143,38 @@ public class DndTile extends QSTile<QSTile.BooleanState> { mListening = listening; if (mListening) { mController.addCallback(mZenCallback); getSharedPrefs(mContext).registerOnSharedPreferenceChangeListener(mPrefListener); } else { mController.removeCallback(mZenCallback); getSharedPrefs(mContext).unregisterOnSharedPreferenceChangeListener(mPrefListener); } } private static SharedPreferences getSharedPrefs(Context context) { return context.getSharedPreferences(context.getPackageName(), 0); } private final OnSharedPreferenceChangeListener mPrefListener = new OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (PREF_KEY_COMBINED_ICON.equals(key) || PREF_KEY_VISIBLE.equals(key)) { refreshState(); } } }; private final ZenModeController.Callback mZenCallback = new ZenModeController.Callback() { public void onZenChanged(int zen) { refreshState(zen); } }; private static SharedPreferences getSharedPrefs(Context context) { return context.getSharedPreferences(context.getPackageName(), 0); } private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mVisible = intent.getBooleanExtra(EXTRA_VISIBLE, false); getSharedPrefs(mContext).edit().putBoolean(PREF_KEY_VISIBLE, mVisible).commit(); final boolean visible = intent.getBooleanExtra(EXTRA_VISIBLE, false); setVisible(mContext, visible); refreshState(); } }; Loading packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java +2 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.util.Log; import android.util.SparseArray; import com.android.systemui.R; import com.android.systemui.qs.tiles.DndTile; import java.io.FileDescriptor; import java.io.PrintWriter; Loading Loading @@ -489,8 +490,7 @@ public class VolumeDialogController { public void showDndTile(boolean visible) { if (D.BUG) Log.d(TAG, "showDndTile"); mContext.sendBroadcast(new Intent("com.android.systemui.dndtile.SET_VISIBLE") .putExtra("visible", visible)); DndTile.setVisible(mContext, visible); } private final class VC extends IVolumeController.Stub { Loading Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java +21 −11 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.provider.Settings; import android.provider.Settings.Global; import android.view.LayoutInflater; Loading @@ -46,20 +47,17 @@ public class DndTile extends QSTile<QSTile.BooleanState> { private final DndDetailAdapter mDetailAdapter; private boolean mListening; private boolean mVisible; private boolean mShowingDetail; public DndTile(Host host) { super(host); mController = host.getZenModeController(); mDetailAdapter = new DndDetailAdapter(); mVisible = isVisible(host.getContext()); mContext.registerReceiver(mReceiver, new IntentFilter(ACTION_SET_VISIBLE)); } public static void setVisible(Context context, boolean visible) { context.sendBroadcast(new Intent(DndTile.ACTION_SET_VISIBLE) .putExtra(DndTile.EXTRA_VISIBLE, visible)); getSharedPrefs(context).edit().putBoolean(PREF_KEY_VISIBLE, visible).commit(); } public static boolean isVisible(Context context) { Loading Loading @@ -98,7 +96,7 @@ public class DndTile extends QSTile<QSTile.BooleanState> { protected void handleUpdateState(BooleanState state, Object arg) { final int zen = arg instanceof Integer ? (Integer) arg : mController.getZen(); state.value = zen != Global.ZEN_MODE_OFF; state.visible = mVisible; state.visible = isVisible(mContext); switch (zen) { case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS: state.icon = ResourceIcon.get(R.drawable.ic_qs_dnd_on); Loading Loading @@ -145,26 +143,38 @@ public class DndTile extends QSTile<QSTile.BooleanState> { mListening = listening; if (mListening) { mController.addCallback(mZenCallback); getSharedPrefs(mContext).registerOnSharedPreferenceChangeListener(mPrefListener); } else { mController.removeCallback(mZenCallback); getSharedPrefs(mContext).unregisterOnSharedPreferenceChangeListener(mPrefListener); } } private static SharedPreferences getSharedPrefs(Context context) { return context.getSharedPreferences(context.getPackageName(), 0); } private final OnSharedPreferenceChangeListener mPrefListener = new OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (PREF_KEY_COMBINED_ICON.equals(key) || PREF_KEY_VISIBLE.equals(key)) { refreshState(); } } }; private final ZenModeController.Callback mZenCallback = new ZenModeController.Callback() { public void onZenChanged(int zen) { refreshState(zen); } }; private static SharedPreferences getSharedPrefs(Context context) { return context.getSharedPreferences(context.getPackageName(), 0); } private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mVisible = intent.getBooleanExtra(EXTRA_VISIBLE, false); getSharedPrefs(mContext).edit().putBoolean(PREF_KEY_VISIBLE, mVisible).commit(); final boolean visible = intent.getBooleanExtra(EXTRA_VISIBLE, false); setVisible(mContext, visible); refreshState(); } }; Loading
packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java +2 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.util.Log; import android.util.SparseArray; import com.android.systemui.R; import com.android.systemui.qs.tiles.DndTile; import java.io.FileDescriptor; import java.io.PrintWriter; Loading Loading @@ -489,8 +490,7 @@ public class VolumeDialogController { public void showDndTile(boolean visible) { if (D.BUG) Log.d(TAG, "showDndTile"); mContext.sendBroadcast(new Intent("com.android.systemui.dndtile.SET_VISIBLE") .putExtra("visible", visible)); DndTile.setVisible(mContext, visible); } private final class VC extends IVolumeController.Stub { Loading