aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-08-26 09:50:44 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-08-26 09:50:44 +0000
commit864eb2126983977f9d7d7db12592fff0c8ede1cb (patch)
treef3b4ad542e8b69e867d4b3ce460e1d7aaaa04f5a /app/src
parentb29bbf4321205a665ed74ecf05b54205d34d0840 (diff)
downloadinfinity-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 '')
-rw-r--r--app/src/main/AndroidManifest.xml3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/LoginActivity.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/NotificationUtils.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/res/layout/activity_login.xml21
-rw-r--r--app/src/main/res/layout/item_post_detail.xml62
-rw-r--r--app/src/main/res/values/arrays.xml16
-rw-r--r--app/src/main/res/values/strings.xml1
-rw-r--r--app/src/main/res/xml/main_preferences.xml9
12 files changed, 77 insertions, 79 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5b41bd5d..46d43af7 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -150,7 +150,8 @@
<activity
android:name=".LoginActivity"
android:label="@string/login_activity_label"
- android:parentActivityName=".MainActivity" />
+ android:parentActivityName=".MainActivity"
+ android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".ViewImageActivity"
android:parentActivityName=".MainActivity"
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";
}
diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml
index 236d52e4..e993cd2d 100644
--- a/app/src/main/res/layout/activity_login.xml
+++ b/app/src/main/res/layout/activity_login.xml
@@ -1,14 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:application="ml.docilealligator.infinityforreddit.LoginActivity">
+ <com.google.android.material.appbar.AppBarLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="@style/AppTheme.AppBarOverlay">
+
+ <androidx.appcompat.widget.Toolbar
+ android:id="@+id/toolbar_login_activity"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ app:popupTheme="@style/AppTheme.PopupOverlay"
+ app:navigationIcon="?attr/homeAsUpIndicator" />
+
+ </com.google.android.material.appbar.AppBarLayout>
+
<WebView
android:id="@+id/webview_login_activity"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior" />
-</androidx.constraintlayout.widget.ConstraintLayout>
+</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/app/src/main/res/layout/item_post_detail.xml b/app/src/main/res/layout/item_post_detail.xml
index b1299ca5..32a0f3b1 100644
--- a/app/src/main/res/layout/item_post_detail.xml
+++ b/app/src/main/res/layout/item_post_detail.xml
@@ -169,68 +169,6 @@
</androidx.constraintlayout.widget.ConstraintLayout>
- <!--<RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingStart="16dp"
- android:paddingEnd="16dp"
- android:paddingTop="16dp">
-
- <com.google.android.material.chip.Chip
- android:id="@+id/type_text_view_item_post_detail"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginEnd="16dp"
- android:textColor="@android:color/white"
- android:layout_centerVertical="true"
- app:chipBackgroundColor="@color/backgroundColorPrimaryDark"/>
-
- <ImageView
- android:id="@+id/gilded_image_view_item_post_detail"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:layout_toEndOf="@id/type_text_view_item_post_detail"
- android:layout_centerVertical="true"
- android:visibility="gone"/>
-
- <TextView
- android:id="@+id/gilded_number_text_view_item_post_detail"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="4dp"
- android:layout_marginEnd="8dp"
- android:layout_toEndOf="@id/gilded_image_view_item_post_detail"
- android:layout_centerVertical="true"
- android:visibility="gone"
- android:textSize="20sp"
- android:textColor="@color/gold"/>
-
- <ImageView
- android:id="@+id/crosspost_image_view_item_post_detail"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:layout_marginStart="8dp"
- android:layout_marginEnd="8dp"
- android:layout_toEndOf="@id/gilded_number_text_view_item_post_detail"
- android:layout_centerVertical="true"
- android:src="@drawable/crosspost"
- android:tint="@color/colorAccent"
- android:visibility="gone"/>
-
- <com.google.android.material.chip.Chip
- android:id="@+id/nsfw_text_view_item_post_detail"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/nsfw"
- android:layout_alignParentEnd="true"
- android:layout_marginStart="8dp"
- android:textColor="@android:color/white"
- android:visibility="gone"
- android:layout_centerVertical="true"
- app:chipBackgroundColor="@color/colorAccent"/>
-
- </RelativeLayout>-->
-
<LinearLayout
android:id="@+id/spoiler_flair_linear_layout_item_post_detail"
android:layout_width="match_parent"
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 56477516..f82fc670 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -36,4 +36,20 @@
<item>1</item>
<item>2</item>
</string-array>
+
+ <string-array name="settings_lazy_mode_interval">
+ <item>2.5s</item>
+ <item>3s</item>
+ <item>5s</item>
+ <item>7s</item>
+ <item>10s</item>
+ </string-array>
+
+ <string-array name="settings_lazy_mode_interval_values">
+ <item>2.5</item>
+ <item>3</item>
+ <item>5</item>
+ <item>7</item>
+ <item>10</item>
+ </string-array>
</resources> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 09740a2f..2d19ae76 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -258,6 +258,7 @@
<string name="settings_theme_light__theme_summary">Light Theme</string>
<string name="settings_theme_dark_theme_summary">Dark Theme</string>
<string name="settings_theme_system_default_summary">Device default</string>
+ <string name="settings_lazy_mode_interval_title">Lazy Mode Interval</string>
<string name="settings_enable_nsfw_title">Enable NSFW</string>
<string name="settings_acknowledgement_master_title">Acknowledgement</string>
diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml
index 7ccfa301..7d482fae 100644
--- a/app/src/main/res/xml/main_preferences.xml
+++ b/app/src/main/res/xml/main_preferences.xml
@@ -16,6 +16,15 @@
app:title="@string/settings_theme_title"
app:useSimpleSummaryProvider="true" />
+ <ListPreference
+ app:defaultValue="2.5"
+ android:entries="@array/settings_lazy_mode_interval"
+ app:entryValues="@array/settings_lazy_mode_interval_values"
+ app:key="lazy_mode_interval"
+ app:icon="@drawable/ic_outline_access_time_24px"
+ app:title="@string/settings_lazy_mode_interval_title"
+ app:useSimpleSummaryProvider="true" />
+
<SwitchPreference
app:defaultValue="false"
app:key="nsfw"