Reorganize settings. Opening link in app is now available.

This commit is contained in:
Alex Ning 2020-01-31 22:09:46 +08:00
parent 119afb6084
commit 02db44e532
22 changed files with 570 additions and 407 deletions

View File

@ -154,16 +154,21 @@ public class LinkResolverActivity extends AppCompatActivity {
} }
private void deepLinkError(Uri uri) { private void deepLinkError(Uri uri) {
PackageManager pm = getPackageManager();
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.OPEN_LINK_IN_APP, false)) {
openInCustomTabs(uri, pm);
return;
}
String authority = uri.getAuthority(); String authority = uri.getAuthority();
if(authority != null && (authority.contains("reddit.com") || authority.contains("redd.it") || authority.contains("reddit.app.link"))) { if(authority != null && (authority.contains("reddit.com") || authority.contains("redd.it") || authority.contains("reddit.app.link"))) {
openInCustomTabs(uri, getPackageManager()); openInCustomTabs(uri, pm);
return; return;
} }
Intent intent = new Intent(Intent.ACTION_VIEW); Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri); intent.setData(uri);
PackageManager pm = getPackageManager();
List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0); List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0);
ArrayList<String> packageNames = new ArrayList<>(); ArrayList<String> packageNames = new ArrayList<>();

View File

@ -17,6 +17,7 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Settings.AboutPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.AboutPreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.InterfacePreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment;
public class SettingsActivity extends BaseActivity implements public class SettingsActivity extends BaseActivity implements
@ -66,6 +67,8 @@ public class SettingsActivity extends BaseActivity implements
setTitle(R.string.settings_activity_label); setTitle(R.string.settings_activity_label);
} else if (getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity) instanceof AboutPreferenceFragment) { } else if (getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity) instanceof AboutPreferenceFragment) {
setTitle(R.string.settings_about_master_title); setTitle(R.string.settings_about_master_title);
} else if (getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity) instanceof InterfacePreferenceFragment) {
setTitle(R.string.settings_interface_title);
} }
}); });
} }

View File

@ -2,11 +2,13 @@ package ml.docilealligator.infinityforreddit.Settings;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
@ -19,6 +21,8 @@ import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
*/ */
public class AboutPreferenceFragment extends PreferenceFragmentCompat { public class AboutPreferenceFragment extends PreferenceFragmentCompat {
private Activity activity;
@Override @Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.about_preferences, rootKey); setPreferencesFromResource(R.xml.about_preferences, rootKey);
@ -30,9 +34,6 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat {
Preference subredditPreference = findPreference(SharedPreferencesUtils.SUBREDDIT_KEY); Preference subredditPreference = findPreference(SharedPreferencesUtils.SUBREDDIT_KEY);
Preference sharePreference = findPreference(SharedPreferencesUtils.SHARE_KEY); Preference sharePreference = findPreference(SharedPreferencesUtils.SHARE_KEY);
Activity activity = getActivity();
if (activity != null) {
if (openSourcePreference != null) { if (openSourcePreference != null) {
openSourcePreference.setOnPreferenceClickListener(preference -> { openSourcePreference.setOnPreferenceClickListener(preference -> {
Intent intent = new Intent(activity, LinkResolverActivity.class); Intent intent = new Intent(activity, LinkResolverActivity.class);
@ -102,5 +103,10 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat {
}); });
} }
} }
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
activity = (Activity) context;
} }
} }

View File

