AI2 Component  (Version nb184)
BulkPermissionRequest.java
Go to the documentation of this file.
1 // -*- mode: java; c-basic-offset: 2; -*-
2 // Copyright 2019 MIT, All rights reserved
3 // Released under the Apache License, Version 2.0
4 // http://www.apache.org/licenses/LICENSE-2.0
5 
6 package com.google.appinventor.components.runtime.util;
7 
10 
11 import java.util.ArrayList;
12 import java.util.Collections;
13 import java.util.List;
14 
22 public abstract class BulkPermissionRequest {
23  private Component source;
24  private String caller;
25  private String[] permissions;
26 
34  protected BulkPermissionRequest(Component source, String caller, String... permissions) {
35  this.source = source;
36  this.caller = caller;
37  this.permissions = permissions;
38  }
39 
45  public abstract void onGranted();
46 
53  public void onDenied(String[] permissions) {
54  Form form = (Form) source.getDispatchDelegate();
55  for (String permission : permissions) {
56  form.dispatchPermissionDeniedEvent(source, caller, permission);
57  }
58  }
59 
65  public final List<String> getPermissions() {
66  List<String> result = new ArrayList<>(permissions.length);
67  Collections.addAll(result, permissions);
68  return result;
69  }
70 }
com.google.appinventor.components.runtime.util.BulkPermissionRequest.BulkPermissionRequest
BulkPermissionRequest(Component source, String caller, String... permissions)
Definition: BulkPermissionRequest.java:34
com.google.appinventor.components.runtime.util.BulkPermissionRequest.onDenied
void onDenied(String[] permissions)
Definition: BulkPermissionRequest.java:53
com.google.appinventor.components
com.google.appinventor.components.runtime.Component.getDispatchDelegate
HandlesEventDispatching getDispatchDelegate()
com.google.appinventor.components.runtime.Form.dispatchPermissionDeniedEvent
void dispatchPermissionDeniedEvent(final Component component, final String functionName, final PermissionException exception)
Definition: Form.java:987
com.google.appinventor.components.runtime.util.BulkPermissionRequest.onGranted
abstract void onGranted()
com.google.appinventor.components.runtime.util.BulkPermissionRequest
Definition: BulkPermissionRequest.java:22
com.google.appinventor.components.runtime
Copyright 2009-2011 Google, All Rights reserved.
Definition: AccelerometerSensor.java:8
com.google.appinventor.components.runtime.Component
Definition: Component.java:17
com.google
com
com.google.appinventor.components.runtime.util.BulkPermissionRequest.getPermissions
final List< String > getPermissions()
Definition: BulkPermissionRequest.java:65
com.google.appinventor.components.runtime.Form
Definition: Form.java:126
com.google.appinventor