Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app shortcut created #1313

Closed
wants to merge 2 commits into from
Closed

Conversation

tanvidadu
Copy link
Collaborator

Description

Fixes #814

Added app static app shortcuts for activities Nearby, Settings and Notifications .

Tests performed

Tested on API 26 ( oreo ) with build variant betaDebug.

Screenshots showing what changed

app-shortcuts

@codecov-io
Copy link

codecov-io commented Mar 15, 2018

Codecov Report

Merging #1313 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1313   +/-   ##
======================================
  Coverage    3.82%   3.82%           
======================================
  Files         125     125           
  Lines        5902    5902           
  Branches      582     582           
======================================
  Hits          226     226           
  Misses       5661    5661           
  Partials       15      15

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e412c9a...fdb9f45. Read the comment docs.

@psh
Copy link
Collaborator

psh commented Mar 16, 2018

I did a very quick smoke test -

$ ./gradlew clean insPrDeb

Installed into an emulator

> Task :app:installProdDebug
Installing APK '1313-prod-debug.apk' on 'Nexus_5X_API_27_x86(AVD) - 8.1.0' for app:prodDebug
Installed on 1 device.

And I cant launch any of the three shortcuts - for instance, logcat told me

03-16 00:49:51.573  2418  2418 E Launcher: Unable to launch. tag=ShortcutInfo(id=-1 type=DEEPSHORTCUT container=-1 screen=-1 cell(-1,-1) span(1,1) minSpan(1,1) rank=0 user=UserHandle{0} title=Nearby) intent=Intent { act=android.intent.action.MAIN cat=[com.android.launcher3.DEEP_SHORTCUT] flg=0x10200000 pkg=fr.free.nrw.commons.debug cmp=fr.free.nrw.commons.debug/fr.free.nrw.commons.auth.LoginActivity bnds=[467,982][1045,1129] (has extras) }
03-16 00:49:51.573  2418  2418 E Launcher: android.content.ActivityNotFoundException: Shortcut could not be started
03-16 00:49:51.573  2418  2418 E Launcher: 	at android.content.pm.LauncherApps.startShortcut(LauncherApps.java:956)
03-16 00:49:51.573  2418  2418 E Launcher: 	at android.content.pm.LauncherApps.startShortcut(LauncherApps.java:922)
03-16 00:49:51.573  2418  2418 E Launcher: 	at com.android.launcher3.shortcuts.DeepShortcutManager.startShortcut(SourceFile:152)
03-16 00:49:51.573  2418  2418 E Launcher: 	at com.android.launcher3.Launcher.startShortcutIntentSafely(SourceFile:2604)
03-16 00:49:51.573  2418  2418 E Launcher: 	at com.android.launcher3.Launcher.startActivitySafely(SourceFile:2691)
03-16 00:49:51.573  2418  2418 E Launcher: 	at com.android.launcher3.Launcher.startAppShortcutOrInfoActivity(SourceFile:2454)
03-16 00:49:51.573  2418  2418 E Launcher: 	at com.android.launcher3.Launcher.onClickAppShortcut(SourceFile:2439)
03-16 00:49:51.573  2418  2418 E Launcher: 	at com.android.launcher3.Launcher.onClick(SourceFile:2277)
03-16 00:49:51.573  2418  2418 E Launcher: 	at android.view.View.performClick(View.java:6294)
03-16 00:49:51.573  2418  2418 E Launcher: 	at com.android.launcher3.shortcuts.DeepShortcutTextView.performClick(SourceFile:81)
03-16 00:49:51.573  2418  2418 E Launcher: 	at android.view.View$PerformClick.run(View.java:24770)
03-16 00:49:51.573  2418  2418 E Launcher: 	at android.os.Handler.handleCallback(Handler.java:790)
03-16 00:49:51.573  2418  2418 E Launcher: 	at android.os.Handler.dispatchMessage(Handler.java:99)
03-16 00:49:51.573  2418  2418 E Launcher: 	at android.os.Looper.loop(Looper.java:164)
03-16 00:49:51.573  2418  2418 E Launcher: 	at android.app.ActivityThread.main(ActivityThread.java:6494)
03-16 00:49:51.573  2418  2418 E Launcher: 	at java.lang.reflect.Method.invoke(Native Method)
03-16 00:49:51.573  2418  2418 E Launcher: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
03-16 00:49:51.573  2418  2418 E Launcher: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

@tanvidadu
Copy link
Collaborator Author

tanvidadu commented Mar 16, 2018

@psh I have fixed it. I forgot to add applicationIdSuffix for debug.
I have tested the changes for both betaRelease and betaDebug on Pixel XL API 26
Thanks :)

@psh
Copy link
Collaborator

psh commented Mar 16, 2018

