Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId 'com.seafile.seadroid2'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 123
versionName "2.2.48"
versionCode 125
versionName "2.2.50"
multiDexEnabled true
resValue "string", "authorities", applicationId + '.cameraupload.provider'
resValue "string", "account_type", "com.seafile.seadroid2.account.api2"
Expand Down Expand Up @@ -124,6 +124,12 @@ android {
implementation 'com.shuyu:gsyVideoPlayer-java:3.0.0'
implementation 'com.shuyu:gsyVideoPlayer-ex_so:3.0.0'
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
implementation 'com.github.getActivity:XXPermissions:16.2'
implementation 'io.reactivex.rxjava3:rxjava:3.1.5'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'
implementation 'com.google.code.gson:gson:2.10'



implementation 'com.yydcdut:markdown-processor:0.1.3'
implementation 'ren.qinc.edit:lib:0.0.5'//editor undo redo
Expand Down
3 changes: 3 additions & 0 deletions app/proguard-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
-dontoptimize
-dontpreverify

-keep class org.litepal.** {*;}
-keep class * extends org.litepal.crud.LitePalSupport {*;}

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
<!--<uses-permission android:name="android.permission.WRITE_CONTACTS"/>-->

<!--android 9.0 FOREGROUND_SERVICE -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_SYNC_STATS"/>


<application
Expand Down Expand Up @@ -125,9 +128,9 @@
</intent-filter>
</activity>

<activity android:name="com.seafile.seadroid2.ui.activity.SeafilePathChooserActivity"
android:label="@string/app_name">
</activity>
<activity
android:name="com.seafile.seadroid2.ui.activity.SeafilePathChooserActivity"
android:label="@string/app_name"></activity>

<activity android:name="com.seafile.seadroid2.ui.activity.FileActivity"
android:label="@string/app_name">
Expand Down Expand Up @@ -159,6 +162,9 @@
<activity android:name="com.seafile.seadroid2.cameraupload.CameraUploadConfigActivity"
android:label="@string/app_name">
</activity>
<activity android:name=".backupdirectory.DirectoryUploadConfigActivity"
android:label="@string/app_name">
</activity>
<!--<activity android:name="com.seafile.seadroid2.cameraupload.ContactsUploadConfigActivity"-->
<!--android:label="@string/app_name">-->
<!--</activity>-->
Expand Down Expand Up @@ -192,6 +198,7 @@
</intent-filter>
</provider>
<service android:name="com.seafile.seadroid2.transfer.TransferService" > </service>
<service android:name="com.seafile.seadroid2.backupdirectory.FileDirService" > </service>
<service android:name="com.seafile.seadroid2.monitor.FileMonitorService" > </service>
<service android:name=".cameraupload.MediaObserverService" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.seafile.seadroid2.ui.CustomNotificationBuilder;
import com.seafile.seadroid2.util.Utils;


import java.io.File;

public class SeadroidApplication extends Application {
Expand All @@ -40,7 +41,6 @@ public void onCreate() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
initNotificationChannel();
}

Utils.logPhoneModelInfo();
}