@ -2,12 +2,14 @@ package ml.docilealligator.infinityforreddit.Settings;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -23,9 +25,9 @@ import ml.docilealligator.infinityforreddit.R;
*/ */
public class AcknowledgementFragment extends Fragment { public class AcknowledgementFragment extends Fragment {
@BindView(R.id.recycler_view_acknowledgement_fragment) @BindView(R.id.recycler_view_acknowledgement_fragment)
RecyclerView recyclerView; RecyclerView recyclerView;
private Activity activity;
public AcknowledgementFragment() { public AcknowledgementFragment() {
// Required empty public constructor // Required empty public constructor
@ -37,8 +39,6 @@ public class AcknowledgementFragment extends Fragment {
View rootView = inflater.inflate(R.layout.fragment_acknowledgement, container, false); View rootView = inflater.inflate(R.layout.fragment_acknowledgement, container, false);
ButterKnife.bind(this, rootView); ButterKnife.bind(this, rootView);
Activity activity = getActivity();
ArrayList<Acknowledgement> acknowledgements = new ArrayList<>(); ArrayList<Acknowledgement> acknowledgements = new ArrayList<>();
acknowledgements.add(new Acknowledgement("ExoPlayer", acknowledgements.add(new Acknowledgement("ExoPlayer",
"An application level media player for Android", "An application level media player for Android",
@ -107,4 +107,10 @@ public class AcknowledgementFragment extends Fragment {
return rootView; return rootView;
} }
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
activity = (Activity) context;
}
} }

View File

@ -2,10 +2,12 @@ package ml.docilealligator.infinityforreddit.Settings;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
@ -18,6 +20,8 @@ import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
*/ */
public class CreditsPreferenceFragment extends PreferenceFragmentCompat { public class CreditsPreferenceFragment extends PreferenceFragmentCompat {
private Activity activity;
@Override @Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.credits_preferences, rootKey); setPreferencesFromResource(R.xml.credits_preferences, rootKey);
@ -30,9 +34,6 @@ public class CreditsPreferenceFragment extends PreferenceFragmentCompat {
Preference thumbtackIconPreference = findPreference(SharedPreferencesUtils.THUMBTACK_ICON_KEY); Preference thumbtackIconPreference = findPreference(SharedPreferencesUtils.THUMBTACK_ICON_KEY);
Preference materialIconsPreference = findPreference(SharedPreferencesUtils.MATERIAL_ICONS_KEY); Preference materialIconsPreference = findPreference(SharedPreferencesUtils.MATERIAL_ICONS_KEY);
Activity activity = getActivity();
if (activity != null) {
if (iconForegroundPreference != null) { if (iconForegroundPreference != null) {
iconForegroundPreference.setOnPreferenceClickListener(preference -> { iconForegroundPreference.setOnPreferenceClickListener(preference -> {
Intent intent = new Intent(activity, LinkResolverActivity.class); Intent intent = new Intent(activity, LinkResolverActivity.class);
@ -96,5 +97,10 @@ public class CreditsPreferenceFragment extends PreferenceFragmentCompat {
}); });
} }
} }
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
activity = (Activity) context;
} }
} }

View File

@ -1,8 +1,10 @@
package ml.docilealligator.infinityforreddit.Settings; package ml.docilealligator.infinityforreddit.Settings;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.preference.ListPreference; import androidx.preference.ListPreference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
@ -13,12 +15,11 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
public class FontSizePreferenceFragment extends PreferenceFragmentCompat { public class FontSizePreferenceFragment extends PreferenceFragmentCompat {
private Activity activity;
@Override @Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.font_size_preferences, rootKey); setPreferencesFromResource(R.xml.font_size_preferences, rootKey);
Activity activity = getActivity();
if (activity != null) {
ListPreference fontSizePreference = findPreference(SharedPreferencesUtils.FONT_SIZE_KEY); ListPreference fontSizePreference = findPreference(SharedPreferencesUtils.FONT_SIZE_KEY);
ListPreference titleFontSizePreference = findPreference(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY); ListPreference titleFontSizePreference = findPreference(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY);
ListPreference contentFontSizePreference = findPreference(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY); ListPreference contentFontSizePreference = findPreference(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY);
@ -45,5 +46,10 @@ public class FontSizePreferenceFragment extends PreferenceFragmentCompat {
}); });
} }
} }
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
activity = (Activity) context;
} }
} }

View File

@ -0,0 +1,20 @@
package ml.docilealligator.infinityforreddit.Settings;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceFragmentCompat;
import ml.docilealligator.infinityforreddit.R;
/**
* A simple {@link Fragment} subclass.
*/
public class GesturesAndButtonsPreferenceFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.gestures_and_buttons_preference, rootKey);
}
}

View File

