Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.justadeveloper96.android:permissionhelper:1.1.2'
implementation project(':permissionhelper')
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import android.annotation.TargetApi;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import androidx.appcompat.app.AlertDialog;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableField;
import android.os.Build;
Expand Down Expand Up @@ -86,7 +89,28 @@ public void onPermissionRejectedManyTimes(List<String> rejectedPerms, int reques
}
Toast.makeText(MainActivity.this,"Rejected "+s.substring(1),Toast.LENGTH_SHORT).show();
}
});

@Override
public boolean interceptPermissionsRejected(@NonNull List<String> rejectedPerms, final int request_code) {
new AlertDialog.Builder(MainActivity.this)
.setTitle("Permissions")
.setMessage("Please grant all the permissions")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
permissionHelper.requestPermission(needed_permissions.toArray(new String[needed_permissions.size()]), request_code);
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
}
})
.create().show();
return true;
}
});

binding.get.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.novoda:bintray-release:0.9.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31"
classpath 'com.novoda:bintray-release:0.9.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
4 changes: 2 additions & 2 deletions permissionhelper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.2.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class PermissionHelper {
public interface PermissionsListener {
void onPermissionGranted(int request_code);
void onPermissionRejectedManyTimes(@NonNull List<String> rejectedPerms, int request_code);
boolean interceptPermissionsRejected(@NonNull List<String> rejectedPerms, int request_code);
}

private WeakReference<Activity> activity_view;
Expand Down Expand Up @@ -142,7 +143,9 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
if (deniedpermissions.size() > 0) {
res = res.substring(1);
if (!never_ask_again) {
getRequestAgainAlertDialog(getActivity(), res,requestCode);
if(!getListener().interceptPermissionsRejected(deniedpermissions, requestCode)) {
getRequestAgainAlertDialog(getActivity(), res,requestCode);
}
} else {
goToSettingsAlertDialog(getActivity(), res,requestCode);
}
Expand Down Expand Up @@ -268,4 +271,4 @@ public void onDestroy() {
frag_v4_view = null;
}

}
}