Browse Source

新用户强制绑定可以退出

e 6 years ago
parent
commit
24e857524e

+ 4 - 0
app/src/main/AndroidManifest.xml

15
     <uses-permission android:name="android.permission.GET_TASKS" />
15
     <uses-permission android:name="android.permission.GET_TASKS" />
16
     <uses-permission android:name="android.permission.VIBRATE" />
16
     <uses-permission android:name="android.permission.VIBRATE" />
17
 
17
 
18
+    <!--Api 27-->
19
+    <!--<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>-->
20
+    <!--<uses-permission android:name="android.permission.WRITE_SETTINGS"/>-->
21
+
18
     <application
22
     <application
19
         android:name=".MyApplication"
23
         android:name=".MyApplication"
20
         android:allowBackup="true"
24
         android:allowBackup="true"

+ 32 - 0
app/src/main/java/com/kuxuan/moneynote/MyApplication.java

1
 package com.kuxuan.moneynote;
1
 package com.kuxuan.moneynote;
2
 
2
 
3
 import android.app.Application;
3
 import android.app.Application;
4
+import android.os.Build;
4
 import android.os.SystemClock;
5
 import android.os.SystemClock;
6
+import android.support.annotation.RequiresApi;
5
 
7
 
6
 import com.kuxuan.moneynote.utils.DisplayUtil;
8
 import com.kuxuan.moneynote.utils.DisplayUtil;
7
 import com.umeng.analytics.MobclickAgent;
9
 import com.umeng.analytics.MobclickAgent;
26
 //    private static final String UMENT_SECRET="59b64bfa677baa34a00017ca";
28
 //    private static final String UMENT_SECRET="59b64bfa677baa34a00017ca";
27
     private static final String UMENG_APPKEY="59fc677e734be45f110001f6";
29
     private static final String UMENG_APPKEY="59fc677e734be45f110001f6";
28
 
30
 
31
+    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
29
     @Override
32
     @Override
30
     public void onCreate() {
33
     public void onCreate() {
31
         super.onCreate();
34
         super.onCreate();
55
             PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
58
             PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
56
         }
59
         }
57
 
60
 
61
+
62
+
63
+
64
+        //api 27后监听网络变化
65
+/*        ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
66
+        NetworkRequest.Builder builder = new NetworkRequest.Builder();
67
+        NetworkRequest request = builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
68
+                .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
69
+                .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
70
+                .build();
71
+
72
+        connectivityManager.requestNetwork(request,
73
+                new ConnectivityManager.NetworkCallback() {
74
+
75
+                    @Override
76
+                    public void onLost(Network network) {
77
+                        super.onLost(network);
78
+                        Toast.makeText(getApplicationContext(),"网络未连接",Toast.LENGTH_SHORT).show();
79
+                    }
80
+
81
+                    @Override public void onAvailable(Network network) {
82
+                        super.onAvailable(network);
83
+                        Toast.makeText(getApplicationContext(),"网络已连接",Toast.LENGTH_SHORT).show();
84
+                    }
85
+
86
+
87
+                });*/
88
+
89
+
58
     }
90
     }
59
 
91
 
60
 //    private AppComponent mAppComponent;
92
 //    private AppComponent mAppComponent;

+ 2 - 0
app/src/main/java/com/kuxuan/moneynote/common/Constant.java

51
 
51
 
52
         public static final String IsLoginOut = "isloginout";
52
         public static final String IsLoginOut = "isloginout";
53
 
53
 
54
+        public static final String ISWECHATNEWUSERFIRSTLOGIN="iswechatnewuserfirstlogin";
55
+
54
     }
56
     }
55
 
57
 
56
 
58
 

+ 0 - 1
app/src/main/java/com/kuxuan/moneynote/servier/ServiceUtil.java

38
     public static void stopUpData(Context context) {
38
     public static void stopUpData(Context context) {
39
         Intent intent = new Intent(context, UpDataService.class);
39
         Intent intent = new Intent(context, UpDataService.class);
40
         context.stopService(intent);
40
         context.stopService(intent);
41
-
42
     }
41
     }
43
 }
42
 }

+ 1 - 1
app/src/main/java/com/kuxuan/moneynote/ui/activitys/LunchActivity.java