@ -0,0 +1,95 @@
package ml.docilealligator.infinityforreddit.Settings;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.preference.ListPreference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreference;
import org.greenrobot.eventbus.EventBus;
import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
/**
* A simple {@link Fragment} subclass.
*/
public class InterfacePreferenceFragment extends PreferenceFragmentCompat {
private Activity activity;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.interface_preference, rootKey);
SwitchPreference immersiveInterfaceSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY);
SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY);
SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
SwitchPreference showElapsedTimeSwitch = findPreference(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY);
ListPreference defaultPostLayoutSwitch = findPreference(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY);
SwitchPreference showDividerInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT);
if (immersiveInterfaceSwitch != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
immersiveInterfaceSwitch.setVisible(true);
immersiveInterfaceSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new RecreateActivityEvent());
return true;
});
} else {
immersiveInterfaceSwitch.setVisible(false);
}
}
if (bottomAppBarSwitch != null) {
bottomAppBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new RecreateActivityEvent());
return true;
});
}
if (voteButtonsOnTheRightSwitch != null) {
voteButtonsOnTheRightSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeVoteButtonsPositionEvent((Boolean) newValue));
return true;
});
}
if (showElapsedTimeSwitch != null) {
showElapsedTimeSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeShowElapsedTimeEvent((Boolean) newValue));
return true;
});
}
if (defaultPostLayoutSwitch != null) {
defaultPostLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangePostLayoutEvent(Integer.parseInt((String) newValue)));
return true;
});
}
if (showDividerInCompactLayout != null) {
showDividerInCompactLayout.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ShowDividerInCompactLayoutPreferenceEvent((Boolean) newValue));
return true;
});
}
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
activity = (Activity) context;
}
}

View File

@ -2,11 +2,13 @@ package ml.docilealligator.infinityforreddit.Settings;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatDelegate; import androidx.appcompat.app.AppCompatDelegate;
import androidx.preference.ListPreference; import androidx.preference.ListPreference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
@ -18,12 +20,8 @@ import javax.inject.Inject;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent; import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
@ -40,22 +38,14 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
@Inject @Inject
SharedPreferences sharedPreferences; SharedPreferences sharedPreferences;
private Activity activity;
@Override @Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.main_preferences, rootKey); setPreferencesFromResource(R.xml.main_preferences, rootKey);
Activity activity = getActivity();
if (activity != null) {
((Infinity) activity.getApplication()).getAppComponent().inject(this); ((Infinity) activity.getApplication()).getAppComponent().inject(this);
SwitchPreference amoledDarkSwitch = findPreference(SharedPreferencesUtils.AMOLED_DARK_KEY); SwitchPreference amoledDarkSwitch = findPreference(SharedPreferencesUtils.AMOLED_DARK_KEY);
SwitchPreference immersiveInterfaceSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY);
SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY);
SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
SwitchPreference showElapsedTimeSwitch = findPreference(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY);
ListPreference defaultPostLayoutSwitch = findPreference(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY);
SwitchPreference showDividerInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT);
SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY); SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY); SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY);
SwitchPreference blurSpoilerSwitch = findPreference(SharedPreferencesUtils.BLUR_SPOILER_KEY); SwitchPreference blurSpoilerSwitch = findPreference(SharedPreferencesUtils.BLUR_SPOILER_KEY);
@ -71,53 +61,6 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
}); });
} }
if (immersiveInterfaceSwitch != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
immersiveInterfaceSwitch.setVisible(true);
immersiveInterfaceSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new RecreateActivityEvent());
return true;
});
} else {
immersiveInterfaceSwitch.setVisible(false);
}
}
if (bottomAppBarSwitch != null) {
bottomAppBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new RecreateActivityEvent());
return true;
});
}
if (voteButtonsOnTheRightSwitch != null) {
voteButtonsOnTheRightSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeVoteButtonsPositionEvent((Boolean) newValue));
return true;
});
}
if (showElapsedTimeSwitch != null) {
showElapsedTimeSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeShowElapsedTimeEvent((Boolean) newValue));
return true;
});
}
if (defaultPostLayoutSwitch != null) {
defaultPostLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangePostLayoutEvent(Integer.parseInt((String) newValue)));
return true;
});
}
if (showDividerInCompactLayout != null) {
showDividerInCompactLayout.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ShowDividerInCompactLayoutPreferenceEvent((Boolean) newValue));
return true;
});
}
if (nsfwSwitch != null) { if (nsfwSwitch != null) {
nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> { nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeNSFWEvent((Boolean) newValue)); EventBus.getDefault().post(new ChangeNSFWEvent((Boolean) newValue));
@ -179,5 +122,10 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
}); });
} }
} }
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
activity = (Activity) context;
} }
} }

View File

