|
|
@@ -1,12 +1,17 @@
|
|
|
package com.sheep.jiuyan.samllsheep.page;
|
|
|
|
|
|
import android.Manifest;
|
|
|
+import android.app.AlertDialog;
|
|
|
+import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Build;
|
|
|
+import android.os.Handler;
|
|
|
import android.os.SystemClock;
|
|
|
import android.provider.Settings;
|
|
|
import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
|
+import android.widget.FrameLayout;
|
|
|
+import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import com.mylhyl.acp.Acp;
|
|
|
@@ -26,7 +31,10 @@ import java.util.List;
|
|
|
* Created by kemllor on 2018/1/24.
|
|
|
*/
|
|
|
|
|
|
-public class SplashActivity extends BaseActivity {
|
|
|
+public class SplashActivity extends BaseActivity implements View.OnClickListener {
|
|
|
+
|
|
|
+ private FrameLayout fl;
|
|
|
+
|
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
|
return R.layout.splash_activity;
|
|
|
@@ -34,26 +42,12 @@ public class SplashActivity extends BaseActivity {
|
|
|
|
|
|
@Override
|
|
|
public void initView() {
|
|
|
-
|
|
|
+ fl=(FrameLayout)findViewById(R.id.fl);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void initListener() {
|
|
|
- findViewById(R.id.btn_join).setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- String openId = SpUtils.getOpenId(getApplicationContext());
|
|
|
- if (!TextUtils.isEmpty(openId)) {
|
|
|
- Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
|
|
- startActivity(intent);
|
|
|
- finish();
|
|
|
- } else {
|
|
|
- Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
|
|
|
- startActivity(intent);
|
|
|
- finish();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ fl.setOnClickListener(this);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -65,35 +59,18 @@ public class SplashActivity extends BaseActivity {
|
|
|
* 申请读写权限6.0
|
|
|
*/
|
|
|
private void getSA() {
|
|
|
- if (Build.VERSION.SDK_INT >= 23) {
|
|
|
- boolean has = PremissUtils.hasPermission(this);
|
|
|
- if (!has) {
|
|
|
- PremissUtils.openUsageAccessPage(this);
|
|
|
- }
|
|
|
- }
|
|
|
- if (Build.VERSION.SDK_INT >= 23) {
|
|
|
- if (Settings.canDrawOverlays(SplashActivity.this)) {
|
|
|
- Intent intent = new Intent(SplashActivity.this, FloatService.class);
|
|
|
- startService(intent);
|
|
|
- } else {
|
|
|
- //若没有权限,提示获取.
|
|
|
- Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
|
|
|
- Toast.makeText(SplashActivity.this, "需要取得权限以使用悬浮窗", Toast.LENGTH_SHORT).show();
|
|
|
- startActivity(intent);
|
|
|
- }
|
|
|
- } else {
|
|
|
- Intent intent = new Intent(SplashActivity.this, FloatService.class);
|
|
|
- startService(intent);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
Acp.getInstance(this).request(new AcpOptions.Builder()
|
|
|
.setPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE
|
|
|
- , Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_STATE
|
|
|
+ ,Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_STATE
|
|
|
)
|
|
|
.build(),
|
|
|
new AcpListener() {
|
|
|
@Override
|
|
|
public void onGranted() {
|
|
|
ClassFileHelper.getInstance().createSDDirection();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -102,7 +79,70 @@ public class SplashActivity extends BaseActivity {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
+ if (Build.VERSION.SDK_INT >= 23) {
|
|
|
+ if (Settings.canDrawOverlays(SplashActivity.this)) {
|
|
|
+ Intent intent = new Intent(SplashActivity.this, FloatService.class);
|
|
|
+ startService(intent);
|
|
|
+ } else {
|
|
|
+ //若没有权限,提示获取.
|
|
|
+ showPremissSet();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Intent intent = new Intent(SplashActivity.this, FloatService.class);
|
|
|
+ startService(intent);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ switch (v.getId()){
|
|
|
+ case R.id.fl:
|
|
|
+ goMain();
|
|
|
+ break;
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ private void goMain(){
|
|
|
+ String openId = SpUtils.getOpenId(getApplicationContext());
|
|
|
+ if (!TextUtils.isEmpty(openId)) {
|
|
|
+ Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
|
|
+ startActivity(intent);
|
|
|
+ finish();
|
|
|
+ } else {
|
|
|
+ Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
|
|
|
+ startActivity(intent);
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showPremissSet(){
|
|
|
+
|
|
|
+ new AlertDialog.Builder(this)
|
|
|
+ .setTitle("温馨提示!")
|
|
|
+ .setMessage("亲!要赚钱需要手动开启悬浮框和在其他上层显示权限 请逐一开启哟!")
|
|
|
+ .setPositiveButton("去开启", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
|
|
|
+ startActivity(intent);
|
|
|
+ if (Build.VERSION.SDK_INT >= 23) {
|
|
|
+ boolean has = PremissUtils.hasPermission(SplashActivity.this);
|
|
|
+ if (!has) {
|
|
|
+ PremissUtils.openUsageAccessPage(SplashActivity.this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|