Introduces a redirect guard so share requests and quick settings tile compose requests when not logged in will give a login page instead of crashing.
This commit is contained in:
parent
2cb0b96abd
commit
209f1ec4a5
|
@ -61,6 +61,7 @@ public class BaseActivity extends AppCompatActivity {
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
redirectIfNotLoggedIn();
|
||||||
createMastodonAPI();
|
createMastodonAPI();
|
||||||
createTuskyAPI();
|
createTuskyAPI();
|
||||||
|
|
||||||
|
@ -153,6 +154,19 @@ public class BaseActivity extends AppCompatActivity {
|
||||||
tuskyAPI = retrofit.create(TuskyAPI.class);
|
tuskyAPI = retrofit.create(TuskyAPI.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void redirectIfNotLoggedIn() {
|
||||||
|
SharedPreferences preferences = getSharedPreferences(
|
||||||
|
getString(R.string.preferences_file_key), Context.MODE_PRIVATE);
|
||||||
|
String domain = preferences.getString("domain", null);
|
||||||
|
String accessToken = preferences.getString("accessToken", null);
|
||||||
|
if (domain != null && accessToken != null) {
|
||||||
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
TypedValue value = new TypedValue();
|
TypedValue value = new TypedValue();
|
||||||
|
|
Loading…
Reference in New Issue