Skip to content

Commit

Permalink
ModifyCachePath (#891)
Browse files Browse the repository at this point in the history
* Modify the local cache path

* Add mobile information collection

* Modify the log path and add the device log collection
  • Loading branch information
maxiaoping authored May 14, 2021
1 parent d965071 commit 6fc5e3f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 12 deletions.
6 changes: 3 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 110
versionName "2.2.35"
versionCode 111
versionName "2.2.36"
multiDexEnabled true
resValue "string", "authorities", applicationId + '.cameraupload.provider'
resValue "string", "account_type", "com.seafile.seadroid2.account.api2"
Expand Down Expand Up @@ -75,7 +75,7 @@ android {
}
release {
signingConfig signingConfigs.release
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
applicationVariants.all { variant ->
variant.outputs.all { output ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.seafile.seadroid2.data.StorageManager;
import com.seafile.seadroid2.gesturelock.AppLockManager;
import com.seafile.seadroid2.ui.CustomNotificationBuilder;
import com.seafile.seadroid2.util.Utils;

import java.io.File;

Expand All @@ -39,6 +40,8 @@ public void onCreate() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
initNotificationChannel();
}

Utils.logPhoneModelInfo();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ public final static StorageManager getInstance() {
private Location buildClassicLocation() {
Location classic = new Location();
classic.id = -1; // Android IDs start at 0. so "-1" is safe for us
String rootPath = SeadroidApplication.getAppContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
File[] externalMediaDirs = SeadroidApplication.getAppContext().getExternalMediaDirs();
String rootPath = externalMediaDirs[0].getAbsolutePath();
// String rootPath = SeadroidApplication.getAppContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
// classic.mediaPath = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Seafile/");
classic.mediaPath = new File(rootPath + "/Seafile/");
classic.cachePath = new File(classic.mediaPath, "cache");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ public static List<String> getAutoScannedPathList() {

List<String> pathList = Lists.newArrayList();
for (String path : paths) {
String rootPath = SeadroidApplication.getAppContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
File[] externalMediaDirs = SeadroidApplication.getAppContext().getExternalMediaDirs();
String rootPath = externalMediaDirs[0].getAbsolutePath();
// String rootPath = SeadroidApplication.getAppContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
// String fullPath = Utils.pathJoin(Environment.getExternalStorageDirectory().getAbsolutePath(), path);
String fullPath = Utils.pathJoin(rootPath, path);
pathList.add(fullPath);
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/seafile/seadroid2/util/GlideCache.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.seafile.seadroid2.util;

import android.content.Context;
import android.os.Environment;
import android.support.annotation.NonNull;

import com.bumptech.glide.GlideBuilder;
Expand All @@ -17,7 +16,9 @@ public class GlideCache extends AppGlideModule {
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
super.applyOptions(context, builder);
String rootPath = SeadroidApplication.getAppContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
// String rootPath = SeadroidApplication.getAppContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
File[] externalMediaDirs = SeadroidApplication.getAppContext().getExternalMediaDirs();
String rootPath = externalMediaDirs[0].getAbsolutePath();
File dirPath = new File(rootPath + "/GlideCache/");
builder.setDiskCache(new DiskLruCacheFactory(dirPath.getAbsolutePath(), 1024 * 1024 * 50));
}
Expand Down
22 changes: 19 additions & 3 deletions app/src/main/java/com/seafile/seadroid2/util/SeafileLog.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.seafile.seadroid2.util;

import android.content.Context;
import android.os.Environment;
import android.util.Log;

import com.seafile.seadroid2.SeadroidApplication;
Expand Down Expand Up @@ -95,7 +94,9 @@ private static void writeLogtoFile(String mylogtype, String tag, String text) {
String needWriteFile = logfile.format(nowtime);
String needWriteMessage = myLogSdf.format(nowtime) + " " + mylogtype + " " + tag + " " + text;
// File dirsFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Seafile/");
String rootPath = SeadroidApplication.getAppContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
// String rootPath = SeadroidApplication.getAppContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
File[] externalMediaDirs = SeadroidApplication.getAppContext().getExternalMediaDirs();
String rootPath = externalMediaDirs[0].getAbsolutePath();
File dirsFile = new File(rootPath + "/Seafile/");
if (!dirsFile.exists()) {
dirsFile.mkdirs();
Expand Down Expand Up @@ -125,7 +126,9 @@ private static void writeLogtoFile(String mylogtype, String tag, String text) {
*/
public static void delFile() {
String needDelFiel = logfile.format(getDateBefore());
String rootPath = SeadroidApplication.getAppContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
File[] externalMediaDirs = SeadroidApplication.getAppContext().getExternalMediaDirs();
String rootPath = externalMediaDirs[0].getAbsolutePath();
// String rootPath = SeadroidApplication.getAppContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
// File dirPath = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Seafile/");
File dirPath = new File(rootPath + "/Seafile/");
File file = new File(dirPath, needDelFiel + MYLOGFILENAME);// MYLOG_PATH_SDCARD_DIR
Expand All @@ -144,4 +147,17 @@ private static Date getDateBefore() {
now.set(Calendar.DATE, now.get(Calendar.DATE) - SDCARD_LOG_FILE_SAVE_DAYS);
return now.getTime();
}

public static String getDeviceBrand() {
return android.os.Build.BRAND;
}

public static String getSystemModel() {
return android.os.Build.MODEL;
}

public static String getSystemVersion() {
return android.os.Build.VERSION.RELEASE;
}

}
8 changes: 6 additions & 2 deletions app/src/main/java/com/seafile/seadroid2/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -983,10 +983,14 @@ public static String getRealPathFromURI(Context context, Uri contentUri, String
}
}

public static void logPhoneModelInfo() {
SeafileLog.d(DEBUG_TAG, "phoneModelInfo-------" + SeafileLog.getDeviceBrand() + "/" + SeafileLog.getSystemModel() + "/" + SeafileLog.getSystemVersion());
}

public static void utilsLogInfo(boolean b, String info) {
if (b) {
Log.d(DEBUG_TAG, info);
// SeafileLog.d(DEBUG_TAG, info);
// Log.d(DEBUG_TAG, info);
SeafileLog.d(DEBUG_TAG, info);
}
}
}
Expand Down

0 comments on commit 6fc5e3f

Please sign in to comment.