mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-10-06 05:49:49 +02:00
Changing lazy mode interval in Settings is now available.
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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.";
|
||||
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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)) {
|
||||
|
@@ -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";
|
||||
}
|
||||
|
Reference in New Issue
Block a user