Przeglądaj źródła

修复控件找不到的bug和记住密码无效的bug

tianwei 3 lat temu
rodzic
commit
2bced08958

+ 2 - 2
BaiAnXi/app/build.gradle

@@ -7,8 +7,8 @@ android {
         applicationId "com.baianxi.safemanager"
         minSdkVersion 21
         targetSdkVersion 28
-        versionCode 1
-        versionName "1.0"
+        versionCode 2
+        versionName "1.0.2"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         //////////////JPUSH start///////////////
         ndk {

+ 12 - 10
BaiAnXi/app/src/main/java/com/baianxi/safemanager/LoginActivity.java

@@ -56,25 +56,27 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
         String userName = SPUtils.getInstance().getString(constu.LOGIN_NAME, null);
         String password = SPUtils.getInstance().getString(constu.LOGIN_PWD, null);
 
+
+        if (!StringUtils.isEmpty(userName)) {
+            etName.setText(userName);
+        }
+
         boolean rememberPwd = SPUtils.getInstance().getBoolean(constu.LOGIN_REMEMBER_PWD, true);
         vRememberPwd.setTag(rememberPwd);
-        if (rememberPwd){
-            if(!StringUtils.isEmpty(userName)){
-                etName.setText(userName);
-            }
-            if(!StringUtils.isEmpty(password)){
+        if (rememberPwd) {
+            if (!StringUtils.isEmpty(password)) {
                 etPwd.setText(password);
             }
             ivRememberPwd.setBackground(getResources().getDrawable(R.drawable.checkactive2x));
-        }else {
+        } else {
             ivRememberPwd.setBackground(getResources().getDrawable(R.drawable.checknormal2x));
         }
 
         boolean loginAuto = SPUtils.getInstance().getBoolean(constu.LOGIN_REMEMBER_AUTO, true);
         vLoginAuto.setTag(loginAuto);
-        if (loginAuto){
+        if (loginAuto) {
             ivLogonAuto.setBackground(getResources().getDrawable(R.drawable.checkactive2x));
-        }else {
+        } else {
             ivLogonAuto.setBackground(getResources().getDrawable(R.drawable.checknormal2x));
         }
 
@@ -85,7 +87,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
 //        }
     }
 
-    private void setIvRememberPwd(boolean isClick){
+    private void setIvRememberPwd(boolean isClick) {
         if (isClick) {
             ivRememberPwd.setBackground(getResources().getDrawable(R.drawable.checknormal2x));
             vRememberPwd.setTag(false);
@@ -97,7 +99,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
         }
     }
 
-    private void setIvLogonAuto(boolean isClick){
+    private void setIvLogonAuto(boolean isClick) {
         if (isClick) {
             ivLogonAuto.setBackground(getResources().getDrawable(R.drawable.checknormal2x));
             vLoginAuto.setTag(false);

+ 3 - 3
BaiAnXi/app/src/main/java/com/baianxi/safemanager/MainActivity.java

@@ -225,12 +225,12 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
 
             @Override
             public void onSuccess(int code, String msg, JSONObject data) {
-                if(code == 0){
+                if (code == 0) {
                     int total = data.getIntValue("total");
-                    if (total > 0){
+                    if (total > 0) {
                         tvNewMessage.setVisibility(View.VISIBLE);
                         tvNewMessage.setText(total + "");
-                    }else {
+                    } else {
                         tvNewMessage.setVisibility(View.INVISIBLE);
                     }
                 } else {

+ 4 - 1
BaiAnXi/app/src/main/java/com/baianxi/safemanager/SettingActivity.java

@@ -50,7 +50,10 @@ public class SettingActivity extends BaseActivity implements View.OnClickListene
     private void logout(){
         SPUtils.getInstance().put(constu.LOGIN_TOKEN, "");
 //        SPUtils.getInstance().put(constu.LOGIN_NAME, "");
-        SPUtils.getInstance().put(constu.LOGIN_PWD, "");
+        boolean rememberPwd = SPUtils.getInstance().getBoolean(constu.LOGIN_REMEMBER_PWD, true);
+        if (!rememberPwd) {
+            SPUtils.getInstance().put(constu.LOGIN_PWD, "");
+        }
         SPUtils.getInstance().put(constu.LOGIN_UTYPE, "");
         SPUtils.getInstance().put(constu.LOGIN_USERID, "");
         SPUtils.getInstance().put(constu.LOGIN_ROLE, "");

+ 3 - 4
BaiAnXi/app/src/main/java/com/baianxi/safemanager/SplashActivity.java

@@ -22,12 +22,11 @@ public class SplashActivity extends AppCompatActivity {
         String userName = SPUtils.getInstance().getString(constu.LOGIN_NAME, null);
         String password = SPUtils.getInstance().getString(constu.LOGIN_PWD, null);
         String token = SPUtils.getInstance().getString(constu.LOGIN_TOKEN, null);
-        Intent it = getIntent();
 
-
-        if (!StringUtils.isEmpty(userName) && !StringUtils.isEmpty(password) && !StringUtils.isEmpty(token)){
+        boolean loginAuto = SPUtils.getInstance().getBoolean(constu.LOGIN_REMEMBER_AUTO, true);
+        if (!StringUtils.isEmpty(userName) && !StringUtils.isEmpty(password) && !StringUtils.isEmpty(token) && loginAuto) {
             Intent intent = new Intent(SplashActivity.this, MainActivity.class);
-            if (!StringUtils.isEmpty(getIntent().getPackage()) && getApplicationInfo().packageName.equals(getIntent().getPackage())){
+            if (!StringUtils.isEmpty(getIntent().getPackage()) && getApplicationInfo().packageName.equals(getIntent().getPackage())) {
                 //打开消息界面
                 intent.putExtra(constu.BOOT_MESSAGE_KEY, constu.BOOT_MESSAGE_VALUE);
             }

+ 5 - 4
BaiAnXi/app/src/main/java/com/baianxi/safemanager/ui/HomeFragment.java

@@ -44,7 +44,7 @@ import java.util.List;
 public class HomeFragment extends Fragment implements View.OnClickListener {
 
     private Button btStartTask;
-    private ImageView ivHomeBeauty;
+    private ImageView ivHomeBeauty, ivCompanyTop;
     private Dialog mCameraDialog;
     private TextView tvCompany, tvTopCompany;
     private MyPieView pieView, pieViewHazard;
@@ -75,6 +75,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
         btStartTask = getView().findViewById(R.id.bt_home_start_task);
         btStartTask.setOnClickListener(this);
         ivHomeBeauty = getView().findViewById(R.id.iv_home_beauty);
+        ivCompanyTop = getView().findViewById(R.id.iv_home_company_top);
         pieView = getView().findViewById(R.id.pie_home_risk);
 //        ArrayList<PieHelper> pieHelperArrayList = new ArrayList<PieHelper>();
 //        pieHelperArrayList.add(new PieHelper(10, getResources().getColor(R.color.risk_high)));
@@ -338,9 +339,9 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
         JSONArray enterprise_children = data.getJSONArray("enterprise_children");
         if (enterprise_children != null){
             tvTopCompany.setVisibility(View.VISIBLE);
-            getView().findViewById(R.id.iv_home_company_top).setVisibility(View.VISIBLE);
+            ivCompanyTop.setVisibility(View.VISIBLE);
             tvTopCompany.setOnClickListener(this);
-            getView().findViewById(R.id.iv_home_company_top).setOnClickListener(this);
+            ivCompanyTop.setOnClickListener(this);
             enterpriseItems.clear();
             for (int i = 0; i < enterprise_children.size(); i++) {
                 JSONObject enterprise = enterprise_children.getJSONObject(i);
@@ -348,7 +349,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
             }
         } else {
             tvTopCompany.setVisibility(View.INVISIBLE);
-            getView().findViewById(R.id.iv_home_company_top).setVisibility(View.INVISIBLE);
+            ivCompanyTop.setVisibility(View.INVISIBLE);
         }
     }
 

+ 4 - 2
BaiAnXi/build.gradle

@@ -1,4 +1,6 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+ext {
+    sourceCompatibility = JavaVersion.VERSION_1_8
+}// Top-level build file where you can add configuration options common to all sub-projects/modules.
 
 buildscript {
     repositories {
@@ -14,7 +16,7 @@ buildscript {
 
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:4.0.1'
+        classpath 'com.android.tools.build:gradle:4.1.1'
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files

+ 2 - 2
BaiAnXi/gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
-#Thu Jul 30 09:30:15 CST 2020
+#Mon Mar 22 20:17:27 CST 2021
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip