diff --git a/app/src/main/java/com/hippo/ehviewer/Settings.java b/app/src/main/java/com/hippo/ehviewer/Settings.java index ac34b3015..bb967a156 100755 --- a/app/src/main/java/com/hippo/ehviewer/Settings.java +++ b/app/src/main/java/com/hippo/ehviewer/Settings.java @@ -25,7 +25,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.preference.PreferenceManager; -import com.hippo.ehviewer.client.EhConfig; import com.hippo.ehviewer.client.data.FavListUrlBuilder; import com.hippo.ehviewer.ui.CommonOperations; import com.hippo.ehviewer.ui.scene.GalleryListScene; @@ -58,10 +57,6 @@ public class Settings { public static final String KEY_SHOW_JPN_TITLE = "show_jpn_title"; public static final String KEY_SHOW_TAG_TRANSLATIONS = "show_tag_translations"; public static final String KEY_TAG_TRANSLATIONS_SOURCE = "tag_translations_source"; - public static final String KEY_DEFAULT_CATEGORIES = "default_categories"; - public static final int DEFAULT_DEFAULT_CATEGORIES = EhConfig.ALL_CATEGORY; - public static final String KEY_EXCLUDED_TAG_NAMESPACES = "excluded_tag_namespaces"; - public static final String KEY_EXCLUDED_LANGUAGES = "excluded_languages"; public static final String KEY_REQUEST_NEWS = "request_news"; public static final String KEY_REQUEST_NEWS_TIMER = "request_news_timer"; public static final String KEY_REQUEST_NEWS_TIMER_HOUR = "request_news_timer_hour"; @@ -92,8 +87,6 @@ public class Settings { public static final String KEY_DOWNLOAD_SAVE_QUERY = "image_query"; public static final String KEY_DOWNLOAD_SAVE_FRAGMENT = "image_fragment"; public static final String KEY_MEDIA_SCAN = "media_scan"; - public static final String KEY_IMAGE_RESOLUTION = "image_size"; - public static final String DEFAULT_IMAGE_RESOLUTION = EhConfig.IMAGE_SIZE_AUTO; public static final int INVALID_DEFAULT_FAV_SLOT = -2; /******************** ****** Advanced @@ -133,8 +126,6 @@ public class Settings { private static final String KEY_SHOW_GALLERY_PAGES = "show_gallery_pages"; private static final boolean DEFAULT_SHOW_GALLERY_PAGES = false; private static final boolean DEFAULT_SHOW_TAG_TRANSLATIONS = false; - private static final int DEFAULT_EXCLUDED_TAG_NAMESPACES = 0; - private static final String DEFAULT_EXCLUDED_LANGUAGES = null; private static final String KEY_METERED_NETWORK_WARNING = "cellular_network_warning"; private static final boolean DEFAULT_METERED_NETWORK_WARNING = false; private static final String KEY_APP_LINK_VERIFY_TIP = "app_link_verify_tip"; @@ -216,11 +207,9 @@ public class Settings { public static boolean LIST_THUMB_SIZE_INITED = false; public static SharedPreferences sSettingsPre; private static int LIST_THUMB_SIZE = 40; - private static EhConfig sEhConfig; public static void initialize() { sSettingsPre = PreferenceManager.getDefaultSharedPreferences(EhApplication.getApplication()); - sEhConfig = loadEhConfig(); fixDefaultValue(); } @@ -241,16 +230,6 @@ public class Settings { } } - private static EhConfig loadEhConfig() { - EhConfig ehConfig = new EhConfig(); - ehConfig.imageSize = getImageResolution(); - ehConfig.excludedLanguages = getExcludedLanguages(); - ehConfig.defaultCategories = getDefaultCategories(); - ehConfig.excludedNamespaces = getExcludedTagNamespaces(); - ehConfig.setDirty(); - return ehConfig; - } - public static boolean getBoolean(String key, boolean defValue) { try { return sSettingsPre.getBoolean(key, defValue); @@ -339,10 +318,6 @@ public class Settings { putBoolean(KEY_REMOVE_IMAGE_FILES, value); } - public static EhConfig getEhConfig() { - return sEhConfig; - } - public static boolean getNeedSignIn() { return getBoolean(KEY_NEED_SIGN_IN, DEFAULT_NEED_SIGN_IN); } @@ -440,18 +415,6 @@ public class Settings { putBoolean(KEY_SHOW_TAG_TRANSLATIONS, value); } - public static int getDefaultCategories() { - return getInt(KEY_DEFAULT_CATEGORIES, DEFAULT_DEFAULT_CATEGORIES); - } - - public static int getExcludedTagNamespaces() { - return getInt(KEY_EXCLUDED_TAG_NAMESPACES, DEFAULT_EXCLUDED_TAG_NAMESPACES); - } - - public static String getExcludedLanguages() { - return getString(KEY_EXCLUDED_LANGUAGES, DEFAULT_EXCLUDED_LANGUAGES); - } - public static boolean getMeteredNetworkWarning() { return getBoolean(KEY_METERED_NETWORK_WARNING, DEFAULT_METERED_NETWORK_WARNING); } @@ -536,16 +499,6 @@ public class Settings { return getIntFromStr(KEY_PRELOAD_IMAGE, DEFAULT_PRELOAD_IMAGE); } - public static String getImageResolution() { - return getString(KEY_IMAGE_RESOLUTION, DEFAULT_IMAGE_RESOLUTION); - } - - public static void putImageResolution(String value) { - sEhConfig.imageSize = value; - sEhConfig.setDirty(); - putString(KEY_IMAGE_RESOLUTION, value); - } - public static boolean getDownloadOriginImage() { return getBoolean(KEY_DOWNLOAD_ORIGIN_IMAGE, DEFAULT_DOWNLOAD_ORIGIN_IMAGE); } diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhConfig.java b/app/src/main/java/com/hippo/ehviewer/client/EhConfig.java deleted file mode 100644 index 53952e353..000000000 --- a/app/src/main/java/com/hippo/ehviewer/client/EhConfig.java +++ /dev/null @@ -1,806 +0,0 @@ -/* - * Copyright 2015 Hippo Seven - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hippo.ehviewer.client; - -import com.hippo.network.InetValidator; - -/** - * Some configurable stuff about EH. It ends up cookie. - */ -public class EhConfig implements Cloneable { - - /** - * The Cookie key of uconfig - */ - public static final String KEY_UCONFIG = "uconfig"; - /** - * The Cookie key of lofi resolution - */ - public static final String KEY_LOFI_RESOLUTION = "xres"; - /** - * The Cookie key of show warning - */ - public static final String KEY_CONTENT_WARNING = "nw"; - /** - * load images through the Hentai@Home Network - */ - public static final String LOAD_FROM_HAH_YES = "y"; - /** - * do not load images through the Hentai@Home Network - */ - public static final String LOAD_FROM_HAH_NO = "n"; - /** - * Image Size Auto - */ - public static final String IMAGE_SIZE_AUTO = "a"; - /** - * Image Size 780x - */ - public static final String IMAGE_SIZE_780X = "780"; - /** - * Image Size 980x - */ - public static final String IMAGE_SIZE_980X = "980"; - /** - * Image Size 1280x - */ - public static final String IMAGE_SIZE_1280X = "1280"; - /** - * Image Size 1600x - */ - public static final String IMAGE_SIZE_1600X = "1600"; - /** - * Image Size 2400x - */ - public static final String IMAGE_SIZE_2400X = "2400"; - /** - * Manual Accept, Manual Start - */ - public static final String ARCHIVER_DOWNLOAD_MAMS = "0"; - /** - * >Manual Accept, Auto Start - */ - public static final String ARCHIVER_DOWNLOAD_AAMS = "1"; - /** - * Auto Accept, Manual Start - */ - public static final String ARCHIVER_DOWNLOAD_MAAS = "2"; - /** - * Auto Accept, Auto Start - */ - public static final String ARCHIVER_DOWNLOAD_AAAS = "3"; - /** - * List View on the front and search pages - */ - public static final String LAYOUT_MODE_LIST = "l"; - /** - * Thumbnail View on the front and search pages - */ - public static final String LAYOUT_MODE_THUMB = "t"; - public static final int MISC = 0x1; - public static final int DOUJINSHI = 0x2; - public static final int MANGA = 0x4; - public static final int ARTIST_CG = 0x8; - public static final int GAME_CG = 0x10; - public static final int IMAGE_SET = 0x20; - public static final int COSPLAY = 0x40; - public static final int ASIAN_PORN = 0x80; - public static final int NON_H = 0x100; - public static final int WESTERN = 0x200; - public static final int ALL_CATEGORY = 0x3ff; - public static final int NAMESPACES_RECLASS = 0x1; - public static final int NAMESPACES_LANGUAGE = 0x2; - public static final int NAMESPACES_PARODY = 0x4; - public static final int NAMESPACES_CHARACTER = 0x8; - public static final int NAMESPACES_GROUP = 0x10; - public static final int NAMESPACES_ARTIST = 0x20; - public static final int NAMESPACES_MALE = 0x40; - public static final int NAMESPACES_FEMALE = 0x80; - public static final String JAPANESE_ORIGINAL = "0"; - public static final String JAPANESE_TRANSLATED = "1024"; - public static final String JAPANESE_REWRITE = "2048"; - public static final String ENGLISH_ORIGINAL = "1"; - public static final String ENGLISH_TRANSLATED = "1025"; - public static final String ENGLISH_REWRITE = "2049"; - public static final String CHINESE_ORIGINAL = "10"; - public static final String CHINESE_TRANSLATED = "1034"; - public static final String CHINESE_REWRITE = "2058"; - public static final String DUTCH_ORIGINAL = "20"; - public static final String DUTCH_TRANSLATED = "1044"; - public static final String DUTCH_REWRITE = "2068"; - public static final String FRENCH_ORIGINAL = "30"; - public static final String FRENCH_TRANSLATED = "1054"; - public static final String FRENCH_REWRITE = "2078"; - public static final String GERMAN_ORIGINAL = "40"; - public static final String GERMAN_TRANSLATED = "1064"; - public static final String GERMAN_REWRITE = "2088"; - public static final String HUNGARIAN_ORIGINAL = "50"; - public static final String HUNGARIAN_TRANSLATED = "1074"; - public static final String HUNGARIAN_REWRITE = "2098"; - public static final String ITALIAN_ORIGINAL = "60"; - public static final String ITALIAN_TRANSLATED = "1084"; - public static final String ITALIAN_REWRITE = "2108"; - public static final String KOREAN_ORIGINAL = "70"; - public static final String KOREAN_TRANSLATED = "1094"; - public static final String KOREAN_REWRITE = "2118"; - public static final String POLISH_ORIGINAL = "80"; - public static final String POLISH_TRANSLATED = "1104"; - public static final String POLISH_REWRITE = "2128"; - public static final String PORTUGUESE_ORIGINAL = "90"; - public static final String PORTUGUESE_TRANSLATED = "1114"; - public static final String PORTUGUESE_REWRITE = "2138"; - public static final String RUSSIAN_ORIGINAL = "100"; - public static final String RUSSIAN_TRANSLATED = "1124"; - public static final String RUSSIAN_REWRITE = "2148"; - public static final String SPANISH_ORIGINAL = "110"; - public static final String SPANISH_TRANSLATED = "1134"; - public static final String SPANISH_REWRITE = "2158"; - public static final String THAI_ORIGINAL = "120"; - public static final String THAI_TRANSLATED = "1144"; - public static final String THAI_REWRITE = "2168"; - public static final String VIETNAMESE_ORIGINAL = "130"; - public static final String VIETNAMESE_TRANSLATED = "1154"; - public static final String VIETNAMESE_REWRITE = "2178"; - public static final String NA_ORIGINAL = "254"; - public static final String NA_TRANSLATED = "1278"; - public static final String NA_REWRITE = "2302"; - public static final String OTHER_ORIGINAL = "255"; - public static final String OTHER_TRANSLATED = "1279"; - public static final String OTHER_REWRITE = "2303"; - /** - * 25 results per page for the index/search page and torrent search pages - */ - public static final String RESULT_COUNT_25 = "0"; - /** - * 50 results per page for the index/search page and torrent search pages - */ - public static final String RESULT_COUNT_50 = "1"; - /** - * 100 results per page for the index/search page and torrent search pages - */ - public static final String RESULT_COUNT_100 = "2"; - /** - * 200 results per page for the index/search page and torrent search pages - */ - public static final String RESULT_COUNT_200 = "3"; - /** - * On mouse-over - */ - public static final String MOUSE_OVER_YES = "m"; - /** - * On page load - */ - public static final String MOUSE_OVER_NO = "p"; - /** - * Preview normal size - */ - public static final String PREVIEW_SIZE_NORMAL = "m"; - /** - * Preview large size - */ - public static final String PREVIEW_SIZE_LARGE = "l"; - /** - * 4 row preview per page - */ - public static final String PREVIEW_ROW_4 = "2"; - /** - * 10 row preview per page - */ - public static final String PREVIEW_ROW_10 = "5"; - /** - * 20 row preview per page - */ - public static final String PREVIEW_ROW_20 = "10"; - /** - * 40 row preview per page - */ - public static final String PREVIEW_ROW_40 = "20"; - /** - * Oldest comments first - */ - public static final String COMMENTS_SORT_OLDEST_FIRST = "a"; - /** - * Recent comments first - */ - public static final String COMMENTS_SORT_RECENT_FIRST = "d"; - /** - * By highest score - */ - public static final String COMMENTS_SORT_HIGHEST_SCORE_FIRST = "s"; - /** - * Show gallery comment votes On score hover or click - */ - public static final String COMMENTS_VOTES_POP = "0"; - /** - * Always show gallery comment votes - */ - public static final String COMMENTS_VOTES_ALWAYS = "1"; - /** - * Sort order for gallery tags alphabetically - */ - public static final String TAGS_SORT_ALPHABETICAL = "a"; - /** - * Sort order for gallery tags by tag power - */ - public static final String TAGS_SORT_POWER = "p"; - /** - * Show gallery page numbers - */ - public static final String SHOW_GALLERY_INDEX_YES = "1"; - /** - * Do not show gallery page numbers - */ - public static final String SHOW_GALLERY_INDEX_NO = "0"; - /** - * Enable Tag Flagging - */ - public static final String ENABLE_TAG_FLAGGING_YES = "y"; - /** - * Do not enable Tag Flagging - */ - public static final String ENABLE_TAG_FLAGGING_NO = "n"; - /** - * Always display the original images - */ - public static final String ALWAYS_ORIGINAL_YES = "y"; - /** - * Do not Always display the original images - */ - public static final String ALWAYS_ORIGINAL_NO = "n"; - /** - * Enable the Multi-Page Viewe - */ - public static final String MULTI_PAGE_YES = "y"; - /** - * Do not enable the Multi-Page Viewe - */ - public static final String MULTI_PAGE_NO = "n"; - /** - * Align left, only scale if image is larger than browser width - */ - public static final String MULTI_PAGE_STYLE_N = "n"; - /** - * Align center, only scale if image is larger than browser width - */ - public static final String MULTI_PAGE_STYLE_C = "c"; - /** - * Align center, Always scale images to fit browser width - */ - public static final String MULTI_PAGE_STYLE_Y = "y"; - /** - * Show Multi-Page Viewer Thumbnail Pane - */ - public static final String MULTI_PAGE_THUMB_SHOW = "n"; - /** - * Hide Multi-Page Viewer Thumbnail Pane - */ - public static final String MULTI_PAGE_THUMB_HIDE = "y"; - /** - * 460x for lofi resolution - */ - public static final String LOFI_RESOLUTION_460X = "1"; - /** - * 780X for lofi resolution - */ - public static final String LOFI_RESOLUTION_780X = "2"; - /** - * 980X for lofi resolution - */ - public static final String LOFI_RESOLUTION_980X = "3"; - /** - * show warning - */ - public static final String CONTENT_WARNING_SHOW = "0"; - /** - * not show warning - */ - public static final String CONTENT_WARNING_NOT_SHOW = "1"; - /** - * The key of load images through the Hentai@Home Network - * - * @see #LOAD_FROM_HAH_YES - * @see #LOAD_FROM_HAH_NO - */ - private static final String KEY_LOAD_FROM_HAH = "uh"; - /** - * The key of Image Size Settings - * - * @see #IMAGE_SIZE_AUTO - * @see #IMAGE_SIZE_780X - * @see #IMAGE_SIZE_980X - * @see #IMAGE_SIZE_1280X - * @see #IMAGE_SIZE_1600X - * @see #IMAGE_SIZE_2400X - */ - private static final String KEY_IMAGE_SIZE = "xr"; - /** - * The key of scale images width - */ - private static final String KEY_SCALE_WIDTH = "rx"; - /** - * The key of scale images height - */ - private static final String KEY_SCALE_HEIGHT = "ry"; - /** - * The key of Gallery Name Display - * - * @see #GALLERY_TITLE_DEFAULT - * @see #GALLERY_TITLE_JAPANESE - */ - private static final String KEY_GALLERY_TITLE = "tl"; - /** - * The key of the behavior for downloading archiver - * - * @see #ARCHIVER_DOWNLOAD_MAMS - * @see #ARCHIVER_DOWNLOAD_MAAS - * @see #ARCHIVER_DOWNLOAD_AAMS - * @see #ARCHIVER_DOWNLOAD_AAAS - */ - private static final String KEY_ARCHIVER_DOWNLOAD = "ar"; - /** - * The key of display mode would you like to use on the front and search pages - * - * @see #LAYOUT_MODE_LIST - * @see #LAYOUT_MODE_THUMB - */ - private static final String KEY_LAYOUT_MODE = "dm"; - /** - * The key for show popular - * - * @see #POPULAR_YES - * @see #POPULAR_NO - */ - private static final String KEY_POPULAR = "prn"; - /** - * The key of categories would you like to view as default on the front page - */ - private static final String KEY_DEFAULT_CATEGORIES = "cats"; - /** - * The key for favorites sort - * - * @see #FAVORITES_SORT_GALLERY_UPDATE_TIME - * @see #FAVORITES_SORT_FAVORITED_TIME - */ - private static final String KEY_FAVORITES_SORT = "fs"; - /** - * The key of exclude certain namespaces from a default tag search - */ - private static final String KEY_EXCLUDED_NAMESPACES = "xns"; - /** - * The key of hide galleries in certain languages from the gallery list and searches - */ - private static final String KEY_EXCLUDED_LANGUAGES = "xl"; - /** - * The key of how many results would you like per page for the index/search page and torrent search pages - * - * @see #RESULT_COUNT_25 - * @see #RESULT_COUNT_50 - * @see #RESULT_COUNT_100 - * @see #RESULT_COUNT_200 - */ - private static final String KEY_RESULT_COUNT = "rc"; - /** - * The key of mouse-over thumb - * - * @see #MOUSE_OVER_YES - * @see #MOUSE_OVER_NO - */ - private static final String KEY_MOUSE_OVER = "lt"; - /** - * The key of preview size - * - * @see #PREVIEW_SIZE_NORMAL - * @see #PREVIEW_SIZE_LARGE - */ - private static final String KEY_PREVIEW_SIZE = "ts"; - /** - * The key of preview row per page - * - * @see #PREVIEW_ROW_4 - * @see #PREVIEW_ROW_10 - * @see #PREVIEW_ROW_20 - * @see #PREVIEW_ROW_40 - */ - private static final String KEY_PREVIEW_ROW = "tr"; - /** - * The key of sort order for gallery comments - * - * @see #COMMENTS_SORT_OLDEST_FIRST - * @see #COMMENTS_SORT_RECENT_FIRST - * @see #COMMENTS_SORT_HIGHEST_SCORE_FIRST - */ - private static final String KEY_COMMENTS_SORT = "cs"; - /** - * The key of show gallery comment votes - * - * @see #COMMENTS_VOTES_POP - * @see #COMMENTS_VOTES_ALWAYS - */ - private static final String KEY_COMMENTS_VOTES = "sc"; - /** - * The key of sort order for gallery tags - * - * @see #TAGS_SORT_ALPHABETICAL - * @see #TAGS_SORT_POWER - */ - private static final String KEY_TAGS_SORT = "to"; - /** - * The key of show gallery page numbers - * - * @see #SHOW_GALLERY_INDEX_NO - * @see #SHOW_GALLERY_INDEX_YES - */ - private static final String KEY_SHOW_GALLERY_INDEX = "pn"; - /** - * The key of the IP:Port of a proxy-enabled Hentai@Home Client - * to load all images - */ - private static final String KEY_HAH_CLIENT_IP_PORT = "hp"; - /** - * The key of the passkey of a proxy-enabled Hentai@Home Client - * to load all images - */ - private static final String KEY_HAH_CLIENT_PASSKEY = "hk"; - /** - * The key of enable Tag Flagging - * - * @see #ENABLE_TAG_FLAGGING_NO - * @see #ENABLE_TAG_FLAGGING_YES - */ - private static final String KEY_ENABLE_TAG_FLAGGING = "tf"; - /** - * The key of always display the original images instead of the resampled versions - * - * @see #ALWAYS_ORIGINAL_NO - * @see #ALWAYS_ORIGINAL_YES - */ - private static final String KEY_ALWAYS_ORIGINAL = "oi"; - /** - * The key of enable the multi-Page Viewer - * - * @see #MULTI_PAGE_NO - * @see #MULTI_PAGE_YES - */ - private static final String KEY_MULTI_PAGE = "qb"; - /** - * The key of multi-Page Viewer Display Style - * - * @see #MULTI_PAGE_STYLE_C - * @see #MULTI_PAGE_STYLE_N - * @see #MULTI_PAGE_STYLE_Y - */ - private static final String KEY_MULTI_PAGE_STYLE = "ms"; - /** - * The key of multi-Page Viewer Thumbnail Pane - * - * @see #MULTI_PAGE_THUMB_HIDE - * @see #MULTI_PAGE_THUMB_SHOW - */ - private static final String KEY_MULTI_PAGE_THUMB = "mt"; - /** - * Default gallery title - */ - private static final String GALLERY_TITLE_DEFAULT = "r"; - /** - * Japanese gallery title - */ - private static final String GALLERY_TITLE_JAPANESE = "j"; - /** - * Show popular - */ - private static final String POPULAR_YES = "y"; - /** - * Don't show popular - */ - private static final String POPULAR_NO = "n"; - /** - * Sort favorites by last gallery update time - */ - private static final String FAVORITES_SORT_GALLERY_UPDATE_TIME = "p"; - /** - * Sort favorites by favorited time - */ - private static final String FAVORITES_SORT_FAVORITED_TIME = "f"; - /** - * Load images through the Hentai@Home Network
- * key: {@link #KEY_LOAD_FROM_HAH}
- * value: {@link #LOAD_FROM_HAH_YES}, {@link #LOAD_FROM_HAH_NO} - */ - public String loadFromHAH = LOAD_FROM_HAH_YES; - - /** - * Image Size
- * key: {@link #KEY_IMAGE_SIZE}
- * value: {@link #IMAGE_SIZE_AUTO}, {@link #IMAGE_SIZE_780X}, {@link #IMAGE_SIZE_980X}, - * {@link #IMAGE_SIZE_1280X}, {@link #IMAGE_SIZE_1600X}, {@link #IMAGE_SIZE_2400X} - */ - public String imageSize = IMAGE_SIZE_AUTO; - - /** - * Scale width
- * key: {@link #KEY_SCALE_WIDTH}
- * value: 0 for no limit - */ - public int scaleWidth = 0; - - /** - * Scale height
- * key: {@link #KEY_SCALE_HEIGHT}
- * value: 0 for no limit - */ - public int scaleHeight = 0; - - /** - * Gallery title
- * key: {@link #KEY_GALLERY_TITLE}
- * value: {@link #GALLERY_TITLE_DEFAULT}, {@link #GALLERY_TITLE_JAPANESE} - */ - public String galleryTitle = GALLERY_TITLE_DEFAULT; - - /** - * The default behavior for downloading an archiver
- * key: {@link #KEY_ARCHIVER_DOWNLOAD}
- * value: {@link #ARCHIVER_DOWNLOAD_MAMS}, {@link #ARCHIVER_DOWNLOAD_AAMS}, - * {@link #ARCHIVER_DOWNLOAD_MAAS}, {@link #ARCHIVER_DOWNLOAD_AAAS} - */ - public String archiverDownload = ARCHIVER_DOWNLOAD_MAMS; - - /** - * Display mode used on the front and search pages
- * false for list, true for thumb
- * key: {@link #KEY_LAYOUT_MODE}
- * value: {@link #LAYOUT_MODE_LIST}, {@link #LAYOUT_MODE_THUMB} - */ - public String layoutMode = LAYOUT_MODE_LIST; - - /** - * Show popular or not
- * key: {@link #KEY_POPULAR}
- * value: {@link #POPULAR_YES}, {@link #POPULAR_NO} - */ - public String popular = POPULAR_YES; - - /** - * Default categories on the front page
- * key: {@link #KEY_DEFAULT_CATEGORIES}
- * value: the value of categories, for multiple use & operation, - * 0 for none - */ - public int defaultCategories = 0; - - /** - *
- * key: {@link #KEY_FAVORITES_SORT}
- * value: {@link #FAVORITES_SORT_GALLERY_UPDATE_TIME}, {@link #FAVORITES_SORT_FAVORITED_TIME} - */ - public String favoritesSort = FAVORITES_SORT_FAVORITED_TIME; - - /** - * Certain namespaces excluded from a default tag search
- * key: {@link #KEY_EXCLUDED_NAMESPACES}
- * value: the value of namespaces, for multiple use & operation, - * 0 for none - */ - public int excludedNamespaces = 0; - - /** - * Certain languages excluded from list and searches
- * key: {@link #KEY_EXCLUDED_LANGUAGES}
- * value: {@link #JAPANESE_TRANSLATED}, {@link #JAPANESE_REWRITE} ... - * For multiple languages, use x to combine them, like 1x1024x2048 - */ - public String excludedLanguages = ""; - - /** - * How many results would you like per page for the index/search page - * and torrent search pages
- * key: {@link #KEY_RESULT_COUNT}
- * value: {@link #RESULT_COUNT_25}, {@link #RESULT_COUNT_50}, - * {@link #RESULT_COUNT_100}, {@link #RESULT_COUNT_200}
- * Require Hath Perk:Paging Enlargement - */ - public String resultCount = RESULT_COUNT_25; - - /** - * mouse-over thumb
- * key: {@link #KEY_MOUSE_OVER}
- * value: {@link #MOUSE_OVER_YES}, {@link #MOUSE_OVER_NO} - */ - public String mouseOver = MOUSE_OVER_YES; - - /** - * Default preview mode
- * key: {@link #KEY_PREVIEW_SIZE}
- * value: {@link #PREVIEW_SIZE_NORMAL}, {@link #PREVIEW_SIZE_LARGE} - */ - public String previewSize = PREVIEW_SIZE_LARGE; - - /** - * Preview row
- * key: {@link #KEY_PREVIEW_ROW}
- * value: {@link #PREVIEW_ROW_4}, {@link #PREVIEW_ROW_10}, - * {@link #PREVIEW_ROW_20}, {@link #PREVIEW_ROW_40} - */ - public String previewRow = PREVIEW_ROW_4; - - /** - * Sort order for gallery comments
- * key: {@link #KEY_COMMENTS_SORT}
- * value: {@link #COMMENTS_SORT_OLDEST_FIRST}, {@link #COMMENTS_SORT_RECENT_FIRST}, - * {@link #COMMENTS_SORT_HIGHEST_SCORE_FIRST} - */ - public String commentSort = COMMENTS_SORT_OLDEST_FIRST; - - /** - * Show gallery comment votes mode
- * key: {@link #KEY_COMMENTS_VOTES}
- * value: {@link #COMMENTS_VOTES_POP}, {@link #COMMENTS_VOTES_ALWAYS} - */ - public String commentVotes = COMMENTS_VOTES_POP; - - - /** - * Sort order for gallery tags
- * key: {@link #KEY_TAGS_SORT}
- * value: {@link #TAGS_SORT_ALPHABETICAL}, {@link #TAGS_SORT_POWER} - */ - public String tagSort = TAGS_SORT_ALPHABETICAL; - - /** - * Show gallery page numbers
- * key: {@link #KEY_SHOW_GALLERY_INDEX}
- * value: {@link #SHOW_GALLERY_INDEX_YES}, {@link #SHOW_GALLERY_INDEX_NO} - */ - public String showGalleryIndex = SHOW_GALLERY_INDEX_YES; - - /** - * The IP of a proxy-enabled Hentai@Home Client - * to load all images
- * key: {@link #KEY_HAH_CLIENT_IP_PORT}
- */ - public String hahClientIp = ""; - - /** - * The PORT of a proxy-enabled Hentai@Home Client - * to load all images
- * key: {@link #KEY_HAH_CLIENT_IP_PORT}
- */ - public int hahClientPort = -1; - - /** - * The passkey of a proxy-enabled Hentai@Home Client - * to load all images
- * key: {@link #KEY_HAH_CLIENT_PASSKEY}
- */ - public String hahClientPasskey = ""; - - /** - * Enable tag flagging - * key: {@link #KEY_ENABLE_TAG_FLAGGING}
- * value: {@link #ENABLE_TAG_FLAGGING_YES}, {@link #ENABLE_TAG_FLAGGING_NO}
- * Bronze Star or Hath Perk: Tag Flagging Required - */ - public String enableTagFlagging = ENABLE_TAG_FLAGGING_NO; - - /** - * Always display the original images instead of the resampled versions
- * key: {@link #KEY_ALWAYS_ORIGINAL}
- * value: {@link #ALWAYS_ORIGINAL_YES}, {@link #ALWAYS_ORIGINAL_NO}
- * Silver Star or Hath Perk: Source Nexus Required - */ - public String alwaysOriginal = ALWAYS_ORIGINAL_NO; - - /** - * Enable the multi-Page Viewer
- * key: {@link #KEY_MULTI_PAGE}
- * value: {@link #MULTI_PAGE_YES}, {@link #MULTI_PAGE_NO}
- * Gold Star or Hath Perk: Multi-Page Viewer Required - */ - public String multiPage = MULTI_PAGE_NO; - - /** - * Multi-Page Viewer Display Style
- * key: {@link #KEY_MULTI_PAGE_STYLE}
- * value: {@link #MULTI_PAGE_STYLE_N}, {@link #MULTI_PAGE_STYLE_C}, - * {@link #MULTI_PAGE_STYLE_Y}
- * Gold Star or Hath Perk: Multi-Page Viewer Required - */ - public String multiPageStyle = MULTI_PAGE_STYLE_N; - - /** - * Multi-Page Viewer Thumbnail Pane
- * key: {@link #KEY_MULTI_PAGE_THUMB}
- * value: {@link #MULTI_PAGE_THUMB_SHOW}, {@link #MULTI_PAGE_THUMB_HIDE}
- * Gold Star or Hath Perk: Multi-Page Viewer Required - */ - public String multiPageThumb = MULTI_PAGE_THUMB_SHOW; - - /** - * Lofi resolution - * key: {@link #KEY_LOFI_RESOLUTION}
- * value: {@link #LOFI_RESOLUTION_460X}, {@link #LOFI_RESOLUTION_780X}, - * {@link #LOFI_RESOLUTION_980X} - */ - public String lofiResolution = LOFI_RESOLUTION_980X; - - /** - * Show content warning - * key: {@link #KEY_CONTENT_WARNING}
- * value: {@link #CONTENT_WARNING_SHOW}, {@link #CONTENT_WARNING_NOT_SHOW} - */ - public String contentWarning = CONTENT_WARNING_NOT_SHOW; - - private String mUconfig; - - private boolean mDirty = true; - - @Override - public EhConfig clone() { - try { - return (EhConfig) super.clone(); - } catch (CloneNotSupportedException e) { - throw new IllegalStateException(e); - } - } - - public synchronized void setDirty() { - mDirty = true; - } - - private void updateUconfig() { - String hahClientIpPort = (InetValidator.isValidInet4Address(hahClientIp) && - InetValidator.isValidInetPort(hahClientPort)) ? - hahClientIp + "%3A" + hahClientPort : ""; - String hahClientPasskey = null == this.hahClientPasskey ? "" : this.hahClientPasskey; - mUconfig = KEY_LOAD_FROM_HAH + "_" + loadFromHAH + "-" + - KEY_IMAGE_SIZE + "_" + imageSize + "-" + - KEY_SCALE_WIDTH + "_" + scaleWidth + "-" + - KEY_SCALE_HEIGHT + "_" + scaleHeight + "-" + - KEY_GALLERY_TITLE + "_" + galleryTitle + "-" + - KEY_ARCHIVER_DOWNLOAD + "_" + archiverDownload + "-" + - KEY_LAYOUT_MODE + "_" + layoutMode + "-" + - KEY_POPULAR + "_" + popular + "-" + - KEY_DEFAULT_CATEGORIES + "_" + defaultCategories + "-" + - KEY_FAVORITES_SORT + "_" + favoritesSort + "-" + - KEY_EXCLUDED_NAMESPACES + "_" + excludedNamespaces + "-" + - KEY_EXCLUDED_LANGUAGES + "_" + excludedLanguages + "-" + - KEY_RESULT_COUNT + "_" + resultCount + "-" + - KEY_MOUSE_OVER + "_" + mouseOver + "-" + - KEY_PREVIEW_SIZE + "_" + previewSize + "-" + - KEY_PREVIEW_ROW + "_" + previewRow + "-" + - KEY_COMMENTS_SORT + "_" + commentSort + "-" + - KEY_COMMENTS_VOTES + "_" + commentVotes + "-" + - KEY_TAGS_SORT + "_" + tagSort + "-" + - KEY_SHOW_GALLERY_INDEX + "_" + showGalleryIndex + "-" + - KEY_HAH_CLIENT_IP_PORT + "_" + hahClientIpPort + "-" + - KEY_HAH_CLIENT_PASSKEY + "_" + hahClientPasskey + "-" + - KEY_ENABLE_TAG_FLAGGING + "_" + enableTagFlagging + "-" + - KEY_ALWAYS_ORIGINAL + "_" + alwaysOriginal + "-" + - KEY_MULTI_PAGE + "_" + multiPage + "-" + - KEY_MULTI_PAGE_STYLE + "_" + multiPageStyle + "-" + - KEY_MULTI_PAGE_THUMB + "_" + multiPageThumb; - } - - public synchronized String uconfig() { - if (mDirty) { - mDirty = false; - updateUconfig(); - } - - return mUconfig; - } -} diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhCookieStore.kt b/app/src/main/java/com/hippo/ehviewer/client/EhCookieStore.kt index 61d736b3c..d4acab206 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhCookieStore.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhCookieStore.kt @@ -42,9 +42,11 @@ object EhCookieStore : CookieJar { const val KEY_IPB_MEMBER_ID = "ipb_member_id" const val KEY_IPB_PASS_HASH = "ipb_pass_hash" const val KEY_IGNEOUS = "igneous" + private const val KEY_CONTENT_WARNING = "nw" + private const val CONTENT_WARNING_NOT_SHOW = "1" private val sTipsCookie: Cookie = Cookie.Builder() - .name(EhConfig.KEY_CONTENT_WARNING) - .value(EhConfig.CONTENT_WARNING_NOT_SHOW) + .name(KEY_CONTENT_WARNING) + .value(CONTENT_WARNING_NOT_SHOW) .domain(EhUrl.DOMAIN_E) .path("/") .expiresAt(Long.MAX_VALUE) @@ -232,10 +234,7 @@ object EhCookieStore : CookieJar { // Add all but skip some for (cookie in cookies) { val name = cookie.name - if (EhConfig.KEY_CONTENT_WARNING == name) { - continue - } - if (EhConfig.KEY_UCONFIG == name) { + if (KEY_CONTENT_WARNING == name) { continue } result.add(cookie) diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhUtils.kt b/app/src/main/java/com/hippo/ehviewer/client/EhUtils.kt index 8a0e2c436..619f0f607 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhUtils.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhUtils.kt @@ -23,6 +23,17 @@ import java.util.regex.Pattern object EhUtils { const val NONE = -1 // Use it for homepage + const val MISC = 0x1 + const val DOUJINSHI = 0x2 + const val MANGA = 0x4 + const val ARTIST_CG = 0x8 + const val GAME_CG = 0x10 + const val IMAGE_SET = 0x20 + const val COSPLAY = 0x40 + const val ASIAN_PORN = 0x80 + const val NON_H = 0x100 + const val WESTERN = 0x200 + const val ALL_CATEGORY = 0x3ff const val PRIVATE = 0x400 const val UNKNOWN = 0x800 @@ -51,16 +62,16 @@ object EhUtils { ) private val CATEGORY_VALUES = hashMapOf( - EhConfig.MISC to arrayOf("misc"), - EhConfig.DOUJINSHI to arrayOf("doujinshi"), - EhConfig.MANGA to arrayOf("manga"), - EhConfig.ARTIST_CG to arrayOf("artistcg", "Artist CG Sets", "Artist CG"), - EhConfig.GAME_CG to arrayOf("gamecg", "Game CG Sets", "Game CG"), - EhConfig.IMAGE_SET to arrayOf("imageset", "Image Sets", "Image Set"), - EhConfig.COSPLAY to arrayOf("cosplay"), - EhConfig.ASIAN_PORN to arrayOf("asianporn", "Asian Porn"), - EhConfig.NON_H to arrayOf("non-h"), - EhConfig.WESTERN to arrayOf("western"), + MISC to arrayOf("misc"), + DOUJINSHI to arrayOf("doujinshi"), + MANGA to arrayOf("manga"), + ARTIST_CG to arrayOf("artistcg", "Artist CG Sets", "Artist CG"), + GAME_CG to arrayOf("gamecg", "Game CG Sets", "Game CG"), + IMAGE_SET to arrayOf("imageset", "Image Sets", "Image Set"), + COSPLAY to arrayOf("cosplay"), + ASIAN_PORN to arrayOf("asianporn", "Asian Porn"), + NON_H to arrayOf("non-h"), + WESTERN to arrayOf("western"), PRIVATE to arrayOf("private"), UNKNOWN to arrayOf("unknown") ) @@ -85,16 +96,16 @@ object EhUtils { fun getCategoryColor(category: Int): Int { return when (category) { - EhConfig.DOUJINSHI -> BG_COLOR_DOUJINSHI - EhConfig.MANGA -> BG_COLOR_MANGA - EhConfig.ARTIST_CG -> BG_COLOR_ARTIST_CG - EhConfig.GAME_CG -> BG_COLOR_GAME_CG - EhConfig.WESTERN -> BG_COLOR_WESTERN - EhConfig.NON_H -> BG_COLOR_NON_H - EhConfig.IMAGE_SET -> BG_COLOR_IMAGE_SET - EhConfig.COSPLAY -> BG_COLOR_COSPLAY - EhConfig.ASIAN_PORN -> BG_COLOR_ASIAN_PORN - EhConfig.MISC -> BG_COLOR_MISC + DOUJINSHI -> BG_COLOR_DOUJINSHI + MANGA -> BG_COLOR_MANGA + ARTIST_CG -> BG_COLOR_ARTIST_CG + GAME_CG -> BG_COLOR_GAME_CG + WESTERN -> BG_COLOR_WESTERN + NON_H -> BG_COLOR_NON_H + IMAGE_SET -> BG_COLOR_IMAGE_SET + COSPLAY -> BG_COLOR_COSPLAY + ASIAN_PORN -> BG_COLOR_ASIAN_PORN + MISC -> BG_COLOR_MISC else -> BG_COLOR_UNKNOWN }.toInt() } diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.kt b/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.kt index d211a43da..8a993f3be 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.kt @@ -18,7 +18,6 @@ package com.hippo.ehviewer.client.data import android.os.Parcelable import android.text.TextUtils import androidx.annotation.IntDef -import com.hippo.ehviewer.client.EhConfig import com.hippo.ehviewer.client.EhUrl import com.hippo.ehviewer.client.EhUtils import com.hippo.ehviewer.dao.QuickSearch @@ -161,48 +160,48 @@ data class ListUrlBuilder( val value = str.substring(index + 1) when (key) { "f_cats" -> { - val cats = NumberUtils.parseIntSafely(value, EhConfig.ALL_CATEGORY) - category = category or (cats.inv() and EhConfig.ALL_CATEGORY) + val cats = NumberUtils.parseIntSafely(value, EhUtils.ALL_CATEGORY) + category = category or (cats.inv() and EhUtils.ALL_CATEGORY) } "f_doujinshi" -> if ("1" == value) { - category = category or EhConfig.DOUJINSHI + category = category or EhUtils.DOUJINSHI } "f_manga" -> if ("1" == value) { - category = category or EhConfig.MANGA + category = category or EhUtils.MANGA } "f_artistcg" -> if ("1" == value) { - category = category or EhConfig.ARTIST_CG + category = category or EhUtils.ARTIST_CG } "f_gamecg" -> if ("1" == value) { - category = category or EhConfig.GAME_CG + category = category or EhUtils.GAME_CG } "f_western" -> if ("1" == value) { - category = category or EhConfig.WESTERN + category = category or EhUtils.WESTERN } "f_non-h" -> if ("1" == value) { - category = category or EhConfig.NON_H + category = category or EhUtils.NON_H } "f_imageset" -> if ("1" == value) { - category = category or EhConfig.IMAGE_SET + category = category or EhUtils.IMAGE_SET } "f_cosplay" -> if ("1" == value) { - category = category or EhConfig.COSPLAY + category = category or EhUtils.COSPLAY } "f_asianporn" -> if ("1" == value) { - category = category or EhConfig.ASIAN_PORN + category = category or EhUtils.ASIAN_PORN } "f_misc" -> if ("1" == value) { - category = category or EhConfig.MISC + category = category or EhUtils.MISC } "f_search" -> try { @@ -281,7 +280,7 @@ data class ListUrlBuilder( } val ub = UrlBuilder(url) if (this.category != EhUtils.NONE) { - ub.addQuery("f_cats", category.inv() and EhConfig.ALL_CATEGORY) + ub.addQuery("f_cats", category.inv() and EhUtils.ALL_CATEGORY) } mSHash?.let { ub.addQuery("f_shash", it) diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/DownloadFragment.java b/app/src/main/java/com/hippo/ehviewer/ui/fragment/DownloadFragment.java index 79501fdad..ca997846d 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/DownloadFragment.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/DownloadFragment.java @@ -63,13 +63,11 @@ public class DownloadFragment extends BasePreferenceFragment { addPreferencesFromResource(R.xml.download_settings); Preference mediaScan = findPreference(Settings.KEY_MEDIA_SCAN); - Preference imageResolution = findPreference(Settings.KEY_IMAGE_RESOLUTION); mDownloadLocation = findPreference(KEY_DOWNLOAD_LOCATION); onUpdateDownloadLocation(); mediaScan.setOnPreferenceChangeListener(this); - imageResolution.setOnPreferenceChangeListener(this); if (mDownloadLocation != null) { mDownloadLocation.setOnPreferenceClickListener(this); @@ -144,11 +142,6 @@ public class DownloadFragment extends BasePreferenceFragment { } } return true; - } else if (Settings.KEY_IMAGE_RESOLUTION.equals(key)) { - if (newValue instanceof String) { - Settings.putImageResolution((String) newValue); - } - return true; } return false; } diff --git a/app/src/main/java/com/hippo/ehviewer/widget/SearchLayout.kt b/app/src/main/java/com/hippo/ehviewer/widget/SearchLayout.kt index 10b741a40..a57a71fd1 100644 --- a/app/src/main/java/com/hippo/ehviewer/widget/SearchLayout.kt +++ b/app/src/main/java/com/hippo/ehviewer/widget/SearchLayout.kt @@ -42,7 +42,7 @@ import com.hippo.easyrecyclerview.EasyRecyclerView import com.hippo.easyrecyclerview.MarginItemDecoration import com.hippo.easyrecyclerview.SimpleHolder import com.hippo.ehviewer.R -import com.hippo.ehviewer.client.EhConfig +import com.hippo.ehviewer.client.EhUtils import com.hippo.ehviewer.client.data.ListUrlBuilder import com.hippo.ehviewer.client.exception.EhException import com.hippo.widget.RadioGridGroup @@ -94,7 +94,7 @@ class SearchLayout @JvmOverloads constructor( decoration.applyPaddings(this) // Create normal view mNormalView = mInflater.inflate(R.layout.search_normal, null) - val mCategoryStored = mSharePref.getInt(SEARCH_CATEGORY_PREF, EhConfig.ALL_CATEGORY) + val mCategoryStored = mSharePref.getInt(SEARCH_CATEGORY_PREF, EhUtils.ALL_CATEGORY) mCategoryGroup = mNormalView.findViewById(R.id.search_category_chipgroup) for (mPair in mCategoryTable) { val mChip = inflate(context, R.layout.filter_chip, null) as IdentifiedChip @@ -362,16 +362,16 @@ class SearchLayout @JvmOverloads constructor( 3, 2 ) private val mCategoryTable: ArrayList> = arrayListOf( - Pair(EhConfig.DOUJINSHI, R.string.doujinshi), - Pair(EhConfig.MANGA, R.string.manga), - Pair(EhConfig.ARTIST_CG, R.string.artist_cg), - Pair(EhConfig.GAME_CG, R.string.game_cg), - Pair(EhConfig.WESTERN, R.string.western), - Pair(EhConfig.NON_H, R.string.non_h), - Pair(EhConfig.IMAGE_SET, R.string.image_set), - Pair(EhConfig.COSPLAY, R.string.cosplay), - Pair(EhConfig.ASIAN_PORN, R.string.asian_porn), - Pair(EhConfig.MISC, R.string.misc) + Pair(EhUtils.DOUJINSHI, R.string.doujinshi), + Pair(EhUtils.MANGA, R.string.manga), + Pair(EhUtils.ARTIST_CG, R.string.artist_cg), + Pair(EhUtils.GAME_CG, R.string.game_cg), + Pair(EhUtils.WESTERN, R.string.western), + Pair(EhUtils.NON_H, R.string.non_h), + Pair(EhUtils.IMAGE_SET, R.string.image_set), + Pair(EhUtils.COSPLAY, R.string.cosplay), + Pair(EhUtils.ASIAN_PORN, R.string.asian_porn), + Pair(EhUtils.MISC, R.string.misc) ) private val SEARCH_ITEM_TYPE = arrayOf( intArrayOf(ITEM_TYPE_NORMAL, ITEM_TYPE_NORMAL_ADVANCE, ITEM_TYPE_ACTION), intArrayOf( diff --git a/app/src/main/res/xml/download_settings.xml b/app/src/main/res/xml/download_settings.xml index 712dbaa87..072a92bd8 100644 --- a/app/src/main/res/xml/download_settings.xml +++ b/app/src/main/res/xml/download_settings.xml @@ -57,15 +57,6 @@ app:entryValues="@array/preload_image_entry_values" app:iconSpaceReserved="false" /> - -