-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.java
66 lines (51 loc) · 2.63 KB
/
code.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.trackapps.digitalsignature;
import android.Manifest;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.permissionx.guolindev.PermissionX;
import com.permissionx.guolindev.callback.ExplainReasonCallback;
import com.permissionx.guolindev.callback.ForwardToSettingsCallback;
import com.permissionx.guolindev.callback.RequestCallback;
import com.permissionx.guolindev.request.ExplainScope;
import com.permissionx.guolindev.request.ForwardScope;
import java.util.List;
public class Splash extends AppCompatActivity {
public int touch = 0;
protected int _splashTime = 300;
String[] permissions = new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
PermissionX.init(this).permissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE)
.onExplainRequestReason(new ExplainReasonCallback() {
@Override
public void onExplainReason(@NonNull ExplainScope scope, @NonNull List<String> deniedList) {
scope.showRequestReasonDialog(deniedList, "These Permissions must be granted in order to use this App", "OK", "Cancel");
}
})
.onForwardToSettings(new ForwardToSettingsCallback() {
@Override
public void onForwardToSettings(@NonNull ForwardScope scope, @NonNull List<String> deniedList) {
scope.showForwardToSettingsDialog(deniedList, "You need to allow necessary permissions in Settings manually", "OK", "Cancel");
}
})
.request(new RequestCallback() {
@Override
public void onResult(boolean allGranted, @NonNull List<String> grantedList, @NonNull List<String> deniedList) {
if(allGranted){
Toast.makeText(Splash.this, "All permissions are granted", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Splash.this, TopActivity.class);
startActivity(intent);
finish();
}else{
Toast.makeText(Splash.this, "Permissions Denied", Toast.LENGTH_LONG).show();
}
}
});
}
}