Move AppConfig
This commit is contained in:
1 parent
fa8cd69bf5
commit
4e185a9b44
3 files changed
+52
-10
No files matched your search
+24
-7
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.util;
|
||||
package com.hippo.ehviewer;
|
||||
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -25,23 +25,40 @@ import java.io.File;
|
||||
*/
|
||||
public final class AppConfig {
|
||||
|
||||
private static final String APP_FOLDER_NAME = "EhViewer";
|
||||
private static final String APP_DIRNAME = "EhViewer";
|
||||
private static final String CRASH_DIRNAME = "crash";
|
||||
private static final String DOWNLOAD_DIRNAME = "download";
|
||||
private static final String TORRENT_DIRNAME = "torrent";
|
||||
|
||||
public static @Nullable File getAppFolder() {
|
||||
public static @Nullable
|
||||
File getAppDir() {
|
||||
if (Environment.getExternalStorageState()
|
||||
.equals(android.os.Environment.MEDIA_MOUNTED)) {
|
||||
return new File(Environment.getExternalStorageDirectory(), APP_FOLDER_NAME);
|
||||
.equals(Environment.MEDIA_MOUNTED)) {
|
||||
return new File(Environment.getExternalStorageDirectory(), APP_DIRNAME);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable File getFileInAppFolder(String filename) {
|
||||
File appFolder = getAppFolder();
|
||||
public static @Nullable File getFileInAppDir(String filename) {
|
||||
File appFolder = getAppDir();
|
||||
if (appFolder != null) {
|
||||
return new File(appFolder, filename);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable File getCrashDir() {
|
||||
return getFileInAppDir(CRASH_DIRNAME);
|
||||
}
|
||||
|
||||
public static @Nullable File getDownloadDir() {
|
||||
return getFileInAppDir(DOWNLOAD_DIRNAME);
|
||||
}
|
||||
|
||||
public static @Nullable File getTorrentDir() {
|
||||
return getFileInAppDir(TORRENT_DIRNAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.hippo.util;
|
||||
|
||||
import android.os.Process;
|
||||
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.BuildConfig;
|
||||
|
||||
import java.io.File;
|
||||
@@ -34,6 +35,7 @@ public class Log {
|
||||
private static final String TAG = Log.class.getSimpleName();
|
||||
|
||||
private static final String NO_MESSAGE = "No Message";
|
||||
private static final String LOG_FILENAME = "ehviewer.log";
|
||||
|
||||
private static final SaveLogThreadExecutor sSaveLogThreadPool;
|
||||
private static final Pool<SaveMsgTask> sSaveLogTaskPool;
|
||||
@@ -47,7 +49,7 @@ public class Log {
|
||||
sSaveLogThreadPool = new SaveLogThreadExecutor();
|
||||
sSaveLogTaskPool = new Pool<>(10);
|
||||
sDataFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.ENGLISH);
|
||||
sLogFile = AppConfig.getFileInAppFolder("ehviewer.log");
|
||||
sLogFile = AppConfig.getFileInAppDir(LOG_FILENAME);
|
||||
sSupportSaveLog = FileUtils.ensureFile(sLogFile);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user