diff --git a/app/src/main/java/com/nmc/android/ui/utils/Log_NMC.kt b/app/src/main/java/com/nmc/android/ui/utils/Log_NMC.kt new file mode 100644 index 000000000000..e111bbd395a7 --- /dev/null +++ b/app/src/main/java/com/nmc/android/ui/utils/Log_NMC.kt @@ -0,0 +1,42 @@ +package com.nmc.android.ui.utils + +import com.owncloud.android.BuildConfig +import com.owncloud.android.lib.common.utils.Log_OC + +/** + * NMC log interpreter class + * this class will be used whenever we have to reduce the logs writing + * this will avoid printing logs in release builds + * todo: can be extended later for more functions + */ +object Log_NMC { + @JvmStatic + fun v(tag: String?, msg: String?) { + if (BuildConfig.DEBUG) Log_OC.v(tag, msg) + } + + @JvmStatic + fun d(tag: String?, msg: String?) { + if (BuildConfig.DEBUG) Log_OC.d(tag, msg) + } + + @JvmStatic + fun d(tag: String, msg: String, e: Exception) { + if (BuildConfig.DEBUG) Log_OC.d(tag, msg, e) + } + + @JvmStatic + fun i(tag: String?, msg: String?) { + if (BuildConfig.DEBUG) Log_OC.i(tag, msg) + } + + @JvmStatic + fun e(tag: String?, msg: String?) { + if (BuildConfig.DEBUG) Log_OC.e(tag, msg) + } + + @JvmStatic + fun w(tag: String?, msg: String?) { + if (BuildConfig.DEBUG) Log_OC.w(tag, msg) + } +} diff --git a/app/src/main/java/com/owncloud/android/datamodel/MediaProvider.java b/app/src/main/java/com/owncloud/android/datamodel/MediaProvider.java index c3dd31c29290..03e3e025e57f 100644 --- a/app/src/main/java/com/owncloud/android/datamodel/MediaProvider.java +++ b/app/src/main/java/com/owncloud/android/datamodel/MediaProvider.java @@ -12,8 +12,8 @@ import android.net.Uri; import android.provider.MediaStore; +import com.nmc.android.ui.utils.Log_NMC; import com.owncloud.android.MainApp; -import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.utils.PermissionUtil; import com.owncloud.android.utils.theme.ViewThemeUtils; @@ -107,7 +107,7 @@ public static List getImageFolders(ContentResolver contentResolver, MediaStore.Images.Media.DATE_TAKEN, ContentResolverHelper.SORT_DIRECTION_DESCENDING, itemLimit); - Log_OC.d(TAG, "Reading images for " + mediaFolder.folderName); + Log_NMC.d(TAG, "Reading images for " + mediaFolder.folderName); if (cursorImages != null) { String filePath; @@ -217,7 +217,7 @@ public static List getVideoFolders(ContentResolver contentResolver, ContentResolverHelper.SORT_DIRECTION_DESCENDING, itemLimit); - Log_OC.d(TAG, "Reading videos for " + mediaFolder.folderName); + Log_NMC.d(TAG, "Reading videos for " + mediaFolder.folderName); if (cursorVideos != null) { String filePath; diff --git a/app/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/app/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index 9bf6a7f7e9bd..2f5a532e06a8 100644 --- a/app/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/app/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -36,6 +36,7 @@ import com.nextcloud.client.account.User; import com.nextcloud.client.network.ConnectivityService; +import com.nmc.android.ui.utils.Log_NMC; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.lib.common.OwnCloudAccount; @@ -123,7 +124,7 @@ protected Void doInBackground(File... params) { } String cachePath = cacheDir.getPath() + File.separator + CACHE_FOLDER; - Log_OC.d(TAG, "thumbnail cache dir: " + cachePath); + Log_NMC.d(TAG, "thumbnail cache dir: " + cachePath); File diskCacheDir = new File(cachePath); // migrate from external cache to internal cache @@ -140,7 +141,7 @@ protected Void doInBackground(File... params) { mThumbnailCache = new DiskLruImageCache(diskCacheDir, DISK_CACHE_SIZE, mCompressFormat, mCompressQuality); } catch (Exception e) { - Log_OC.d(TAG, "Disk cache init failed", e); + Log_NMC.d(TAG, "Disk cache init failed", e); mThumbnailCache = null; } } @@ -723,7 +724,7 @@ private Bitmap doThumbnailFromOCFileInBackground() { file.getLocalId() + "&x=" + pxW + "&y=" + pxH; } - Log_OC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri); + Log_NMC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri); getMethod = new GetMethod(uri); getMethod.setRequestHeader("Cookie", "nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true"); @@ -756,7 +757,7 @@ private Bitmap doThumbnailFromOCFileInBackground() { // Add thumbnail to cache if (thumbnail != null) { - Log_OC.d(TAG, "add thumbnail to cache: " + file.getFileName()); + Log_NMC.d(TAG, "add thumbnail to cache: " + file.getFileName()); addBitmapToCache(imageKey, thumbnail); } } @@ -926,13 +927,13 @@ private Bitmap doFileInBackground(File file, Type type) { thumbnail = retriever.getFrameAtTime(-1); } catch (Exception ex) { // can't create a bitmap - Log_OC.w(TAG, "Failed to create bitmap from video " + file.getAbsolutePath()); + Log_NMC.w(TAG, "Failed to create bitmap from video " + file.getAbsolutePath()); } finally { try { retriever.release(); } catch (RuntimeException | IOException ex) { // Ignore failure at this point. - Log_OC.w(TAG, "Failed release MediaMetadataRetriever for " + file.getAbsolutePath()); + Log_NMC.w(TAG, "Failed release MediaMetadataRetriever for " + file.getAbsolutePath()); } } @@ -1051,7 +1052,7 @@ Drawable doAvatarInBackground() { int px = mResources.getInteger(R.integer.file_avatar_px); String uri = mClient.getBaseUri() + "/index.php/avatar/" + Uri.encode(mUserId) + "/" + px; - Log_OC.d("Avatar", "URI: " + uri); + Log_NMC.d("Avatar", "URI: " + uri); get = new GetMethod(uri); // only use eTag if available and corresponding avatar is still there @@ -1325,7 +1326,7 @@ public static void generateThumbnailFromOCFile(OCFile file, User user, Context c String uri = client.getBaseUri() + "/index.php/apps/files/api/v1/thumbnail/" + pxW + "/" + pxH + Uri.encode(file.getRemotePath(), "/"); - Log_OC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri); + Log_NMC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri); getMethod = new GetMethod(uri); getMethod.setRequestHeader("Cookie", "nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true"); @@ -1348,7 +1349,7 @@ public static void generateThumbnailFromOCFile(OCFile file, User user, Context c thumbnail = handlePNG(thumbnail, pxW, pxH); } - Log_OC.d(TAG, "add thumbnail to cache: " + file.getFileName()); + Log_NMC.d(TAG, "add thumbnail to cache: " + file.getFileName()); addBitmapToCache(imageKey, thumbnail); } } catch (Exception e) { @@ -1402,7 +1403,7 @@ private static Bitmap doResizedImageInBackground(OCFile file, FileDataStorageMan String uri = mClient.getBaseUri() + "/index.php/core/preview?fileId=" + file.getRemoteId() + "&x=" + (pxW / 2) + "&y=" + (pxH / 2) + "&a=1&mode=cover&forceIcon=0"; - Log_OC.d(TAG, "generate resized image: " + file.getFileName() + " URI: " + uri); + Log_NMC.d(TAG, "generate resized image: " + file.getFileName() + " URI: " + uri); getMethod = new GetMethod(uri); int status = mClient.executeMethod(getMethod); @@ -1420,7 +1421,7 @@ private static Bitmap doResizedImageInBackground(OCFile file, FileDataStorageMan // Add thumbnail to cache if (thumbnail != null) { - Log_OC.d(TAG, "add resized image to cache: " + file.getFileName()); + Log_NMC.d(TAG, "add resized image to cache: " + file.getFileName()); addBitmapToCache(imageKey, thumbnail); }