Expand Down
33 changes: 33 additions & 0 deletions app/src/main/java/com/seafile/seadroid2/SettingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ private SettingsManager() {
public static final String SHARED_PREF_CAMERA_UPLOAD_ACCOUNT_SERVER = PKG + ".camera.account.server";
public static final String SHARED_PREF_CAMERA_UPLOAD_ACCOUNT_TOKEN = PKG + ".camera.account.token";
public static final String CAMERA_UPLOAD_SWITCH_KEY = "camera_upload_switch_key";
public static final String DIRECTORY_UPLOAD_SWITCH_KEY = "directory_upload_switch_key";
public static final String CAMERA_UPLOAD_REPO_KEY = "camera_upload_repo_key";
public static final String CAMERA_UPLOAD_ADVANCED_SCREEN_KEY = "screen_camera_upload_advanced_feature";
public static final String CAMERA_UPLOAD_ADVANCED_CATEGORY_KEY = "category_camera_upload_advanced_key";
public static final String CAMERA_UPLOAD_ALLOW_DATA_PLAN_SWITCH_KEY = "allow_data_plan_switch_key";

public static final String CAMERA_UPLOAD_ALLOW_VIDEOS_SWITCH_KEY = "allow_videos_upload_switch_key";
public static final String CAMERA_UPLOAD_BUCKETS_KEY = "camera_upload_buckets_key";
public static final String CAMERA_UPLOAD_CATEGORY_KEY = "category_camera_upload_key";
Expand Down Expand Up @@ -102,6 +104,16 @@ private SettingsManager() {
public static final String PIC_CHECK_START = "pic_check_start";
public static final String UPLOAD_COMPLETED_TIME = "upload_completed_time";

//DirSyncStatus
public static final String DIR_UPLOAD_ALLOW_DATA_PLAN_SWITCH_KEY = "dir_allow_data_plan_switch_key";
public static final String DIR_AUTOMATIC_UPLOAD_SWITCH_KEY = "dir_automatic_upload_switch_key";
public static final String SAVE_BACKUP_ACCOUNT_EMAIL = "save_backup_account_email";
public static final String FOLDER_UPLOAD_CATEGORY_KEY = "file_directory_upload_key";
public static final String FOLDER_BACKUP_MODE = "folder_backup_mode";
public static final String FOLDER_BACKUP_LIBRARY = "folder_backup_library";
public static final String FOLDER_BACKUP_KEY = "folder_backup_key";
public static final String FOLDER_BACKUP_STATE = "folder_backup_state";

public static long lock_timestamp = 0;
public static final long LOCK_EXPIRATION_MSECS = 5 * 60 * 1000;

Expand Down Expand Up @@ -233,6 +245,9 @@ public boolean checkCameraUploadNetworkAvailable() {
public boolean isDataPlanAllowed() {
return settingsSharedPref.getBoolean(CAMERA_UPLOAD_ALLOW_DATA_PLAN_SWITCH_KEY, false);
}
public boolean isDirDataPlanAllowed() {
return settingsSharedPref.getBoolean(DIR_UPLOAD_ALLOW_DATA_PLAN_SWITCH_KEY, false);
}

public boolean isVideosUploadAllowed() {
return settingsSharedPref.getBoolean(CAMERA_UPLOAD_ALLOW_VIDEOS_SWITCH_KEY, false);
Expand All @@ -241,6 +256,16 @@ public boolean isVideosUploadAllowed() {
public void saveDataPlanAllowed(boolean isAllowed) {
settingsSharedPref.edit().putBoolean(CAMERA_UPLOAD_ALLOW_DATA_PLAN_SWITCH_KEY, isAllowed).commit();
}
public void saveDirDataPlanAllowed(boolean isAllowed) {
settingsSharedPref.edit().putBoolean(DIR_UPLOAD_ALLOW_DATA_PLAN_SWITCH_KEY, isAllowed).commit();
}

public void saveDirAutomaticUpload(boolean isAllowed) {
settingsSharedPref.edit().putBoolean(DIR_AUTOMATIC_UPLOAD_SWITCH_KEY, isAllowed).commit();
}
public boolean isDirAutomaticUpload() {
return settingsSharedPref.getBoolean(DIR_AUTOMATIC_UPLOAD_SWITCH_KEY, false);
}

public void saveVideosAllowed(boolean isVideosUploadAllowed) {
settingsSharedPref.edit().putBoolean(CAMERA_UPLOAD_ALLOW_VIDEOS_SWITCH_KEY, isVideosUploadAllowed).commit();
Expand Down Expand Up @@ -302,6 +327,14 @@ public void saveUploadCompletedTime(String completedTime) {
public String getUploadCompletedTime() {
return sharedPref.getString(SettingsManager.UPLOAD_COMPLETED_TIME, null);
}
public void saveBackupEmail(String path) {
editor.putString(SAVE_BACKUP_ACCOUNT_EMAIL, path);
editor.commit();
}

public String getBackupEmail() {
return sharedPref.getString(SettingsManager.SAVE_BACKUP_ACCOUNT_EMAIL, null);
}

public void savePrivacyPolicyConfirmed(int type) {
editor.putInt(PRIVACY_POLICY_CONFIRMED, type).commit();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
package com.seafile.seadroid2.backupdirectory;


import android.app.Activity;
import android.app.ProgressDialog;

import com.seafile.seadroid2.R;
import com.seafile.seadroid2.SeadroidApplication;
import com.seafile.seadroid2.util.Utils;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.schedulers.Schedulers;


public class BeanListManager {

public static final int TypeAddTabbar = 0;
public static final int TypeDelTabbar = 1;
public static final int TypeInitTabbar = 2;

public static void upDataFileBeanListByAsyn(Activity at, List<String> selectFilePath, List<FileBean> fileBeanList, FileListAdapter fileListAdapter, String path, List<String> fileTypes, int sortType) {

if (fileBeanList == null) {
fileBeanList = new ArrayList<>();
} else if (fileBeanList.size() != 0) {
fileBeanList.clear();
}

Observable
.just(fileBeanList)
.map(new Function<List<FileBean>, List<FileBean>>() {
@Override
public List<FileBean> apply(List<FileBean> fileBeanList) throws Throwable {
FileBean fileBean;
File file = FileTools.getFileByPath(path);
File[] files = file.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
fileBean = new FileBean(files[i].getAbsolutePath(), false);
if (selectFilePath != null && selectFilePath.size() > 0) {
for (String str : selectFilePath) {
if (fileBean.getFilePath().equals(str)) {
fileBean.setChecked(true);
}
}
}
fileBeanList.add(fileBean);
}
}
sortFileBeanList(fileBeanList, sortType);
return fileBeanList;
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<List<FileBean>>() {
public ProgressDialog pg;

@Override
public void onSubscribe(@NonNull Disposable d) {
pg = new ProgressDialog(at);
pg.show();

}

@Override
public void onNext(@NonNull List<FileBean> fileBeanList) {
if (fileListAdapter != null) {
fileListAdapter.updateListData(fileBeanList);
fileListAdapter.notifyDataSetChanged();
}
}

@Override
public void onError(@NonNull Throwable e) {
pg.dismiss();
}

@Override
public void onComplete() {
pg.dismiss();
}
});

}

public static void sortFileBeanList(List<FileBean> fileBeanList, int sortType) {
Collections.sort(fileBeanList, new Comparator<FileBean>() {
@Override
public int compare(FileBean o1, FileBean o2) {

if (o1.isDir() && o2.isFile())
return -1;
if (o1.isFile() && o2.isDir())
return 1;

switch (sortType) {
case Constants.SORT_NAME_ASC:
return o1.getFileName().compareToIgnoreCase(o2.getFileName());
case Constants.SORT_NAME_DESC:
return o2.getFileName().compareToIgnoreCase(o1.getFileName());
case Constants.SORT_TIME_ASC:
long diff = o1.getModifyTime() - o2.getModifyTime();
if (diff > 0)
return 1;
else if (diff == 0)
return 0;
else
return -1;
case Constants.SORT_TIME_DESC:
diff = o2.getModifyTime() - o1.getModifyTime();
if (diff > 0)
return 1;
else if (diff == 0)
return 0;
else
return -1;
case Constants.SORT_SIZE_ASC:
diff = o1.getSimpleSize() - o2.getSimpleSize();
if (diff > 0)
return 1;
else if (diff == 0)
return 0;
else
return -1;
case Constants.SORT_SIZE_DESC:
diff = o2.getSimpleSize() - o1.getSimpleSize();
if (diff > 0)
return 1;
else if (diff == 0)
return 0;
else
return -1;
default:
return 0;
}
}
});
}

public static void getTabbarFileBeanList(List<TabbarFileBean> tabbarList, String path, List<String> SdCardList) {
if (SdCardList.contains(path)) {
int i = SdCardList.indexOf(path);
if (i == 0) {
tabbarList.add(0, new TabbarFileBean(path, SeadroidApplication.getAppContext().getString(R.string.internal_storage), false, null));
} else if (i > 0) {
tabbarList.add(0, new TabbarFileBean(path, String.format("SD%d", i), false, null));
} else {
tabbarList.add(0, new TabbarFileBean(path, SeadroidApplication.getAppContext().getString(R.string.internal_storage_err), false, null));
}
return;
}
tabbarList.add(0, new TabbarFileBean(path, false));
getTabbarFileBeanList(tabbarList, FileTools.getParentPath(path), SdCardList);
}


public static List<TabbarFileBean> upDataTabbarFileBeanList(List<TabbarFileBean> tabbarList, TabbarFileListAdapter tabbarAdapter, String path, int type, List<String> SdCardList) {
switch (type) {
case TypeAddTabbar:
tabbarList.add(new TabbarFileBean(path, false));
break;
case TypeDelTabbar:
for (int i = tabbarList.size() - 1; i >= 0; i--) {
if (tabbarList.get(i).getFilePath().length() > path.length()) {
tabbarList.remove(i);
} else {
break;
}
}
break;
case TypeInitTabbar:
if (tabbarList == null) {
tabbarList = new ArrayList<>();
} else {
tabbarList.clear();
}
getTabbarFileBeanList(tabbarList, path, SdCardList);
break;
}

if (tabbarAdapter != null) {
tabbarAdapter.updateListData(tabbarList);
tabbarAdapter.notifyDataSetChanged();
}

return tabbarList;
}

}

Loading