diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-08-26 09:50:44 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-08-26 09:50:44 +0000 |
commit | 864eb2126983977f9d7d7db12592fff0c8ede1cb (patch) | |
tree | f3b4ad542e8b69e867d4b3ce460e1d7aaaa04f5a /app/src/main/java | |
parent | b29bbf4321205a665ed74ecf05b54205d34d0840 (diff) | |
download | infinity-for-reddit-864eb2126983977f9d7d7db12592fff0c8ede1cb.tar infinity-for-reddit-864eb2126983977f9d7d7db12592fff0c8ede1cb.tar.gz infinity-for-reddit-864eb2126983977f9d7d7db12592fff0c8ede1cb.tar.bz2 infinity-for-reddit-864eb2126983977f9d7d7db12592fff0c8ede1cb.tar.lz infinity-for-reddit-864eb2126983977f9d7d7db12592fff0c8ede1cb.tar.xz infinity-for-reddit-864eb2126983977f9d7d7db12592fff0c8ede1cb.tar.zst infinity-for-reddit-864eb2126983977f9d7d7db12592fff0c8ede1cb.zip |
Changing lazy mode interval in Settings is now available.
Diffstat (limited to 'app/src/main/java')
6 files changed, 31 insertions, 13 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/LoginActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/LoginActivity.java index ebd5df13..9b053749 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/LoginActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/LoginActivity.java @@ -16,6 +16,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; +import androidx.appcompat.widget.Toolbar; import org.json.JSONException; import org.json.JSONObject; @@ -26,6 +27,8 @@ import java.util.Map; import javax.inject.Inject; import javax.inject.Named; +import butterknife.BindView; +import butterknife.ButterKnife; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -38,6 +41,8 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES; public class LoginActivity extends AppCompatActivity { + @BindView(R.id.toolbar_login_activity) Toolbar toolbar; + private String authCode; @Inject @@ -59,8 +64,12 @@ public class LoginActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); + ButterKnife.bind(this); + ((Infinity) getApplication()).getAppComponent().inject(this); + setSupportActionBar(toolbar); + boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2")); switch (themeType) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java index 86446023..8488adbc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java @@ -1055,7 +1055,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe } } - public void changeNSFW(boolean nsfw) { + void changeNSFW(boolean nsfw) { if(frontPagePostFragment != null) { frontPagePostFragment.changeNSFW(nsfw); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/NotificationUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/NotificationUtils.java index ce71a57e..2fc832d5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/NotificationUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/NotificationUtils.java @@ -9,10 +9,11 @@ import androidx.core.app.NotificationManagerCompat; class NotificationUtils { static final String CHANNEL_POST_MEDIA = "Post Media"; - static final String CHANNEL_ID_NEW_COMMENTS = "new_comments"; - static final String CHANNEL_NEW_COMMENTS = "New Comments"; - static final int SUMMARY_BASE_ID_UNREAD_MESSAGE = 0; - static final int NOTIFICATION_BASE_ID_UNREAD_MESSAGE = 1; + static final String CHANNEL_ID_NEW_MESSAGES = "new_messages"; + static final String CHANNEL_NEW_MESSAGES = "New Messages"; + + private static final int SUMMARY_BASE_ID_UNREAD_MESSAGE = 0; + private static final int NOTIFICATION_BASE_ID_UNREAD_MESSAGE = 1; private static final String GROUP_USER_BASE = "ml.docilealligator.infinityforreddit."; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java index a1267632..493d0a27 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java @@ -86,6 +86,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator { private Runnable lazyModeRunnable; private CountDownTimer resumeLazyModeCountDownTimer; + private float lazyModeInterval; + @Inject @Named("no_oauth") Retrofit mRetrofit; @@ -124,6 +126,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator { lazyModeHandler = new Handler(); + lazyModeInterval = Float.parseFloat(mSharedPreferences.getString(SharedPreferencesUtils.LAZY_MODE_INTERVAL_KEY, "2.5")); + smoothScroller = new LinearSmoothScroller(activity) { @Override protected int getVerticalSnapPreference() { @@ -157,11 +161,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mLinearLayoutManager.startSmoothScroll(smoothScroller); } } - lazyModeHandler.postDelayed(this, 2500); + lazyModeHandler.postDelayed(this, (long) (lazyModeInterval * 1000)); } }; - resumeLazyModeCountDownTimer = new CountDownTimer(2500, 2500) { + resumeLazyModeCountDownTimer = new CountDownTimer((long) (lazyModeInterval * 1000), (long) (lazyModeInterval * 1000)) { @Override public void onTick(long l) { @@ -416,9 +420,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator { public void startLazyMode() { isInLazyMode = true; isLazyModePaused = false; - lazyModeHandler.postDelayed(lazyModeRunnable, 2500); + + lazyModeInterval = Float.parseFloat(mSharedPreferences.getString(SharedPreferencesUtils.LAZY_MODE_INTERVAL_KEY, "2.5")); + lazyModeHandler.postDelayed(lazyModeRunnable, (long) (lazyModeInterval * 1000)); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - Toast.makeText(activity, getString(R.string.lazy_mode_start, 2.5), Toast.LENGTH_SHORT).show(); + Toast.makeText(activity, getString(R.string.lazy_mode_start, lazyModeInterval), + Toast.LENGTH_SHORT).show(); } @Override @@ -439,7 +446,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if(resumeNow) { lazyModeHandler.post(lazyModeRunnable); } else { - lazyModeHandler.postDelayed(lazyModeRunnable, 2500); + lazyModeHandler.postDelayed(lazyModeRunnable, (long) (lazyModeInterval * 1000)); } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java index 6c2e5f75..46cffca7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java @@ -77,7 +77,7 @@ public class PullNotificationWorker extends Worker { NotificationCompat.Builder summaryBuilder = NotificationUtils.buildSummaryNotification(context, notificationManager, accountName, context.getString(R.string.notification_new_messages, messages.size()), - NotificationUtils.CHANNEL_ID_NEW_COMMENTS, NotificationUtils.CHANNEL_NEW_COMMENTS, + NotificationUtils.CHANNEL_ID_NEW_MESSAGES, NotificationUtils.CHANNEL_NEW_MESSAGES, NotificationUtils.getAccountGroupName(accountName)); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); @@ -110,8 +110,8 @@ public class PullNotificationWorker extends Worker { NotificationCompat.Builder builder = NotificationUtils.buildNotification(notificationManager, context, title, message.getBody(), summary, - NotificationUtils.CHANNEL_ID_NEW_COMMENTS, - NotificationUtils.CHANNEL_NEW_COMMENTS, + NotificationUtils.CHANNEL_ID_NEW_MESSAGES, + NotificationUtils.CHANNEL_NEW_MESSAGES, NotificationUtils.getAccountGroupName(accountName)); if(kind.equals(Message.TYPE_COMMENT)) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java index d0673942..061c94df 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java @@ -7,6 +7,7 @@ package ml.docilealligator.infinityforreddit; public class SharedPreferencesUtils { public static final String ENABLE_NOTIFICATION_KEY = "enable_notification"; public static final String NOTIFICATION_INTERVAL_KEY = "notificaiton_interval"; + public static final String LAZY_MODE_INTERVAL_KEY = "lazy_mode_interval"; public static final String NSFW_KEY = "nsfw"; public static final String THEME_KEY = "theme"; } |