Skip to content

Commit

Permalink
Code optimization (#962)
Browse files Browse the repository at this point in the history
* Selecting a Backup Directory

* Add a folder backup module

* The backup upload information is added to Settings

* Update Select or cancel a backup folder

* Updating a backup folder

* Updated the folder backup

* Update backup folder

* update backup folder

* Updated folder backup and added global exception capture

* Updated the backup folder name

* Folder backup reconstruction

* Update folder backup

* Updated the backup folder name

* Update folder backup message notification

* Update the display of folder backup status

* Update folder backup

* Update folder backup

* Update the folder backup logic

* Update the display of folder backup status

* Updated the folder backup and photo sync display status logic

* Update backup folder FileAlterationMonitor

* Updated the folder backup interface

* Update folder backup observer

* Update the folder backup upload link

* Update the folder backup transfer tag

* Improve the code

- Fix an issue: When select the root of the repo, the file upload fails
- Rename variables, classes, functions to make them more readable
- Format the code for some classes
- Format some UI layout code

* Improve the code

- Rename variables, classes, functions to make them more readable

* Fix and optimize

- FIX an issue: When no folder or library is selected, a crash occurs
- Optimize UI layout

* Improve the code

- A bug found, TODO has been marked

* Improve the code

* remove the leakcanary lib

* upgrade app version

- gitignore file adds ignore rules

* Improvements, optimizations and fixes

- Optimize AccountManager Class, add proxy implementation
- Optimize the Adapter of the three pages on the home page
- format code
- Optimize the UI of the star page and recently modified page
- Unified image loading framework
- Modify some strings, layout, dimens

---------

Co-authored-by: maxiaoping <634115572@qq.com>
  • Loading branch information
zhwanng and maxiaoping authored Mar 28, 2023
1 parent 485d05e commit 3a61a20
Show file tree
Hide file tree
Showing 122 changed files with 6,909 additions and 2,675 deletions.
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

0 comments on commit 3a61a20

Please sign in to comment.