Add settings for usage of the new captcha window and google cookies

dev
k1rakishou 6 years ago
parent 1d38254309
commit 6fdc7b74c2
  1. 4
      Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java
  2. 1
      Clover/app/src/main/java/org/floens/chan/ui/captcha/v2/CaptchaNoJsPresenterV2.java
  3. 43
      Clover/app/src/main/java/org/floens/chan/ui/controller/BehaviourSettingsController.java
  4. 2
      Clover/app/src/main/java/org/floens/chan/ui/settings/SettingsController.java
  5. 7
      Clover/app/src/main/res/values/strings.xml

@ -160,6 +160,8 @@ public class ChanSettings {
public static final LongSetting updateCheckInterval; public static final LongSetting updateCheckInterval;
public static final BooleanSetting crashReporting; public static final BooleanSetting crashReporting;
public static final BooleanSetting useNewCaptchaWindow;
public static final BooleanSetting useRealGoogleCookies;
static { static {
SettingProvider p = new SharedPreferencesSettingProvider(AndroidUtils.getPreferences()); SettingProvider p = new SharedPreferencesSettingProvider(AndroidUtils.getPreferences());
@ -250,6 +252,8 @@ public class ChanSettings {
updateCheckInterval = new LongSetting(p, "update_check_interval", UpdateManager.DEFAULT_UPDATE_CHECK_INTERVAL_MS); updateCheckInterval = new LongSetting(p, "update_check_interval", UpdateManager.DEFAULT_UPDATE_CHECK_INTERVAL_MS);
crashReporting = new BooleanSetting(p, "preference_crash_reporting", true); crashReporting = new BooleanSetting(p, "preference_crash_reporting", true);
useNewCaptchaWindow = new BooleanSetting(p, "use_new_captcha_window", true);
useRealGoogleCookies = new BooleanSetting(p, "use_real_google_cookies", false);
// Old (but possibly still in some users phone) // Old (but possibly still in some users phone)
// preference_board_view_mode default "list" // preference_board_view_mode default "list"

@ -52,7 +52,6 @@ public class CaptchaNoJsPresenterV2 {
private static final int SUCCESS_STATUS_CODE = 200; private static final int SUCCESS_STATUS_CODE = 200;
private static final long CAPTCHA_REQUEST_THROTTLE_MS = 3000L; private static final long CAPTCHA_REQUEST_THROTTLE_MS = 3000L;
// this should be updated once in 3 months IIRC
private static final String googleCookies = private static final String googleCookies =
"SID=gjaHjfFJPAN5HO3MVVZpjHFKa_249dsfjHa9klsiaflsd99.asHqjsM2lAS; " + "SID=gjaHjfFJPAN5HO3MVVZpjHFKa_249dsfjHa9klsiaflsd99.asHqjsM2lAS; " +
"HSID=j7m0aFJ82lPF7Hd9d; " + "HSID=j7m0aFJ82lPF7Hd9d; " +

@ -39,6 +39,7 @@ import static org.floens.chan.Chan.injector;
public class BehaviourSettingsController extends SettingsController { public class BehaviourSettingsController extends SettingsController {
private SettingView forceEnglishSetting; private SettingView forceEnglishSetting;
private SettingView useNewCaptchaWindow;
public BehaviourSettingsController(Context context) { public BehaviourSettingsController(Context context) {
super(context); super(context);
@ -47,14 +48,10 @@ public class BehaviourSettingsController extends SettingsController {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
navigation.setTitle(R.string.settings_screen_behavior); navigation.setTitle(R.string.settings_screen_behavior);
setupLayout(); setupLayout();
rebuildPreferences();
populatePreferences();
buildPreferences();
} }
@Override @Override
@ -63,10 +60,27 @@ public class BehaviourSettingsController extends SettingsController {
if (item == forceEnglishSetting) { if (item == forceEnglishSetting) {
Toast.makeText(context, R.string.setting_force_english_locale_toggle_notice, Toast.makeText(context, R.string.setting_force_english_locale_toggle_notice,
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
} else if (item == useNewCaptchaWindow) {
// when user disables the new captcha window also disable the usage of the google cookies
if (!ChanSettings.useNewCaptchaWindow.get()) {
ChanSettings.useRealGoogleCookies.set(false);
}
rebuildPreferences();
} }
} }
private void rebuildPreferences() {
populatePreferences();
buildPreferences();
}
private void populatePreferences() { private void populatePreferences() {
requiresUiRefresh.clear();
groups.clear();
requiresRestart.clear();
// General group // General group
{ {
SettingsGroup general = new SettingsGroup(R.string.settings_group_general); SettingsGroup general = new SettingsGroup(R.string.settings_group_general);
@ -152,6 +166,25 @@ public class BehaviourSettingsController extends SettingsController {
groups.add(post); groups.add(post);
} }
// Captcha group
{
SettingsGroup captcha = new SettingsGroup(R.string.settings_captcha_group);
useNewCaptchaWindow = captcha.add(new BooleanSettingView(this,
ChanSettings.useNewCaptchaWindow,
R.string.settings_use_new_captcha_window,
0));
if (ChanSettings.useNewCaptchaWindow.get()) {
captcha.add(new BooleanSettingView(this,
ChanSettings.useRealGoogleCookies,
R.string.settings_use_real_google_cookies,
R.string.settings_use_real_google_cookies_description));
}
groups.add(captcha);
}
// Proxy group // Proxy group
{ {
SettingsGroup proxy = new SettingsGroup(R.string.settings_group_proxy); SettingsGroup proxy = new SettingsGroup(R.string.settings_group_proxy);

@ -140,6 +140,8 @@ public class SettingsController extends Controller implements AndroidUtils.OnMea
protected void buildPreferences() { protected void buildPreferences() {
LayoutInflater inf = LayoutInflater.from(context); LayoutInflater inf = LayoutInflater.from(context);
boolean firstGroup = true; boolean firstGroup = true;
content.removeAllViews();
for (SettingsGroup group : groups) { for (SettingsGroup group : groups) {
LinearLayout groupLayout = (LinearLayout) inf.inflate(R.layout.setting_group, content, false); LinearLayout groupLayout = (LinearLayout) inf.inflate(R.layout.setting_group, content, false);
((TextView) groupLayout.findViewById(R.id.header)).setText(group.name); ((TextView) groupLayout.findViewById(R.id.header)).setText(group.name);

@ -577,6 +577,13 @@ Don't have a 4chan Pass?<br>
"</string> "</string>
<string name="settings_screen_theme">Themes</string> <string name="settings_screen_theme">Themes</string>
<!-- Captcha settings -->
<string name="settings_captcha_group" tools:ignore="MissingTranslation">Captcha</string>
<string name="settings_use_new_captcha_window" tools:ignore="MissingTranslation">Use new captcha window for no-js captcha</string>
<string name="settings_use_real_google_cookies" tools:ignore="MissingTranslation">Use real google cookies instead of hardcoded ones</string>
<string name="settings_use_real_google_cookies_description" tools:ignore="MissingTranslation">By using the real google cookies a GET request to the google.com will be executed to get the google cookies (SID, HSID, SSID, NID) which will be stored on the device and used for captcha authentication. Why would you need them? Because the hardcoded ones sometimes will make you re-enter the captcha dozens of times. Those cookies will be updated automatically (once in a month). But it will also be possible to update them manually</string>
<string name="captcha_layout_v2_verify_button_text" tools:ignore="MissingTranslation">Verify</string> <string name="captcha_layout_v2_verify_button_text" tools:ignore="MissingTranslation">Verify</string>
<string name="captcha_layout_v2_reload" tools:ignore="MissingTranslation">Reload</string> <string name="captcha_layout_v2_reload" tools:ignore="MissingTranslation">Reload</string>
<string name="captcha_layout_v2_use_old_captcha" tools:ignore="MissingTranslation">Use old captcha</string> <string name="captcha_layout_v2_use_old_captcha" tools:ignore="MissingTranslation">Use old captcha</string>

Loading…
Cancel
Save