diff options
| author | bigrushdog <randall.rushing@gmail.com> | 2019-05-06 10:18:20 -0700 |
|---|---|---|
| committer | Ali B <abittin@gmail.com> | 2019-06-08 15:42:37 +0300 |
| commit | 390a9ac481400ddf677164b3ee8b28e6385823f9 (patch) | |
| tree | e2046ec7209dd5083cccdad718d24c694b866f89 | |
| parent | af20c9fa87c14f78c8e648de535933f4bc613c9a (diff) | |
SmartNav: Eliminate needless BroadcastReceiver in BaseNavigationBar [2/2]
Change-Id: I13083e3745a7f2d8c95f516e9eb5b817afde0502
Signed-off-by: Josh Fox (XlxFoXxlX) <joshfox87@gmail.com>
4 files changed, 8 insertions, 35 deletions
diff --git a/src/com/android/systemui/navigation/BaseNavigationBar.java b/src/com/android/systemui/navigation/BaseNavigationBar.java index deb3bb3..1f0b5f6 100644 --- a/src/com/android/systemui/navigation/BaseNavigationBar.java +++ b/src/com/android/systemui/navigation/BaseNavigationBar.java @@ -143,29 +143,15 @@ public abstract class BaseNavigationBar extends LinearLayout implements Navigato } } - private final BroadcastReceiver mReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (mPulse != null) { - mPulse.onReceive(intent); - } - onReceivedIntent(intent); - } - }; - - private void onReceivedIntent(Intent intent) { + @Override + public void onReceive(Intent intent) { if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) { notifyScreenOn(true); } else if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) { notifyScreenOn(false); - } else { - onReceive(intent); } } - public void onReceive(Intent intent) { - } - public BaseNavigationBar(Context context) { this(context, null); } @@ -179,14 +165,6 @@ public abstract class BaseNavigationBar extends LinearLayout implements Navigato mSmartObserver = new SmartObserver(mHandler, context.getContentResolver()); mSpringSystem = SpringSystem.create(); sIsTablet = !ActionUtils.navigationBarCanMove(); - IntentFilter filter = new IntentFilter(); - filter.addAction(AudioManager.STREAM_MUTE_CHANGED_ACTION); - filter.addAction(AudioManager.VOLUME_CHANGED_ACTION); - filter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGING); - filter.addAction(Intent.ACTION_SCREEN_ON); - filter.addAction(Intent.ACTION_SCREEN_OFF); - filter.addAction(Intent.ACTION_BOOT_COMPLETED); - context.registerReceiver(mReceiver, filter); } // require implementation. Surely they have something to clean up @@ -365,9 +343,6 @@ public abstract class BaseNavigationBar extends LinearLayout implements Navigato public final void notifyInflateFromUser() { getBarTransitions().transitionTo(BarTransitions.MODE_TRANSPARENT, false); mScreenOn = true; - if (mPulse != null) { - mPulse.notifyScreenOn(mScreenOn); - } onInflateFromUser(); } @@ -403,11 +378,6 @@ public abstract class BaseNavigationBar extends LinearLayout implements Navigato } flushSpringSystem(); onDispose(); - unsetListeners(); - } - - private void unsetListeners() { - getContext().unregisterReceiver(mReceiver); } private void notifyVerticalChangedListener(boolean newVertical) { @@ -418,9 +388,6 @@ public abstract class BaseNavigationBar extends LinearLayout implements Navigato public void notifyScreenOn(boolean screenOn) { mScreenOn = screenOn; - if (mPulse != null) { - mPulse.notifyScreenOn(screenOn); - } setDisabledFlags(mDisabledFlags, true); } diff --git a/src/com/android/systemui/navigation/Navigator.java b/src/com/android/systemui/navigation/Navigator.java index 24d7bed..1587255 100644 --- a/src/com/android/systemui/navigation/Navigator.java +++ b/src/com/android/systemui/navigation/Navigator.java @@ -39,6 +39,7 @@ import com.android.systemui.statusbar.phone.NotificationPanelView; import com.android.systemui.statusbar.policy.KeyButtonDrawable; import android.content.Context; +import android.content.Intent; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.view.View; @@ -151,4 +152,7 @@ public interface Navigator extends PluginListener<NavGesture> { // get our editor and pipe commands directly to it public default Editor getEditor() { return null; } + + // allow implementations to parse intents from receiver in fragment + public default void onReceive(Intent intent) {} } diff --git a/src/com/android/systemui/navigation/fling/FlingView.java b/src/com/android/systemui/navigation/fling/FlingView.java index 9e91694..58eb6a2 100644 --- a/src/com/android/systemui/navigation/fling/FlingView.java +++ b/src/com/android/systemui/navigation/fling/FlingView.java @@ -190,6 +190,7 @@ public class FlingView extends BaseNavigationBar { @Override public void onReceive(Intent intent) { + super.onReceive(intent); if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { mLogoController.setLogoIcon(); } diff --git a/src/com/android/systemui/navigation/smartbar/SmartBarView.java b/src/com/android/systemui/navigation/smartbar/SmartBarView.java index 5355848..8732166 100644 --- a/src/com/android/systemui/navigation/smartbar/SmartBarView.java +++ b/src/com/android/systemui/navigation/smartbar/SmartBarView.java @@ -161,6 +161,7 @@ public class SmartBarView extends BaseNavigationBar { @Override public void onReceive(Intent intent) { + super.onReceive(intent); if (AudioManager.STREAM_MUTE_CHANGED_ACTION.equals(intent.getAction()) || (AudioManager.VOLUME_CHANGED_ACTION.equals(intent.getAction()))) { int streamType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1); |
