update icon.
authorTrillGates <williamtrillgates@gmail.com>
Thu, 15 Jul 2021 03:48:31 +0000 (11:48 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Thu, 15 Jul 2021 03:48:31 +0000 (11:48 +0800)
app/src/main/java/com/ic/launcher/presenter/StatusBarPresenter.java
app/src/main/java/com/ic/launcher/view/StatusBarView.java
app/src/main/res/layout/item_status_bar.xml
app/src/main/res/mipmap-mdpi/top_alarm_open.png
app/src/main/res/mipmap-mdpi/top_icon_ic_talk_msg.png
app/src/main/res/mipmap-mdpi/top_icon_miss_phone.png
app/src/main/res/mipmap-mdpi/top_icon_shake.png [new file with mode: 0644]
app/src/main/res/mipmap-mdpi/top_icon_silent.png
app/src/main/res/mipmap-mdpi/top_icon_warning_msg_un_read.png
app/src/main/res/mipmap-mdpi/top_icon_wear.png

index 038db74..3fc78e0 100644 (file)
@@ -2,11 +2,13 @@ package com.ic.launcher.presenter;
 
 import android.bluetooth.BluetoothAdapter;
 import android.content.BroadcastReceiver;
+import android.content.ContentResolver;
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.database.ContentObserver;
+import android.database.Cursor;
 import android.location.LocationManager;
 import android.net.Uri;
 import android.net.wifi.WifiManager;
@@ -44,19 +46,24 @@ public class StatusBarPresenter extends StatusBarBasePresenter {
     public MutableLiveData<Boolean> silentState = new MutableLiveData<>();
     //微聊新消息
     public MutableLiveData<Boolean> icTalkMsgState = new MutableLiveData<>();
+    //震动图标
+    public MutableLiveData<Boolean> shakeValue = new MutableLiveData<>();
     //
     private final ExecutorService executorService;
     //
     private NetworkConnectChangedReceiver mNetworkChangeListener;
+    private final ContentResolver contentResolver;
 
     private StatusBarPresenter(Context context) {
         super(context);
         executorService = Executors.newSingleThreadExecutor();
+        contentResolver = mContext.getContentResolver();
         //监听各种状态
         //需要初始化一次,然后进行监听
         getWifiState();
         getGpsState();
         getBtState();
+        //需要监听的
         getWearState();
         getUnReadMsgState();
         getAlarmState();
@@ -64,6 +71,51 @@ public class StatusBarPresenter extends StatusBarBasePresenter {
         getSilentState();
         checkIcTalkMsg();
         checkHasMissCall();
+        observerContentChange();
+    }
+
+    private void observerContentChange() {
+        contentResolver.registerContentObserver(Uri.parse(SETTINGS + ".key_silent"), true,
+                new ContentObserver(null) {
+                    @Override
+                    public void onChange(boolean selfChange) {
+                        ICLogger.d("on silent state update...");
+                        getSilentState();
+                    }
+                });
+        contentResolver.registerContentObserver(Uri.parse(SETTINGS + ".key_shake_mode"), true,
+                new ContentObserver(null) {
+                    @Override
+                    public void onChange(boolean selfChange) {
+                        getShakeState();
+                    }
+                });
+    }
+
+    private void getShakeState() {
+        executorService.execute(() -> {
+            //key_shake_mode
+            String isShake = getContent("key_shake_mode");
+            if ("1".equals(isShake)) {
+                shakeValue.postValue(Boolean.TRUE);
+            } else {
+                shakeValue.postValue(Boolean.FALSE);
+            }
+        });
+    }
+
+    private String getContent(String key) {
+        Cursor query = contentResolver.query(Uri.parse(SETTINGS), new String[]{"s_value"},
+                "s_key=?", new String[]{key}, null);
+        if (query != null) {
+            if (query.moveToNext()) {
+                String string = query.getString(0);
+                ICLogger.d("value == > " + string);
+                return string;
+            }
+            query.close();
+        }
+        return null;
     }
 
     private void checkHasMissCall() {
@@ -71,7 +123,13 @@ public class StatusBarPresenter extends StatusBarBasePresenter {
     }
 
     private void getSilentState() {
-        // silentState.postValue(true);
+        //key_silent
+        String string = getContent("key_silent");
+        if ("1".equals(string)) {
+            silentState.postValue(Boolean.TRUE);
+        } else {
+            silentState.postValue(Boolean.FALSE);
+        }
     }
 
     private void checkIcTalkMsg() {
index 6fbe1cf..239a015 100644 (file)
@@ -33,6 +33,7 @@ public class StatusBarView extends FrameLayout {
     private View phoneView;
     private View icTalkView;
     private View silentIconView;
+    private View shakeView;
 
     public StatusBarView(@NonNull Context context) {
         this(context, null);
@@ -64,6 +65,7 @@ public class StatusBarView extends FrameLayout {
         phoneView = findViewById(R.id.top_icon_phone);
         icTalkView = findViewById(R.id.top_icon_ic_talk);
         silentIconView = findViewById(R.id.top_icon_silent);
+        shakeView = findViewById(R.id.top_icon_ic_shake);
     }
 
     public void initPresenter(LifecycleOwner lifecycleOwner) {
@@ -78,11 +80,11 @@ public class StatusBarView extends FrameLayout {
         });
         statusBarPresenter.gpsState.observe(lifecycleOwner, isOpen -> {
             //GPS定位是否打开
-            locationView.setVisibility(isOpen == Boolean.TRUE? VISIBLE : GONE);
+            locationView.setVisibility(isOpen == Boolean.TRUE ? VISIBLE : GONE);
         });
         statusBarPresenter.icTalkMsgState.observe(lifecycleOwner, hasIcTalkMsg -> {
             //是否有微聊消息
-            icTalkView.setVisibility(hasIcTalkMsg== Boolean.TRUE ? VISIBLE : GONE);
+            icTalkView.setVisibility(hasIcTalkMsg == Boolean.TRUE ? VISIBLE : GONE);
         });
         statusBarPresenter.isWifiOpen.observe(lifecycleOwner, isWifiOpen -> {
             //wifi是否打开
@@ -90,23 +92,23 @@ public class StatusBarView extends FrameLayout {
         });
         statusBarPresenter.missCallState.observe(lifecycleOwner, hasMiss -> {
             //是否有未接电话
-            phoneView.setVisibility(hasMiss == Boolean.TRUE? VISIBLE : GONE);
+            phoneView.setVisibility(hasMiss == Boolean.TRUE ? VISIBLE : GONE);
         });
         statusBarPresenter.wearState.observe(lifecycleOwner, hasWear -> {
             //是否有穿戴
-            wearView.setVisibility(hasWear == Boolean.TRUE? VISIBLE : GONE);
+            wearView.setVisibility(hasWear == Boolean.TRUE ? VISIBLE : GONE);
         });
         statusBarPresenter.msgUnReadState.observe(lifecycleOwner, hasRead -> {
             //消息是否有读
-            newMsgView.setVisibility(hasRead == Boolean.TRUE? VISIBLE : GONE);
+            newMsgView.setVisibility(hasRead == Boolean.TRUE ? VISIBLE : GONE);
         });
         statusBarPresenter.warningReadState.observe(lifecycleOwner, hasRead -> {
             //警告消息是否有没阅读
-            warningMsgUnReadView.setVisibility(hasRead == Boolean.TRUE? VISIBLE : GONE);
+            warningMsgUnReadView.setVisibility(hasRead == Boolean.TRUE ? VISIBLE : GONE);
         });
         statusBarPresenter.silentState.observe(lifecycleOwner, isSilent -> {
             //是不是静音状态
-            silentIconView.setVisibility(isSilent == Boolean.TRUE? VISIBLE : GONE);
+            silentIconView.setVisibility(isSilent == Boolean.TRUE ? VISIBLE : GONE);
         });
         statusBarPresenter.batteryLev.observe(lifecycleOwner, lev -> {
             //电量还有多少
@@ -118,6 +120,13 @@ public class StatusBarView extends FrameLayout {
                 batteryView.updateCurrentLev(0);
             }
         });
+        statusBarPresenter.shakeValue.observe(lifecycleOwner, isShake -> {
+            if (isShake == null || isShake == Boolean.FALSE) {
+                shakeView.setVisibility(GONE);
+            } else {
+                shakeView.setVisibility(VISIBLE);
+            }
+        });
         statusBarPresenter.networkTypeValue.observe(lifecycleOwner, type -> {
             signalView.updateNetworkType(type);
         });
index 8c516ee..8d399e6 100644 (file)
             android:src="@mipmap/top_icon_ic_talk_msg"
             android:visibility="gone" />
 
+        <ImageView
+            android:id="@+id/top_icon_ic_shake"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:src="@mipmap/top_icon_shake"
+            android:visibility="gone" />
+
+
         <ImageView
             android:id="@+id/top_icon_silent"
             android:layout_width="wrap_content"
index 44d87d5..10b29d0 100644 (file)
Binary files a/app/src/main/res/mipmap-mdpi/top_alarm_open.png and b/app/src/main/res/mipmap-mdpi/top_alarm_open.png differ
index b61eca4..ad9ddd9 100644 (file)
Binary files a/app/src/main/res/mipmap-mdpi/top_icon_ic_talk_msg.png and b/app/src/main/res/mipmap-mdpi/top_icon_ic_talk_msg.png differ
index 04af0e2..b1b0e5f 100644 (file)
Binary files a/app/src/main/res/mipmap-mdpi/top_icon_miss_phone.png and b/app/src/main/res/mipmap-mdpi/top_icon_miss_phone.png differ
diff --git a/app/src/main/res/mipmap-mdpi/top_icon_shake.png b/app/src/main/res/mipmap-mdpi/top_icon_shake.png
new file mode 100644 (file)
index 0000000..49bca66
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/top_icon_shake.png differ
index d55d0fd..68e1f86 100644 (file)
Binary files a/app/src/main/res/mipmap-mdpi/top_icon_silent.png and b/app/src/main/res/mipmap-mdpi/top_icon_silent.png differ
index 2a4fb6b..a060bf5 100644 (file)
Binary files a/app/src/main/res/mipmap-mdpi/top_icon_warning_msg_un_read.png and b/app/src/main/res/mipmap-mdpi/top_icon_warning_msg_un_read.png differ
index 60094cd..f9f94c5 100644 (file)
Binary files a/app/src/main/res/mipmap-mdpi/top_icon_wear.png and b/app/src/main/res/mipmap-mdpi/top_icon_wear.png differ