@ -2,9 +2,11 @@ package ml.docilealligator.infinityforreddit.Settings;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.preference.ListPreference; import androidx.preference.ListPreference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
@ -34,14 +36,12 @@ public class NotificationPreferenceFragment extends PreferenceFragmentCompat {
private boolean enableNotification; private boolean enableNotification;
private long notificationInterval; private long notificationInterval;
private WorkManager workManager; private WorkManager workManager;
private Activity activity;
@Override @Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.notification_preferences, rootKey); setPreferencesFromResource(R.xml.notification_preferences, rootKey);
Activity activity = getActivity();
if (activity != null) {
workManager = WorkManager.getInstance(activity); workManager = WorkManager.getInstance(activity);
((Infinity) activity.getApplication()).getAppComponent().inject(this); ((Infinity) activity.getApplication()).getAppComponent().inject(this);
@ -112,5 +112,10 @@ public class NotificationPreferenceFragment extends PreferenceFragmentCompat {
}); });
} }
} }
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
activity = (Activity) context;
} }
} }

View File

@ -68,4 +68,5 @@ public class SharedPreferencesUtils {
public static final String VOLUME_KEYS_NAVIGATE_COMMENTS = "volume_keys_navigate_comments"; public static final String VOLUME_KEYS_NAVIGATE_COMMENTS = "volume_keys_navigate_comments";
public static final String VOLUME_KEYS_NAVIGATE_POSTS = "volume_keys_navigate_posts"; public static final String VOLUME_KEYS_NAVIGATE_POSTS = "volume_keys_navigate_posts";
public static final String MUTE_VIDEO = "mute_video"; public static final String MUTE_VIDEO = "mute_video";
public static final String OPEN_LINK_IN_APP = "open_link_in_app";
} }

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M4.59,6.89c0.7,-0.71 1.4,-1.35 1.71,-1.22 0.5,0.2 0,1.03 -0.3,1.52 -0.25,0.42 -2.86,3.89 -2.86,6.31 0,1.28 0.48,2.34 1.34,2.98 0.75,0.56 1.74,0.73 2.64,0.46 1.07,-0.31 1.95,-1.4 3.06,-2.77 1.21,-1.49 2.83,-3.44 4.08,-3.44 1.63,0 1.65,1.01 1.76,1.79 -3.78,0.64 -5.38,3.67 -5.38,5.37 0,1.7 1.44,3.09 3.21,3.09 1.63,0 4.29,-1.33 4.69,-6.1L21,14.88v-2.5h-2.47c-0.15,-1.65 -1.09,-4.2 -4.03,-4.2 -2.25,0 -4.18,1.91 -4.94,2.84 -0.58,0.73 -2.06,2.48 -2.29,2.72 -0.25,0.3 -0.68,0.84 -1.11,0.84 -0.45,0 -0.72,-0.83 -0.36,-1.92 0.35,-1.09 1.4,-2.86 1.85,-3.52 0.78,-1.14 1.3,-1.92 1.3,-3.28C8.95,3.69 7.31,3 6.44,3 5.12,3 3.97,4 3.72,4.25c-0.36,0.36 -0.66,0.66 -0.88,0.93l1.75,1.71zM13.88,18.55c-0.31,0 -0.74,-0.26 -0.74,-0.72 0,-0.6 0.73,-2.2 2.87,-2.76 -0.3,2.69 -1.43,3.48 -2.13,3.48z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM15,18L4,18v-4h11v4zM15,13L4,13L4,9h11v4zM20,18h-4L16,9h4v9z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M4.59,6.89c0.7,-0.71 1.4,-1.35 1.71,-1.22 0.5,0.2 0,1.03 -0.3,1.52 -0.25,0.42 -2.86,3.89 -2.86,6.31 0,1.28 0.48,2.34 1.34,2.98 0.75,0.56 1.74,0.73 2.64,0.46 1.07,-0.31 1.95,-1.4 3.06,-2.77 1.21,-1.49 2.83,-3.44 4.08,-3.44 1.63,0 1.65,1.01 1.76,1.79 -3.78,0.64 -5.38,3.67 -5.38,5.37 0,1.7 1.44,3.09 3.21,3.09 1.63,0 4.29,-1.33 4.69,-6.1L21,14.88v-2.5h-2.47c-0.15,-1.65 -1.09,-4.2 -4.03,-4.2 -2.25,0 -4.18,1.91 -4.94,2.84 -0.58,0.73 -2.06,2.48 -2.29,2.72 -0.25,0.3 -0.68,0.84 -1.11,0.84 -0.45,0 -0.72,-0.83 -0.36,-1.92 0.35,-1.09 1.4,-2.86 1.85,-3.52 0.78,-1.14 1.3,-1.92 1.3,-3.28C8.95,3.69 7.31,3 6.44,3 5.12,3 3.97,4 3.72,4.25c-0.36,0.36 -0.66,0.66 -0.88,0.93l1.75,1.71zM13.88,18.55c-0.31,0 -0.74,-0.26 -0.74,-0.72 0,-0.6 0.73,-2.2 2.87,-2.76 -0.3,2.69 -1.43,3.48 -2.13,3.48z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM15,18L4,18v-4h11v4zM15,13L4,13L4,9h11v4zM20,18h-4L16,9h4v9z"/>
</vector>

