Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission Denied listener Added #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MainActivity extends AppCompatActivity {
public class MainActivity extends AppCompatActivity implements PermissionDeniedListener {
private SmsVerifyCatcher smsVerifyCatcher;

@Override
Expand Down Expand Up @@ -83,6 +83,6 @@ protected void onStop() {
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
smsVerifyCatcher.onRequestPermissionsResult(requestCode, permissions, grantResults);
smsVerifyCatcher.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.stfalcon.smsverifycatcher;

public interface PermissionDeniedListener {
void onPermissionDenied();
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ public void setFilter(String regexp) {
this.filter = regexp;
}

public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults, PermissionDeniedListener permissionDeniedListener) {
switch (requestCode) {
case PERMISSION_REQUEST_CODE:
if (grantResults.length > 1 &&
grantResults[0] == PackageManager.PERMISSION_GRANTED &&
grantResults[1] == PackageManager.PERMISSION_GRANTED) {
registerReceiver();
}
} else {
Toast.makeText(activity, "Permission denied, you have to manually enter OTP now", Toast.LENGTH_LONG).show();
permissionDeniedListener.onPermissionDenied();
}
break;
default:
break;
Expand Down