add callback for permission request result, style nits

This commit is contained in:
Brad Parker 2017-03-20 14:46:43 +00:00
parent b1e94e8215
commit 61cbb25b12

View File

@ -35,12 +35,15 @@ public class RetroActivityCommon extends RetroActivityLocation
private boolean addPermission(List<String> permissionsList, String permission)
{
if (checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
if (checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED)
{
permissionsList.add(permission);
// Check for Rationale Option
if (!shouldShowRequestPermissionRationale(permission))
return false;
}
return true;
}
@ -79,7 +82,8 @@ public class RetroActivityCommon extends RetroActivityLocation
message = message + ", " + permissionsNeeded.get(i);
showMessageOKCancel(message,
new DialogInterface.OnClickListener() {
new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
@ -101,6 +105,24 @@ public class RetroActivityCommon extends RetroActivityLocation
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
{
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
for (int i = 0; i < permissions.length; i++)
{
if(grantResults[i] == PackageManager.PERMISSION_GRANTED)
{
Log.i("RetroActivity", "Permission: " + permissions[i] + " was granted.");
}
else
{
Log.i("RetroActivity", "Permission: " + permissions[i] + " was not granted.");
}
}
}
public boolean isAndroidTV()
{
Configuration config = getResources().getConfiguration();