Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/quick_actions/quick_actions_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.5

* Fixes Java warnings.

## 1.0.4

* Fixes compatibility with AGP versions older than 4.2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ android {
checkAllWarnings true
warningsAsErrors true
disable 'AndroidGradlePluginVersion', 'InvalidPackage', 'GradleDependency'
baseline file("lint-baseline.xml")
}

dependencies {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
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.Objects;
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";
private static final String CHANNEL_ID = "plugins.flutter.io/quick_actions_android";

private final Context context;
private Activity activity;
Expand All @@ -42,7 +43,7 @@ void setActivity(Activity activity) {
}

@Override
public void onMethodCall(MethodCall call, MethodChannel.Result result) {
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
// We already know that this functionality does not work for anything
// lower than API 25 so we chose not to return error. Instead we do nothing.
Expand All @@ -54,13 +55,12 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
switch (call.method) {
case "setShortcutItems":
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
List<Map<String, String>> serializedShortcuts = call.arguments();
List<Map<String, String>> serializedShortcuts = Objects.requireNonNull(call.arguments());
List<ShortcutInfo> shortcuts = deserializeShortcuts(serializedShortcuts);

Executor uiThreadExecutor = new UiThreadExecutor();
ThreadPoolExecutor executor =
new ThreadPoolExecutor(
0, 1, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
new ThreadPoolExecutor(0, 1, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the warning with Runnable? Just curious

Copy link
Collaborator Author

@stuartmorgan-g stuartmorgan-g May 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this is one of the AS-specific lints rather than something that shows up in our tooling checks, but I cleaned it up since it's trivial and reduces warning noise in Android Studio. The message is just something along the lines of LinkedBlockingQueue<Runnable> could be LinkedBlockingQueue<>. It's because specifying the generic isn't necessary when it can be clearly inferred from context (like here, where the method parameter requires a ...<Runnable>).


executor.execute(
() -> {
Expand Down Expand Up @@ -140,6 +140,8 @@ private List<ShortcutInfo> deserializeShortcuts(List<Map<String, String>> shortc
return shortcutInfos;
}

// This method requires doing dynamic resource lookup, which is a discouraged API.
@SuppressWarnings("DiscouragedApi")
private int loadResourceId(Context context, String icon) {
if (icon == null) {
return 0;
Expand Down Expand Up @@ -167,7 +169,7 @@ private Intent getIntentToOpenMainActivity(String type) {
.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
}

private static class UiThreadExecutor implements Executor {
static class UiThreadExecutor implements Executor {
private final Handler handler = new Handler(Looper.getMainLooper());

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.content.Intent;
import android.content.pm.ShortcutManager;
import android.os.Build;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
Expand All @@ -30,23 +31,24 @@ public class QuickActionsPlugin implements FlutterPlugin, ActivityAware, NewInte
* <p>Must be called when the application is created.
*/
@SuppressWarnings("deprecation")
public static void registerWith(io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
public static void registerWith(
@NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
final QuickActionsPlugin plugin = new QuickActionsPlugin();
plugin.setupChannel(registrar.messenger(), registrar.context(), registrar.activity());
}

@Override
public void onAttachedToEngine(FlutterPluginBinding binding) {
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
setupChannel(binding.getBinaryMessenger(), binding.getApplicationContext(), null);
}

@Override
public void onDetachedFromEngine(FlutterPluginBinding binding) {
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
teardownChannel();
}

@Override
public void onAttachedToActivity(ActivityPluginBinding binding) {
public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
activity = binding.getActivity();
handler.setActivity(activity);
binding.addOnNewIntentListener(this);
Expand All @@ -59,7 +61,7 @@ public void onDetachedFromActivity() {
}

@Override
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) {
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
binding.removeOnNewIntentListener(this);
onAttachedToActivity(binding);
}
Expand All @@ -70,7 +72,7 @@ public void onDetachedFromActivityForConfigChanges() {
}

@Override
public boolean onNewIntent(Intent intent) {
public boolean onNewIntent(@NonNull Intent intent) {
// Do nothing for anything lower than API 25 as the functionality isn't supported.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: quick_actions_android
description: An implementation for the Android platform of the Flutter `quick_actions` plugin.
repository: https://github.com/flutter/packages/tree/main/packages/quick_actions/quick_actions_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
version: 1.0.4
version: 1.0.5

environment:
sdk: ">=2.17.0 <4.0.0"
Expand Down