master
fengyuecanzhu 3 years ago
parent 973d6552ce
commit 6cdc5effe0
  1. 4
      app/build.gradle
  2. 2
      app/src/main/java/xyz/fycz/myreader/common/URLCONST.java
  3. 27
      app/src/main/java/xyz/fycz/myreader/model/user/UserService2.kt
  4. 2
      app/src/main/java/xyz/fycz/myreader/ui/activity/LoginActivity.java
  5. 1
      app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java
  6. 1
      app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java
  7. 2
      app/src/main/java/xyz/fycz/myreader/util/help/JsExtensions.java
  8. 5
      app/src/main/res/layout/fragment_mine.xml

@ -238,6 +238,10 @@ dependencies {
} }
implementation 'com.nshmura:recyclertablayout:1.5.0' implementation 'com.nshmura:recyclertablayout:1.5.0'
// https://mvnrepository.com/artifact/net.lingala.zip4j/zip4j
implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.9.1'
} }
greendao { greendao {

@ -29,7 +29,7 @@ public class URLCONST {
public static final String AD_URL = FY_READER_URL + "/ad"; public static final String AD_URL = FY_READER_URL + "/ad";
public static final String LOG_UPLOAD_URL = FY_READER_URL + "/logUpload"; 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 THANKS_URL = FY_READER_URL + "/thanks/";
public static final String USER_URL = "https://user." + DEFAULT_DOMAIN; public static final String USER_URL = "http://101.43.83.105:12123";
public static final String DONATE = "https://gitee.com/fengyuecanzhu/Donate/raw/master"; public static final String DONATE = "https://gitee.com/fengyuecanzhu/Donate/raw/master";

@ -5,6 +5,8 @@ import io.reactivex.Single
import io.reactivex.SingleOnSubscribe import io.reactivex.SingleOnSubscribe
import io.reactivex.SingleSource import io.reactivex.SingleSource
import io.reactivex.functions.Function import io.reactivex.functions.Function
import net.lingala.zip4j.ZipFile
import net.lingala.zip4j.model.UnzipParameters
import okhttp3.MediaType import okhttp3.MediaType
import okhttp3.RequestBody import okhttp3.RequestBody
import xyz.fycz.myreader.application.App import xyz.fycz.myreader.application.App
@ -20,6 +22,10 @@ import xyz.fycz.myreader.util.utils.GSON
import xyz.fycz.myreader.util.utils.OkHttpUtils import xyz.fycz.myreader.util.utils.OkHttpUtils
import xyz.fycz.myreader.util.utils.RxUtils import xyz.fycz.myreader.util.utils.RxUtils
import java.io.File import java.io.File
import net.lingala.zip4j.model.enums.EncryptionMethod
import net.lingala.zip4j.model.ZipParameters
/** /**
* @author fengyue * @author fengyue
@ -100,10 +106,19 @@ object UserService2 {
.flatMap(Function<Boolean, SingleSource<Result>> { .flatMap(Function<Boolean, SingleSource<Result>> {
Single.create { Single.create {
val inputFile = FileUtils.getFile(APPCONST.FILE_DIR + "webBackup") val inputFile = FileUtils.getFile(APPCONST.FILE_DIR + "webBackup")
val zipFile = FileUtils.getFile(APPCONST.FILE_DIR + "webBackup.zip")
//压缩文件 //压缩文件
ZipUtils.zipFile(inputFile, zipFile) // ZipUtils.zipFile(inputFile, zipFile)
FileUtils.deleteFile(zipFile.absolutePath) val zipParameters = ZipParameters().apply {
isEncryptFiles = true
encryptionMethod = EncryptionMethod.AES
}
ZipFile(
APPCONST.FILE_DIR + "webBackup.zip",
CyptoUtils.decode(APPCONST.KEY, user.password).toCharArray()
)
.addFolder(inputFile, zipParameters)
val zipFile = FileUtils.getFile(APPCONST.FILE_DIR + "webBackup.zip")
FileUtils.deleteFile(inputFile.absolutePath)
val ret = OkHttpUtils.upload( val ret = OkHttpUtils.upload(
URLCONST.USER_URL + "/do/bak?" + URLCONST.USER_URL + "/do/bak?" +
"username=${user.userName}" + "username=${user.userName}" +
@ -133,11 +148,13 @@ object UserService2 {
return@SingleOnSubscribe return@SingleOnSubscribe
} }
if (FileUtils.writeFile(bytes, zipFile)) { if (FileUtils.writeFile(bytes, zipFile)) {
ZipUtils.unzipFile(zipFile.absolutePath, APPCONST.FILE_DIR) // ZipUtils.unzipFile(zipFile.absolutePath, APPCONST.FILE_DIR)
ZipFile(zipFile, CyptoUtils.decode(APPCONST.KEY, user.password).toCharArray())
.extractAll(APPCONST.FILE_DIR)
zipFile.delete() zipFile.delete()
restore(APPCONST.FILE_DIR + "webBackup/", object : Restore.CallBack { restore(APPCONST.FILE_DIR + "webBackup/", object : Restore.CallBack {
override fun restoreSuccess() { override fun restoreSuccess() {
FileUtils.deleteFile(zipFile.absolutePath) FileUtils.deleteFile(APPCONST.FILE_DIR + "webBackup/")
it.onSuccess(Result(100, "成功从网络同步到本地")) it.onSuccess(Result(100, "成功从网络同步到本地"))
} }

@ -16,6 +16,7 @@ import androidx.appcompat.widget.Toolbar;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import xyz.fycz.myreader.R; import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.base.BaseActivity; import xyz.fycz.myreader.base.BaseActivity;
import xyz.fycz.myreader.base.BitIntentDataManager; import xyz.fycz.myreader.base.BitIntentDataManager;
import xyz.fycz.myreader.base.observer.MySingleObserver; import xyz.fycz.myreader.base.observer.MySingleObserver;
@ -129,6 +130,7 @@ public class LoginActivity extends BaseActivity implements TextWatcher {
binding.btLogin.setEnabled(false); binding.btLogin.setEnabled(false);
dialog.dismiss(); dialog.dismiss();
createCaptcha(); createCaptcha();
if (App.isDebug()) e.printStackTrace();
} }
}); });
}); });

@ -528,6 +528,7 @@ public class MineFragment extends BaseFragment {
DialogCreator.createTipDialog(getContext(), "同步失败,请重试!\n" + e.getLocalizedMessage()); DialogCreator.createTipDialog(getContext(), "同步失败,请重试!\n" + e.getLocalizedMessage());
} }
dialog.dismiss(); dialog.dismiss();
if (App.isDebug()) e.printStackTrace();
} }
}); });
} }

@ -1010,6 +1010,7 @@ public class BookcasePresenter implements BasePresenter {
if (!isAutoSyn) { if (!isAutoSyn) {
DialogCreator.createTipDialog(mMainActivity, "同步失败,请重试!\n" + e.getLocalizedMessage()); DialogCreator.createTipDialog(mMainActivity, "同步失败,请重试!\n" + e.getLocalizedMessage());
} }
if (App.isDebug()) e.printStackTrace();
} }
}); });
} }

@ -35,8 +35,6 @@ import xyz.fycz.myreader.util.utils.StringUtils;
@Keep @Keep
@SuppressWarnings({"unused"}) @SuppressWarnings({"unused"})
public interface JsExtensions { public interface JsExtensions {
String TAG = JsExtensions.class.getSimpleName(); String TAG = JsExtensions.class.getSimpleName();

@ -45,6 +45,7 @@
app:tint="@color/textPrimary" app:tint="@color/textPrimary"
android:src="@drawable/ic_user" android:src="@drawable/ic_user"
/> />
<TextView <TextView
android:id="@+id/tv_user" android:id="@+id/tv_user"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -52,9 +53,9 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginStart="15dp" android:layout_marginStart="15dp"
android:layout_toEndOf="@id/iv_user" android:layout_toEndOf="@id/iv_user"
android:text="登录/注册"
android:textColor="@color/textSecondary" android:textColor="@color/textSecondary"
android:textSize="@dimen/text_medium_size" android:textSize="@dimen/text_normal_size" />
android:text="登录/注册"/>
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout

Loading…
Cancel
Save