Starting the application from a clean install, with the app logged out, I am able to select all three options from the shortcut menu and it launches directly into those activities. After entering the app using one of these shortcuts, when I select "Home" on the navigation drawer, the app crashes

java.lang.RuntimeException: Unable to start activity ComponentInfo{fr.free.nrw.commons.debug/fr.free.nrw.commons.contributions.ContributionsActivity}: java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.accounts.Account.name' on a null object reference
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
	at android.app.ActivityThread.-wrap11(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6494)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.accounts.Account.name' on a null object reference
	at fr.free.nrw.commons.contributions.ContributionsActivity.setUploadCount(ContributionsActivity.java:276)
	at fr.free.nrw.commons.contributions.ContributionsActivity.onCreate(ContributionsActivity.java:145)
	at android.app.Activity.performCreate(Activity.java:7009)
	at android.app.Activity.performCreate(Activity.java:7000)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
	... 9 more

This is actually a huge problem. What's happening is that the shortcuts are bypassing the login process and jumping directly into the app. If I am logged out I shouldn't be able to do that. Basically, if I select "Nearby" from the app shortcut and I am logged out, I should stop at the login screen. If I am allowed further into the app things go badly wrong.

Secondly, although you solved the android.content.ActivityNotFoundException problem for our debug build, the Release build still fails with the exception. The challenge is that in the Release version of the code we dont have the ".debug" in our package name.

ActivityManager: START u0 {act=androidr.intent.action.VIEW flg=0x1000c000 cmp=fr.free.nrw.commons.debug/fr.free.nrw.commons.notification.NotificationActivity bnds=[467,688][1045,835]} from uid 10082
LauncherAppsService: Couldn't start activity, code=-92
Launcher: Unable to launch. tag=ShortcutInfo(id=-1 type=DEEPSHORTCUT container=-1 screen=-1 cell(-1,-1) span(1,1) minSpan(1,1) rank=2 user=UserHandle{0} title=Notifications) intent=Intent { act=android.intent.action.MAIN cat=[com.android.launcher3.DEEP_SHORTCUT] flg=0x10200000 pkg=fr.free.nrw.commons cmp=fr.free.nrw.commons/.auth.LoginActivity bnds=[467,688][1045,835] (has extras) }
Launcher: android.content.ActivityNotFoundException: Shortcut could not be started
Launcher: 	at android.content.pm.LauncherApps.startShortcut(LauncherApps.java:956)
Launcher: 	at android.content.pm.LauncherApps.startShortcut(LauncherApps.java:922)
Launcher: 	at com.android.launcher3.shortcuts.DeepShortcutManager.startShortcut(SourceFile:152)
Launcher: 	at com.android.launcher3.Launcher.startShortcutIntentSafely(SourceFile:2604)
Launcher: 	at com.android.launcher3.Launcher.startActivitySafely(SourceFile:2691)
Launcher: 	at com.android.launcher3.Launcher.startAppShortcutOrInfoActivity(SourceFile:2454)
Launcher: 	at com.android.launcher3.Launcher.onClickAppShortcut(SourceFile:2439)
Launcher: 	at com.android.launcher3.Launcher.onClick(SourceFile:2277)
Launcher: 	at android.view.View.performClick(View.java:6294)
Launcher: 	at com.android.launcher3.shortcuts.DeepShortcutTextView.performClick(SourceFile:81)
Launcher: 	at android.view.View$PerformClick.run(View.java:24770)
Launcher: 	at android.os.Handler.handleCallback(Handler.java:790)
Launcher: 	at android.os.Handler.dispatchMessage(Handler.java:99)
Launcher: 	at android.os.Looper.loop(Looper.java:164)
Launcher: 	at android.app.ActivityThread.main(ActivityThread.java:6494)
Launcher: 	at java.lang.reflect.Method.invoke(Native Method)
Launcher: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
Launcher: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

There will need to be different configuration files for the debug and the release build variants.

@tanvidadu
Copy link
Collaborator Author

tanvidadu commented Mar 17, 2018

Second one can be easily solved by adding another intent specific for release version for each shortcut.
For first one I think can be solved using Dynamic Shortcuts. Each time dynamically setting intents depending upon whether the user has logged in or not.
@psh what is your opinion on dynamic intents ?

@tanvidadu
Copy link
Collaborator Author

@psh plz give me reviews on the above idea, so i can go ahead with development.

@maskaravivek
Copy link
Member

@tanvidadu Do you still need any help in resolving the above issues? It would be great if you could bring this PR to completion. :)

@tanvidadu
Copy link
Collaborator Author

A lot of changes needs to be made, depending upon whether the user is logged in or not :)
As soon as #1486 gets Merged I will start working on it on a fresh pr!

@maskaravivek
Copy link
Member

Awesome, thanks. Closing this PR then. :)

@tanvidadu tanvidadu deleted the appshortcut branch August 3, 2018 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants