gt:         updateCheckTime = new LongSetting(p, "update_check_time", 0L);
context: /*
   * Clover - 4chan browser https://github.com/Floens/Clover/
   * Copyright (C) 2014  Floens
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */
  package org.floens.flutter.core.settings;
  
  import android.content.SharedPreferences;
  import android.os.Environment;
  import android.text.TextUtils;
  
  import org.floens.flutter.Chan;
  import org.floens.flutter.R;
  import org.floens.flutter.core.manager.WatchManager;
  import org.floens.flutter.core.update.UpdateManager;
  import org.floens.flutter.ui.adapter.PostsFilter;
  import org.floens.flutter.utils.AndroidUtils;
  
  import java.io.File;
  import java.net.InetSocketAddress;
  import java.net.Proxy;
  
  import de.greenrobot.event.EventBus;
  
  public class ChanSettings {
      public enum MediaAutoLoadMode implements OptionSettingItem {
          // ALways auto load, either wifi or mobile
          ALL("all"),
          // Only auto load if on wifi
          WIFI("wifi"),
          // Never auto load
          NONE("none");
  
          String name;
  
          MediaAutoLoadMode(String name) {
              this.name = name;
          }
  
          @Override
          public String getName() {
              return name;
          }
      }
  
      public enum PostViewMode implements OptionSettingItem {
          LIST("list"),
          CARD("grid");
  
          String name;
  
          PostViewMode(String name) {
              this.name = name;
          }
  
          @Override
          public String getName() {
              return name;
          }
      }
  
      public enum LayoutMode implements OptionSettingItem {
          AUTO("auto"),
          PHONE("phone"),
          SLIDE("slide"),
          SPLIT("split");
  
          String name;
  
          LayoutMode(String name) {
              this.name = name;
          }
  
          @Override
          public String getName() {
              return name;
          }
      }
  
      private static Proxy proxy;
  
      private static final StringSetting theme;
      public static final OptionsSetting<LayoutMode> layoutMode;
      public static final StringSetting fontSize;
      public static final BooleanSetting fontCondensed;
      public static final BooleanSetting openLinkConfirmation;
      public static final BooleanSetting autoRefreshThread;
      //    public static final BooleanSetting imageAutoLoad;
      public static final OptionsSetting<MediaAutoLoadMode> imageAutoLoadNetwork;
      public static final OptionsSetting<MediaAutoLoadMode> videoAutoLoadNetwork;
      public static final BooleanSetting videoOpenExternal;
      public static final BooleanSetting textOnly;
      public static final BooleanSetting videoErrorIgnore;
      public static final OptionsSetting<PostViewMode> boardViewMode;
      public static final IntegerSetting boardGridSpanCount;
      public static final StringSetting boardOrder;
  
      public static final StringSetting postDefaultName;
      public static final BooleanSetting postPinThread;
      public static final BooleanSetting postNewCaptcha;
  
      public static final BooleanSetting developer;
  
      public static final StringSetting saveLocation;
      public static final BooleanSetting saveOriginalFilename;
      public static final BooleanSetting shareUrl;
      public static final BooleanSetting networkHttps;
      public static final BooleanSetting enableReplyFab;
      public static final BooleanSetting anonymize;
      public static final BooleanSetting anonymizeIds;
      public static final BooleanSetting showAnonymousName;
      public static final BooleanSetting revealImageSpoilers;
      public static final BooleanSetting revealTextSpoilers;
      public static final BooleanSetting repliesButtonsBottom;
      public static final BooleanSetting confirmExit;
      public static final BooleanSetting tapNoReply;
      public static final BooleanSetting volumeKeysScrolling;
      public static final BooleanSetting postFullDate;
      public static final BooleanSetting postFileInfo;
      public static final BooleanSetting postFilename;
      public static final BooleanSetting neverHideToolbar;
      public static final BooleanSetting controllerSwipeable;
      public static final BooleanSetting saveBoardFolder;
  
      public static final BooleanSetting watchEnabled;
      public static final BooleanSetting watchCountdown;
      public static final BooleanSetting watchBackground;
      public static final IntegerSetting watchBackgroundInterval;
      public static final StringSetting watchNotifyMode;
      public static final StringSetting watchSound;
      public static final BooleanSetting watchPeek;
      public static final StringSetting watchLed;
  
      public static final StringSetting passToken;
      public static final StringSetting passPin;
      public static final StringSetting passId;
  
      public static final BooleanSetting historyEnabled;
  
      public static final IntegerSetting previousVersion;
  
      public static final BooleanSetting proxyEnabled;
      public static final StringSetting proxyAddress;
      public static final IntegerSetting proxyPort;
  
      public static final CounterSetting settingsOpenCounter;
      public static final CounterSetting historyOpenCounter;
      public static final CounterSetting replyOpenCounter;
      public static final CounterSetting threadOpenCounter;
  
      public static final LongSetting updateCheckTime;
      public static final LongSetting updateCheckInterval;
  
      static {
          SharedPreferences p = AndroidUtils.getPreferences();
  
          theme = new StringSetting(p, "preference_theme", "light");
  
          layoutMode = new OptionsSetting<>(p, "preference_layout_mode", LayoutMode.values(), LayoutMode.AUTO);
  
          boolean tablet = AndroidUtils.getRes().getBoolean(R.bool.is_tablet);
  
          fontSize = new StringSetting(p, "preference_font", tablet ? "16" : "14");
          fontCondensed = new BooleanSetting(p, "preference_font_condensed", false);
          openLinkConfirmation = new BooleanSetting(p, "preference_open_link_confirmation", false);
          autoRefreshThread = new BooleanSetting(p, "preference_auto_refresh_thread", true);
  //        imageAutoLoad = new BooleanSetting(p, "preference_image_auto_load", true);
          imageAutoLoadNetwork = new OptionsSetting<>(p, "preference_image_auto_load_network", MediaAutoLoadMode.values(), MediaAutoLoadMode.WIFI);
          videoAutoLoadNetwork = new OptionsSetting<>(p, "preference_video_auto_load_network", MediaAutoLoadMode.values(), MediaAutoLoadMode.WIFI);
          videoOpenExternal = new BooleanSetting(p, "preference_video_external", false);
          textOnly = new BooleanSetting(p, "preference_text_only", false);
          videoErrorIgnore = new BooleanSetting(p, "preference_video_error_ignore", false);
          boardViewMode = new OptionsSetting<>(p, "preference_board_view_mode", PostViewMode.values(), PostViewMode.LIST);
          boardGridSpanCount = new IntegerSetting(p, "preference_board_grid_span_count", 0);
          boardOrder = new StringSetting(p, "preference_board_order", PostsFilter.Order.BUMP.name);
  
          postDefaultName = new StringSetting(p, "preference_default_name", "");
          postPinThread = new BooleanSetting(p, "preference_pin_on_post", false);
          postNewCaptcha = new BooleanSetting(p, "preference_new_captcha", true);
  
          developer = new BooleanSetting(p, "preference_developer", false);
  
          saveLocation = new StringSetting(p, "preference_image_save_location", Environment.getExternalStorageDirectory() + File.separator + "Clover");
          saveLocation.addCallback(new Setting.SettingCallback<String>() {
              @Override
              public void onValueChange(Setting setting, String value) {
                  EventBus.getDefault().post(new SettingChanged<>(saveLocation));
              }
          });
          saveOriginalFilename = new BooleanSetting(p, "preference_image_save_original", false);
          shareUrl = new BooleanSetting(p, "preference_image_share_url", false);
          networkHttps = new BooleanSetting(p, "preference_network_https", true);
          enableReplyFab = new BooleanSetting(p, "preference_enable_reply_fab", true);
          anonymize = new BooleanSetting(p, "preference_anonymize", false);
          anonymizeIds = new BooleanSetting(p, "preference_anonymize_ids", false);
          showAnonymousName = new BooleanSetting(p, "preference_show_anonymous_name", false);
          revealImageSpoilers = new BooleanSetting(p, "preference_reveal_image_spoilers", false);
          revealTextSpoilers = new BooleanSetting(p, "preference_reveal_text_spoilers", false);
          repliesButtonsBottom = new BooleanSetting(p, "preference_buttons_bottom", false);
          confirmExit = new BooleanSetting(p, "preference_confirm_exit", false);
          tapNoReply = new BooleanSetting(p, "preference_tap_no_reply", false);
          volumeKeysScrolling = new BooleanSetting(p, "preference_volume_key_scrolling", false);
          postFullDate = new BooleanSetting(p, "preference_post_full_date", false);
          postFileInfo = new BooleanSetting(p, "preference_post_file_info", true);
          postFilename = new BooleanSetting(p, "preference_post_filename", false);
          neverHideToolbar = new BooleanSetting(p, "preference_never_hide_toolbar", false);
          controllerSwipeable = new BooleanSetting(p, "preference_controller_swipeable", true);
          saveBoardFolder = new BooleanSetting(p, "preference_save_subboard", false);
  
          watchEnabled = new BooleanSetting(p, "preference_watch_enabled", false);
          watchEnabled.addCallback(new Setting.SettingCallback<Boolean>() {
              @Override
              public void onValueChange(Setting setting, Boolean value) {
                  Chan.getWatchManager().onWatchEnabledChanged(value);
              }
          });
          watchCountdown = new BooleanSetting(p, "preference_watch_countdown", false);
          watchBackground = new BooleanSetting(p, "preference_watch_background_enabled", false);
          watchBackground.addCallback(new Setting.SettingCallback<Boolean>() {
              @Override
              public void onValueChange(Setting setting, Boolean value) {
                  Chan.getWatchManager().onBackgroundWatchingChanged(value);
              }
          });
          watchBackgroundInterval = new IntegerSetting(p, "preference_watch_background_interval", WatchManager.DEFAULT_BACKGROUND_INTERVAL);
          watchNotifyMode = new StringSetting(p, "preference_watch_notify_mode", "all");
          watchSound = new StringSetting(p, "preference_watch_sound", "quotes");
          watchPeek = new BooleanSetting(p, "preference_watch_peek", true);
          watchLed = new StringSetting(p, "preference_watch_led", "ffffffff");
  
          passToken = new StringSetting(p, "preference_pass_token", "");
          passPin = new StringSetting(p, "preference_pass_pin", "");
          passId = new StringSetting(p, "preference_pass_id", "");
  
          historyEnabled = new BooleanSetting(p, "preference_history_enabled", true);
  
          previousVersion = new IntegerSetting(p, "preference_previous_version", 0);
  
          proxyEnabled = new BooleanSetting(p, "preference_proxy_enabled", false);
          proxyEnabled.addCallback(new Setting.SettingCallback<Boolean>() {
              @Override
              public void onValueChange(Setting setting, Boolean value) {
                  loadProxy();
              }
          });
          proxyAddress = new StringSetting(p, "preference_proxy_address", "");
          proxyAddress.addCallback(new Setting.SettingCallback<String>() {
              @Override
              public void onValueChange(Setting setting, String value) {
                  loadProxy();
              }
          });
          proxyPort = new IntegerSetting(p, "preference_proxy_port", 80);
          proxyPort.addCallback(new Setting.SettingCallback<Integer>() {
              @Override
              public void onValueChange(Setting setting, Integer value) {
                  loadProxy();
              }
          });
          loadProxy();
  
          settingsOpenCounter = new CounterSetting(p, "counter_settings_open");
          historyOpenCounter = new CounterSetting(p, "counter_history_open");
          replyOpenCounter = new CounterSetting(p, "counter_reply_open");
          threadOpenCounter = new CounterSetting(p, "counter_thread_open");
  
  