修改了界面的状态控制,以及结束UI界面
authorTrillGates <williamtrillgates@gmail.com>
Fri, 22 Oct 2021 08:35:52 +0000 (16:35 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Fri, 22 Oct 2021 08:35:52 +0000 (16:35 +0800)
app/release/ICSOS_V2_2110221020_release.apk [deleted file]
app/release/ICSOS_V3_2110221633_release.apk [new file with mode: 0644]
app/release/output-metadata.json
app/src/main/java/com/ic/sos/MainActivity.java
app/src/main/java/com/ic/sos/SOSPresenter.java
app/src/main/java/com/ic/sos/SOSState.java
app/version_code.properties

diff --git a/app/release/ICSOS_V2_2110221020_release.apk b/app/release/ICSOS_V2_2110221020_release.apk
deleted file mode 100644 (file)
index a069a57..0000000
Binary files a/app/release/ICSOS_V2_2110221020_release.apk and /dev/null differ
diff --git a/app/release/ICSOS_V3_2110221633_release.apk b/app/release/ICSOS_V3_2110221633_release.apk
new file mode 100644 (file)
index 0000000..f6b79c5
Binary files /dev/null and b/app/release/ICSOS_V3_2110221633_release.apk differ
index 7055e55..743c57f 100644 (file)
@@ -12,7 +12,7 @@
       "filters": [],
       "versionCode": 1,
       "versionName": "1.0",
-      "outputFile": "ICSOS_V2_2110221020_release.apk"
+      "outputFile": "ICSOS_V3_2110221633_release.apk"
     }
   ]
 }
\ No newline at end of file
index d87e437..a798e6e 100644 (file)
@@ -6,6 +6,7 @@ import androidx.lifecycle.Observer;
 import android.content.Intent;
 import android.os.Bundle;
 import android.support.v4.app.INotificationSideChannel;
+import android.view.View;
 
 /**
  * SOS拨号策略:
@@ -20,26 +21,48 @@ import android.support.v4.app.INotificationSideChannel;
 public class MainActivity extends AppCompatActivity {
 
     private SOSPresenter sosPresenter;
+    private View callingPage;
+    private View errorPage;
+    private View initPage;
+    private View noSimPage;
+    private View noNumberPage;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
         initView();
-        //sosPresenter = new SOSPresenter(this);
+        sosPresenter = new SOSPresenter(this);
         //监听状态变化
-        //initObserver();
+        initObserver();
     }
 
-    private void initView() {
+    private void hideAll() {
+        callingPage.setVisibility(View.GONE);
+        errorPage.setVisibility(View.GONE);
+        initPage.setVisibility(View.GONE);
+        noSimPage.setVisibility(View.GONE);
+        noNumberPage.setVisibility(View.GONE);
+    }
 
+    private void initView() {
+        //找到各个页面
+        callingPage = findViewById(R.id.calling_page);
+        errorPage = findViewById(R.id.error_page);
+        initPage = findViewById(R.id.init_page);
+        noSimPage = findViewById(R.id.no_sim_page);
+        noNumberPage = findViewById(R.id.no_number_page);
     }
 
     @Override
     protected void onResume() {
         super.onResume();
         //当UI重新可见的时候,检查是否需要进行下一个拨号
-        //TODO:
+        //判断是否有完成第一次拨号,如果有的话就检查是否进行下一次拨号
+        if (sosPresenter.hasFirstCall()) {
+            //检查下一个拨号
+            sosPresenter.checkNextCall();
+        }
     }
 
     @Override
@@ -49,8 +72,28 @@ public class MainActivity extends AppCompatActivity {
 
     private void initObserver() {
         sosPresenter.stateValue.observe(this, sosState -> {
+            hideAll();
             //状态变化,改变UI
-            //TODO:
+            switch (sosState) {
+                case NONE:
+                    initPage.setVisibility(View.VISIBLE);
+                    break;
+                case NO_SIM:
+                    noSimPage.setVisibility(View.VISIBLE);
+                    break;
+                case CALLING:
+                    callingPage.setVisibility(View.VISIBLE);
+                    break;
+                case NO_SOS_NUM:
+                    noNumberPage.setVisibility(View.VISIBLE);
+                    break;
+                case CALL_FAILED:
+                    errorPage.setVisibility(View.VISIBLE);
+                    break;
+                case FINISH:
+                    finish();
+                    break;
+            }
         });
     }
 
index 2ed2dd0..496756f 100644 (file)
@@ -89,7 +89,8 @@ public class SOSPresenter {
             switch (state) {
                 case STATE_END:
                     ICLogger.d("通话结束");
-                    checkNextCall();
+                    //在activity onResume的时候再去检查
+                    //checkNextCall();
                     break;
                 case STATE_HAND_UP_ING:
                     ICLogger.d("正在挂断");
@@ -112,7 +113,7 @@ public class SOSPresenter {
     /**
      * 根据条件进行下一轮拨号
      */
-    private void checkNextCall() {
+    public void checkNextCall() {
         boolean doCallNext;
         //是否进行下一个拨号,结合策略和是否有接听
 
@@ -146,6 +147,7 @@ public class SOSPresenter {
             handler.postDelayed(this::doSosCall, 10000);
         } else {
             ICLogger.d("结束界面...");
+            stateValue.postValue(SOSState.FINISH);
         }
     }
 
@@ -163,6 +165,7 @@ public class SOSPresenter {
         if (phoneNumList.size() > 0) {
             //可以拨号
             doSosCall();
+            hasFirstCall = true;
         }
     }
 
@@ -217,6 +220,12 @@ public class SOSPresenter {
 
     private int currentLoopGroupTime = 0;
 
+    private boolean hasFirstCall = false;
+
+    public boolean hasFirstCall() {
+        return hasFirstCall;
+    }
+
     /**
      * 根据策略去拨号
      */
@@ -328,6 +337,7 @@ public class SOSPresenter {
 
 
     public void cleared() {
+        hasFirstCall = false;
         phoneNumList.clear();
         mContext.unregisterReceiver(stateReceiver);
     }
index a379749..796c870 100644 (file)
@@ -5,5 +5,6 @@ public enum SOSState {
     NO_SOS_NUM/*没有SOS号码*/,
     NO_SIM/*没有sim卡*/,
     CALLING/*正在拨号*/,
-    CALL_FAILED/*拨号失败*/
+    CALL_FAILED/*拨号失败*/,
+    FINISH/*结束SOS*/
 }
index 7281394..ae4b87b 100644 (file)
@@ -1,2 +1,2 @@
-#Fri Oct 22 10:20:19 CST 2021
-VERSION_CODE=2
+#Fri Oct 22 16:33:14 CST 2021
+VERSION_CODE=3