Skip to content

Commit

Permalink
Fix crash on share when not loggedin
Browse files Browse the repository at this point in the history
    java.lang.RuntimeException:
      at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2957)
      at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3032)
      at android.app.ActivityThread.-wrap11 (Unknown Source)
      at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1696)
      at android.os.Handler.dispatchMessage (Handler.java:105)
      at android.os.Looper.loop (Looper.java:164)
      at android.app.ActivityThread.main (ActivityThread.java:6944)
      at java.lang.reflect.Method.invoke (Native Method)
      at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
      at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)
    Caused by: java.lang.IllegalArgumentException:
      at okhttp3.HttpUrl$Builder.parse (HttpUrl.java:1333)
      at okhttp3.HttpUrl.get (HttpUrl.java:916)
      at retrofit2.Retrofit$Builder.baseUrl (Retrofit.java:458)
      at com.github.gotify.api.ClientFactory.defaultClient (ClientFactory.java:47)
      at com.github.gotify.api.ClientFactory.clientToken (ClientFactory.java:28)
      at com.github.gotify.sharing.ShareActivity.onCreate (ShareActivity.java:82)
      at android.app.Activity.performCreate (Activity.java:7183)
      at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1220)
      at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2910)
  • Loading branch information
jmattheis committed Jan 9, 2022
1 parent 2a72853 commit 0f008ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

if (!settings.tokenExists()) {
Toast.makeText(getApplicationContext(), R.string.not_loggedin_share, Toast.LENGTH_SHORT)
.show();
finish();
return;
}

ApiClient client =
ClientFactory.clientToken(settings.url(), settings.sslSettings(), settings.token());
appsHolder = new ApplicationHolder(this, client);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@
<string name="push_priority_hint">Priority</string>
<string name="push_missing_app_info">There are no applications available on the server to push a message to.</string>
<string name="message_copied_to_clipboard">Content copied to clipboard</string>
<string name="not_loggedin_share">Cannot share to Gotify, because you aren\'t logged in.</string>
</resources>

0 comments on commit 0f008ac

Please sign in to comment.