Pārlūkot izejas kodu

<查询异常日志入口增加密码验证>

weizhengliang 4 gadi atpakaļ
vecāks
revīzija
32f6fee19a

+ 1 - 1
app/build.gradle

@@ -26,7 +26,7 @@ android {
         minSdkVersion 15
         minSdkVersion 15
         targetSdkVersion 26
         targetSdkVersion 26
         versionCode 1
         versionCode 1
-        versionName "1.53"
+        versionName "1.54"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
         multiDexEnabled true
         multiDexEnabled true
 
 

+ 27 - 18
app/src/main/java/com/wdkl/callingdoor/base/BaseActivity.java

@@ -4,6 +4,7 @@ import android.content.Context;
 import android.content.DialogInterface;
 import android.content.DialogInterface;
 import android.os.Bundle;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.support.annotation.Nullable;
+import android.text.TextUtils;
 import android.view.MotionEvent;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.View;
 import android.view.Window;
 import android.view.Window;
@@ -252,24 +253,32 @@ public abstract class BaseActivity<T extends BasePresenterI, V> extends AutoLayo
 
 
         builder.setTitle(title);
         builder.setTitle(title);
         builder.setMessage(message);
         builder.setMessage(message);
-        builder.setPositiveButton(button_t1, new DialogInterface.OnClickListener() {
-            @Override
-            public void onClick(DialogInterface dialog, int which) {
-                onClickButtonOne();
-            }
-        });
-        builder.setNegativeButton(button_t2, new DialogInterface.OnClickListener() {
-            @Override
-            public void onClick(DialogInterface dialog, int which) {
-                onClickButtonTwo();
-            }
-        });
-        builder.setNeutralButton(button_t3, new DialogInterface.OnClickListener() {
-            @Override
-            public void onClick(DialogInterface dialog, int which) {
-                onClickButtonThree();
-            }
-        });
+        if (!TextUtils.isEmpty(button_t1)) {
+            builder.setPositiveButton(button_t1, new DialogInterface.OnClickListener() {
+                @Override
+                public void onClick(DialogInterface dialog, int which) {
+                    onClickButtonOne();
+                }
+            });
+        }
+
+        if (!TextUtils.isEmpty(button_t2)) {
+            builder.setNegativeButton(button_t2, new DialogInterface.OnClickListener() {
+                @Override
+                public void onClick(DialogInterface dialog, int which) {
+                    onClickButtonTwo();
+                }
+            });
+        }
+
+        if (!TextUtils.isEmpty(button_t3)) {
+            builder.setNeutralButton(button_t3, new DialogInterface.OnClickListener() {
+                @Override
+                public void onClick(DialogInterface dialog, int which) {
+                    onClickButtonThree();
+                }
+            });
+        }
         builder.show();
         builder.show();
     }
     }
 
 

+ 29 - 1
app/src/main/java/com/wdkl/callingdoor/ui/CallingDoorActivity.java

@@ -4,6 +4,7 @@ import android.app.AlarmManager;
 import android.app.PendingIntent;
 import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.IntentFilter;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Drawable;
@@ -14,13 +15,16 @@ import android.os.CountDownTimer;
 import android.os.Handler;
 import android.os.Handler;
 import android.os.Message;
 import android.os.Message;
 import android.provider.Settings;
 import android.provider.Settings;
+import android.support.v7.app.AlertDialog;
 import android.support.v7.widget.CardView;
 import android.support.v7.widget.CardView;
 import android.support.v7.widget.DefaultItemAnimator;
 import android.support.v7.widget.DefaultItemAnimator;
 import android.support.v7.widget.GridLayoutManager;
 import android.support.v7.widget.GridLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
 import android.util.Log;
 import android.util.Log;
 import android.view.MotionEvent;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.View;
+import android.widget.EditText;
 import android.widget.ImageView;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 import android.widget.TextView;
@@ -1859,7 +1863,31 @@ public class CallingDoorActivity extends BaseActivity implements SerialPortUtil.
     @Override
     @Override
     public void onClickButtonThree() {
     public void onClickButtonThree() {
         super.onClickButtonThree();
         super.onClickButtonThree();
-        startActivity(new Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS));
+
+        View dialogView = View.inflate(context, R.layout.dialog_error_log, null);
+        final EditText pwd = dialogView.findViewById(R.id.edit_password);
+        AlertDialog.Builder builder = new AlertDialog.Builder(context);
+        builder.setTitle("查询异常日志");
+        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                String password = pwd.getText().toString().trim();
+                if (TextUtils.isEmpty(password)) {
+                    ToastUtil.showToast("密码不能为空");
+                    return;
+                }
+
+                if (password.equals(TimeUtil.getPassWord())) {
+                    startActivity(new Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS));
+                } else {
+                    ToastUtil.showToast("密码错误");
+                }
+            }
+        });
+
+        AlertDialog pwdDialog = builder.create();
+        pwdDialog.setView(dialogView);
+        pwdDialog.show();
     }
     }
 
 
     /**
     /**

+ 16 - 0
app/src/main/res/layout/dialog_error_log.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <EditText
+        android:id="@+id/edit_password"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:textSize="24dp"
+        android:hint="请输入密码"
+        android:inputType="number"/>
+
+</LinearLayout>