View File

@ -293,6 +293,9 @@
<string name="settings_theme_dark_theme_summary">Dark 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_theme_system_default_summary">Device default</string>
<string name="settings_amoled_dark_title">Amoled Dark</string> <string name="settings_amoled_dark_title">Amoled Dark</string>
<string name="settings_interface_title">Interface</string>
<string name="settings_gestures_and_buttons_title">Gestures &amp; Buttons</string>
<string name="settings_open_link_in_app_title">Open Link In App</string>
<string name="settings_immersive_interface_title">Immersive Interface</string> <string name="settings_immersive_interface_title">Immersive Interface</string>
<string name="settings_enable_bottom_app_bar_title">Enable Bottom Navigation</string> <string name="settings_enable_bottom_app_bar_title">Enable Bottom Navigation</string>
<string name="settings_vote_buttons_on_the_right_title">Vote Buttons on the Right</string> <string name="settings_vote_buttons_on_the_right_title">Vote Buttons on the Right</string>
@ -302,7 +305,7 @@
<string name="settings_show_elapsed_time">Show Elapsed Time in Posts and Comments</string> <string name="settings_show_elapsed_time">Show Elapsed Time in Posts and Comments</string>
<string name="settings_default_post_layout">Default Post Layout</string> <string name="settings_default_post_layout">Default Post Layout</string>
<string name="settings_show_divider_in_compact_layout">Show Divider in Compact Layout</string> <string name="settings_show_divider_in_compact_layout">Show Divider in Compact Layout</string>
<string name="swipe_to_go_back_from_post_detail">Swipe Right to Go Back From Comments</string> <string name="settings_swipe_to_go_back_from_post_detail_title">Swipe Right to Go Back From Comments</string>
<string name="settings_lazy_mode_interval_title">Lazy Mode Interval</string> <string name="settings_lazy_mode_interval_title">Lazy Mode Interval</string>
<string name="settings_font_size_title">Font Size</string> <string name="settings_font_size_title">Font Size</string>
<string name="settings_title_font_size_title">Title Font Size</string> <string name="settings_title_font_size_title">Title Font Size</string>
@ -414,4 +417,7 @@
<string name="save_comment">Save comment</string> <string name="save_comment">Save comment</string>
<string name="unsave_comment">Unsave comment</string> <string name="unsave_comment">Unsave comment</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<SwitchPreference
app:defaultValue="true"
app:key="swipe_to_go_back_from_post_detail"
app:title="@string/settings_swipe_to_go_back_from_post_detail_title" />
<SwitchPreference
app:defaultValue="false"
app:key="volume_keys_navigate_comments"
app:title="@string/settings_volume_keys_navigate_comments_title" />
<SwitchPreference
app:defaultValue="false"
app:key="volume_keys_navigate_posts"
app:title="@string/settings_volume_keys_navigate_posts_title" />
</PreferenceScreen>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Preference
app:title="@string/settings_font_size_title"
app:icon="@drawable/ic_font_size_24dp"
app:fragment="ml.docilealligator.infinityforreddit.Settings.FontSizePreferenceFragment" />
<SwitchPreference
app:defaultValue="true"
app:key="immersive_interface"
app:title="@string/settings_immersive_interface_title"
app:isPreferenceVisible="false" />
<SwitchPreference
app:defaultValue="false"
app:key="bottom_app_bar"
app:title="@string/settings_enable_bottom_app_bar_title" />
<SwitchPreference
app:defaultValue="false"
app:key="vote_buttons_on_the_right"
app:title="@string/settings_vote_buttons_on_the_right_title" />
<SwitchPreference
app:defaultValue="false"
app:key="show_elapsed_time"
app:title="@string/settings_show_elapsed_time" />
<ListPreference
app:defaultValue="0"
android:entries="@array/settings_default_post_layout"
app:entryValues="@array/settings_default_post_layout_values"
app:key="default_post_layout"
app:title="@string/settings_default_post_layout"
app:useSimpleSummaryProvider="true" />
<SwitchPreference
app:defaultValue="true"
app:key="show_divider_in_compact_layout"
app:title="@string/settings_show_divider_in_compact_layout" />
</PreferenceScreen>

