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'
// https://mvnrepository.com/artifact/net.lingala.zip4j/zip4j
implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.9.1'
}
greendao {

@ -29,7 +29,7 @@ public class URLCONST {
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 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";

@ -5,6 +5,8 @@ import io.reactivex.Single
import io.reactivex.SingleOnSubscribe
import io.reactivex.SingleSource
import io.reactivex.functions.Function
import net.lingala.zip4j.ZipFile
import net.lingala.zip4j.model.UnzipParameters
import okhttp3.MediaType
import okhttp3.RequestBody
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.RxUtils
import java.io.File
import net.lingala.zip4j.model.enums.EncryptionMethod
import net.lingala.zip4j.model.ZipParameters
/**
* @author fengyue
@ -100,10 +106,19 @@ object UserService2 {
.flatMap(Function<Boolean, SingleSource<Result>> {
Single.create {
val inputFile = FileUtils.getFile(APPCONST.FILE_DIR + "webBackup")
val zipFile = FileUtils.getFile(APPCONST.FILE_DIR + "webBackup.zip")
//压缩文件
ZipUtils.zipFile(inputFile, zipFile)
FileUtils.deleteFile(zipFile.absolutePath)
// ZipUtils.zipFile(inputFile, zipFile)
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(
URLCONST.USER_URL + "/do/bak?" +
"username=${user.userName}" +
@ -133,11 +148,13 @@ object UserService2 {
return@SingleOnSubscribe
}
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()
restore(APPCONST.FILE_DIR + "webBackup/", object : Restore.CallBack {
override fun restoreSuccess() {
FileUtils.deleteFile(zipFile.absolutePath)
FileUtils.deleteFile(APPCONST.FILE_DIR + "webBackup/")
it.onSuccess(Result(100, "成功从网络同步到本地"))
}

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

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

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

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

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

Loading…
Cancel
Save