88
 //            LoginStatusUtil.loginOut();
88
 //            LoginStatusUtil.loginOut();
89
 //            EventBus.getDefault().post(new LoginOutEvent());
89
 //            EventBus.getDefault().post(new LoginOutEvent());
90
 //        }
90
 //        }
91
-
91
+        SPUtil.remove(getApplicationContext(),Constant.IsFirstWEiChatLogin.ISWECHATNEWUSERFIRSTLOGIN);
92
         if((Boolean) SPUtil.get(this, Constant.IsFirstWEiChatLogin.ISWEICHATLOGIN,false)&&(Boolean) SPUtil.get(this,Constant.IsFirstWEiChatLogin.IsLoginOut,false)){
92
         if((Boolean) SPUtil.get(this, Constant.IsFirstWEiChatLogin.ISWEICHATLOGIN,false)&&(Boolean) SPUtil.get(this,Constant.IsFirstWEiChatLogin.IsLoginOut,false)){
93
             LoginStatusUtil.loginOut();
93
             LoginStatusUtil.loginOut();
94
             EventBus.getDefault().post(new LoginOutEvent());
94
             EventBus.getDefault().post(new LoginOutEvent());

+ 39 - 16
app/src/main/java/com/kuxuan/moneynote/ui/activitys/bindphone/BindActivity.java

18
 import com.kuxuan.moneynote.common.Constant;
18
 import com.kuxuan.moneynote.common.Constant;
19
 import com.kuxuan.moneynote.json.BaseJson;
19
 import com.kuxuan.moneynote.json.BaseJson;
20
 import com.kuxuan.moneynote.json.netbody.CheckMobileBody;
20
 import com.kuxuan.moneynote.json.netbody.CheckMobileBody;
21
+import com.kuxuan.moneynote.ui.activitys.eventbus.LoginOutEvent;
21
 import com.kuxuan.moneynote.ui.weight.CustormDialog;
22
 import com.kuxuan.moneynote.ui.weight.CustormDialog;
22
 import com.kuxuan.moneynote.utils.AppManager;
23
 import com.kuxuan.moneynote.utils.AppManager;
24
+import com.kuxuan.moneynote.utils.LoginStatusUtil;
23
 import com.kuxuan.moneynote.utils.SPUtil;
25
 import com.kuxuan.moneynote.utils.SPUtil;
24
 import com.kuxuan.moneynote.utils.ToastUtil;
26
 import com.kuxuan.moneynote.utils.ToastUtil;
25
 import com.kuxuan.moneynote.utils.UIHelper;
27
 import com.kuxuan.moneynote.utils.UIHelper;
26
 import com.umeng.analytics.MobclickAgent;
28
 import com.umeng.analytics.MobclickAgent;
27
 
29
 
30
+import org.greenrobot.eventbus.EventBus;
31
+
28
 import butterknife.Bind;
32
 import butterknife.Bind;
29
 import butterknife.OnClick;
33
 import butterknife.OnClick;
30
 import io.reactivex.android.schedulers.AndroidSchedulers;
34
 import io.reactivex.android.schedulers.AndroidSchedulers;
70
             e.printStackTrace();
74
             e.printStackTrace();
71
         }
75
         }
72
 
76
 
73
-
74
         register_btn.setText(getResources().getString(R.string.next_step));
77
         register_btn.setText(getResources().getString(R.string.next_step));
75
             getTitleView(1).setTitle(getResources().getString(R.string.bind_phone));
78
             getTitleView(1).setTitle(getResources().getString(R.string.bind_phone));
76
 
79
 
78
             @Override
81
             @Override
79
             public void onClick(View view) {
82
             public void onClick(View view) {
80
 
83
 
81
-
82
-                if(isFirstWechatLogin){
84
+                boolean iswechat_newUserFirstLogin = (boolean) SPUtil.get(getApplicationContext(),Constant.IsFirstWEiChatLogin.ISWECHATNEWUSERFIRSTLOGIN,true);
85
+                if(isFirstWechatLogin&&iswechat_newUserFirstLogin){
83
 
86
 
84
                     //老用户
87
                     //老用户
85
-                    if(!newUser){
86
-                        oldUser();
88
+                    if(newUser){
89
+                        if(iswechat_newUserFirstLogin) {
90
+                            newUser();
91
+                        }else {
92
+                            finish();
93
+                        }
87
                     }else {
94
                     }else {
88
-                        newUser();
95
+                        oldUser();
89
                     }
96
                     }
90
 
97
 
91
                 }else {
98
                 }else {
108
 
115
 
109
         builder.setMessage("为了保证您的数据安全与多账户数据同步,请您绑定手机号,以免导致数据丢失");
116
         builder.setMessage("为了保证您的数据安全与多账户数据同步,请您绑定手机号,以免导致数据丢失");
110
 
117
 
118
+        SPUtil.putAndApply(getApplicationContext(),Constant.IsFirstWEiChatLogin.ISWECHATNEWUSERFIRSTLOGIN,false);
119
+
111
         builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
120
         builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
112
             @Override
121
             @Override
113
             public void onClick(DialogInterface dialog, int which) {
122
             public void onClick(DialogInterface dialog, int which) {
114
-
115
                 dialog.dismiss();
123
                 dialog.dismiss();
116
-
117
             }
124
             }
118
         });
125
         });
119
 
126
 
267
     @Override
274
     @Override
268
     public void onBackPressed() {
275
     public void onBackPressed() {
269
 
276
 
270
-        if(isFirstWechatLogin){
277
+        boolean iswechat_newUserFirstLogin = (boolean) SPUtil.get(getApplicationContext(),Constant.IsFirstWEiChatLogin.ISWECHATNEWUSERFIRSTLOGIN,true);
271
 
278
 
279
+        if(isFirstWechatLogin){
272
             //老用户
280
             //老用户
273
-            if(!newUser){
274
-
275
-                oldUser();
281
+            if(newUser){
282
+                if(iswechat_newUserFirstLogin) {
283
+                    newUser();
284
+                }else {
285
+                    finish();
286
+                }
276
 
287
 
277
             }else {
288
             }else {
278
-
279
-                newUser();
280
-
289
+                oldUser();
281
             }
290
             }
282
-
283
         }else {
291
         }else {
284
             finish();
292
             finish();
285
         }
293
         }
286
 
294
 
287
     }
295
     }
288
 
296
 
297
+    private void finishLoginOut() {
298
+        SPUtil.remove(getApplicationContext(),Constant.IsFirstWEiChatLogin.ISWECHATNEWUSERFIRSTLOGIN);
299
+        LoginStatusUtil.loginOut();
300
+        EventBus.getDefault().post(new LoginOutEvent());
301
+    }
302
+
289
     private void goToNext() {
303
     private void goToNext() {
290
         Bundle bundle = new Bundle();
304
         Bundle bundle = new Bundle();
291
         bundle.putString(BindPhoneActivity.PHONE, editText.getText().toString());
305
         bundle.putString(BindPhoneActivity.PHONE, editText.getText().toString());
294
     }
308
     }
295
     @Override
309
     @Override
296
     protected void onDestroy() {
310
     protected void onDestroy() {
311
+        boolean iswechat_newUserFirstLogin = (boolean) SPUtil.get(getApplicationContext(),Constant.IsFirstWEiChatLogin.ISWECHATNEWUSERFIRSTLOGIN,true);
312
+        if(isFirstWechatLogin){
313
+            //老用户
314
+            if(newUser){
315
+                if(!iswechat_newUserFirstLogin) {
316
+                    finishLoginOut();
317
+                }
318
+                }
319
+            }
297
         super.onDestroy();
320
         super.onDestroy();
298
         AppManager.getAppManager().finishActivity(this);
321
         AppManager.getAppManager().finishActivity(this);
299
     }
322
     }

+ 0 - 1
app/src/main/java/com/kuxuan/moneynote/ui/fragments/details/DetialFragment.java

294
     @Subscribe(threadMode = ThreadMode.MAIN)
294
     @Subscribe(threadMode = ThreadMode.MAIN)
295
     public void onMessageEvent(NetworkEvent networkEvent) {
295
     public void onMessageEvent(NetworkEvent networkEvent) {
296
         checkNet();
296
         checkNet();
297
-
298
     }
297
     }
299
 
298
 
300
     @Override
299
     @Override