Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code optimization #962

Merged
merged 33 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e5999d2
Selecting a Backup Directory
maxiaoping Sep 22, 2022
e030f77
Add a folder backup module
maxiaoping Nov 11, 2022
a4dd5d3
The backup upload information is added to Settings
maxiaoping Dec 9, 2022
629c872
Update Select or cancel a backup folder
maxiaoping Jan 6, 2023
8c52068
Updating a backup folder
maxiaoping Jan 6, 2023
762fbbb
Updated the folder backup
maxiaoping Jan 6, 2023
04e0870
Update backup folder
maxiaoping Feb 1, 2023
0d2e842
update backup folder
maxiaoping Feb 1, 2023
f078f02
Updated folder backup and added global exception capture
maxiaoping Feb 8, 2023
ea8929a
Updated the backup folder name
maxiaoping Feb 10, 2023
c79956a
Folder backup reconstruction
maxiaoping Feb 11, 2023
793341d
Update folder backup
maxiaoping Feb 16, 2023
5fb7f9c
Updated the backup folder name
maxiaoping Feb 17, 2023
351d3cf
Update folder backup message notification
maxiaoping Feb 20, 2023
b4c6886
Update the display of folder backup status
maxiaoping Feb 25, 2023
7c07fcd
Update folder backup
maxiaoping Feb 25, 2023
1e1e1ac
Update folder backup
maxiaoping Feb 25, 2023
334f227
Update the folder backup logic
maxiaoping Feb 27, 2023
8a09388
Update the display of folder backup status
maxiaoping Mar 2, 2023
2eab112
Updated the folder backup and photo sync display status logic
maxiaoping Mar 2, 2023
1d18bbd
Update backup folder FileAlterationMonitor
maxiaoping Mar 2, 2023
114c7ba
Updated the folder backup interface
maxiaoping Mar 13, 2023
2d24915
Update folder backup observer
maxiaoping Mar 14, 2023
0ac4f40
Update the folder backup upload link
maxiaoping Mar 16, 2023
cbad36e
Update the folder backup transfer tag
maxiaoping Mar 16, 2023
e7bcfa7
Improve the code
zhwanng Mar 22, 2023
45075eb
Improve the code
zhwanng Mar 22, 2023
ebcc5e5
Fix and optimize
zhwanng Mar 23, 2023
b0ddbf4
Improve the code
zhwanng Mar 23, 2023
6a1c13e
Improve the code
zhwanng Mar 24, 2023
f8e8616
remove the leakcanary lib
zhwanng Mar 25, 2023
02a22f2
upgrade app version
zhwanng Mar 25, 2023
d79fbc8
Improvements, optimizations and fixes
zhwanng Mar 28, 2023
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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ debugkey.properties
# Misc
.DS_Store
app/seed.txt
app/map.txt
out/

*.store
*.jks

# keystore
.keystore
.store
seadroid-key

/build
13 changes: 10 additions & 3 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 126
versionName "2.3.0"
multiDexEnabled true
resValue "string", "authorities", applicationId + '.cameraupload.provider'
resValue "string", "account_type", "com.seafile.seadroid2.account.api2"
Expand Down Expand Up @@ -107,8 +107,10 @@ android {
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.android.support:design:${rootProject.ext.supportLibVersion}"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
implementation 'com.github.kevinsawicki:http-request:6.0'
implementation 'commons-io:commons-io:2.11.0'
Expand All @@ -124,11 +126,16 @@ 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
implementation 'com.github.tiagohm.MarkdownView:library:0.19.0'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'org.greenrobot:eventbus:3.3.1'
//glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
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=".folderbackup.FolderBackupConfigActivity"
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.folderbackup.FolderBackupService" > </service>
<service android:name="com.seafile.seadroid2.monitor.FileMonitorService" > </service>
<service android:name=".cameraupload.MediaObserverService" />

Expand Down
73 changes: 42 additions & 31 deletions app/src/main/java/com/seafile/seadroid2/SeadroidApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,38 @@

import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.fonts.MaterialCommunityModule;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.seafile.seadroid2.avatar.AuthImageDownloader;
import com.seafile.seadroid2.data.StorageManager;
import com.seafile.seadroid2.gesturelock.AppLockManager;
import com.seafile.seadroid2.ui.CustomNotificationBuilder;
import com.seafile.seadroid2.util.CrashHandler;
import com.seafile.seadroid2.util.Utils;

import java.io.File;

public class SeadroidApplication extends Application {
private static Context context;
private int waitingNumber;
private int totalNumber;
private int scanUploadStatus;
private static SeadroidApplication instance;
private int totalBackup;
private int waitingBackup;

public void onCreate() {
super.onCreate();
Iconify.with(new MaterialCommunityModule());
instance = this;
initImageLoader(getApplicationContext());
// initImageLoader(getApplicationContext());

// set gesture lock if available
AppLockManager.getInstance().enableDefaultAppLockIfAvailable(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
initNotificationChannel();
}

CrashHandler crashHandler = CrashHandler.getInstance();
crashHandler.init(this);
Utils.logPhoneModelInfo();


//
// com.blankj.utilcode.util.Utils.init(this);
}

@Override
Expand All @@ -58,26 +57,26 @@ public static SeadroidApplication getInstance() {
return instance;
}

public static void initImageLoader(Context context) {

File cacheDir = StorageManager.getInstance().getThumbnailsDir();
// This configuration tuning is custom. You can tune every option, you may tune some of them,
// or you can create default configuration by
// ImageLoaderConfiguration.createDefault(this);
// method.
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.diskCache(new UnlimitedDiscCache(cacheDir))
.threadPriority(Thread.NORM_PRIORITY - 2)
.denyCacheImageMultipleSizesInMemory()
.diskCacheFileNameGenerator(new Md5FileNameGenerator())
.diskCacheSize(50 * 1024 * 1024) // 50 Mb
.tasksProcessingOrder(QueueProcessingType.LIFO)
.imageDownloader(new AuthImageDownloader(context, 10000, 10000))
.writeDebugLogs() // Remove for release app
.build();
// Initialize ImageLoader with configuration.
ImageLoader.getInstance().init(config);
}
// public static void initImageLoader(Context context) {
//
// File cacheDir = StorageManager.getInstance().getThumbnailsDir();
// // This configuration tuning is custom. You can tune every option, you may tune some of them,
// // or you can create default configuration by
// // ImageLoaderConfiguration.createDefault(this);
// // method.
// ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
// .diskCache(new UnlimitedDiscCache(cacheDir))
// .threadPriority(Thread.NORM_PRIORITY - 2)
// .denyCacheImageMultipleSizesInMemory()
// .diskCacheFileNameGenerator(new Md5FileNameGenerator())
// .diskCacheSize(50 * 1024 * 1024) // 50 Mb
// .tasksProcessingOrder(QueueProcessingType.LIFO)
// .imageDownloader(new AuthImageDownloader(context, 10000, 10000))
// .writeDebugLogs() // Remove for release app
// .build();
// // Initialize ImageLoader with configuration.
// ImageLoader.getInstance().init(config);
// }

private void initNotificationChannel() {
String channelName = getString(R.string.channel_name_error);
Expand Down Expand Up @@ -125,4 +124,16 @@ public int getScanUploadStatus() {
return scanUploadStatus;
}

public int getTotalBackup() {
return totalBackup;
}

public int getWaitingBackup() {
return waitingBackup;
}

public void setFolderBackupNumber(int totalBackup, int waitingBackup) {
this.totalBackup = totalBackup;
this.waitingBackup = waitingBackup;
}
}
Loading