|
@@ -14,16 +14,14 @@ import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.os.Handler;
|
|
import android.os.Message;
|
|
import android.os.Message;
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
-import android.util.Log;
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.NonNull;
|
|
-import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
|
|
import com.srp.AuthApi.AuthApi;
|
|
import com.srp.AuthApi.AuthApi;
|
|
import com.srp.AuthApi.AuthApplyResponse;
|
|
import com.srp.AuthApi.AuthApplyResponse;
|
|
import com.srp.AuthApi.ErrorCodeConfig;
|
|
import com.srp.AuthApi.ErrorCodeConfig;
|
|
-import com.sunwin.visitorapp.activity.HomeAc;
|
|
|
|
|
|
+import com.sunwin.visitorapp.activity.AuthActivity;
|
|
import com.sunwin.visitorapp.face.FRAbsLoopFactory;
|
|
import com.sunwin.visitorapp.face.FRAbsLoopFactory;
|
|
import com.sunwin.visitorapp.service.PullDataService;
|
|
import com.sunwin.visitorapp.service.PullDataService;
|
|
import com.sunwin.visitorapp.utils.AppManager;
|
|
import com.sunwin.visitorapp.utils.AppManager;
|
|
@@ -41,7 +39,7 @@ import java.lang.ref.WeakReference;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
|
|
|
|
-public class SplashActivity extends AppCompatActivity {
|
|
|
|
|
|
+public class SplashActivity extends BaseActivity {
|
|
|
|
|
|
private static final int REQUEST_FOR_PERMISSION = 100;
|
|
private static final int REQUEST_FOR_PERMISSION = 100;
|
|
private static final String TAG = "SplashActivity";
|
|
private static final String TAG = "SplashActivity";
|
|
@@ -72,7 +70,6 @@ public class SplashActivity extends AppCompatActivity {
|
|
}
|
|
}
|
|
|
|
|
|
private void initData() {
|
|
private void initData() {
|
|
- authPermission();
|
|
|
|
initPermission();
|
|
initPermission();
|
|
requestDevicePermission();
|
|
requestDevicePermission();
|
|
}
|
|
}
|
|
@@ -81,14 +78,11 @@ public class SplashActivity extends AppCompatActivity {
|
|
|
|
|
|
// String cert = readExternal(CERT_PATH).trim();
|
|
// String cert = readExternal(CERT_PATH).trim();
|
|
String cert = SharePrefenceUtils.getString(Constant.ISharePrefence.CERT, "");
|
|
String cert = SharePrefenceUtils.getString(Constant.ISharePrefence.CERT, "");
|
|
- if (TextUtils.isEmpty(cert)){
|
|
|
|
- cert = readFile(this);
|
|
|
|
- }
|
|
|
|
if (TextUtils.isEmpty(cert)) {
|
|
if (TextUtils.isEmpty(cert)) {
|
|
-// Toast.makeText(this, "cert is null", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
+ startAuthActivity();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ loadingDialog.showLoadingDialog("授权中,请等待...");
|
|
authApi.authDevice(this.getApplicationContext(), cert, "", new AuthApi.AuthDeviceCallBack() {
|
|
authApi.authDevice(this.getApplicationContext(), cert, "", new AuthApi.AuthDeviceCallBack() {
|
|
@Override
|
|
@Override
|
|
public void GetAuthDeviceResult(final AuthApplyResponse result) {
|
|
public void GetAuthDeviceResult(final AuthApplyResponse result) {
|
|
@@ -100,6 +94,8 @@ public class SplashActivity extends AppCompatActivity {
|
|
ToastUtils.showToast("Apply update: OK");
|
|
ToastUtils.showToast("Apply update: OK");
|
|
SharePrefenceUtils.putBoolean(Constant.ISharePrefence.ISINIT, true);
|
|
SharePrefenceUtils.putBoolean(Constant.ISharePrefence.ISINIT, true);
|
|
new FRAbsLoopFactory().createFRAblLoop(SplashActivity.this, Constant.NumerValue.FRABS_TYPE);
|
|
new FRAbsLoopFactory().createFRAblLoop(SplashActivity.this, Constant.NumerValue.FRABS_TYPE);
|
|
|
|
+ loadingDialog.dismissLoadingDialog();
|
|
|
|
+ openApplication();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
} else {
|
|
} else {
|
|
@@ -107,6 +103,8 @@ public class SplashActivity extends AppCompatActivity {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
ToastUtils.showToast("Apply update: error. error code is: " + result.errorCode + " , error message: " + result.errorMessage);
|
|
ToastUtils.showToast("Apply update: error. error code is: " + result.errorCode + " , error message: " + result.errorMessage);
|
|
|
|
+ loadingDialog.dismissLoadingDialog();
|
|
|
|
+ startAuthActivity();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -115,6 +113,11 @@ public class SplashActivity extends AppCompatActivity {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void startAuthActivity() {
|
|
|
|
+ startActivity(new Intent(SplashActivity.this, AuthActivity.class));
|
|
|
|
+ finish();
|
|
|
|
+ }
|
|
|
|
+
|
|
public String readFile(Context context) {
|
|
public String readFile(Context context) {
|
|
String content = "";
|
|
String content = "";
|
|
try {
|
|
try {
|
|
@@ -136,7 +139,7 @@ public class SplashActivity extends AppCompatActivity {
|
|
} catch (IOException var9) {
|
|
} catch (IOException var9) {
|
|
LogUtil.d(TAG, var9.getMessage());
|
|
LogUtil.d(TAG, var9.getMessage());
|
|
}
|
|
}
|
|
- SharePrefenceUtils.putString(Constant.ISharePrefence.CERT,content);
|
|
|
|
|
|
+ SharePrefenceUtils.putString(Constant.ISharePrefence.CERT, content);
|
|
return content;
|
|
return content;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -170,7 +173,7 @@ public class SplashActivity extends AppCompatActivity {
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
requestPer2();
|
|
requestPer2();
|
|
} else {
|
|
} else {
|
|
- openApplication();
|
|
|
|
|
|
+ authAndOpenApplication();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -185,7 +188,7 @@ public class SplashActivity extends AppCompatActivity {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (permissions.size() == 0) {
|
|
if (permissions.size() == 0) {
|
|
- openApplication();
|
|
|
|
|
|
+ authAndOpenApplication();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
String[] permissionStr = permissions.toArray(new String[0]);
|
|
String[] permissionStr = permissions.toArray(new String[0]);
|
|
@@ -201,7 +204,7 @@ public class SplashActivity extends AppCompatActivity {
|
|
switch (requestCode) {
|
|
switch (requestCode) {
|
|
case REQUEST_FOR_PERMISSION:
|
|
case REQUEST_FOR_PERMISSION:
|
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
- openApplication();
|
|
|
|
|
|
+ authAndOpenApplication();
|
|
} else {
|
|
} else {
|
|
ToastUtils.showToast("请您授予应用相应权限!");
|
|
ToastUtils.showToast("请您授予应用相应权限!");
|
|
}
|
|
}
|
|
@@ -212,29 +215,8 @@ public class SplashActivity extends AppCompatActivity {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 进入应用程序
|
|
|
|
- */
|
|
|
|
- private void openApplication() {
|
|
|
|
- boolean isLogin = SharePrefenceUtils.getBoolean(Constant.ISharePrefence.LOGINTAG, false);
|
|
|
|
- if (isLogin) {
|
|
|
|
- gotoMain();
|
|
|
|
- } else {
|
|
|
|
- gotoLogin();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void gotoMain() {
|
|
|
|
- Intent intent = new Intent(this, HomeAc.class);
|
|
|
|
- startActivity(intent);
|
|
|
|
- finish();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void gotoLogin() {
|
|
|
|
- Intent intent = new Intent(this, LoginActivity.class);
|
|
|
|
- startActivity(intent);
|
|
|
|
- finish();
|
|
|
|
|
|
+ protected void authAndOpenApplication() {
|
|
|
|
+ authPermission();
|
|
}
|
|
}
|
|
|
|
|
|
private final String ACTION_USB_PERMISSION = "com.sunwin.visitorapp.USB_PERMISSION";
|
|
private final String ACTION_USB_PERMISSION = "com.sunwin.visitorapp.USB_PERMISSION";
|