aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewMessageActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java2
-rw-r--r--app/src/main/res/values/strings.xml2
7 files changed, 21 insertions, 7 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
index 65530111..b398b201 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
@@ -15,6 +15,7 @@ import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
@@ -253,6 +254,8 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
if(account == null || !account.getUsername().equals(mNewAccountName)) {
new SwitchAccountAsyncTask(mRedditDataRoomDatabase, mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
+ Toast.makeText(this, R.string.account_switched, Toast.LENGTH_SHORT).show();
+
mNewAccountName = null;
if(newAccount == null) {
mNullAccessToken = true;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java
index 66d1b3f2..0a90e9a4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java
@@ -32,7 +32,6 @@ public class PullNotificationWorker extends Worker {
static final String WORKER_TAG = "PNWT";
private Context context;
- private RedditAPI api;
@Inject
@Named("oauth_without_authenticator")
@@ -45,7 +44,6 @@ public class PullNotificationWorker extends Worker {
super(context, workerParams);
this.context = context;
((Infinity) context.getApplicationContext()).getAppComponent().inject(this);
- api = mOauthWithoutAuthenticatorRetrofit.create(RedditAPI.class);
}
@NonNull
@@ -185,9 +183,10 @@ public class PullNotificationWorker extends Worker {
}
private Response<String> fetchMessages(Account account) throws IOException, JSONException {
- Response<String> response = api.getMessages(
- RedditUtils.getOAuthHeader(account.getAccessToken()),
- FetchMessages.WHERE_INBOX, null).execute();
+ Response<String> response = mOauthWithoutAuthenticatorRetrofit.create(RedditAPI.class)
+ .getMessages(RedditUtils.getOAuthHeader(account.getAccessToken()),
+ FetchMessages.WHERE_UNREAD, null).execute();
+
if(response.isSuccessful()) {
return response;
} else {
@@ -198,7 +197,8 @@ public class PullNotificationWorker extends Worker {
params.put(RedditUtils.GRANT_TYPE_KEY, RedditUtils.GRANT_TYPE_REFRESH_TOKEN);
params.put(RedditUtils.REFRESH_TOKEN_KEY, refreshToken);
- Response accessTokenResponse = api.getAccessToken(RedditUtils.getHttpBasicAuthHeader(), params).execute();
+ Response accessTokenResponse = mOauthWithoutAuthenticatorRetrofit.create(RedditAPI.class)
+ .getAccessToken(RedditUtils.getHttpBasicAuthHeader(), params).execute();
if(accessTokenResponse.isSuccessful() && accessTokenResponse.body() != null) {
JSONObject jsonObject = new JSONObject((String) accessTokenResponse.body());
String newAccessToken = jsonObject.getString(RedditUtils.ACCESS_TOKEN_KEY);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewMessageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewMessageActivity.java
index a35a9c66..f2c9d277 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewMessageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewMessageActivity.java
@@ -13,6 +13,7 @@ import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
@@ -156,6 +157,8 @@ public class ViewMessageActivity extends AppCompatActivity {
if(account == null || !account.getUsername().equals(mNewAccountName)) {
new SwitchAccountAsyncTask(mRedditDataRoomDatabase, mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
+ Toast.makeText(this, R.string.account_switched, Toast.LENGTH_SHORT).show();
+
mNewAccountName = null;
if(newAccount == null) {
mNullAccessToken = true;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
index f8d2a41b..e7d14b6f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
@@ -223,6 +223,8 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
if(account == null || !account.getUsername().equals(mNewAccountName)) {
new SwitchAccountAsyncTask(mRedditDataRoomDatabase, mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
+ Toast.makeText(this, R.string.account_switched, Toast.LENGTH_SHORT).show();
+
mNewAccountName = null;
if(newAccount == null) {
mNullAccessToken = true;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
index f981c9c1..2bac9cae 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
@@ -277,6 +277,8 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
if(account == null || !account.getUsername().equals(mNewAccountName)) {
new SwitchAccountAsyncTask(mRedditDataRoomDatabase, mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
+ Toast.makeText(this, R.string.account_switched, Toast.LENGTH_SHORT).show();
+
mNewAccountName = null;
if(newAccount == null) {
mNullAccessToken = true;
@@ -432,7 +434,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java
index f3b1d1ba..98b653a8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java
@@ -357,6 +357,8 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
if(account == null || !account.getUsername().equals(mNewAccountName)) {
new SwitchAccountAsyncTask(mRedditDataRoomDatabase, mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
+ Toast.makeText(this, R.string.account_switched, Toast.LENGTH_SHORT).show();
+
mNewAccountName = null;
if(newAccount == null) {
mNullAccessToken = true;
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2d02c866..77b3dcd2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -234,4 +234,6 @@
<string name="label_account">Account</string>
<string name="label_post">Post</string>
+
+ <string name="account_switched">Account Switched. So all other pages are gone.</string>
</resources>