diff --git a/.idea/misc.xml b/.idea/misc.xml index 5f24a5e..e81aa36 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -34,10 +34,12 @@ + + diff --git a/app/build.gradle b/app/build.gradle index 8db0e34..6c93a7c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -44,7 +44,7 @@ def getVersionName(){ def hun = (version / 100).toInteger() def ten = (version / 10).toInteger() % 10 def one = version % 10 - return hun + "." + ten + "." + one + return hun + "." + ten + "." + one + "-beta" } def versionN = getVersionName() diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2b2234d..82d6116 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -131,6 +131,7 @@ + diff --git a/app/src/main/assets/updatelog.fy b/app/src/main/assets/updatelog.fy index 60536d3..82d4efb 100644 --- a/app/src/main/assets/updatelog.fy +++ b/app/src/main/assets/updatelog.fy @@ -1,10 +1,17 @@ +2022.03.04 +风月读书v2.4.0 +更新内容: +1、新增用户中心 +2、修复v2.3.9版本搜索界面书源分组显示错位的问题 + 2022.03.03 -风月读书v2.3.9 +风月读书v2.3.9-beta 更新内容: -1、新增书源订阅功能,移除内置书源,原内置书源界面改为订阅书源(注:订阅书源全部搜集自网络,每月更新) +1、新增书源订阅功能,移除内置书源,原内置书源界面改为订阅书源(订阅书源全部搜集自网络,每月更新) 2、新增去除广告功能 3、设置新增我的界面显示方式 4、修复已知bug +注:此为beta版本,可能存在未知bug 2022.02.23 风月读书v2.3.8 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 59bb823..3596ed7 100644 --- a/app/src/main/java/xyz/fycz/myreader/application/App.java +++ b/app/src/main/java/xyz/fycz/myreader/application/App.java @@ -95,7 +95,7 @@ public class App extends Application { initNightTheme(); // LLog.init(APPCONST.LOG_DIR); initDialogX(); - AdUtils.initAd(); + //AdUtils.initAd(); } diff --git a/app/src/main/java/xyz/fycz/myreader/base/BaseActivity.java b/app/src/main/java/xyz/fycz/myreader/base/BaseActivity.java index 1368a85..51371f3 100644 --- a/app/src/main/java/xyz/fycz/myreader/base/BaseActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/base/BaseActivity.java @@ -35,15 +35,18 @@ import xyz.fycz.myreader.util.utils.AdUtils; * @author fengyue * @date 2020/8/12 20:02 */ -public abstract class BaseActivity extends SwipeBackActivity { +public abstract class BaseActivity extends SwipeBackActivity { private static final int INVALID_VAL = -1; + protected VB binding; + protected static final String INTENT = "intent"; protected CompositeDisposable mDisposable; protected Toolbar mToolbar; + /****************************abstract area*************************************/ /** * 绑定视图 diff --git a/app/src/main/java/xyz/fycz/myreader/base/BaseTabActivity.java b/app/src/main/java/xyz/fycz/myreader/base/BaseTabActivity.java index 4a506d4..9340788 100644 --- a/app/src/main/java/xyz/fycz/myreader/base/BaseTabActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/base/BaseTabActivity.java @@ -17,7 +17,7 @@ import xyz.fycz.myreader.R; * @date 2020/8/12 20:02 */ -public abstract class BaseTabActivity extends BaseActivity { +public abstract class BaseTabActivity extends BaseActivity { /**************View***************/ protected TabLayout mTlIndicator; protected ViewPager mVp; diff --git a/app/src/main/java/xyz/fycz/myreader/common/APPCONST.java b/app/src/main/java/xyz/fycz/myreader/common/APPCONST.java index 9edbd16..58cd4e6 100644 --- a/app/src/main/java/xyz/fycz/myreader/common/APPCONST.java +++ b/app/src/main/java/xyz/fycz/myreader/common/APPCONST.java @@ -104,6 +104,8 @@ public class APPCONST { public static final int REQUEST_AUTH_EMAIL = 1016; public static final int REQUEST_SETTING = 1017; public static final int REQUEST_SUBSCRIBE = 1018; + public static final int REQUEST_LOGOUT = 1019; + public static final int REQUEST_RESET_PWD = 1020; public static final int REQUEST_READ = 1; diff --git a/app/src/main/java/xyz/fycz/myreader/common/URLCONST.java b/app/src/main/java/xyz/fycz/myreader/common/URLCONST.java index d36ab21..887f46b 100644 --- a/app/src/main/java/xyz/fycz/myreader/common/URLCONST.java +++ b/app/src/main/java/xyz/fycz/myreader/common/URLCONST.java @@ -26,9 +26,9 @@ public class URLCONST { public static final String FY_READER_URL = "https://fyreader." + getDefaultDomain(); - public static final String LOG_UPLOAD_URL = FY_READER_URL + "/logUpload"; - public static final String THANKS_URL = FY_READER_URL + "/thanks/"; public static final String USER_URL = "http://101.43.83.105:12123"; + public static final String LOG_UPLOAD_URL = USER_URL + "/do/logUpload"; + public static final String THANKS_URL = FY_READER_URL + "/thanks/"; public static final String AD_URL = USER_URL + "/do/ad"; public static final String DONATE = "https://gitee.com/fengyuecanzhu/Donate/raw/master"; diff --git a/app/src/main/java/xyz/fycz/myreader/entity/ad/AdConfig.java b/app/src/main/java/xyz/fycz/myreader/entity/ad/AdConfig.java index 8ace2e4..b5f4737 100644 --- a/app/src/main/java/xyz/fycz/myreader/entity/ad/AdConfig.java +++ b/app/src/main/java/xyz/fycz/myreader/entity/ad/AdConfig.java @@ -2,6 +2,8 @@ package xyz.fycz.myreader.entity.ad; import androidx.annotation.NonNull; +import com.google.gson.Gson; + import xyz.fycz.myreader.util.utils.GsonExtensionsKt; /** @@ -11,8 +13,10 @@ import xyz.fycz.myreader.util.utils.GsonExtensionsKt; public class AdConfig { //是否云控 private boolean isCloud; - //是否有广告 + //是否有广告(总开关) private boolean hasAd; + //是否有广告(用户) + private boolean userHasAd; //配置过期时间 private int expireTime; //应用处于后台一段时间展示开屏广告(单位:分钟) @@ -35,8 +39,10 @@ public class AdConfig { public AdConfig() { } - public AdConfig(boolean hasAd, int expireTime, int backAdTime, int intervalAdTime, int removeAdTime, int maxRemove, int totalRemove, boolean subSource) { + public AdConfig(boolean isCloud, boolean hasAd, boolean userHasAd, int expireTime, int backAdTime, int intervalAdTime, int removeAdTime, int maxRemove, int totalRemove, boolean subSource) { + this.isCloud = isCloud; this.hasAd = hasAd; + this.userHasAd = userHasAd; this.expireTime = expireTime; this.backAdTime = backAdTime; this.intervalAdTime = intervalAdTime; @@ -140,6 +146,14 @@ public class AdConfig { this.subSource = subSource; } + public boolean isUserHasAd() { + return userHasAd; + } + + public void setUserHasAd(boolean userHasAd) { + this.userHasAd = userHasAd; + } + @NonNull @Override public String toString() { diff --git a/app/src/main/java/xyz/fycz/myreader/model/user/User.java b/app/src/main/java/xyz/fycz/myreader/model/user/User.java index d61f5ff..c85ace4 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/user/User.java +++ b/app/src/main/java/xyz/fycz/myreader/model/user/User.java @@ -1,5 +1,9 @@ package xyz.fycz.myreader.model.user; +import androidx.annotation.NonNull; + +import xyz.fycz.myreader.util.utils.GsonExtensionsKt; + /** * @author fengyue * @date 2020/7/12 17:35 @@ -9,6 +13,9 @@ public class User { private String userName; private String password; private String email; + private String backupTime; + private String noAdTime; + private String noAdId; public User() { } @@ -35,6 +42,15 @@ public class User { this.email = email; } + public User(Integer userId, String userName, String password, String email, String backupTime, String noAdTime, String noAdId) { + this.userId = userId; + this.userName = userName; + this.password = password; + this.email = email; + this.backupTime = backupTime; + this.noAdTime = noAdTime; + this.noAdId = noAdId; + } public Integer getUserId() { return userId; @@ -67,4 +83,34 @@ public class User { public void setEmail(String email) { this.email = email; } + + public String getBackupTime() { + return backupTime; + } + + public void setBackupTime(String backupTime) { + this.backupTime = backupTime; + } + + public String getNoAdTime() { + return noAdTime; + } + + public void setNoAdTime(String noAdTime) { + this.noAdTime = noAdTime; + } + + public String getNoAdId() { + return noAdId; + } + + public void setNoAdId(String noAdId) { + this.noAdId = noAdId; + } + + @NonNull + @Override + public String toString() { + return GsonExtensionsKt.getGSON().toJson(this); + } } diff --git a/app/src/main/java/xyz/fycz/myreader/model/user/UserService.kt b/app/src/main/java/xyz/fycz/myreader/model/user/UserService.kt index 74caa55..edc4dfa 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/user/UserService.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/user/UserService.kt @@ -21,6 +21,7 @@ import xyz.fycz.myreader.util.utils.GSON import xyz.fycz.myreader.util.utils.OkHttpUtils import xyz.fycz.myreader.util.utils.RxUtils import java.io.File +import java.util.* /** * @author fengyue @@ -97,6 +98,42 @@ object UserService { }).compose { RxUtils.toSimpleSingle(it) } } + fun getInfo(user: User): Single { + return Single.create(SingleOnSubscribe { + val mediaType = "application/x-www-form-urlencoded".toMediaTypeOrNull() + val body = "username=${user.userName}" + + "&password=${user.password}" + + makeAuth() + val requestBody = body.toRequestBody(mediaType) + val ret = OkHttpUtils.getHtml(URLCONST.USER_URL + "/do/getInfo", requestBody, "UTF-8") + it.onSuccess(GSON.fromJson(ret, Result::class.java)) + }).compose { RxUtils.toSimpleSingle(it) } + } + + fun bindId(username: String): Single { + return Single.create(SingleOnSubscribe { + val mediaType = "application/x-www-form-urlencoded".toMediaTypeOrNull() + val body = "username=${username}" + + "&deviceId=${getUUID()}" + + makeAuth() + val requestBody = body.toRequestBody(mediaType) + val ret = OkHttpUtils.getHtml(URLCONST.USER_URL + "/do/bindId", requestBody, "UTF-8") + it.onSuccess(GSON.fromJson(ret, Result::class.java)) + }).compose { RxUtils.toSimpleSingle(it) } + } + + fun bindCammy(username: String, cammy: String): Single { + return Single.create(SingleOnSubscribe { + val mediaType = "application/x-www-form-urlencoded".toMediaTypeOrNull() + val body = "username=${username}" + + "&cammy=$cammy" + + makeAuth() + val requestBody = body.toRequestBody(mediaType) + val ret = OkHttpUtils.getHtml(URLCONST.USER_URL + "/do/bindCammy", requestBody, "UTF-8") + it.onSuccess(GSON.fromJson(ret, Result::class.java)) + }).compose { RxUtils.toSimpleSingle(it) } + } + fun webBackup(user: User): Single { return Backup.backup(App.getmContext(), APPCONST.FILE_DIR + "webBackup/") .flatMap(Function> { @@ -195,11 +232,22 @@ object UserService { return readConfig() != null } - public fun makeAuth(): String { + fun getUUID(): String { + val file = FileUtils.getFile(APPCONST.QQ_DATA_DIR + "monId") + var uuid = file.readText() + if (uuid.isEmpty()) { + uuid = UUID.randomUUID().toString() + file.writeText(uuid) + } + return uuid + } + + fun makeAuth(): String { return "&signal=" + AppInfoUtils.getSingInfo( App.getmContext(), App.getApplication().packageName, AppInfoUtils.SHA1 - ) + "&appVersion=" + App.getVersionCode() + "&isDebug=" + App.isDebug() + ) + "&appVersion=" + App.getVersionCode() + + "&deviceId=" + getUUID() + "&isDebug=" + App.isDebug() } } \ No newline at end of file diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java index 31cc541..7021226 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java @@ -40,8 +40,7 @@ import xyz.fycz.myreader.webapi.LanZouApi; * @author fengyue * @date 2020/9/18 22:21 */ -public class AboutActivity extends BaseActivity { - private ActivityAboutBinding binding; +public class AboutActivity extends BaseActivity { @Override protected void bindView() { 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 733270d..b74128b 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 @@ -27,9 +27,8 @@ import xyz.fycz.myreader.util.utils.FileUtils; * @author fengyue * @date 2021/4/23 12:51 */ -public class AdSettingActivity extends BaseActivity { +public class AdSettingActivity extends BaseActivity { - private ActivityAdSettingBinding binding; private LoadingDialog loadingDialog; private SharedPreUtils spu; private int curAdTimes; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/AuthEmailActivity.kt b/app/src/main/java/xyz/fycz/myreader/ui/activity/AuthEmailActivity.kt index 2d7a1d8..7b878a0 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/AuthEmailActivity.kt +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/AuthEmailActivity.kt @@ -30,9 +30,8 @@ import java.util.* * @author fengyue * @date 2021/12/9 15:20 */ -class AuthEmailActivity : BaseActivity(), SingleObserver { +class AuthEmailActivity : BaseActivity(), SingleObserver { - private lateinit var binding: ActivityAuthEmailBinding private var email = "" private var password = "" private var emailCode = "" diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java index 9b12af8..28948f5 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java @@ -73,9 +73,8 @@ import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; * @author fengyue * @date 2020/8/17 11:39 */ -public class BookDetailedActivity extends BaseActivity { +public class BookDetailedActivity extends BaseActivity { - private ActivityBookDetailBinding binding; private static final String TAG = BookDetailedActivity.class.getSimpleName(); private Book mBook; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookInfoEditActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookInfoEditActivity.java index 8c0691e..cb582a7 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookInfoEditActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookInfoEditActivity.java @@ -28,8 +28,7 @@ import xyz.fycz.myreader.webapi.crawler.ReadCrawlerUtil; * @author fengyue * @date 2021/4/24 15:05 */ -public class BookInfoEditActivity extends BaseActivity { - private ActivityBookInfoEditBinding binding; +public class BookInfoEditActivity extends BaseActivity { private Book mBook; private String imgUrl; private String bookName; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookSourceActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookSourceActivity.java index d094052..a01d29a 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookSourceActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookSourceActivity.java @@ -29,9 +29,8 @@ import xyz.fycz.myreader.ui.fragment.SubscribeSourceFragment; * @author fengyue * @date 2021/2/10 9:14 */ -public class BookSourceActivity extends BaseTabActivity { +public class BookSourceActivity extends BaseTabActivity { - private ActivityBooksourceBinding binding; private SearchView searchView; @Override 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 27c9cff..026d382 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 @@ -43,8 +43,7 @@ import xyz.fycz.myreader.webapi.crawler.find.QiDianMobileRank; * @author fengyue * @date 2020/9/13 21:11 */ -public class BookstoreActivity extends BaseActivity { - private ActiityBookstoreBinding binding; +public class BookstoreActivity extends BaseActivity { private FindCrawler3 findCrawler3; private LinearLayoutManager mLinearLayoutManager; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/CatalogActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/CatalogActivity.java index 81895c9..080ebbf 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/CatalogActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/CatalogActivity.java @@ -21,10 +21,8 @@ import xyz.fycz.myreader.ui.fragment.CatalogFragment; /** * 书籍目录activity */ -public class CatalogActivity extends BaseActivity { +public class CatalogActivity extends BaseActivity { - - private ActivityCatalogBinding binding; private SearchView searchView; private Book mBook; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/CrashActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/CrashActivity.java index 9edfbca..5b86eb7 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/CrashActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/CrashActivity.java @@ -39,9 +39,7 @@ import xyz.fycz.myreader.util.ToastUtils; * @author fengyue * @date 2022/1/22 9:15 */ -public class CrashActivity extends BaseActivity { - private ActivityCrashBinding binding; - +public class CrashActivity extends BaseActivity { /** * 报错代码行数正则表达式 */ diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/DonateActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/DonateActivity.java index dc28772..2190aa0 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/DonateActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/DonateActivity.java @@ -29,9 +29,8 @@ import xyz.fycz.myreader.util.utils.AdUtils; * @author fengyue * @date 2021/4/23 21:23 */ -public class DonateActivity extends BaseActivity { +public class DonateActivity extends BaseActivity { - private ActivityDonateBinding binding; private static final String TAG = DonateActivity.class.getSimpleName(); @Override diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/FeedbackActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/FeedbackActivity.java index ec5bd37..6593b58 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/FeedbackActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/FeedbackActivity.java @@ -20,9 +20,7 @@ import xyz.fycz.myreader.ui.dialog.DialogCreator; * @author fengyue * @date 2020/12/24 20:48 */ -public class FeedbackActivity extends BaseActivity { - - private ActivityFeedbackBinding binding; +public class FeedbackActivity extends BaseActivity { @Override protected void bindView() { diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/FileSystemActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/FileSystemActivity.java index a6faa06..c67daf7 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/FileSystemActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/FileSystemActivity.java @@ -29,11 +29,9 @@ import xyz.fycz.myreader.util.utils.FileUtils; * @date 2020/8/12 20:02 */ -public class FileSystemActivity extends BaseTabActivity { +public class FileSystemActivity extends BaseTabActivity { private static final String TAG = "FileSystemActivity"; - private ActivityFileSystemBinding binding; - private LocalBookFragment mLocalFragment; private FileCategoryFragment mCategoryFragment; private BaseFileFragment mCurFragment; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/FindBookActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/FindBookActivity.java index 5d62670..5b04d5b 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/FindBookActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/FindBookActivity.java @@ -35,8 +35,7 @@ import xyz.fycz.myreader.webapi.crawler.source.find.ThirdFindCrawler; * @author fengyue * @date 2021/7/21 20:10 */ -public class FindBookActivity extends BaseActivity { - private ActivityFindBookBinding binding; +public class FindBookActivity extends BaseActivity { private BookSource source; private FindCrawler findCrawler; private List groups; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/FontsActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/FontsActivity.java index b6ccddf..946de54 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/FontsActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/FontsActivity.java @@ -34,8 +34,7 @@ import static xyz.fycz.myreader.util.UriFileUtil.getPath; * @author fengyue * @date 2020/9/19 12:04 */ -public class FontsActivity extends BaseActivity { - private ActivityFontsBinding binding; +public class FontsActivity extends BaseActivity { private ArrayList mFonts; private FontsAdapter mFontsAdapter; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/GroupManagerActivity.kt b/app/src/main/java/xyz/fycz/myreader/ui/activity/GroupManagerActivity.kt index a514379..ab1a0ab 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/GroupManagerActivity.kt +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/GroupManagerActivity.kt @@ -25,8 +25,7 @@ import xyz.fycz.myreader.util.SharedPreUtils * @author fengyue * @date 2021/8/30 12:48 */ -class GroupManagerActivity : BaseActivity() { - private lateinit var binding: ActivityGroupManagerBinding +class GroupManagerActivity : BaseActivity() { private lateinit var adapter: BookGroupAdapter diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/LoginActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/LoginActivity.java index 443a108..9d64ac6 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/LoginActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/LoginActivity.java @@ -38,9 +38,8 @@ import xyz.fycz.myreader.util.utils.StringUtils; * @author fengyue * @date 2020/9/18 22:27 */ -public class LoginActivity extends BaseActivity implements TextWatcher { +public class LoginActivity extends BaseActivity implements TextWatcher { - private ActivityLoginBinding binding; private String code; private Disposable loginDisp; private LoadingDialog dialog; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java index f44213b..8579223 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java @@ -58,11 +58,9 @@ import static androidx.fragment.app.FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CU * @author fengyue * @date 2020/9/13 13:03 */ -public class MainActivity extends BaseActivity { +public class MainActivity extends BaseActivity { public static final String TAG = MainActivity.class.getSimpleName(); - private ActivityMainBinding binding; - private List mFragments = new ArrayList<>(); private String[] titles; private String groupName; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java index fcd40bf..9e205f9 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java @@ -63,9 +63,7 @@ import static xyz.fycz.myreader.common.APPCONST.BOOK_CACHE_PATH; * 阅读界面的更多设置 */ -public class MoreSettingActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener { - - private ActivityMoreSettingBinding binding; +public class MoreSettingActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener { private boolean needRefresh; private boolean upMenu; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/QRCodeScanActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/QRCodeScanActivity.java index 4cf585e..590be25 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/QRCodeScanActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/QRCodeScanActivity.java @@ -37,10 +37,7 @@ import static xyz.fycz.myreader.util.UriFileUtil.getPath; * @date 2020/11/30 8:31 */ -public class QRCodeScanActivity extends BaseActivity implements QRCodeView.Delegate { - - - private ActivityQrcodeCaptureBinding binding; +public class QRCodeScanActivity extends BaseActivity implements QRCodeView.Delegate { private final int REQUEST_QR_IMAGE = 202; private boolean flashlightIsOpen; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java index c965ff1..b490873 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java @@ -124,12 +124,9 @@ import static xyz.fycz.myreader.util.UriFileUtil.getPath; * @author fengyue * @date 2020/10/21 16:46 */ -public class ReadActivity extends BaseActivity implements ColorPickerDialogListener, View.OnTouchListener { +public class ReadActivity extends BaseActivity implements ColorPickerDialogListener, View.OnTouchListener { private static final String TAG = ReadActivity.class.getSimpleName(); - /*****************************View***********************************/ - private ActivityReadBinding binding; - /***************************variable*****************************/ private Book mBook; private List aBooks; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadRecordActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadRecordActivity.java index f6f4384..726b589 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadRecordActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadRecordActivity.java @@ -41,8 +41,7 @@ import xyz.fycz.myreader.widget.DividerItemDecoration; * @author fengyue * @date 2021/6/1 19:07 */ -public class ReadRecordActivity extends BaseActivity { - private ActivityReadRecordBinding binding; +public class ReadRecordActivity extends BaseActivity { private List records; private long allTime; private BaseListAdapter mAdapter; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/RegisterActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/RegisterActivity.java index 2b354a2..a064e7c 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/RegisterActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/RegisterActivity.java @@ -31,9 +31,7 @@ import xyz.fycz.myreader.util.utils.StringUtils; * @author fengyue * @date 2020/9/18 22:37 */ -public class RegisterActivity extends BaseActivity { - - private ActivityRegisterBinding binding; +public class RegisterActivity extends BaseActivity { private String code; private String username = ""; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/RemoveAdActivity.kt b/app/src/main/java/xyz/fycz/myreader/ui/activity/RemoveAdActivity.kt index 49832f8..4c031a8 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/RemoveAdActivity.kt +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/RemoveAdActivity.kt @@ -15,8 +15,7 @@ import xyz.fycz.myreader.util.utils.AdUtils * @author fengyue * @date 2022/3/3 17:04 */ -class RemoveAdActivity : BaseActivity() { - private lateinit var binding: ActivityRemoveAdBinding +class RemoveAdActivity : BaseActivity() { private var rewardLastTime = 0L override fun bindView() { diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReplaceRuleActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReplaceRuleActivity.java index 98b34cd..4e6bafa 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReplaceRuleActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReplaceRuleActivity.java @@ -59,9 +59,7 @@ import static xyz.fycz.myreader.util.UriFileUtil.getPath; * @author fengyue * @date 2021/1/19 10:02 */ -public class ReplaceRuleActivity extends BaseActivity { - - private ActivityReplaceRuleBinding binding; +public class ReplaceRuleActivity extends BaseActivity { private SearchView searchView; private List mReplaceRules; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/RestartActivity.kt b/app/src/main/java/xyz/fycz/myreader/ui/activity/RestartActivity.kt index 5d939a4..6367bd3 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/RestartActivity.kt +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/RestartActivity.kt @@ -13,7 +13,7 @@ import xyz.fycz.myreader.util.ToastUtils * @author fengyue * @date 2022/1/22 8:57 */ -class RestartActivity : BaseActivity() { +class RestartActivity : BaseActivity() { override fun bindView() {} companion object { 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 88404fe..e695dad 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 @@ -72,9 +72,7 @@ import xyz.fycz.myreader.widget.TagGroup; * @author fengyue * @date 2020/9/18 21:58 */ -public class SearchBookActivity extends BaseActivity { - - private ActivitySearchBookBinding binding; +public class SearchBookActivity extends BaseActivity { private SearchAdapter mSearchBookAdapter; private String searchKey;//搜索关键字 @@ -416,9 +414,10 @@ public class SearchBookActivity extends BaseActivity { if (menu == null) return; String searchGroup = SharedPreUtils.getInstance().getString("searchGroup"); menu.removeGroup(R.id.source_group); - MenuItem item = menu.add(R.id.source_group, Menu.NONE, Menu.NONE, R.string.all_source); + MenuItem first = menu.add(R.id.source_group, Menu.NONE, Menu.NONE, R.string.all_source); boolean hasChecked = false; List groupList = BookSourceManager.getEnableGroupList(); + MenuItem item; for (String groupName : groupList) { item = menu.add(R.id.source_group, Menu.NONE, Menu.NONE, groupName); if (groupName.equals(searchGroup)) { @@ -427,7 +426,7 @@ public class SearchBookActivity extends BaseActivity { } } if (!hasChecked || "".equals(searchGroup)) { - item.setChecked(true); + first.setChecked(true); } menu.setGroupCheckable(R.id.source_group, true, true); } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchWordActivity.kt b/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchWordActivity.kt index 85d2483..f6ef9fa 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchWordActivity.kt +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchWordActivity.kt @@ -31,9 +31,7 @@ import xyz.fycz.myreader.widget.page.PageLoader * @author fengyue * @date 2021/12/5 19:57 */ -class SearchWordActivity : BaseActivity() { - - private lateinit var binding: ActivitySearchWordBinding +class SearchWordActivity : BaseActivity() { private lateinit var book: Book private lateinit var chapters: List private lateinit var pageLoader: PageLoader diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceDebugActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceDebugActivity.java index 7e120e2..99c0067 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceDebugActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceDebugActivity.java @@ -60,9 +60,7 @@ import static xyz.fycz.myreader.util.utils.OkHttpUtils.getCookies; * @author fengyue * @date 2021/2/12 18:55 */ -public class SourceDebugActivity extends BaseActivity { - private ActivitySourceDebugBinding binding; - +public class SourceDebugActivity extends BaseActivity { private DebugEntity debugEntity; private ReadCrawler rc; private Disposable disposable; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceEditActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceEditActivity.java index 17fcb25..52b81ae 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceEditActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceEditActivity.java @@ -40,9 +40,7 @@ import xyz.fycz.myreader.webapi.crawler.source.MatcherCrawler; * @author fengyue * @date 2021/2/9 10:54 */ -public class SourceEditActivity extends BaseActivity { - private ActivitySourceEditBinding binding; - +public class SourceEditActivity extends BaseActivity { private BookSource source; private List sourceEntities; private List searchEntities; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceLoginActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceLoginActivity.java index 250a9f1..64df88f 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceLoginActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceLoginActivity.java @@ -24,8 +24,7 @@ import xyz.fycz.myreader.util.ToastUtils; * @author fengyue * @date 2021/5/15 10:43 */ -public class SourceLoginActivity extends BaseActivity { - private ActivitySourceLoginBinding binding; +public class SourceLoginActivity extends BaseActivity { private BookSource bookSource; private boolean checking = false; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceSubscribeActivity.kt b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceSubscribeActivity.kt index c5c34ff..c0a9eb5 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceSubscribeActivity.kt +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SourceSubscribeActivity.kt @@ -34,8 +34,7 @@ import xyz.fycz.myreader.webapi.LanZouApi * @author fengyue * @date 2022/3/3 9:56 */ -class SourceSubscribeActivity : BaseActivity() { - private lateinit var binding: ActivitySourceSubscribeBinding +class SourceSubscribeActivity : BaseActivity() { private lateinit var fileAdapter: BaseListAdapter private var page = 1 private var subscribeDis: Disposable? = null 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 ece65ba..c408ba0 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 @@ -43,12 +43,11 @@ import xyz.fycz.myreader.util.utils.MD5Utils; import xyz.fycz.myreader.util.utils.OkHttpUtils; import xyz.fycz.myreader.util.utils.SystemBarUtils; -public class SplashActivity extends BaseActivity { +public class SplashActivity extends BaseActivity { /*************Constant**********/ public static final String TAG = SplashActivity.class.getSimpleName(); public static int WAIT_INTERVAL = 0; - private ActivitySplashBinding binding; private SharedPreUtils spu; private int todayAdCount; private int adTimes; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/UserInfoActivity.kt b/app/src/main/java/xyz/fycz/myreader/ui/activity/UserInfoActivity.kt new file mode 100644 index 0000000..e31be74 --- /dev/null +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/UserInfoActivity.kt @@ -0,0 +1,227 @@ +package xyz.fycz.myreader.ui.activity + +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.view.View +import androidx.appcompat.widget.Toolbar +import io.reactivex.Single +import io.reactivex.SingleEmitter +import io.reactivex.disposables.Disposable +import org.jetbrains.anko.startActivityForResult +import xyz.fycz.myreader.R +import xyz.fycz.myreader.application.App +import xyz.fycz.myreader.base.BaseActivity +import xyz.fycz.myreader.base.adapter2.onClick +import xyz.fycz.myreader.base.observer.MySingleObserver +import xyz.fycz.myreader.common.APPCONST +import xyz.fycz.myreader.databinding.ActivityUserInfoBinding +import xyz.fycz.myreader.greendao.entity.rule.BookSource +import xyz.fycz.myreader.model.user.Result +import xyz.fycz.myreader.model.user.User +import xyz.fycz.myreader.model.user.UserService +import xyz.fycz.myreader.ui.dialog.LoadingDialog +import xyz.fycz.myreader.ui.dialog.MyAlertDialog +import xyz.fycz.myreader.util.ToastUtils +import xyz.fycz.myreader.util.utils.* + +/** + * @author fengyue + * @date 2022/3/4 18:38 + */ +class UserInfoActivity : BaseActivity() { + + private var user: User? = null + private lateinit var dialog: LoadingDialog + private var dis: Disposable? = null + + override fun bindView() { + binding = ActivityUserInfoBinding.inflate(layoutInflater) + setContentView(binding.root) + } + + override fun setUpToolbar(toolbar: Toolbar?) { + super.setUpToolbar(toolbar) + setStatusBarColor(R.color.colorPrimary, true) + supportActionBar?.title = getString(R.string.userinfo) + } + + override fun initData(savedInstanceState: Bundle?) { + dialog = LoadingDialog(this, "正在请求") { + dis?.dispose() + if (user == null || user?.email.isNullOrEmpty()) + finish() + } + initData() + } + + private fun initData() { + dialog.show() + user = UserService.readConfig() + if (user == null) { + ToastUtils.showWarring("用户未登录") + dialog.dismiss() + finish() + return + } + UserService.getInfo(user!!).subscribe(object : MySingleObserver() { + override fun onSubscribe(d: Disposable) { + addDisposable(d) + dis = d + } + + override fun onSuccess(t: Result) { + if (t.code < 200) { + user = GSON.fromJsonObject(GSON.toJson(t.result)) + dialog.dismiss() + initInfo() + } else { + ToastUtils.showError(t.result.toString()) + dialog.dismiss() + finish() + } + } + + override fun onError(e: Throwable) { + ToastUtils.showError("用户信息获取失败\n" + e.localizedMessage) + dialog.dismiss() + finish() + } + }) + } + + private fun initInfo() { + binding.tvUsername.text = user?.userName + binding.tvEmail.text = + StringUtils.getStarString2( + user?.email, 3, + user?.email!!.length - user?.email!!.indexOf("@") + ) + if (user?.backupTime.isNullOrEmpty()) { + binding.tvLastWebBackTime.text = "未同步" + } else { + binding.tvLastWebBackTime.text = user?.backupTime + } + if (user?.noAdTime.isNullOrEmpty()) { + binding.tvNoAdTime.text = "无记录" + } else { + binding.tvNoAdTime.text = user?.noAdTime + } + if (UserService.getUUID() == user?.noAdId) { + binding.tvNoAdDevice.text = "已绑定此设备" + } else { + binding.tvNoAdDevice.text = "点击绑定" + } + } + + override fun initWidget() { + AdUtils.checkHasAd(true, false) + .subscribe(object : MySingleObserver() { + override fun onSubscribe(d: Disposable) { + addDisposable(d) + } + + override fun onSuccess(t: Boolean) { + if (t) { + binding.llNoAdService.visibility = View.VISIBLE + } else { + binding.llNoAdService.visibility = View.GONE + } + } + + override fun onError(e: Throwable) { + binding.llNoAdService.visibility = View.GONE + } + }) + } + + override fun initClick() { + binding.rlResetPwd.onClick { + val intent = Intent(this, AuthEmailActivity::class.java) + startActivityForResult(intent, APPCONST.REQUEST_RESET_PWD) + } + + binding.rlNoAdDevice.onClick { + if (UserService.getUUID() != user?.noAdId) { + dialog.show() + UserService.bindId(user!!.userName) + .subscribe(object : MySingleObserver() { + override fun onSubscribe(d: Disposable) { + addDisposable(d) + dis = d + } + + override fun onSuccess(t: Result) { + if (t.code < 200) { + user?.noAdId = UserService.getUUID() + ToastUtils.showSuccess("设备绑定成功") + binding.tvNoAdDevice.text = "已绑定此设备" + } else { + ToastUtils.showError(t.result.toString()) + } + dialog.dismiss() + } + + override fun onError(e: Throwable) { + ToastUtils.showError("设备绑定失败\n" + e.localizedMessage) + dialog.dismiss() + } + }) + } + } + + binding.rlCammyEnter.onClick { + var cammy = "" + MyAlertDialog.createInputDia(this, getString(R.string.cammy_enter), + "请输入卡密", "", true, 25, { + cammy = it + }, { _, _ -> + dialog.show() + UserService.bindCammy(user?.userName!!, cammy) + .subscribe(object : MySingleObserver() { + override fun onSubscribe(d: Disposable) { + addDisposable(d) + dis = d + } + + override fun onSuccess(t: Result) { + if (t.code < 200) { + ToastUtils.showSuccess("卡密绑定成功,免广告服务重启后生效") + dialog.dismiss() + initData() + } else { + dialog.dismiss() + ToastUtils.showError(t.result.toString()) + } + } + + override fun onError(e: Throwable) { + ToastUtils.showError("卡密绑定成功\n" + e.localizedMessage) + dialog.dismiss() + } + }) + }) + } + + binding.tvLogout.onClick { + val file = App.getApplication().getFileStreamPath("userConfig.fy") + if (file.delete()) { + ToastUtils.showSuccess("退出成功") + setResult(Activity.RESULT_OK) + finish() + } else { + ToastUtils.showError("退出失败(Error:file.delete())") + } + } + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + if (resultCode == Activity.RESULT_OK){ + if (requestCode == APPCONST.REQUEST_RESET_PWD){ + binding.tvLogout.performClick() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java b/app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java index 0c88d40..1af9f1c 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java @@ -58,11 +58,14 @@ import xyz.fycz.myreader.ui.activity.MainActivity; import xyz.fycz.myreader.ui.activity.MoreSettingActivity; import xyz.fycz.myreader.ui.activity.ReadRecordActivity; import xyz.fycz.myreader.ui.activity.RemoveAdActivity; +import xyz.fycz.myreader.ui.activity.UserInfoActivity; import xyz.fycz.myreader.ui.dialog.DialogCreator; import xyz.fycz.myreader.ui.dialog.LoadingDialog; import xyz.fycz.myreader.util.SharedPreUtils; import xyz.fycz.myreader.util.ToastUtils; +import xyz.fycz.myreader.util.utils.AdUtils; import xyz.fycz.myreader.util.utils.NetworkUtils; +import xyz.fycz.myreader.util.utils.RxUtils; /** * @author fengyue @@ -141,6 +144,22 @@ public class MineFragment extends BaseFragment { } binding.tvThemeModeSelect.setText(themeModeArr[themeMode]); initShowMode(); + AdUtils.checkHasAd(true, true).compose(RxUtils::toSimpleSingle) + .subscribe(new MySingleObserver() { + @Override + public void onSuccess(@NonNull Boolean aBoolean) { + if (aBoolean && AdUtils.getAdConfig().getRemoveAdTime() > 0){ + binding.mineRlRemoveAd.setVisibility(View.VISIBLE); + }else { + binding.mineRlRemoveAd.setVisibility(View.GONE); + } + } + + @Override + public void onError(Throwable e) { + binding.mineRlRemoveAd.setVisibility(View.GONE); + } + }); } private void initShowMode() { @@ -170,19 +189,8 @@ public class MineFragment extends BaseFragment { super.initClick(); binding.mineRlUser.setOnClickListener(v -> { if (isLogin) { - DialogCreator.createCommonDialog(getActivity(), "退出登录", "确定要退出登录吗?" - , true, (dialog, which) -> { - File file = App.getApplication().getFileStreamPath("userConfig.fy"); - if (file.delete()) { - ToastUtils.showSuccess("退出成功"); - isLogin = false; - mHandler.sendEmptyMessage(1); - Intent intent = new Intent(getActivity(), LoginActivity.class); - getActivity().startActivityForResult(intent, APPCONST.REQUEST_LOGIN); - } else { - ToastUtils.showError("退出失败(Error:file.delete())"); - } - }, (dialog, which) -> dialog.dismiss()); + Intent intent = new Intent(getActivity(), UserInfoActivity.class); + startActivityForResult(intent, APPCONST.REQUEST_LOGOUT); } else { Intent intent = new Intent(getActivity(), LoginActivity.class); getActivity().startActivityForResult(intent, APPCONST.REQUEST_LOGIN); @@ -614,11 +622,11 @@ public class MineFragment extends BaseFragment { @Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { if (resultCode == RESULT_OK) { - if (data == null) { - return; - } switch (requestCode) { case APPCONST.REQUEST_LOGIN: + if (data == null) { + return; + } isLogin = data.getBooleanExtra("isLogin", false); user = UserService.INSTANCE.readConfig(); if (isLogin && user != null) { @@ -626,10 +634,17 @@ public class MineFragment extends BaseFragment { } break; case APPCONST.REQUEST_SETTING: + if (data == null) { + return; + } if (data.getBooleanExtra(APPCONST.RESULT_NEED_REFRESH, false)){ initShowMode(); } break; + case APPCONST.REQUEST_LOGOUT: + isLogin = false; + mHandler.sendEmptyMessage(1); + break; } } } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/fragment/SubscribeSourceFragment.kt b/app/src/main/java/xyz/fycz/myreader/ui/fragment/SubscribeSourceFragment.kt index defd55f..e54aaff 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/fragment/SubscribeSourceFragment.kt +++ b/app/src/main/java/xyz/fycz/myreader/ui/fragment/SubscribeSourceFragment.kt @@ -12,6 +12,7 @@ import io.reactivex.SingleEmitter import xyz.fycz.myreader.R import xyz.fycz.myreader.base.BaseFragment import xyz.fycz.myreader.base.adapter2.onClick +import xyz.fycz.myreader.base.adapter2.onLongClick import xyz.fycz.myreader.base.observer.MySingleObserver import xyz.fycz.myreader.common.APPCONST import xyz.fycz.myreader.databinding.FragmentSubscribeSourceBinding @@ -47,7 +48,7 @@ class SubscribeSourceFragment(private val sourceActivity: BookSourceActivity) : getSources() } - private fun getSources(){ + private fun getSources() { Single.create { emitter: SingleEmitter> -> emitter.onSuccess(BookSourceManager.getAllSubSource()) }.compose { RxUtils.toSimpleSingle(it) } @@ -79,6 +80,14 @@ class SubscribeSourceFragment(private val sourceActivity: BookSourceActivity) : //设置分割线 binding.recyclerView.addItemDecoration(DividerItemDecoration(context)) mAdapter?.refreshItems(mBookSources) + + if (mBookSources.isNullOrEmpty()) { + binding.llNoDataTips.visibility = View.VISIBLE + binding.recyclerView.visibility = View.GONE + } else { + binding.llNoDataTips.visibility = View.GONE + binding.recyclerView.visibility = View.VISIBLE + } } override fun initWidget(savedInstanceState: Bundle?) { @@ -87,9 +96,14 @@ class SubscribeSourceFragment(private val sourceActivity: BookSourceActivity) : override fun initClick() { super.initClick() + binding.ivNoDataTips.onClick { + binding.tvSubscribeSource.performClick() + } binding.tvSubscribeSource.onClick { - startActivityForResult(Intent(context, SourceSubscribeActivity::class.java), - APPCONST.REQUEST_SUBSCRIBE) + startActivityForResult( + Intent(context, SourceSubscribeActivity::class.java), + APPCONST.REQUEST_SUBSCRIBE + ) } binding.ivGroup.setOnClickListener { view: View? -> showSourceGroupMenu(view) @@ -101,7 +115,11 @@ class SubscribeSourceFragment(private val sourceActivity: BookSourceActivity) : featuresMenu?.show() } binding.tvSubscribeSourceTip.onClick { - MyAlertDialog.showTipDialogWithLink(context, getString(R.string.subscribe_source_tip), R.string.subscribe_source_detail_tip) + MyAlertDialog.showTipDialogWithLink( + context, + getString(R.string.subscribe_source_tip), + R.string.subscribe_source_detail_tip + ) } } @@ -111,7 +129,7 @@ class SubscribeSourceFragment(private val sourceActivity: BookSourceActivity) : private fun showSourceGroupMenu(view: View?) { val popupMenu = PopupMenu(sourceActivity, view, Gravity.END) val groupList = BookSourceManager.getGroupList(true) - popupMenu.menu.add(0, 0, 0, "所有书源") + popupMenu.menu.add(0, 0, 0, R.string.all_source) for (i in groupList.indices) { popupMenu.menu.add(0, 0, i + 1, groupList[i]) } 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 a27d1bc..0b937b2 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 @@ -30,6 +30,7 @@ import xyz.fycz.myreader.base.observer.MySingleObserver; import xyz.fycz.myreader.common.URLCONST; import xyz.fycz.myreader.entity.ad.AdBean; import xyz.fycz.myreader.entity.ad.AdConfig; +import xyz.fycz.myreader.model.user.User; import xyz.fycz.myreader.model.user.UserService; import xyz.fycz.myreader.util.SharedPreUtils; import xyz.fycz.myreader.util.ToastUtils; @@ -49,7 +50,7 @@ public class AdUtils { String config = getSp().getString("adConfig"); adConfig = GsonExtensionsKt.getGSON().fromJson(config, AdConfig.class); if (adConfig == null || adConfig.getBackAdTime() == 0) { - adConfig = new AdConfig(false, 60, 20, + adConfig = new AdConfig(false, false, false, 60, 20, 60, 6, 3, 48, true); } @@ -60,13 +61,23 @@ public class AdUtils { } public static Single checkHasAd() { - if (hasRemoveAdReward()) return Single.just(false); + return checkHasAd(false, true); + } + + public static Single checkHasAd(boolean noRemove, boolean isUser) { + if (!noRemove && hasRemoveAdReward()) return Single.just(false); initAd(); return Single.create((SingleOnSubscribe) emitter -> { boolean hasAd = false; if (!adConfig.isCloud() || isExpire()) { MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); String body = "type=adConfig" + UserService.INSTANCE.makeAuth(); + if (UserService.INSTANCE.isLogin()) { + User user = UserService.INSTANCE.readConfig(); + if (user != null) { + body += "&user=" + user.getUserName(); + } + } RequestBody requestBody = RequestBody.create(mediaType, body); String jsonStr = OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8"); try { @@ -81,7 +92,7 @@ public class AdUtils { String res = jsonObject.getString("result"); adConfig = GsonExtensionsKt.getGSON().fromJson(res, AdConfig.class); adConfig.setCloud(true); - hasAd = adConfig.isHasAd(); + hasAd = isUser ? adConfig.isUserHasAd() : adConfig.isHasAd(); getSp().putString("adConfig", res); getSp().putLong("adConfigTime", System.currentTimeMillis()); } @@ -90,7 +101,7 @@ public class AdUtils { e.printStackTrace(); } } else { - hasAd = adConfig.isHasAd(); + hasAd = isUser ? adConfig.isUserHasAd() : adConfig.isHasAd(); } emitter.onSuccess(hasAd); }).compose(RxUtils::toSimpleSingle); @@ -167,7 +178,7 @@ public class AdUtils { } public static boolean backSplashAd() { - if (!adConfig.isHasAd()) return false; + if (!adConfig.isUserHasAd()) return false; long splashAdTime = getSp().getLong("splashAdTime"); long backTime = getSp().getLong("backTime"); long currentTime = System.currentTimeMillis(); diff --git a/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java b/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java index 08d0de5..d79f9e7 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java +++ b/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java @@ -42,6 +42,7 @@ import xyz.fycz.myreader.greendao.entity.rule.BookSource; import xyz.fycz.myreader.greendao.service.CookieStore; import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeUrl; import xyz.fycz.myreader.model.third3.http.HttpHelperKt; +import xyz.fycz.myreader.model.user.UserService; import static xyz.fycz.myreader.util.help.SSLSocketClient.createSSLSocketFactory; import static xyz.fycz.myreader.util.help.SSLSocketClient.createTrustAllManager; @@ -333,7 +334,7 @@ public class OkHttpUtils { .build(); Request request = new Request.Builder() - .header("Authorization", "Client-ID " + UUID.randomUUID()) + .header("Authorization", "Client-ID " + UserService.INSTANCE.getUUID()) .url(url) .post(requestBody) .build(); diff --git a/app/src/main/java/xyz/fycz/myreader/util/utils/StringUtils.java b/app/src/main/java/xyz/fycz/myreader/util/utils/StringUtils.java index 0e6b014..d9d8408 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/utils/StringUtils.java +++ b/app/src/main/java/xyz/fycz/myreader/util/utils/StringUtils.java @@ -663,4 +663,55 @@ public class StringUtils { return bytes; } + /** + * 对字符串处理:将指定位置到指定位置的字符以星号代替 + * + * @param content 传入的字符串 + * @param begin 开始位置 + * @param end 结束位置 + * @return + */ + public static String getStarString(String content, int begin, int end) { + if (begin >= content.length() || begin < 0) { + return content; + } + if (end >= content.length() || end < 0) { + return content; + } + if (begin >= end) { + return content; + } + StringBuilder starStr = new StringBuilder(); + for (int i = begin; i < end; i++) { + starStr.append("*"); + } + return content.substring(0, begin) + starStr + content.substring(end, content.length()); + } + + /** + * 对字符加星号处理:除前面几位和后面几位外,其他的字符以星号代替 + * + * @param content 传入的字符串 + * @param frontNum 保留前面字符的位数 + * @param endNum 保留后面字符的位数 + * @return 带星号的字符串 + */ + public static String getStarString2(String content, int frontNum, int endNum) { + if (frontNum >= content.length() || frontNum < 0) { + return content; + } + if (endNum >= content.length() || endNum < 0) { + return content; + } + if (frontNum + endNum >= content.length()) { + return content; + } + StringBuilder starStr = new StringBuilder(); + for (int i = 0; i < (content.length() - frontNum - endNum); i++) { + starStr.append("*"); + } + return content.substring(0, frontNum) + starStr + + content.substring(content.length() - endNum, content.length()); + } + } diff --git a/app/src/main/res/layout/activity_source_subscribe.xml b/app/src/main/res/layout/activity_source_subscribe.xml index dc70fe9..82e2da7 100644 --- a/app/src/main/res/layout/activity_source_subscribe.xml +++ b/app/src/main/res/layout/activity_source_subscribe.xml @@ -7,6 +7,8 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_subscribe_source.xml b/app/src/main/res/layout/fragment_subscribe_source.xml index 62e2677..0909460 100644 --- a/app/src/main/res/layout/fragment_subscribe_source.xml +++ b/app/src/main/res/layout/fragment_subscribe_source.xml @@ -25,7 +25,7 @@ android:gravity="center_vertical" android:paddingStart="10dp" android:paddingEnd="10dp" - android:text="@string/subscribe_source" + android:text="@string/add_subscribe" android:textColor="@color/colorAccent" android:textSize="@dimen/text_small_size" /> @@ -72,15 +72,38 @@ android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/colorBackground" /> + + + + + + android:layout_height="match_parent" + android:background="@color/colorForeground" /> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 22ee29b..a373acc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -104,7 +104,6 @@ 更新日志 GitHub 分享崩溃日志 - 邮箱:fy@fycz.xyz https://github.com/fengyuecanzhu/FYReader 检查更新 致谢名单 @@ -435,6 +434,7 @@ 新建书源 导入书源 书源订阅 + 添加订阅 书源说明 订阅书源说明 取消全选 @@ -542,6 +542,17 @@ 隐藏用户及云服务 1、由于作者没时间维护内置书源导致大部分内置书源已经没法使用,故推出订阅书源 \n\n2、订阅书源全部搜集自网络,将会每月更新一次\n\n3、订阅书源目前处于测试阶段,如出现bug,请前往QQ频道或QQ群(1085028304)进行反馈 + 个人中心 + 用户名 + 邮箱 + 重置密码 + 上次同步时间 + 免广告到期时间 + 免广告设备绑定 + 基础服务 + 免广告服务 + 卡密输入 + 退出登录 diff --git a/app/version_code.properties b/app/version_code.properties index 5eb6ec4..4fa1152 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,3 +1,3 @@ #Fri Jun 18 21:45:31 CST 2021 -VERSION_CODE=239 +VERSION_CODE=240 NEED_CREATE_RELEASE=true