From 7a264f889cbc166ae9b01fff9475fddd8f19f101 Mon Sep 17 00:00:00 2001 From: Matthias Robbers Date: Wed, 31 Mar 2021 13:37:38 +0200 Subject: [PATCH] Automatically initialize library with app startup (#30) --- CHANGELOG.md | 10 ++- README.md | 24 ++---- gradle.properties | 2 +- sample/build.gradle | 3 +- sample/src/main/AndroidManifest.xml | 6 +- .../example/shortbread/SampleApplication.java | 15 ---- .../main/java/shortbread/CodeGenerator.java | 49 +++++++----- .../src/main/java/shortbread/RScanner.java | 2 +- .../main/java/shortbread/ShortcutData.java | 33 +++++--- shortbread/build.gradle | 1 + shortbread/src/main/AndroidManifest.xml | 19 ++++- .../src/main/java/shortbread/Shortbread.java | 54 ++++++------- .../shortbread/ShortbreadInitializer.java | 24 ++++++ .../test/java/shortbread/ShortbreadTest.java | 79 ++++++++----------- .../AdvancedShortcutActivityGenerated.java | 4 - .../BackStackShortcutActivityGenerated.java | 4 - .../DisabledShortcutActivityGenerated.java | 4 - .../ResourcesShortcutActivityGenerated.java | 4 - .../SimpleShortcutActivityGenerated.java | 4 - .../TargetShortcutActivityGenerated.java | 4 - .../TwoShortcutActivitiesGenerated.java | 4 - 21 files changed, 173 insertions(+), 176 deletions(-) delete mode 100755 sample/src/main/java/com/example/shortbread/SampleApplication.java create mode 100644 shortbread/src/main/java/shortbread/ShortbreadInitializer.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 0169482..9ef0c95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,17 @@ Change Log ========== +Version 1.3.0 *(2021-03-31)* +---------------------------- +* New: Shortbread is now initialized automatically using [App Startup](https://developer.android.com/topic/libraries/app-startup) +* Deprecated: `Shortbread.create(context)` - no need to call this anymore as the shortcuts are set automatically during app startup +* Fix: Resource values sometimes were not properly read when the incremental annotation processing was incremental +* Improve: `ActivityLifecycleCallbacks` will not be registered if there are no method shortcuts + + Version 1.2.0 *(2021-03-14)* ---------------------------- -* New: Support for non-final resource IDs. See [README.md](https://github.com/MatthiasRobbers/shortbread##non-final-resource-ids) +* New: Support for non-final resource IDs. See [README.md](https://github.com/MatthiasRobbers/shortbread#non-final-resource-ids) for detailed usage instructions. * Update: `androidx.annotation:annotation` to `1.1.0` * Update: Android Gradle plugin to `4.1.2` diff --git a/README.md b/README.md index 5806796..44cde28 100755 --- a/README.md +++ b/README.md @@ -35,20 +35,6 @@ class BooksActivity : Activity() { } ``` -To display the shortcuts, call `Shortbread.create(Context context)` as early as possible in the app, for -example in `onCreate` of a custom `Application`. - -```kotlin -class App : Application() { - - override fun onCreate() { - super.onCreate() - - Shortbread.create(this) - } -} -``` - Shortcuts can be customized with attributes, just like using the framework API.
@@ -106,8 +92,8 @@ Shortbread is available on `mavenCentral()`. apply plugin: 'kotlin-kapt' dependencies { - implementation 'com.github.matthiasrobbers:shortbread:1.2.0' - kapt 'com.github.matthiasrobbers:shortbread-compiler:1.2.0' + implementation 'com.github.matthiasrobbers:shortbread:1.3.0' + kapt 'com.github.matthiasrobbers:shortbread-compiler:1.3.0' } ```
@@ -116,8 +102,8 @@ dependencies { ```groovy dependencies { - implementation 'com.github.matthiasrobbers:shortbread:1.2.0' - annotationProcessor 'com.github.matthiasrobbers:shortbread-compiler:1.2.0' + implementation 'com.github.matthiasrobbers:shortbread:1.3.0' + annotationProcessor 'com.github.matthiasrobbers:shortbread-compiler:1.3.0' } ``` @@ -137,7 +123,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.github.matthiasrobbers:shortbread-gradle-plugin:1.2.0' + classpath 'com.github.matthiasrobbers:shortbread-gradle-plugin:1.3.0' } } ``` diff --git a/gradle.properties b/gradle.properties index cddf139..4e2f04a 100755 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1536m android.useAndroidX=true GROUP=com.github.matthiasrobbers -VERSION_NAME=1.2.0 +VERSION_NAME=1.3.0 POM_URL=https://github.com/matthiasrobbers/shortbread POM_SCM_URL=https://github.com/matthiasrobbers/shortbread diff --git a/sample/build.gradle b/sample/build.gradle index 3b7fdc9..c14c1fd 100755 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -2,11 +2,10 @@ buildscript { repositories { mavenCentral() google() - mavenLocal() } dependencies { - classpath "com.github.matthiasrobbers:shortbread-gradle-plugin:${VERSION_NAME}" + classpath "com.github.matthiasrobbers:shortbread-gradle-plugin:1.2.0" } } diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 9107887..df05c6b 100755 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -3,11 +3,9 @@ xmlns:android="http://schemas.android.com/apk/res/android"> + android:label="@string/app_name"> diff --git a/sample/src/main/java/com/example/shortbread/SampleApplication.java b/sample/src/main/java/com/example/shortbread/SampleApplication.java deleted file mode 100755 index c0f252c..0000000 --- a/sample/src/main/java/com/example/shortbread/SampleApplication.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.example.shortbread; - -import android.app.Application; - -import shortbread.Shortbread; - -public class SampleApplication extends Application { - - @Override - public void onCreate() { - super.onCreate(); - - Shortbread.create(this); - } -} diff --git a/shortbread-compiler/src/main/java/shortbread/CodeGenerator.java b/shortbread-compiler/src/main/java/shortbread/CodeGenerator.java index 6797141..2778bcf 100755 --- a/shortbread-compiler/src/main/java/shortbread/CodeGenerator.java +++ b/shortbread-compiler/src/main/java/shortbread/CodeGenerator.java @@ -51,15 +51,20 @@ class CodeGenerator { } void generate() { - TypeSpec shortbread = TypeSpec.classBuilder("ShortbreadGenerated") + TypeSpec.Builder shortbreadBuilder = TypeSpec.classBuilder("ShortbreadGenerated") .addAnnotation(AnnotationSpec.builder(suppressLint) .addMember("value", "$S", "NewApi") .addMember("value", "$S", "ResourceType") .build()) .addModifiers(Modifier.PUBLIC, Modifier.FINAL) - .addMethod(createShortcuts()) - .addMethod(callMethodShortcut()) - .build(); + .addMethod(createShortcuts()); + + MethodSpec callMethodShortcut = callMethodShortcut(); + if (callMethodShortcut != null) { + shortbreadBuilder.addMethod(callMethodShortcut); + } + + TypeSpec shortbread = shortbreadBuilder.build(); JavaFile javaFile = JavaFile.builder("shortbread", shortbread) .indent(" ") @@ -231,24 +236,28 @@ private MethodSpec callMethodShortcut() { } } - final MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("callMethodShortcut") - .addModifiers(Modifier.PUBLIC, Modifier.STATIC) - .returns(void.class) - .addParameter(activity, "activity"); - - for (final Map.Entry> annotatedMethodName : classMethodsMap.entrySet()) { - ClassName activityClassName = ClassName.bestGuess(annotatedMethodName.getKey()); - List methodNames = annotatedMethodName.getValue(); - methodBuilder.beginControlFlow("if (activity instanceof $T)", activityClassName); - for (final String methodName : methodNames) { - methodBuilder.beginControlFlow("if ($S.equals(activity.getIntent().getStringExtra($S)))", methodName, EXTRA_METHOD); - methodBuilder.addStatement("(($T) activity).$L()", activityClassName, methodName); + if (classMethodsMap.isEmpty()) { + return null; + } else { + final MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("callMethodShortcut") + .addModifiers(Modifier.PUBLIC, Modifier.STATIC) + .returns(void.class) + .addParameter(activity, "activity"); + + for (final Map.Entry> annotatedMethodName : classMethodsMap.entrySet()) { + ClassName activityClassName = ClassName.bestGuess(annotatedMethodName.getKey()); + List methodNames = annotatedMethodName.getValue(); + methodBuilder.beginControlFlow("if (activity instanceof $T)", activityClassName); + for (final String methodName : methodNames) { + methodBuilder.beginControlFlow("if ($S.equals(activity.getIntent().getStringExtra($S)))", methodName, EXTRA_METHOD); + methodBuilder.addStatement("(($T) activity).$L()", activityClassName, methodName); + methodBuilder.endControlFlow(); + } methodBuilder.endControlFlow(); } - methodBuilder.endControlFlow(); - } - return methodBuilder - .build(); + return methodBuilder + .build(); + } } } diff --git a/shortbread-compiler/src/main/java/shortbread/RScanner.java b/shortbread-compiler/src/main/java/shortbread/RScanner.java index ca14111..71521a4 100644 --- a/shortbread-compiler/src/main/java/shortbread/RScanner.java +++ b/shortbread-compiler/src/main/java/shortbread/RScanner.java @@ -15,7 +15,7 @@ * Copied and stripped from Butter Knife, see * https://github.com/JakeWharton/butterknife/blob/master/butterknife-compiler/src/main/java/butterknife/compiler/ButterKnifeProcessor.java */ -public class RScanner extends TreeScanner { +class RScanner extends TreeScanner { final Map resourceIds = new LinkedHashMap<>(); diff --git a/shortbread-compiler/src/main/java/shortbread/ShortcutData.java b/shortbread-compiler/src/main/java/shortbread/ShortcutData.java index 0b83b42..57b74ef 100644 --- a/shortbread-compiler/src/main/java/shortbread/ShortcutData.java +++ b/shortbread-compiler/src/main/java/shortbread/ShortcutData.java @@ -23,26 +23,41 @@ class ShortcutData { ShortcutData(Shortcut shortcut, Map resourceIds) { id = shortcut.id(); - if (shortcut.shortLabelRes() != 0 && resourceIds.containsKey(shortcut.shortLabelRes())) { - shortLabelRes = resourceIds.get(shortcut.shortLabelRes()); + if (shortcut.shortLabelRes() != 0) { + if (resourceIds.containsKey(shortcut.shortLabelRes())) { + shortLabelRes = resourceIds.get(shortcut.shortLabelRes()); + } else { + shortLabelRes = new Id(shortcut.shortLabelRes()); + } } shortLabelResName = shortcut.shortLabelResName(); shortLabel = shortcut.shortLabel(); - if (shortcut.longLabelRes() != 0 && resourceIds.containsKey(shortcut.longLabelRes())) { - longLabelRes = resourceIds.get(shortcut.longLabelRes()); + if (shortcut.longLabelRes() != 0) { + if (resourceIds.containsKey(shortcut.longLabelRes())) { + longLabelRes = resourceIds.get(shortcut.longLabelRes()); + } else { + longLabelRes = new Id(shortcut.longLabelRes()); + } } longLabelResName = shortcut.longLabelResName(); longLabel = shortcut.longLabel(); - if (shortcut.icon() != 0 && resourceIds.containsKey(shortcut.icon())) { - icon = resourceIds.get(shortcut.icon()); + if (shortcut.icon() != 0) { + if (resourceIds.containsKey(shortcut.icon())) { + icon = resourceIds.get(shortcut.icon()); + } else { + icon = new Id(shortcut.icon()); + } } iconResName = shortcut.iconResName(); - if (shortcut.disabledMessageRes() != 0 - && resourceIds.containsKey(shortcut.disabledMessageRes())) { - disabledMessageRes = resourceIds.get(shortcut.disabledMessageRes()); + if (shortcut.disabledMessageRes() != 0) { + if (resourceIds.containsKey(shortcut.disabledMessageRes())) { + disabledMessageRes = resourceIds.get(shortcut.disabledMessageRes()); + } else { + disabledMessageRes = new Id(shortcut.disabledMessageRes()); + } } disabledMessageResName = shortcut.disabledMessageResName(); disabledMessage = shortcut.disabledMessage(); diff --git a/shortbread/build.gradle b/shortbread/build.gradle index 5d865a0..632fdfa 100755 --- a/shortbread/build.gradle +++ b/shortbread/build.gradle @@ -39,6 +39,7 @@ preBuild.dependsOn copyTestResources dependencies { api project(':shortbread-annotations') + api 'androidx.startup:startup-runtime:1.0.0' testImplementation 'junit:junit:4.13.2' testImplementation 'org.robolectric:robolectric:4.5.1' testImplementation 'org.mockito:mockito-core:3.8.0' diff --git a/shortbread/src/main/AndroidManifest.xml b/shortbread/src/main/AndroidManifest.xml index 88456f5..cbe1424 100755 --- a/shortbread/src/main/AndroidManifest.xml +++ b/shortbread/src/main/AndroidManifest.xml @@ -1 +1,18 @@ - + + + + + + + + + + diff --git a/shortbread/src/main/java/shortbread/Shortbread.java b/shortbread/src/main/java/shortbread/Shortbread.java index 075b82a..a2eca51 100755 --- a/shortbread/src/main/java/shortbread/Shortbread.java +++ b/shortbread/src/main/java/shortbread/Shortbread.java @@ -1,6 +1,5 @@ package shortbread; -import android.annotation.TargetApi; import android.app.Activity; import android.app.Application; import android.content.Context; @@ -12,7 +11,7 @@ import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; -import androidx.annotation.VisibleForTesting; +import androidx.startup.AppInitializer; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -20,17 +19,15 @@ import java.util.List; /** - * Creates app shortcuts from {@code @Shortcut} annotations, {@link #create(Context)} is all that needs to be called. + * Creates app shortcuts from {@code @Shortcut} annotations. This class is automatically created by + * {@link shortbread.ShortbreadInitializer} and sets the shortcuts automatically on app startup. No interaction with + * this class is required, the only code needed is the annotations. */ public final class Shortbread { - private static Class generated; - private static Method createShortcuts; - private static Method callMethodShortcut; - @VisibleForTesting - static boolean shortcutsSet; - @VisibleForTesting - static boolean activityLifecycleCallbacksSet; + private Class generated; + private Method createShortcuts; + private Method callMethodShortcut; private static final String TAG = "Shortbread"; /** @@ -38,10 +35,15 @@ public final class Shortbread { * It will also set an activity lifecycle listener to call an annotated activity method when an activity is started * with a method shortcut. * + * @deprecated No need to call this anymore, the library is automatically initialized by {@link shortbread.ShortbreadInitializer}. * @param context Any context, the implementation will use the application context. */ - @TargetApi(25) + @Deprecated public static void create(@NonNull Context context) { + AppInitializer.getInstance(context).initializeComponent(ShortbreadInitializer.class); + } + + Shortbread(@NonNull Context context) { if (Build.VERSION.SDK_INT < 25) { return; } @@ -50,7 +52,6 @@ public static void create(@NonNull Context context) { try { generated = Class.forName("shortbread.ShortbreadGenerated"); createShortcuts = generated.getMethod("createShortcuts", Context.class); - callMethodShortcut = generated.getMethod("callMethodShortcut", Activity.class); } catch (ClassNotFoundException e) { if (ShortcutUtils.isDebuggable(context)) { Log.d(TAG, "No shortcuts found"); @@ -60,25 +61,25 @@ public static void create(@NonNull Context context) { Log.d(TAG, "Error generating shortcuts", e); } } + + try { + callMethodShortcut = generated.getMethod("callMethodShortcut", Activity.class); + } catch (NoSuchMethodException ignored) { + // no method shortcuts found + } } Context applicationContext = context.getApplicationContext(); - if (!shortcutsSet) { - setShortcuts(applicationContext); - } + setShortcuts(applicationContext); - if (!activityLifecycleCallbacksSet) { + if (callMethodShortcut != null) { setActivityLifecycleCallbacks(applicationContext); } - - if (context instanceof Activity) { - callMethodShortcut((Activity) context); - } } @RequiresApi(25) - private static void setShortcuts(@NonNull Context context) { + private void setShortcuts(@NonNull Context context) { ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class); if (createShortcuts == null) { @@ -105,12 +106,10 @@ private static void setShortcuts(@NonNull Context context) { } } } - - shortcutsSet = true; } @RequiresApi(14) - private static void setActivityLifecycleCallbacks(@NonNull Context applicationContext) { + private void setActivityLifecycleCallbacks(@NonNull Context applicationContext) { ((Application) applicationContext).registerActivityLifecycleCallbacks(new SimpleActivityLifecycleCallbacks() { private Class createdActivityClass; @@ -128,11 +127,9 @@ public void onActivityStarted(@NonNull Activity activity) { } } }); - - activityLifecycleCallbacksSet = true; } - private static void callMethodShortcut(@NonNull Activity activity) { + private void callMethodShortcut(@NonNull Activity activity) { if (callMethodShortcut == null || !activity.getIntent().hasExtra("shortbread_method")) { return; } @@ -149,7 +146,4 @@ private static void callMethodShortcut(@NonNull Activity activity) { } } } - - private Shortbread() { - } } diff --git a/shortbread/src/main/java/shortbread/ShortbreadInitializer.java b/shortbread/src/main/java/shortbread/ShortbreadInitializer.java new file mode 100644 index 0000000..8f44346 --- /dev/null +++ b/shortbread/src/main/java/shortbread/ShortbreadInitializer.java @@ -0,0 +1,24 @@ +package shortbread; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.startup.Initializer; + +import java.util.Collections; +import java.util.List; + +public class ShortbreadInitializer implements Initializer { + + @NonNull + @Override + public Shortbread create(@NonNull Context context) { + return new Shortbread(context); + } + + @NonNull + @Override + public List>> dependencies() { + return Collections.emptyList(); + } +} diff --git a/shortbread/src/test/java/shortbread/ShortbreadTest.java b/shortbread/src/test/java/shortbread/ShortbreadTest.java index 6936d58..7dffad8 100755 --- a/shortbread/src/test/java/shortbread/ShortbreadTest.java +++ b/shortbread/src/test/java/shortbread/ShortbreadTest.java @@ -3,6 +3,7 @@ import android.annotation.TargetApi; import android.app.Activity; import android.app.Application; +import android.content.Context; import android.content.Intent; import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutManager; @@ -11,6 +12,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; +import org.mockito.Captor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; @@ -21,7 +23,6 @@ import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; @@ -31,6 +32,8 @@ @TargetApi(25) public class ShortbreadTest { + @Mock + private Context context; @Mock private Activity activity; @Mock @@ -39,15 +42,13 @@ public class ShortbreadTest { private ShortcutManager shortcutManager; @Mock private Intent intent; + @Captor + ArgumentCaptor lifecycleCallbacksCaptor; @Before public void setUp() { - Shortbread.shortcutsSet = false; - Shortbread.activityLifecycleCallbacksSet = false; - MockitoAnnotations.openMocks(this); - when(activity.getApplicationContext()).thenReturn(application); - when(application.getApplicationContext()).thenReturn(application); + when(context.getApplicationContext()).thenReturn(application); when(application.getSystemService(ShortcutManager.class)).thenReturn(shortcutManager); when(activity.getIntent()).thenReturn(intent); } @@ -55,89 +56,77 @@ public void setUp() { @Test @Config(sdk = 24) public void doesNothingBeforeApi25() { - Shortbread.create(activity); - verifyNoMoreInteractions(activity); + new Shortbread(context); + verifyNoMoreInteractions(context); } @Test public void usesApplicationContext() { - Shortbread.create(activity); - verify(activity).getApplicationContext(); + new Shortbread(context); + verify(context).getApplicationContext(); verify(application).getSystemService(ShortcutManager.class); } @Test - public void registersActivityLifecycleCallbacksOnce() { - Shortbread.create(activity); + public void registersActivityLifecycleCallbacks() { + new Shortbread(context); verify(application).registerActivityLifecycleCallbacks(any(Application.ActivityLifecycleCallbacks.class)); - - Shortbread.create(activity); - verify(application, times(1)).registerActivityLifecycleCallbacks(any(Application.ActivityLifecycleCallbacks.class)); } @Test - public void setsEnabledShortcutsOnce() { - final List enabledShortcuts = ShortbreadGenerated.createShortcuts(activity).get(0); + public void setsEnabledShortcuts() { + final List enabledShortcuts = ShortbreadGenerated.createShortcuts(context).get(0); - Shortbread.create(activity); + new Shortbread(context); verify(shortcutManager).setDynamicShortcuts(enabledShortcuts); - - Shortbread.create(activity); - verify(shortcutManager, times(1)).setDynamicShortcuts(enabledShortcuts); } @Test - public void setsDisabledShortcutsOnce() { + public void setsDisabledShortcuts() { final List disabledShortcuts = ShortbreadGenerated.createShortcuts(activity).get(1); - Shortbread.create(activity); + new Shortbread(context); @SuppressWarnings("rawtypes") ArgumentCaptor captor = ArgumentCaptor.forClass(List.class); //noinspection unchecked verify(shortcutManager).disableShortcuts(captor.capture()); assertEquals(disabledShortcuts.size(), captor.getValue().size()); - - Shortbread.create(activity); - //noinspection unchecked - verify(shortcutManager, times(1)).disableShortcuts(any(List.class)); - } - - @Test - public void intentHasExtra_callsMethodShortcut() { - when(intent.hasExtra("shortbread_method")).thenReturn(true); - ShortbreadGenerated.activityThatWasPassedToCallMethodShortcut = null; - - Shortbread.create(activity); - assertEquals(activity, ShortbreadGenerated.activityThatWasPassedToCallMethodShortcut); } @Test public void intentDoesNotHaveExtra_doesNotCallMethodShortcut() { when(intent.hasExtra("shortbread_method")).thenReturn(false); + + new Shortbread(context); ShortbreadGenerated.activityThatWasPassedToCallMethodShortcut = null; - Shortbread.create(activity); + verify(application).registerActivityLifecycleCallbacks(lifecycleCallbacksCaptor.capture()); + Application.ActivityLifecycleCallbacks lifecycleCallbacks = lifecycleCallbacksCaptor.getValue(); + + lifecycleCallbacks.onActivityCreated(activity, null); + assertNull(ShortbreadGenerated.activityThatWasPassedToCallMethodShortcut); + + lifecycleCallbacks.onActivityStarted(activity); assertNull(ShortbreadGenerated.activityThatWasPassedToCallMethodShortcut); } @Test public void activityLifecycleListenerCallsMethodShortcut() { when(intent.hasExtra("shortbread_method")).thenReturn(true); - Shortbread.create(application); + + new Shortbread(context); ShortbreadGenerated.activityThatWasPassedToCallMethodShortcut = null; - ArgumentCaptor captor = ArgumentCaptor.forClass( - Application.ActivityLifecycleCallbacks.class); - verify(application).registerActivityLifecycleCallbacks(captor.capture()); - Application.ActivityLifecycleCallbacks activityLifecycleCallbacks = captor.getValue(); + verify(application).registerActivityLifecycleCallbacks(lifecycleCallbacksCaptor.capture()); + Application.ActivityLifecycleCallbacks lifecycleCallbacks = lifecycleCallbacksCaptor.getValue(); - activityLifecycleCallbacks.onActivityCreated(activity, null); + lifecycleCallbacks.onActivityCreated(activity, null); assertNull(ShortbreadGenerated.activityThatWasPassedToCallMethodShortcut); - activityLifecycleCallbacks.onActivityStarted(activity); + lifecycleCallbacks.onActivityStarted(activity); assertEquals(activity, ShortbreadGenerated.activityThatWasPassedToCallMethodShortcut); ShortbreadGenerated.activityThatWasPassedToCallMethodShortcut = null; - activityLifecycleCallbacks.onActivityStarted(activity); + lifecycleCallbacks.onActivityStarted(activity); assertNull(ShortbreadGenerated.activityThatWasPassedToCallMethodShortcut); } } diff --git a/shortbread/src/test/resources/AdvancedShortcutActivityGenerated.java b/shortbread/src/test/resources/AdvancedShortcutActivityGenerated.java index a7322c6..3a229df 100755 --- a/shortbread/src/test/resources/AdvancedShortcutActivityGenerated.java +++ b/shortbread/src/test/resources/AdvancedShortcutActivityGenerated.java @@ -1,7 +1,6 @@ package shortbread; import android.annotation.SuppressLint; -import android.app.Activity; import android.app.TaskStackBuilder; import android.content.Context; import android.content.Intent; @@ -35,7 +34,4 @@ public static List> createShortcuts(Context context) { .build()); return Arrays.asList(enabledShortcuts, disabledShortcuts); } - - public static void callMethodShortcut(Activity activity) { - } } diff --git a/shortbread/src/test/resources/BackStackShortcutActivityGenerated.java b/shortbread/src/test/resources/BackStackShortcutActivityGenerated.java index 94452ae..ae2c485 100755 --- a/shortbread/src/test/resources/BackStackShortcutActivityGenerated.java +++ b/shortbread/src/test/resources/BackStackShortcutActivityGenerated.java @@ -1,7 +1,6 @@ package shortbread; import android.annotation.SuppressLint; -import android.app.Activity; import android.app.TaskStackBuilder; import android.content.Context; import android.content.Intent; @@ -34,7 +33,4 @@ public static List> createShortcuts(Context context) { .build()); return Arrays.asList(enabledShortcuts, disabledShortcuts); } - - public static void callMethodShortcut(Activity activity) { - } } diff --git a/shortbread/src/test/resources/DisabledShortcutActivityGenerated.java b/shortbread/src/test/resources/DisabledShortcutActivityGenerated.java index bba842c..6fbb00d 100755 --- a/shortbread/src/test/resources/DisabledShortcutActivityGenerated.java +++ b/shortbread/src/test/resources/DisabledShortcutActivityGenerated.java @@ -1,7 +1,6 @@ package shortbread; import android.annotation.SuppressLint; -import android.app.Activity; import android.app.TaskStackBuilder; import android.content.Context; import android.content.Intent; @@ -31,7 +30,4 @@ public static List> createShortcuts(Context context) { .build()); return Arrays.asList(enabledShortcuts, disabledShortcuts); } - - public static void callMethodShortcut(Activity activity) { - } } diff --git a/shortbread/src/test/resources/ResourcesShortcutActivityGenerated.java b/shortbread/src/test/resources/ResourcesShortcutActivityGenerated.java index c488e8b..cbb3f9f 100755 --- a/shortbread/src/test/resources/ResourcesShortcutActivityGenerated.java +++ b/shortbread/src/test/resources/ResourcesShortcutActivityGenerated.java @@ -1,7 +1,6 @@ package shortbread; import android.annotation.SuppressLint; -import android.app.Activity; import android.app.TaskStackBuilder; import android.content.Context; import android.content.Intent; @@ -35,7 +34,4 @@ public static List> createShortcuts(Context context) { .build()); return Arrays.asList(enabledShortcuts, disabledShortcuts); } - - public static void callMethodShortcut(Activity activity) { - } } diff --git a/shortbread/src/test/resources/SimpleShortcutActivityGenerated.java b/shortbread/src/test/resources/SimpleShortcutActivityGenerated.java index 591656c..50d810b 100755 --- a/shortbread/src/test/resources/SimpleShortcutActivityGenerated.java +++ b/shortbread/src/test/resources/SimpleShortcutActivityGenerated.java @@ -1,7 +1,6 @@ package shortbread; import android.annotation.SuppressLint; -import android.app.Activity; import android.app.TaskStackBuilder; import android.content.Context; import android.content.Intent; @@ -32,7 +31,4 @@ public static List> createShortcuts(Context context) { .build()); return Arrays.asList(enabledShortcuts, disabledShortcuts); } - - public static void callMethodShortcut(Activity activity) { - } } diff --git a/shortbread/src/test/resources/TargetShortcutActivityGenerated.java b/shortbread/src/test/resources/TargetShortcutActivityGenerated.java index 12ea167..0f9d3e8 100755 --- a/shortbread/src/test/resources/TargetShortcutActivityGenerated.java +++ b/shortbread/src/test/resources/TargetShortcutActivityGenerated.java @@ -1,7 +1,6 @@ package shortbread; import android.annotation.SuppressLint; -import android.app.Activity; import android.app.TaskStackBuilder; import android.content.ComponentName; import android.content.Context; @@ -33,7 +32,4 @@ public static List> createShortcuts(Context context) { .build()); return Arrays.asList(enabledShortcuts, disabledShortcuts); } - - public static void callMethodShortcut(Activity activity) { - } } diff --git a/shortbread/src/test/resources/TwoShortcutActivitiesGenerated.java b/shortbread/src/test/resources/TwoShortcutActivitiesGenerated.java index d16d9af..1fc80ea 100755 --- a/shortbread/src/test/resources/TwoShortcutActivitiesGenerated.java +++ b/shortbread/src/test/resources/TwoShortcutActivitiesGenerated.java @@ -1,7 +1,6 @@ package shortbread; import android.annotation.SuppressLint; -import android.app.Activity; import android.app.TaskStackBuilder; import android.content.Context; import android.content.Intent; @@ -45,7 +44,4 @@ public static List> createShortcuts(Context context) { .build()); return Arrays.asList(enabledShortcuts, disabledShortcuts); } - - public static void callMethodShortcut(Activity activity) { - } }