This commit is contained in:
Austin Huang 2021-03-18 17:00:23 -04:00
parent 383ffce89f
commit 7c706e277b
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
5 changed files with 22 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.WindowManager;
import android.widget.AutoCompleteTextView; import android.widget.AutoCompleteTextView;
import android.widget.Toast; import android.widget.Toast;
@ -142,6 +143,8 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
final String cookie = settingsHelper.getString(Constants.COOKIE); final String cookie = settingsHelper.getString(Constants.COOKIE);
CookieUtils.setupCookies(cookie); CookieUtils.setupCookies(cookie);
isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) != 0; isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) != 0;
if (settingsHelper.getBoolean(Constants.FLAG_SECURE))
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
setContentView(binding.getRoot()); setContentView(binding.getRoot());
final Toolbar toolbar = binding.toolbar; final Toolbar toolbar = binding.toolbar;
setSupportActionBar(toolbar); setSupportActionBar(toolbar);

View File

@ -28,6 +28,7 @@ public class GeneralPreferencesFragment extends BasePreferencesFragment {
screen.addPreference(getDefaultTabPreference(context)); screen.addPreference(getDefaultTabPreference(context));
} }
screen.addPreference(getUpdateCheckPreference(context)); screen.addPreference(getUpdateCheckPreference(context));
screen.addPreference(getFlagSecurePreference(context));
} }
private Preference getDefaultTabPreference(@NonNull final Context context) { private Preference getDefaultTabPreference(@NonNull final Context context) {
@ -58,4 +59,17 @@ public class GeneralPreferencesFragment extends BasePreferencesFragment {
preference.setIconSpaceReserved(false); preference.setIconSpaceReserved(false);
return preference; return preference;
} }
private Preference getFlagSecurePreference(@NonNull final Context context) {
return PreferenceHelper.getSwitchPreference(
context,
Constants.FLAG_SECURE,
R.string.flag_secure,
-1,
false,
(preference, newValue) -> {
shouldRecreate();
return true;
});
}
} }

View File

@ -30,6 +30,7 @@ public final class Constants {
// deprecated: public static final String AMOLED_THEME = "amoled_theme"; // deprecated: public static final String AMOLED_THEME = "amoled_theme";
public static final String CHECK_ACTIVITY = "check_activity"; public static final String CHECK_ACTIVITY = "check_activity";
public static final String CHECK_UPDATES = "check_updates"; public static final String CHECK_UPDATES = "check_updates";
public static final String FLAG_SECURE = "flag_secure";
// never Export // never Export
public static final String COOKIE = "cookie"; public static final String COOKIE = "cookie";
public static final String SHOW_QUICK_ACCESS_DIALOG = "show_quick_dlg"; public static final String SHOW_QUICK_ACCESS_DIALOG = "show_quick_dlg";

View File

@ -30,6 +30,7 @@ import static awais.instagrabber.utils.Constants.DEFAULT_TAB;
import static awais.instagrabber.utils.Constants.DEVICE_UUID; import static awais.instagrabber.utils.Constants.DEVICE_UUID;
import static awais.instagrabber.utils.Constants.DM_MARK_AS_SEEN; import static awais.instagrabber.utils.Constants.DM_MARK_AS_SEEN;
import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER; import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER;
import static awais.instagrabber.utils.Constants.FLAG_SECURE;
import static awais.instagrabber.utils.Constants.FOLDER_PATH; import static awais.instagrabber.utils.Constants.FOLDER_PATH;
import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO; import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO;
import static awais.instagrabber.utils.Constants.MARK_AS_SEEN; import static awais.instagrabber.utils.Constants.MARK_AS_SEEN;
@ -139,7 +140,8 @@ public final class SettingsHelper {
@StringDef({DOWNLOAD_USER_FOLDER, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS, @StringDef({DOWNLOAD_USER_FOLDER, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS,
SHOW_CAPTIONS, CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, DM_MARK_AS_SEEN, CHECK_ACTIVITY, SHOW_CAPTIONS, CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, DM_MARK_AS_SEEN, CHECK_ACTIVITY,
CHECK_UPDATES, SWAP_DATE_TIME_FORMAT_ENABLED, PREF_ENABLE_DM_NOTIFICATIONS, PREF_ENABLE_DM_AUTO_REFRESH}) CHECK_UPDATES, SWAP_DATE_TIME_FORMAT_ENABLED, PREF_ENABLE_DM_NOTIFICATIONS, PREF_ENABLE_DM_AUTO_REFRESH,
FLAG_SECURE})
public @interface BooleanSettings {} public @interface BooleanSettings {}
@StringDef({PREV_INSTALL_VERSION, BROWSER_UA_CODE, APP_UA_CODE, PREF_ENABLE_DM_AUTO_REFRESH_FREQ_NUMBER}) @StringDef({PREV_INSTALL_VERSION, BROWSER_UA_CODE, APP_UA_CODE, PREF_ENABLE_DM_AUTO_REFRESH_FREQ_NUMBER})

View File

@ -28,6 +28,7 @@
<string name="title_notifications">Activity</string> <string name="title_notifications">Activity</string>
<string name="title_highlight">Highlight: %s</string> <string name="title_highlight">Highlight: %s</string>
<string name="update_check">Check for updates at startup</string> <string name="update_check">Check for updates at startup</string>
<string name="flag_secure">Block screenshots &amp; app preview</string>
<string name="download_user_folder">Download posts to username folders</string> <string name="download_user_folder">Download posts to username folders</string>
<string name="mark_as_seen_setting">Mark stories as seen after viewing</string> <string name="mark_as_seen_setting">Mark stories as seen after viewing</string>
<string name="mark_as_seen_setting_summary">Story author will know you viewed it</string> <string name="mark_as_seen_setting_summary">Story author will know you viewed it</string>