View File

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<Preference <Preference
app:icon="@drawable/ic_outline_notifications_24px" app:icon="@drawable/ic_outline_notifications_24dp"
app:title="@string/settings_notification_master_title" app:title="@string/settings_notification_master_title"
app:fragment="ml.docilealligator.infinityforreddit.Settings.NotificationPreferenceFragment" /> app:fragment="ml.docilealligator.infinityforreddit.Settings.NotificationPreferenceFragment" />
@ -20,59 +20,21 @@
app:key="amoled_dark" app:key="amoled_dark"
app:title="@string/settings_amoled_dark_title" /> app:title="@string/settings_amoled_dark_title" />
<SwitchPreference <Preference
app:defaultValue="true" app:icon="@drawable/ic_interface_24dp"
app:key="immersive_interface" app:title="@string/settings_interface_title"
app:title="@string/settings_immersive_interface_title" app:fragment="ml.docilealligator.infinityforreddit.Settings.InterfacePreferenceFragment" />
app:isPreferenceVisible="false" />
<Preference
app:icon="@drawable/ic_gesture_24dp"
app:title="@string/settings_gestures_and_buttons_title"
app:fragment="ml.docilealligator.infinityforreddit.Settings.GesturesAndButtonsPreferenceFragment" />
<SwitchPreference <SwitchPreference
app:defaultValue="false" app:defaultValue="false"
app:key="bottom_app_bar" app:icon="@drawable/ic_link"
app:title="@string/settings_enable_bottom_app_bar_title" /> app:key="open_link_in_app"
app:title="@string/settings_open_link_in_app_title" />
<SwitchPreference
app:defaultValue="false"
app:key="vote_buttons_on_the_right"
app:title="@string/settings_vote_buttons_on_the_right_title" />
<SwitchPreference
app:defaultValue="false"
app:key="show_elapsed_time"
app:title="@string/settings_show_elapsed_time" />
<ListPreference
app:defaultValue="0"
android:entries="@array/settings_default_post_layout"
app:entryValues="@array/settings_default_post_layout_values"
app:key="default_post_layout"
app:title="@string/settings_default_post_layout"
app:useSimpleSummaryProvider="true" />
<SwitchPreference
app:defaultValue="true"
app:key="show_divider_in_compact_layout"
app:title="@string/settings_show_divider_in_compact_layout" />
<SwitchPreference
app:defaultValue="true"
app:key="swipe_to_go_back_from_post_detail"
app:title="@string/swipe_to_go_back_from_post_detail" />
<SwitchPreference
app:defaultValue="true"
app:key="swipe_to_go_back_from_post_detail"
app:title="@string/swipe_to_go_back_from_post_detail" />
<SwitchPreference
app:defaultValue="false"
app:key="volume_keys_navigate_comments"
app:title="@string/settings_volume_keys_navigate_comments_title" />
<SwitchPreference
app:defaultValue="false"
app:key="volume_keys_navigate_posts"
app:title="@string/settings_volume_keys_navigate_posts_title" />
<SwitchPreference <SwitchPreference
app:defaultValue="false" app:defaultValue="false"
@ -80,11 +42,6 @@
android:icon="@drawable/ic_mute_preferences_24dp" android:icon="@drawable/ic_mute_preferences_24dp"
app:title="@string/settings_mute_video_title" /> app:title="@string/settings_mute_video_title" />
<Preference
app:title="@string/settings_font_size_title"
app:icon="@drawable/ic_font_size_24dp"
app:fragment="ml.docilealligator.infinityforreddit.Settings.FontSizePreferenceFragment" />
<ListPreference <ListPreference
app:defaultValue="2.5" app:defaultValue="2.5"
android:entries="@array/settings_lazy_mode_interval" android:entries="@array/settings_lazy_mode_interval"

View File

@ -5,7 +5,7 @@
<SwitchPreference <SwitchPreference
app:defaultValue="true" app:defaultValue="true"
app:key="enable_notification" app:key="enable_notification"
app:icon="@drawable/ic_outline_notifications_24px" app:icon="@drawable/ic_outline_notifications_24dp"
app:title="@string/settings_notification_enable_notification_title"/> app:title="@string/settings_notification_enable_notification_title"/>
<ListPreference <ListPreference