- 
                Notifications
    You must be signed in to change notification settings 
- Fork 9.7k
Bump plugin Android compileSdkVersions to 31 #4502
Changes from all commits
e440cbe
              1ebdb16
              3bee3c7
              66bfddc
              aab0a83
              e40e1d6
              8619c7d
              3b7afdc
              ef95aa4
              c25cbac
              fd92106
              309c971
              8466119
              87845cf
              843bcb4
              da93b62
              74e14ea
              9cdca3e
              d2674f7
              ffa2bb7
              7976b3b
              8087087
              db6b14b
              9cfa5e7
              09a9fbd
              d6e2d87
              6c60ea2
              58b2e51
              1f8421e
              8de519d
              9091448
              15cf578
              59217c4
              b00a788
              cdf96ea
              b2a7af3
              2fbd39b
              feefd6a
              e0c36a8
              cd1cab1
              71c1069
              b87f68e
              b291164
              d9f45b9
              3e8fa4f
              615361c
              868547c
              defee15
              70b431b
              dc5a2d6
              b1758c6
              df34dd2
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| ## NEXT | ||
|  | ||
| * Updates example app Android compileSdkVersion to 31. | ||
|  | ||
| ## 0.1.0+4 | ||
|  | ||
| * Updated Android lint settings. | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| ## NEXT | ||
|  | ||
| * Updates example app Android compileSdkVersion to 31. | ||
|  | ||
| ## 2.0.4 | ||
|  | ||
| * Updated Android lint settings. | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| ## NEXT | ||
|  | ||
| * Updates example app Android compileSdkVersion to 31. | ||
|  | ||
| ## 2.1.1 | ||
|  | ||
| * Suppresses unchecked cast warning. | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| ## NEXT | ||
|  | ||
| * Updates example app Android compileSdkVersion to 31. | ||
| * Fix iOS RunnerUITests search paths. | ||
|  | ||
| ## 0.8.4+4 | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -63,7 +63,7 @@ android { | |
| } | ||
| } | ||
|  | ||
| compileSdkVersion 29 | ||
| compileSdkVersion 31 | ||
|  | ||
| lintOptions { | ||
| disable 'InvalidPackage' | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -63,7 +63,7 @@ android { | |
| } | ||
| } | ||
|  | ||
| compileSdkVersion 29 | ||
| compileSdkVersion 31 | ||
|  | ||
| lintOptions { | ||
| disable 'InvalidPackage' | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -13,11 +13,17 @@ | |
| import android.content.res.Resources; | ||
| import android.graphics.drawable.Icon; | ||
| import android.os.Build; | ||
| import android.os.Handler; | ||
| import android.os.Looper; | ||
| import io.flutter.plugin.common.MethodCall; | ||
| import io.flutter.plugin.common.MethodChannel; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.concurrent.Executor; | ||
| import java.util.concurrent.LinkedBlockingQueue; | ||
| import java.util.concurrent.ThreadPoolExecutor; | ||
| import java.util.concurrent.TimeUnit; | ||
|  | ||
| class MethodCallHandlerImpl implements MethodChannel.MethodCallHandler { | ||
| protected static final String EXTRA_ACTION = "some unique action key"; | ||
|  | @@ -47,10 +53,42 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) { | |
| (ShortcutManager) context.getSystemService(Context.SHORTCUT_SERVICE); | ||
| switch (call.method) { | ||
| case "setShortcutItems": | ||
| List<Map<String, String>> serializedShortcuts = call.arguments(); | ||
| List<ShortcutInfo> shortcuts = deserializeShortcuts(serializedShortcuts); | ||
| shortcutManager.setDynamicShortcuts(shortcuts); | ||
| break; | ||
| if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) { | ||
| List<Map<String, String>> serializedShortcuts = call.arguments(); | ||
| List<ShortcutInfo> shortcuts = deserializeShortcuts(serializedShortcuts); | ||
|  | ||
| Executor uiThreadExecutor = new UiThreadExecutor(); | ||
| ThreadPoolExecutor executor = | ||
| new ThreadPoolExecutor( | ||
| 0, 1, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); | ||
|  | ||
| executor.execute( | ||
| () -> { | ||
| boolean dynamicShortcutsSet = false; | ||
| try { | ||
| shortcutManager.setDynamicShortcuts(shortcuts); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now you are calling result after you've dispatched the message to the background thread.  You should call the result after the background task has executed (calling  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
 Does "now" include stable? Plugins support at least back to last stable (often more, but currently for this plugin it's 2.5) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it doesn't I corrected myself over chat. We can't call the result directly until background platform channels is on stable. | ||
| dynamicShortcutsSet = true; | ||
| } catch (Exception e) { | ||
| // Leave dynamicShortcutsSet as false | ||
| } | ||
|  | ||
| final boolean didSucceed = dynamicShortcutsSet; | ||
|  | ||
| // TODO(camsim99): Move re-dispatch below to background thread when Flutter 2.8+ is stable. | ||
| uiThreadExecutor.execute( | ||
| () -> { | ||
| if (didSucceed) { | ||
| result.success(null); | ||
| } else { | ||
| result.error( | ||
| "quick_action_setshortcutitems_failure", | ||
| "Exception thrown when setting dynamic shortcuts", | ||
| null); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
| return; | ||
| case "clearShortcutItems": | ||
| shortcutManager.removeAllDynamicShortcuts(); | ||
| break; | ||
|  | @@ -127,4 +165,13 @@ private Intent getIntentToOpenMainActivity(String type) { | |
| .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
| .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); | ||
| } | ||
|  | ||
| private static class UiThreadExecutor implements Executor { | ||
| private final Handler handler = new Handler(Looper.getMainLooper()); | ||
|  | ||
| @Override | ||
| public void execute(Runnable command) { | ||
| handler.post(command); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Type added to help fix warnings given by
flutter build apk.