public MutableLiveData<Boolean> icTalkMsgState = new MutableLiveData<>();
//震动图标
public MutableLiveData<Boolean> shakeValue = new MutableLiveData<>();
- //
+ //飞行模式
+ public MutableLiveData<Boolean> isPlaneModeValue = new MutableLiveData<>();
private final ExecutorService executorService;
//
private NetworkConnectChangedReceiver mNetworkChangeListener;
checkIcTalkMsg();
checkHasMissCall();
getShakeState();
+ getPlaneMode();
observerContentChange();
}
private void observerContentChange() {
+ //观察飞行模式
+ contentResolver.registerContentObserver(Uri.parse(SETTINGS + ".is_air_mode_enable"), true,
+ new ContentObserver(null) {
+ @Override
+ public void onChange(boolean selfChange) {
+ ICLogger.d("is_air_mode_enable");
+ getPlaneMode();
+ }
+ });
contentResolver.registerContentObserver(Uri.parse(SETTINGS + ".key_silent"), true,
new ContentObserver(null) {
@Override
});
}
+ private void getPlaneMode() {
+ String isPlaneMode = getContent("is_air_mode_enable");
+ if ("1".equals(isPlaneMode)) {
+ isPlaneModeValue.postValue(Boolean.TRUE);
+ } else {
+ isPlaneModeValue.postValue(Boolean.FALSE);
+ }
+ }
+
private void getShakeState() {
executorService.execute(() -> {
//key_shake_mode
private View icTalkView;
private View silentIconView;
private View shakeView;
+ private View planeModeView;
public StatusBarView(@NonNull Context context) {
this(context, null);
icTalkView = findViewById(R.id.top_icon_ic_talk);
silentIconView = findViewById(R.id.top_icon_silent);
shakeView = findViewById(R.id.top_icon_ic_shake);
+ planeModeView = findViewById(R.id.top_icon_plane_mode);
}
public void initPresenter(LifecycleOwner lifecycleOwner) {
//设置闹钟图标显示还是隐藏
alarmView.setVisibility(isAlarmOpen == Boolean.TRUE ? VISIBLE : GONE);
});
+ statusBarPresenter.isPlaneModeValue.observe(lifecycleOwner, isPlaneMode -> {
+ if (isPlaneMode == null || isPlaneMode == Boolean.FALSE) {
+ planeModeView.setVisibility(GONE);
+ } else {
+ planeModeView.setVisibility(VISIBLE);
+ }
+ });
statusBarPresenter.btState.observe(lifecycleOwner, isOpen -> {
//蓝牙是否显示
btView.setVisibility(isOpen == Boolean.TRUE ? VISIBLE : GONE);
<com.ic.launcher.view.MarqueeView
android:id="@+id/mar_queue_view"
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:visibility="gone" />
- </com.ic.launcher.view.MarqueeView>
+ <ImageView
+ android:id="@+id/top_icon_plane_mode"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@mipmap/top_icon_plane_mode"
+ android:visibility="gone" />
+
+ </com.ic.launcher.view.MarqueeView>
</RelativeLayout>
\ No newline at end of file