diff --git a/app/build.gradle b/app/build.gradle index 6c93a7c..6361f37 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -277,7 +277,7 @@ dependencies { } greendao { - schemaVersion 34 + schemaVersion 35 daoPackage 'xyz.fycz.myreader.greendao.gen' // targetGenDir 'src/main/java' } diff --git a/app/src/main/java/xyz/fycz/myreader/application/App.java b/app/src/main/java/xyz/fycz/myreader/application/App.java index 3596ed7..26778db 100644 --- a/app/src/main/java/xyz/fycz/myreader/application/App.java +++ b/app/src/main/java/xyz/fycz/myreader/application/App.java @@ -285,29 +285,28 @@ public class App extends Application { isForceUpdate = Boolean.parseBoolean(contents[1].substring(contents[1].indexOf(":") + 1)); downloadLink = contents[2].substring(contents[2].indexOf(":") + 1).trim(); updateContent = contents[3].substring(contents[3].indexOf(":") + 1); - SharedPreUtils spu = SharedPreUtils.getInstance(); - spu.putString(getmContext().getString(R.string.lanzousKeyStart), contents[4].substring(contents[4].indexOf(":") + 1)); + SharedPreUtils.getInstance().putString(getmContext().getString(R.string.lanzousKeyStart), contents[4].substring(contents[4].indexOf(":") + 1)); String newSplashTime = contents[5].substring(contents[5].indexOf(":") + 1); - String oldSplashTime = spu.getString("splashTime"); - spu.putBoolean("needUdSI", !oldSplashTime.equals(newSplashTime)); - spu.putString("splashTime", contents[5].substring(contents[5].indexOf(":") + 1)); - spu.putString("splashImageUrl", contents[6].substring(contents[6].indexOf(":") + 1)); - spu.putString("splashImageMD5", contents[7].substring(contents[7].indexOf(":") + 1)); + String oldSplashTime = SharedPreUtils.getInstance().getString("splashTime"); + SharedPreUtils.getInstance().putBoolean("needUdSI", !oldSplashTime.equals(newSplashTime)); + SharedPreUtils.getInstance().putString("splashTime", contents[5].substring(contents[5].indexOf(":") + 1)); + SharedPreUtils.getInstance().putString("splashImageUrl", contents[6].substring(contents[6].indexOf(":") + 1)); + SharedPreUtils.getInstance().putString("splashImageMD5", contents[7].substring(contents[7].indexOf(":") + 1)); forceUpdateVersion = Integer.parseInt(contents[8].substring(contents[8].indexOf(":") + 1)); - spu.putInt("forceUpdateVersion", forceUpdateVersion); + SharedPreUtils.getInstance().putInt("forceUpdateVersion", forceUpdateVersion); String domain = contents[9].substring(contents[9].indexOf(":") + 1); - spu.putString("domain", domain); + SharedPreUtils.getInstance().putString("domain", domain); int versionCode = getVersionCode(); isForceUpdate = isForceUpdate && forceUpdateVersion > versionCode; if (!StringHelper.isEmpty(downloadLink)) { - spu.putString(getmContext().getString(R.string.downloadLink), downloadLink); + SharedPreUtils.getInstance().putString(getmContext().getString(R.string.downloadLink), downloadLink); } else { - spu.putString(getmContext().getString(R.string.downloadLink), URLCONST.APP_DIR_URL); + SharedPreUtils.getInstance().putString(getmContext().getString(R.string.downloadLink), URLCONST.APP_DIR_URL); } String[] updateContents = updateContent.split("/"); for (String string : updateContents) { diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/http/HttpHelper.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/http/HttpHelper.kt index 50d7704..c311f50 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/http/HttpHelper.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/http/HttpHelper.kt @@ -1,5 +1,6 @@ package xyz.fycz.myreader.model.third3.http +import android.util.Log import okhttp3.ConnectionSpec import okhttp3.Credentials import okhttp3.Interceptor @@ -47,24 +48,31 @@ val okHttpClient: OkHttpClient by lazy { builder.build() } -val globalProxy by lazy { - val spu = SharedPreUtils.getInstance() - val type = if (spu.getInt("proxyType") == 0) { - "http" - } else { - "socks5" +val globalProxy: String + get() { + val enableProxy = SharedPreUtils.getInstance().getBoolean("enableProxy") + if (!enableProxy) { + return "" + } + val type = if (SharedPreUtils.getInstance().getInt("proxyType") == 0) { + "http" + } else { + "socks5" + } + val host = SharedPreUtils.getInstance().getString("proxyHost") + val port = SharedPreUtils.getInstance().getString("proxyPort") + val username = SharedPreUtils.getInstance().getString("proxyUsername") + val password = SharedPreUtils.getInstance().getString("proxyPassword") + return "$type://$host:$port@$username@$password" } - val host = spu.getString("proxyHost") - val port = spu.getString("proxyPort") - val username = spu.getString("proxyUsername") - val password = spu.getString("proxyPassword") - "$type://$host:$port@$username@$password" -} /** * 缓存代理okHttp */ -fun getProxyClient(proxy: String? = globalProxy, noProxy: Boolean = false): OkHttpClient { +fun getProxyClient(proxy0: String? = null, noProxy: Boolean = false): OkHttpClient { + var proxy = proxy0 + if (proxy.isNullOrEmpty()) proxy = globalProxy + Log.d("getProxyClient", "proxy=$proxy") if (proxy.isNullOrBlank() || noProxy) { return okHttpClient } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/AdSettingActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/AdSettingActivity.java index b74128b..2ba064b 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/AdSettingActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/AdSettingActivity.java @@ -30,7 +30,6 @@ import xyz.fycz.myreader.util.utils.FileUtils; public class AdSettingActivity extends BaseActivity { private LoadingDialog loadingDialog; - private SharedPreUtils spu; private int curAdTimes; private int curAdCount; private boolean bookDetailAd; @@ -51,9 +50,8 @@ public class AdSettingActivity extends BaseActivity { @Override protected void initData(Bundle savedInstanceState) { - spu = SharedPreUtils.getInstance(); - curAdTimes = spu.getInt("curAdTimes", 3); - String splashAdCount = spu.getString("splashAdCount"); + curAdTimes = SharedPreUtils.getInstance().getInt("curAdTimes", 3); + String splashAdCount = SharedPreUtils.getInstance().getString("splashAdCount"); String[] splashAdCounts = splashAdCount.split(":"); String today = DateHelper.getYearMonthDay1(); if (today.equals(splashAdCounts[0])){ @@ -61,7 +59,7 @@ public class AdSettingActivity extends BaseActivity { }else { curAdCount = 0; } - bookDetailAd = spu.getBoolean("bookDetailAd", false); + bookDetailAd = SharedPreUtils.getInstance().getBoolean("bookDetailAd", false); } @Override @@ -135,7 +133,7 @@ public class AdSettingActivity extends BaseActivity { .setTitle(getString(R.string.splash_ad_times)) .setSingleChoiceItems(adTimes, checked, (dialog, which) -> { curAdTimes = ints[which]; - spu.putInt("curAdTimes", curAdTimes); + SharedPreUtils.getInstance().putInt("curAdTimes", curAdTimes); binding.tvSplashCurAdTimes.setText(getString(R.string.splash_cur_ad_times, adTimes[which], curAdCount + "次")); dialog.dismiss(); }).setNegativeButton("取消", null).show();*/ @@ -143,7 +141,7 @@ public class AdSettingActivity extends BaseActivity { .setSelection(checked) .setOnMenuItemClickListener((dialog, text, which) -> { curAdTimes = ints[which]; - spu.putInt("curAdTimes", curAdTimes); + SharedPreUtils.getInstance().putInt("curAdTimes", curAdTimes); binding.tvSplashCurAdTimes.setText(getString(R.string.splash_cur_ad_times, adTimes[which], curAdCount + "次")); return false; }).setCancelButton(R.string.cancel); @@ -157,7 +155,7 @@ public class AdSettingActivity extends BaseActivity { }); binding.rlBookDetailAd.setOnClickListener(v -> { bookDetailAd = !bookDetailAd; - spu.putBoolean("bookDetailAd", bookDetailAd); + SharedPreUtils.getInstance().putBoolean("bookDetailAd", bookDetailAd); binding.scBookDetailAd.setChecked(bookDetailAd); }); binding.rlDeleteAdFile.setOnClickListener(v -> { diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookstoreActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookstoreActivity.java index 026d382..69cf4de 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookstoreActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookstoreActivity.java @@ -182,12 +182,11 @@ public class BookstoreActivity extends BaseActivity { super.processLogic(); getData(); if (findCrawler3.needSearch()) { - SharedPreUtils spu = SharedPreUtils.getInstance(); - boolean isReadTopTip = spu.getBoolean(getString(R.string.isReadTopTip), false); + boolean isReadTopTip = SharedPreUtils.getInstance().getBoolean(getString(R.string.isReadTopTip), false); if (!isReadTopTip) { DialogCreator.createCommonDialog(this, "提示", getResources().getString(R.string.top_sort_tip, title), true, "知道了", "不再提示", null, - (dialog, which) -> spu.putBoolean(getString(R.string.isReadTopTip), true)); + (dialog, which) -> SharedPreUtils.getInstance().putBoolean(getString(R.string.isReadTopTip), true)); } } } @@ -197,13 +196,12 @@ public class BookstoreActivity extends BaseActivity { */ private void getData() { if (findCrawler3 instanceof QiDianMobileRank) { - SharedPreUtils spu = SharedPreUtils.getInstance(); - if (spu.getString(getString(R.string.qdCookie), "").equals("")) { + if (SharedPreUtils.getInstance().getString(getString(R.string.qdCookie), "").equals("")) { ((QiDianMobileRank) findCrawler3).initCookie(this, new ResultCallback() { @Override public void onFinish(Object o, int code) { if (App.isDestroy(BookstoreActivity.this)) return; - spu.putString(getString(R.string.qdCookie), (String) o); + SharedPreUtils.getInstance().putString(getString(R.string.qdCookie), (String) o); mBookTypes = findCrawler3.getBookTypes(); initBooks(); } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchBookActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchBookActivity.java index e695dad..bc0f275 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchBookActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchBookActivity.java @@ -485,9 +485,8 @@ public class SearchBookActivity extends BaseActivity mHotKeys.addAll(Arrays.asList(suggestion)); initSuggestionList(); } else { - SharedPreUtils spu = SharedPreUtils.getInstance(); Single.create((SingleOnSubscribe) emitter -> { - String cookie = spu.getString(getString(R.string.qdCookie), ""); + String cookie = SharedPreUtils.getInstance().getString(getString(R.string.qdCookie), ""); String url = "https://m.qidian.com/majax/search/auto?kw=&"; if (cookie.equals("")) { cookie = "_csrfToken=eXRDlZxmRDLvFAmdgzqvwWAASrxxp2WkVlH4ZM7e; newstatisticUUID=1595991935_2026387981"; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java index c408ba0..8133206 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java @@ -48,7 +48,6 @@ public class SplashActivity extends BaseActivity { public static final String TAG = SplashActivity.class.getSimpleName(); public static int WAIT_INTERVAL = 0; - private SharedPreUtils spu; private int todayAdCount; private int adTimes; private boolean hasStart = false; @@ -137,9 +136,8 @@ public class SplashActivity extends BaseActivity { @Override protected void initData(Bundle savedInstanceState) { startToAd = getIntent().getBooleanExtra(INTENT_TO_AD, false); - spu = SharedPreUtils.getInstance(); - String splashAdCount = spu.getString("splashAdCount"); - adTimes = spu.getInt("curAdTimes", 3); + String splashAdCount = SharedPreUtils.getInstance().getString("splashAdCount"); + adTimes = SharedPreUtils.getInstance().getInt("curAdTimes", 3); String[] splashAdCounts = splashAdCount.split(":"); String today = DateHelper.getYearMonthDay1(); if (today.equals(splashAdCounts[0])) { @@ -374,6 +372,6 @@ public class SplashActivity extends BaseActivity { private void countTodayAd() { String today = DateHelper.getYearMonthDay1(); todayAdCount++; - spu.putString("splashAdCount", today + ":" + todayAdCount); + SharedPreUtils.getInstance().putString("splashAdCount", today + ":" + todayAdCount); } } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/dialog/BookGroupDialog.java b/app/src/main/java/xyz/fycz/myreader/ui/dialog/BookGroupDialog.java index ad9bc3d..d3f1836 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/dialog/BookGroupDialog.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/dialog/BookGroupDialog.java @@ -139,9 +139,8 @@ public class BookGroupDialog { mBookGroupService.addBookGroup(bookGroup); } else { mBookGroupService.updateEntity(bookGroup); - SharedPreUtils spu = SharedPreUtils.getInstance(); - if (spu.getString(mContext.getString(R.string.curBookGroupName), "").equals(oldName)) { - spu.putString(mContext.getString(R.string.curBookGroupName), newGroupName); + if (SharedPreUtils.getInstance().getString(mContext.getString(R.string.curBookGroupName), "").equals(oldName)) { + SharedPreUtils.getInstance().putString(mContext.getString(R.string.curBookGroupName), newGroupName); if (onGroup != null) onGroup.change(); } } @@ -172,10 +171,9 @@ public class BookGroupDialog { if (sb.length() > 0) { sb.deleteCharAt(sb.lastIndexOf("、")); } - SharedPreUtils spu = SharedPreUtils.getInstance(); - if (mBookGroupService.getGroupById(spu.getString(mContext.getString(R.string.curBookGroupId), "")) == null) { - spu.putString(mContext.getString(R.string.curBookGroupId), ""); - spu.putString(mContext.getString(R.string.curBookGroupName), ""); + if (mBookGroupService.getGroupById(SharedPreUtils.getInstance().getString(mContext.getString(R.string.curBookGroupId), "")) == null) { + SharedPreUtils.getInstance().putString(mContext.getString(R.string.curBookGroupId), ""); + SharedPreUtils.getInstance().putString(mContext.getString(R.string.curBookGroupName), ""); onGroup.change(); } ToastUtils.showSuccess("分组[" + sb.toString() + "]删除成功!"); diff --git a/app/src/main/java/xyz/fycz/myreader/ui/fragment/ProxyFragment.kt b/app/src/main/java/xyz/fycz/myreader/ui/fragment/ProxyFragment.kt index 6127f82..4323454 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/fragment/ProxyFragment.kt +++ b/app/src/main/java/xyz/fycz/myreader/ui/fragment/ProxyFragment.kt @@ -2,6 +2,7 @@ package xyz.fycz.myreader.ui.fragment import android.content.DialogInterface import android.os.Bundle +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -37,7 +38,6 @@ class ProxyFragment : BaseFragment() { private lateinit var proxyPassword: String private var mNoProxySourcesDia: AlertDialog? = null private val proxyTypeArr = arrayOf("http", "socks5") - private val spu: SharedPreUtils = SharedPreUtils.getInstance() override fun bindView(inflater: LayoutInflater, container: ViewGroup?): View { binding = FragmentProxySettingBinding.inflate(inflater, container, false) @@ -45,12 +45,13 @@ class ProxyFragment : BaseFragment() { } override fun initData(savedInstanceState: Bundle?) { - enableProxy = spu.getBoolean("enableProxy") - proxyType = spu.getInt("proxyType") - proxyHost = spu.getString("proxyHost") - proxyPort = spu.getString("proxyHost") - proxyUsername = spu.getString("proxyUsername") - proxyPassword = spu.getString("proxyPassword") + enableProxy = SharedPreUtils.getInstance().getBoolean("enableProxy") + Log.d("ProxyFragment", "enableProxy=$enableProxy") + proxyType = SharedPreUtils.getInstance().getInt("proxyType") + proxyHost = SharedPreUtils.getInstance().getString("proxyHost") + proxyPort = SharedPreUtils.getInstance().getString("proxyPort") + proxyUsername = SharedPreUtils.getInstance().getString("proxyUsername") + proxyPassword = SharedPreUtils.getInstance().getString("proxyPassword") } override fun initWidget(savedInstanceState: Bundle?) { @@ -58,16 +59,17 @@ class ProxyFragment : BaseFragment() { if (enableProxy) binding.llContent.visibility = View.VISIBLE binding.tvProxyType.text = proxyTypeArr[proxyType] binding.tvProxyHost.text = proxyHost.ifEmpty { "请输入代理服务器地址" } - binding.tvProxyPort.text = proxyHost.ifEmpty { "请输入代理服务器端口" } - binding.tvProxyUsername.text = proxyHost.ifEmpty { "请输入代理认证用户名" } - binding.tvProxyPassword.text = proxyHost.ifEmpty { "请输入代理认证密码" } + binding.tvProxyPort.text = proxyPort.ifEmpty { "请选择代理服务器端口" } + binding.tvProxyUsername.text = proxyUsername.ifEmpty { "请输入代理认证用户名" } + binding.tvProxyPassword.text = proxyPassword.ifEmpty { "请输入代理认证密码" } } override fun initClick() { binding.rlEnableProxy.onClick { enableProxy = !enableProxy binding.scEnableProxy.isChecked = enableProxy - spu.putBoolean("enableProxy", enableProxy) + SharedPreUtils.getInstance().putBoolean("enableProxy", enableProxy) + Log.d("ProxyFragment", "putBoolean=$enableProxy") binding.llContent.visibility = if (enableProxy) View.VISIBLE else View.GONE } @@ -90,7 +92,7 @@ class ProxyFragment : BaseFragment() { ) { dialog: DialogInterface, _: Int -> proxyHost = tem binding.tvProxyHost.text = proxyHost - spu.putString("proxyHost", proxyHost) + SharedPreUtils.getInstance().putString("proxyHost", proxyHost) dialog.dismiss() } } @@ -100,14 +102,14 @@ class ProxyFragment : BaseFragment() { val threadPick = view.findViewById(R.id.number_picker) threadPick.maxValue = 99999 threadPick.minValue = 10 - threadPick.value = proxyPort.toInt() + threadPick.value = if (proxyPort.isEmpty()) 1080 else proxyPort.toInt() threadPick.setOnScrollListener { _: NumberPicker?, _: Int -> } MyAlertDialog.build(context) .setTitle(R.string.proxy_port) .setView(view) .setPositiveButton(R.string.confirm) { _: DialogInterface?, _: Int -> proxyPort = threadPick.value.toString() - spu.putString("proxyPort", proxyPort) + SharedPreUtils.getInstance().putString("proxyPort", proxyPort) binding.tvProxyPort.text = proxyPort }.setNegativeButton(R.string.cancel, null) .show() @@ -121,7 +123,7 @@ class ProxyFragment : BaseFragment() { ) { dialog: DialogInterface, _: Int -> proxyUsername = tem binding.tvProxyUsername.text = proxyUsername - spu.putString("proxyUsername", proxyUsername) + SharedPreUtils.getInstance().putString("proxyUsername", proxyUsername) dialog.dismiss() } } @@ -134,7 +136,7 @@ class ProxyFragment : BaseFragment() { ) { dialog: DialogInterface, _: Int -> proxyPassword = tem binding.tvProxyPassword.text = proxyPassword - spu.putString("proxyPassword", proxyPassword) + SharedPreUtils.getInstance().putString("proxyPassword", proxyPassword) dialog.dismiss() } } diff --git a/app/src/main/java/xyz/fycz/myreader/util/SharedPreUtils.java b/app/src/main/java/xyz/fycz/myreader/util/SharedPreUtils.java index f2613cc..da2a5a0 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/SharedPreUtils.java +++ b/app/src/main/java/xyz/fycz/myreader/util/SharedPreUtils.java @@ -26,6 +26,7 @@ public class SharedPreUtils { }; } + //不能 public static SharedPreUtils getInstance() { return getInstance(false); } diff --git a/app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java b/app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java index 0b937b2..248c188 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java +++ b/app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java @@ -158,10 +158,9 @@ public class AdUtils { } public static boolean checkTodayShowAd() { - SharedPreUtils spu = SharedPreUtils.getInstance(); - String splashAdCount = spu.getString("splashAdCount"); - boolean bookDetailAd = spu.getBoolean("bookDetailAd", true); - int adTimes = spu.getInt("curAdTimes", 3); + String splashAdCount = SharedPreUtils.getInstance().getString("splashAdCount"); + boolean bookDetailAd = SharedPreUtils.getInstance().getBoolean("bookDetailAd", true); + int adTimes = SharedPreUtils.getInstance().getInt("curAdTimes", 3); String[] splashAdCounts = splashAdCount.split(":"); String today = DateHelper.getYearMonthDay1(); int todayAdCount; diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java b/app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java index f5ef2ce..fc18cf7 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java @@ -155,7 +155,6 @@ public class LanZousApi { } private static String getKey(String html) { - //SharedPreUtils spu = SharedPreUtils.getInstance(); String lanzousKeyStart = "var pposturl = '"; String keyName = StringHelper.getSubString(html, "'sign':", ","); if (keyName.endsWith("'")) { diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/ReadCrawlerUtil.java b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/ReadCrawlerUtil.java index 5b1411e..d6deac3 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/ReadCrawlerUtil.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/ReadCrawlerUtil.java @@ -41,21 +41,20 @@ public class ReadCrawlerUtil { } public static ArrayList getReadCrawlers() { - SharedPreUtils spu = SharedPreUtils.getInstance(); - String searchSource = spu.getString(App.getmContext().getString(R.string.searchSource), null); + String searchSource = SharedPreUtils.getInstance().getString(App.getmContext().getString(R.string.searchSource), null); ArrayList readCrawlers = new ArrayList<>(); if (searchSource == null) { StringBuilder sb = new StringBuilder(); for (LocalBookSource bookSource : LocalBookSource.values()) { if (bookSource.equals(LocalBookSource.fynovel) || bookSource.equals(LocalBookSource.local)) continue; - sb.append(bookSource.toString()); + sb.append(bookSource); sb.append(","); readCrawlers.add(getReadCrawler(bookSource.toString())); } sb.deleteCharAt(sb.lastIndexOf(",")); searchSource = sb.toString(); - spu.putString(App.getmContext().getString(R.string.searchSource), searchSource); + SharedPreUtils.getInstance().putString(App.getmContext().getString(R.string.searchSource), searchSource); } else if (!"".equals(searchSource)) { String[] sources = searchSource.split(","); for (String source : sources) { @@ -76,8 +75,7 @@ public class ReadCrawlerUtil { } public static HashMap getDisableSources() { - SharedPreUtils spu = SharedPreUtils.getInstance(); - String searchSource = spu.getString(App.getmContext().getString(R.string.searchSource), null); + String searchSource = SharedPreUtils.getInstance().getString(App.getmContext().getString(R.string.searchSource), null); HashMap mSources = new LinkedHashMap<>(); if (searchSource == null) { for (LocalBookSource bookSource : LocalBookSource.values()) { @@ -116,8 +114,7 @@ public class ReadCrawlerUtil { } public synchronized static void addReadCrawler(LocalBookSource... bookSources) { - SharedPreUtils spu = SharedPreUtils.getInstance(); - String searchSource = spu.getString(App.getmContext().getString(R.string.searchSource)); + String searchSource = SharedPreUtils.getInstance().getString(App.getmContext().getString(R.string.searchSource)); if ("".equals(searchSource)) { resetReadCrawlers(); return; @@ -131,8 +128,7 @@ public class ReadCrawlerUtil { } public synchronized static void removeReadCrawler(String... bookSources) { - SharedPreUtils spu = SharedPreUtils.getInstance(); - String searchSource = spu.getString(App.getmContext().getString(R.string.searchSource), null); + String searchSource = SharedPreUtils.getInstance().getString(App.getmContext().getString(R.string.searchSource), null); if (searchSource == null) { return; } @@ -153,7 +149,7 @@ public class ReadCrawlerUtil { sb.append(","); } sb.deleteCharAt(sb.lastIndexOf(",")); - spu.putString(App.getmContext().getString(R.string.searchSource), sb.toString()); + SharedPreUtils.getInstance().putString(App.getmContext().getString(R.string.searchSource), sb.toString()); } public static ReadCrawler getReadCrawler(String bookSource) { diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianFindCrawler.java b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianFindCrawler.java index 8bee38f..00701b3 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianFindCrawler.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianFindCrawler.java @@ -147,8 +147,7 @@ public class QiDianFindCrawler extends BaseFindCrawler { kind.setMaxPage(5); } url = url.replace("{sex}", !isFemale ? sex[0] : sex[1]); - SharedPreUtils spu = SharedPreUtils.getInstance(); - String cookie = spu.getString(App.getmContext().getString(R.string.qdCookie), ""); + String cookie = SharedPreUtils.getInstance().getString(App.getmContext().getString(R.string.qdCookie), ""); if (!cookie.equals("")) { url = url.replace("{cookie}", StringHelper.getSubString(cookie, "_csrfToken=", ";")); } else { diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianMobileRank.java b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianMobileRank.java index ec4b155..e3e6143 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianMobileRank.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianMobileRank.java @@ -144,8 +144,7 @@ public class QiDianMobileRank extends FindCrawler3 { url = sortUrl.replace("{catId}", sortName.get(name) + ""); } url = url.replace("{sex}", !isFemale ? sex[0] : sex[1]); - SharedPreUtils spu = SharedPreUtils.getInstance(); - String cookie = spu.getString(App.getmContext().getString(R.string.qdCookie), ""); + String cookie = SharedPreUtils.getInstance().getString(App.getmContext().getString(R.string.qdCookie), ""); if (!cookie.equals("")) { url = url.replace("{cookie}", StringHelper.getSubString(cookie, "_csrfToken=", ";")); } else { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bab8c2e..2676bd2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -570,7 +570,7 @@ 数据解析失败 - 代理设置 + 软件代理设置 设置软件及书源代理 代理类型 代理服务器地址