mirror of https://github.com/M66B/FairEmail.git
Allow revoking permissions
This commit is contained in:
parent
5acf130267
commit
29514be6a2
|
@ -554,13 +554,20 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
try {
|
try {
|
||||||
btnPermissions.setEnabled(false);
|
String[] desired = Helper.getDesiredPermissions(v.getContext());
|
||||||
List<String> requesting = new ArrayList<>();
|
if (Helper.hasPermissions(v.getContext(), desired)) {
|
||||||
for (String permission : Helper.getDesiredPermissions(getContext()))
|
Intent intent = new Intent(
|
||||||
if (!hasPermission(permission))
|
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||||
requesting.add((permission));
|
Uri.parse("package:" + BuildConfig.APPLICATION_ID));
|
||||||
Log.i("Requesting permissions " + TextUtils.join(",", requesting));
|
v.getContext().startActivity(intent);
|
||||||
requestPermissions(requesting.toArray(new String[0]), REQUEST_PERMISSIONS);
|
} else {
|
||||||
|
List<String> requesting = new ArrayList<>();
|
||||||
|
for (String permission : desired)
|
||||||
|
if (!hasPermission(permission))
|
||||||
|
requesting.add((permission));
|
||||||
|
Log.i("Requesting permissions " + TextUtils.join(",", requesting));
|
||||||
|
requestPermissions(requesting.toArray(new String[0]), REQUEST_PERMISSIONS);
|
||||||
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||||
/*
|
/*
|
||||||
|
@ -862,10 +869,13 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
|
||||||
? View.GONE : View.VISIBLE);
|
? View.GONE : View.VISIBLE);
|
||||||
tvPermissionsDone.setText(null);
|
tvPermissionsDone.setText(null);
|
||||||
tvPermissionsDone.setCompoundDrawables(null, null, null, null);
|
tvPermissionsDone.setCompoundDrawables(null, null, null, null);
|
||||||
|
btnPermissions.setText(null);
|
||||||
|
btnPermissions.setCompoundDrawables(null, null, null, null);
|
||||||
|
|
||||||
tvDozeDone.setText(null);
|
tvDozeDone.setText(null);
|
||||||
tvDozeDone.setCompoundDrawables(null, null, null, null);
|
tvDozeDone.setCompoundDrawables(null, null, null, null);
|
||||||
btnDoze.setEnabled(false);
|
btnDoze.setText(null);
|
||||||
|
btnDoze.setCompoundDrawables(null, null, null, null);
|
||||||
tvDoze12.setVisibility(View.GONE);
|
tvDoze12.setVisibility(View.GONE);
|
||||||
|
|
||||||
btnInbox.setEnabled(false);
|
btnInbox.setEnabled(false);
|
||||||
|
@ -1005,17 +1015,19 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
|
||||||
else {
|
else {
|
||||||
Intent intent = new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
|
Intent intent = new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
|
||||||
PackageManager pm = getContext().getPackageManager();
|
PackageManager pm = getContext().getPackageManager();
|
||||||
if (intent.resolveActivity(pm) == null)
|
btnDoze.setEnabled(intent.resolveActivity(pm) != null);
|
||||||
btnDoze.setEnabled(false);
|
|
||||||
else
|
|
||||||
btnDoze.setEnabled(!isIgnoring || BuildConfig.DEBUG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tvDozeDone.setText(isIgnoring ? R.string.title_setup_done : R.string.title_setup_to_do);
|
tvDozeDone.setText(isIgnoring ? R.string.title_setup_done : R.string.title_setup_to_do);
|
||||||
tvDozeDone.setTextColor(isIgnoring ? textColorPrimary : colorWarning);
|
tvDozeDone.setTextColor(isIgnoring ? textColorPrimary : colorWarning);
|
||||||
tvDozeDone.setCompoundDrawablesWithIntrinsicBounds((isIgnoring ? done : todo).mutate(), null, null, null);
|
tvDozeDone.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
(isIgnoring ? done : todo).mutate(), null, null, null);
|
||||||
tvDozeDone.setCompoundDrawableTintList(ColorStateList.valueOf(isIgnoring ? textColorPrimary : colorWarning));
|
tvDozeDone.setCompoundDrawableTintList(ColorStateList.valueOf(isIgnoring ? textColorPrimary : colorWarning));
|
||||||
|
|
||||||
|
btnDoze.setCompoundDrawablesRelativeWithIntrinsicBounds(
|
||||||
|
0, 0, isIgnoring ? R.drawable.twotone_settings_24 : R.drawable.twotone_check_24, 0);
|
||||||
|
btnDoze.setText(isIgnoring ? R.string.title_setup_manage : R.string.title_setup_grant);
|
||||||
|
|
||||||
tvDoze12.setVisibility(!canScheduleExact && !isIgnoring ? View.VISIBLE : View.GONE);
|
tvDoze12.setVisibility(!canScheduleExact && !isIgnoring ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
@ -1196,9 +1208,13 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
|
||||||
|
|
||||||
tvPermissionsDone.setText(all ? R.string.title_setup_done : R.string.title_setup_to_do);
|
tvPermissionsDone.setText(all ? R.string.title_setup_done : R.string.title_setup_to_do);
|
||||||
tvPermissionsDone.setTextColor(all ? textColorPrimary : colorWarning);
|
tvPermissionsDone.setTextColor(all ? textColorPrimary : colorWarning);
|
||||||
tvPermissionsDone.setCompoundDrawablesWithIntrinsicBounds((all ? done : todo).mutate(), null, null, null);
|
tvPermissionsDone.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
(all ? done : todo).mutate(), null, null, null);
|
||||||
tvPermissionsDone.setCompoundDrawableTintList(ColorStateList.valueOf(all ? textColorPrimary : colorWarning));
|
tvPermissionsDone.setCompoundDrawableTintList(ColorStateList.valueOf(all ? textColorPrimary : colorWarning));
|
||||||
btnPermissions.setEnabled(!all);
|
|
||||||
|
btnPermissions.setCompoundDrawablesRelativeWithIntrinsicBounds(
|
||||||
|
0, 0, all ? R.drawable.twotone_settings_24 : R.drawable.twotone_check_24, 0);
|
||||||
|
btnPermissions.setText(all ? R.string.title_setup_manage : R.string.title_setup_grant);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSelectIdentity(Bundle args) {
|
private void onSelectIdentity(Bundle args) {
|
||||||
|
|
Loading…
Reference in New Issue