mirror of
https://github.com/accelforce/Yuito
synced 2024-12-22 13:24:46 +01:00
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) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
redirectIfNotLoggedIn();
|
||||
createMastodonAPI();
|
||||
createTuskyAPI();
|
||||
|
||||
@ -153,6 +154,19 @@ public class BaseActivity extends AppCompatActivity {
|
||||
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
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
TypedValue value = new TypedValue();
|
||||
|
Loading…
Reference in New Issue
Block a user