Skip to content

Commit

Permalink
Google Java Format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Aug 17, 2022
1 parent f13b9b9 commit d3553c5
Showing 1 changed file with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@ interface PermissionRequestListener {
void fail(String message);
}


/** FlutterLocalNotificationsPlugin */
@Keep
public class FlutterLocalNotificationsPlugin
implements MethodCallHandler, PluginRegistry.NewIntentListener, PluginRegistry.RequestPermissionsResultListener, FlutterPlugin, ActivityAware {
implements MethodCallHandler,
PluginRegistry.NewIntentListener,
PluginRegistry.RequestPermissionsResultListener,
FlutterPlugin,
ActivityAware {
private static final String SHARED_PREFERENCES_KEY = "notification_plugin_cache";
private static final String DRAWABLE = "drawable";
private static final String DEFAULT_ICON = "defaultIcon";
Expand Down Expand Up @@ -1244,17 +1247,18 @@ public void onMethodCall(MethodCall call, @NonNull final Result result) {
zonedSchedule(call, result);
break;
case REQUEST_PERMISSION_METHOD:
requestPermission(new PermissionRequestListener() {
@Override
public void complete(boolean granted) {
result.success(granted);
}

@Override
public void fail(String message) {
result.error("PERMISSION_REQUEST_IN_PROGRESS", message, null);
}
});
requestPermission(
new PermissionRequestListener() {
@Override
public void complete(boolean granted) {
result.success(granted);
}

@Override
public void fail(String message) {
result.error("PERMISSION_REQUEST_IN_PROGRESS", message, null);
}
});
break;
case PERIODICALLY_SHOW_METHOD:
case SHOW_DAILY_AT_TIME_METHOD:
Expand Down Expand Up @@ -1545,12 +1549,14 @@ public void requestPermission(@NonNull PermissionRequestListener callback) {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
String permission = Manifest.permission.POST_NOTIFICATIONS;
boolean permissionGranted = ContextCompat.checkSelfPermission(mainActivity,
permission) == PackageManager.PERMISSION_GRANTED;
boolean permissionGranted =
ContextCompat.checkSelfPermission(mainActivity, permission)
== PackageManager.PERMISSION_GRANTED;

if (!permissionGranted) {
permissionRequestInProgress = true;
ActivityCompat.requestPermissions(mainActivity, new String[]{permission}, NOTIFICATION_PERMISSION_REQUEST_CODE);
ActivityCompat.requestPermissions(
mainActivity, new String[] {permission}, NOTIFICATION_PERMISSION_REQUEST_CODE);
} else {
this.callback.complete(true);
permissionRequestInProgress = false;
Expand All @@ -1562,9 +1568,11 @@ public void requestPermission(@NonNull PermissionRequestListener callback) {
}

@Override
public boolean onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
public boolean onRequestPermissionsResult(
int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) {
boolean granted = grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;
boolean granted =
grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;
callback.complete(granted);
permissionRequestInProgress = false;
return granted;
Expand Down

0 comments on commit d3553c5

Please sign in to comment.