Apps-android-commons: App Crashes while trying to nominate an item for deletion, When User is not logged in.

Created on 14 Feb 2021  路  2Comments  路  Source: commons-app/apps-android-commons

Summary:
When the user is not logged in, App Crashes after giving the reason while nominating the item for deletion.

Steps to reproduce:

  1. Open the app without logging in.
  2. Click on any Media to open media detail.
  3. Now try to nominate the media for deletion and click "ok" after giving the reason.

What did you expect the app to do, and what did you see instead?
The app should redirect the user to the login screen.

System logs:

E/AndroidRuntime: FATAL EXCEPTION: main

Process: fr.free.nrw.commons.beta, PID: 18068
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
    at android.app.ContextImpl.startActivity(ContextImpl.java:952)
    at android.app.ContextImpl.startActivity(ContextImpl.java:928)
    at android.content.ContextWrapper.startActivity(ContextWrapper.java:383)
    at fr.free.nrw.commons.auth.LoginActivity.startYourself(LoginActivity.java:459)
    at fr.free.nrw.commons.auth.SessionManager.forceLogin(SessionManager.java:121)
    at fr.free.nrw.commons.delete.ReasonBuilder.checkAccount(ReasonBuilder.java:96)
    at fr.free.nrw.commons.delete.ReasonBuilder.fetchArticleNumber(ReasonBuilder.java:66)
    at fr.free.nrw.commons.delete.ReasonBuilder.getReason(ReasonBuilder.java:51)
    at fr.free.nrw.commons.media.MediaDetailFragment.onDeleteClickeddialogtext(MediaDetailFragment.java:769)
    at fr.free.nrw.commons.media.MediaDetailFragment.lambda$onDeleteButtonClicked$4$MediaDetailFragment(MediaDetailFragment.java:717)
    at fr.free.nrw.commons.media.-$$Lambda$MediaDetailFragment$6CeKf5Kd-vAslDfXw_b_q2Gutuc.onClick(Unknown Source:4)
    at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:177)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Device and Android version:
Device: Pixel 3 emulator, Android 10

Commons app version:
Latest Master

Would you like to work on the issue?
Yes :-)

bug

All 2 comments

Thanks!
You can also choose to hide the action from non-logged in users. Whichever you think makes most sense / is most maintainable :-)

Yes, I think hiding it makes more sense if the user is not able to use it.

Was this page helpful?
0 / 5 - 0 ratings