Bladeren bron

代码优化

huyuguo 4 jaren geleden
bovenliggende
commit
c1b0b52f17

+ 45 - 1
app/src/main/java/com/electric/chargingpile/activity/LoginActivity.java

@ -12,6 +12,7 @@ import android.view.inputmethod.InputMethodManager;
12 12
import android.widget.Button;
13 13
import android.widget.EditText;
14 14
import android.widget.ImageView;
15
import android.widget.LinearLayout;
15 16
import android.widget.TextView;
16 17
import android.widget.Toast;
17 18
@ -41,7 +42,9 @@ import okhttp3.Call;
41 42
public class LoginActivity extends Activity implements View.OnClickListener {
42 43
    private static final String TAG = "LoginActivity";
43 44
    private EditText phone, password;
44
    private TextView login, forgetPassword, newUser;
45
    private TextView login, forgetPassword, newUser, tv_xieyi, tv_yinsi;
46
    ImageView iv_tongyi;
47
    LinearLayout ll_tongyi;
45 48
    private ImageView back;
46 49
    private Button btn_clear, username_clear;
47 50
    InputMethodManager imm;
@ -57,6 +60,7 @@ public class LoginActivity extends Activity implements View.OnClickListener {
57 60
    String encode_token;
58 61
    Context mContext;
59 62
    public static final int RESULT_SUCCESS = 0;
63
    private Boolean flag = true;
60 64
61 65
    public void createDialog() {
62 66
        if (pd_info == null) {
@ -193,6 +197,16 @@ public class LoginActivity extends Activity implements View.OnClickListener {
193 197
        username_clear.setOnClickListener(this);
194 198
        imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
195 199
        sp();
200
201
        tv_yinsi = findViewById(R.id.tv_yinsi);
202
        tv_yinsi.setOnClickListener(this);
203
        tv_xieyi = findViewById(R.id.tv_xieyi);
204
        tv_xieyi.setOnClickListener(this);
205
206
        ll_tongyi = (LinearLayout) findViewById(R.id.ll_tongyi);
207
        ll_tongyi.setOnClickListener(this);
208
        iv_tongyi = (ImageView) findViewById(R.id.iv_tongyi);
209
196 210
    }
197 211
198 212
    private void sp() {
@ -231,7 +245,31 @@ public class LoginActivity extends Activity implements View.OnClickListener {
231 245
            case R.id.username_clear:
232 246
                phone.setText("");
233 247
                break;
248
            case R.id.tv_xieyi:
249
                Intent xieyiintent = new Intent(getApplication(), MyWebViewActivity.class);
250
                xieyiintent.putExtra("url", "http://evcharge.cc/activity/user-proto.html");
251
                startActivity(xieyiintent);
252
                break;
253
            case R.id.tv_yinsi:
254
                Intent yinsintent = new Intent(getApplication(), MyWebViewActivity.class);
255
                yinsintent.putExtra("url", "http://evcharge.cc/pc/privacy.html");
256
                startActivity(yinsintent);
257
                break;
234 258
259
            case R.id.ll_tongyi:
260
                if (flag) {
261
                    iv_tongyi.setImageResource(R.drawable.icon_login_select);
262
                    flag = false;
263
                    login.setBackgroundResource(R.drawable.textview_1green);
264
                    login.setEnabled(false);
265
                } else {
266
                    iv_tongyi.setImageResource(R.drawable.icon_login_selected);
267
                    flag = true;
268
                    if (!phone.getText().toString().equals("") && !password.getText().toString().equals("")) {
269
                        login.setBackgroundResource(R.drawable.textview_greenstyle);
270
                        login.setEnabled(true);
271
                    }
272
                }
235 273
        }
236 274
    }
237 275
@ -242,9 +280,15 @@ public class LoginActivity extends Activity implements View.OnClickListener {
242 280
        } else if (!CheckMobileNum.isMobileNum(phone.getText().toString())) {
243 281
            Toast.makeText(this, "手机号码错误,您输入的是一个无效手机号码", Toast.LENGTH_SHORT).show();
244 282
            return;
283
        } else if (!flag) {
284
            Toast.makeText(this, "请勾选协议与隐私政策", Toast.LENGTH_SHORT).show();
285
            login.setEnabled(false);
286
            login.setBackgroundResource(R.drawable.textview_1green);
245 287
        } else {
246 288
            createDialog();
247 289
            getUserInfo();
290
            login.setEnabled(true);
291
            login.setBackgroundResource(R.drawable.textview_greenstyle);
248 292
        }
249 293
    }
250 294

+ 40 - 27
app/src/main/java/com/electric/chargingpile/activity/PermissionAgreementActivity.java

@ -83,43 +83,56 @@ public class PermissionAgreementActivity extends Activity implements EasyPermiss
83 83
    @Override
84 84
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
85 85
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
86
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
86
//        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
87
        if (requestCode == RC_PHONE_PERM) {
88
            requestStoragePermission();
89
        } else if (requestCode == RC_STORAGE_PERM) {
90
            startActivity(new Intent(PermissionAgreementActivity.this, WelcomeActivity.class));
91
            finish();
92
        }
87 93
    }
88 94
89 95
    @Override
90 96
    public void onPermissionsGranted(int requestCode, List<String> perms) {
97
//        if (requestCode == RC_PHONE_PERM) {
98
//            requestStoragePermission();
99
//        } else if (requestCode == RC_STORAGE_PERM) {
100
//            startActivity(new Intent(PermissionAgreementActivity.this, WelcomeActivity.class));
101
//            finish();
102
//        }
91 103
    }
92 104
93 105
    @Override
94 106
    public void onPermissionsDenied(int requestCode, List<String> perms) {
95 107
        if (requestCode == RC_PHONE_PERM) {
96
            new AlertDialogCommon(PermissionAgreementActivity.this).builder()
97
                    .setMsg("为保证您正常、安全的使用充电桩,需要获取您的电话使用权限,是否前往开启?")
98
                    .setPositiveButton("去开启", new View.OnClickListener() {
99
                        @Override
100
                        public void onClick(View v) {
101
                            SystemTypeUtil.goToPermissionManager(PermissionAgreementActivity.this);
102
                        }
103
                    }).setNegativeButton("取消", new View.OnClickListener() {
104
                @Override
105
                public void onClick(View v) {
106
                    android.os.Process.killProcess(android.os.Process.myPid());
107
                }
108
            }).show();
108
//            requestStoragePermission();
109
//            new AlertDialogCommon(PermissionAgreementActivity.this).builder()
110
//                    .setMsg("为保证您正常、安全的使用充电桩,需要获取您的电话使用权限,是否前往开启?")
111
//                    .setPositiveButton("去开启", new View.OnClickListener() {
112
//                        @Override
113
//                        public void onClick(View v) {
114
//                            SystemTypeUtil.goToPermissionManager(PermissionAgreementActivity.this);
115
//                        }
116
//                    }).setNegativeButton("取消", new View.OnClickListener() {
117
//                @Override
118
//                public void onClick(View v) {
119
//                }
120
//            }).show();
109 121
        } else if (requestCode == RC_STORAGE_PERM) {
110
            new AlertDialogCommon(PermissionAgreementActivity.this).builder()
111
                    .setMsg("为保证您正常、安全的使用充电桩,需要获取您的存储权限,是否前往开启?")
112
                    .setPositiveButton("去开启", new View.OnClickListener() {
113
                        @Override
114
                        public void onClick(View v) {
115
                            SystemTypeUtil.goToPermissionManager(PermissionAgreementActivity.this);
116
                        }
117
                    }).setNegativeButton("取消", new View.OnClickListener() {
118
                @Override
119
                public void onClick(View v) {
120
                    android.os.Process.killProcess(android.os.Process.myPid());
121
                }
122
            }).show();
122
//            startActivity(new Intent(PermissionAgreementActivity.this, WelcomeActivity.class));
123
//            finish();
124
//            new AlertDialogCommon(PermissionAgreementActivity.this).builder()
125
//                    .setMsg("为保证您正常、安全的使用充电桩,需要获取您的存储权限,是否前往开启?")
126
//                    .setPositiveButton("去开启", new View.OnClickListener() {
127
//                        @Override
128
//                        public void onClick(View v) {
129
//                            SystemTypeUtil.goToPermissionManager(PermissionAgreementActivity.this);
130
//                        }
131
//                    }).setNegativeButton("取消", new View.OnClickListener() {
132
//                @Override
133
//                public void onClick(View v) {
134
//                }
135
//            }).show();
123 136
        }
124 137
    }
125 138

+ 1 - 1
app/src/main/java/com/electric/chargingpile/activity/RegisterActivity.java

@ -360,7 +360,7 @@ public class RegisterActivity extends Activity implements OnClickListener {
360 360

361 361
                if (checkTextSubmit()) {
362 362
                    if (!flag) {
363
//                        Toast.makeText(this, "请勾选保密协议", Toast.LENGTH_SHORT).show();
363
                        Toast.makeText(this, "请勾选协议与隐私政策", Toast.LENGTH_SHORT).show();
364 364
                        tvSure.setEnabled(false);
365 365
                        tvSure.setBackgroundResource(R.drawable.textview_1green);
366 366


+ 58 - 0
app/src/main/res/layout/activity_login.xml

@ -132,6 +132,64 @@
132 132
133 133
        </com.zhy.autolayout.AutoLinearLayout>
134 134
135
        <com.zhy.autolayout.AutoLinearLayout
136
            android:layout_width="match_parent"
137
            android:layout_height="wrap_content"
138
            android:background="@color/white"
139
            android:orientation="vertical">
140
141
            <com.zhy.autolayout.AutoLinearLayout
142
                android:id="@+id/ll_tongyi"
143
                android:layout_width="wrap_content"
144
                android:layout_height="wrap_content"
145
                android:orientation="horizontal"
146
                android:layout_marginTop="20dp"
147
                android:layout_gravity="left">
148
149
                <ImageView
150
                    android:id="@+id/iv_tongyi"
151
                    android:layout_width="48px"
152
                    android:layout_height="48px"
153
                    android:src="@drawable/icon_login_selected"
154
                    android:layout_gravity="center"
155
                    android:layout_marginLeft="58px"
156
                    android:layout_marginBottom="1dp"/>
157
158
                <TextView
159
                    android:layout_width="wrap_content"
160
                    android:layout_height="wrap_content"
161
                    android:text="登录即代表您同意"
162
                    android:textSize="13sp"
163
                    android:textColor="@color/ui_69"
164
                    android:layout_marginLeft="10px"
165
                    android:layout_marginBottom="1dp"
166
                    android:layout_gravity="center" />
167
            </com.zhy.autolayout.AutoLinearLayout>
168
169
            <TextView
170
                android:id="@+id/tv_xieyi"
171
                android:layout_marginTop="5dp"
172
                android:layout_marginLeft="64px"
173
                android:layout_width="match_parent"
174
                android:layout_height="wrap_content"
175
                android:text="《充电桩APP用户使用协议》"
176
                android:textColor="#3190e8"
177
                android:textSize="13sp"
178
                android:layout_gravity="center"
179
                android:layout_marginBottom="1dp"/>
180
            <TextView
181
                android:id="@+id/tv_yinsi"
182
                android:layout_marginTop="5dp"
183
                android:layout_marginLeft="64px"
184
                android:layout_width="match_parent"
185
                android:layout_height="wrap_content"
186
                android:text="《充电桩隐私政策》"
187
                android:textColor="#3190e8"
188
                android:textSize="13sp"
189
                android:layout_gravity="center"
190
                android:layout_marginBottom="1dp"/>
191
        </com.zhy.autolayout.AutoLinearLayout>
192
135 193
136 194
        <TextView
137 195
            android:id="@+id/tv_userLogin"