From 4ca0f921a73d2ed2d94a8b5d22f95a96b4bde282 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 20 Dec 2018 11:01:13 +0100 Subject: [PATCH] Resolves #3389 show complete date on click Signed-off-by: Andy Scherzinger --- .../android/db/PreferenceManager.java | 9 ++++++++ .../ui/fragment/FileDetailFragment.java | 22 +++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/owncloud/android/db/PreferenceManager.java b/src/main/java/com/owncloud/android/db/PreferenceManager.java index f39b5bda07..5d42b7d1ff 100644 --- a/src/main/java/com/owncloud/android/db/PreferenceManager.java +++ b/src/main/java/com/owncloud/android/db/PreferenceManager.java @@ -47,6 +47,7 @@ public final class PreferenceManager { private static final String AUTO_PREF__UPLOAD_FILE_EXTENSION_URL = "prefs_upload_file_extension_url"; private static final String AUTO_PREF__UPLOADER_BEHAVIOR = "prefs_uploader_behaviour"; private static final String AUTO_PREF__GRID_COLUMNS = "grid_columns"; + private static final String AUTO_PREF__SHOW_DETAILED_TIMESTAMP = "detailed_timestamp"; public static final String AUTO_PREF__LAST_SEEN_VERSION_CODE = "lastSeenVersionCode"; private static final String PREF__INSTANT_UPLOADING = "instant_uploading"; private static final String PREF__INSTANT_VIDEO_UPLOADING = "instant_video_uploading"; @@ -541,6 +542,14 @@ public final class PreferenceManager { saveLongPreference(context, PREF__LOCK_TIMESTAMP, timestamp); } + public static boolean isShowDetailedTimestamp(Context context) { + return getDefaultSharedPreferences(context).getBoolean(AUTO_PREF__SHOW_DETAILED_TIMESTAMP, false); + } + + public static void setShowDetailedTimestamp(Context context, boolean showDetailedTimestamp) { + saveBooleanPreference(context, AUTO_PREF__SHOW_DETAILED_TIMESTAMP, showDetailedTimestamp); + } + private static void saveBooleanPreference(Context context, String key, boolean value) { SharedPreferences.Editor appPreferences = getDefaultSharedPreferences(context.getApplicationContext()).edit(); appPreferences.putBoolean(key, value).apply(); diff --git a/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java index 48bcf0afa2..c49c49c904 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -4,7 +4,7 @@ * @author Bartek Przybylski * @author David A. Velasco * @author Andy Scherzinger - * Copyright (C) 2011 Bartek Przybylski + * Copyright (C) 2011 Bartek Przybylski * Copyright (C) 2016 ownCloud Inc. * Copyright (C) 2018 Andy Scherzinger * @@ -44,6 +44,7 @@ import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.ThumbnailsCacheManager; +import com.owncloud.android.db.PreferenceManager; import com.owncloud.android.files.FileMenuFilter; import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; import com.owncloud.android.files.services.FileUploader.FileUploaderBinder; @@ -249,6 +250,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener cancelButton.setOnClickListener(this); favoriteIcon.setOnClickListener(this); overflowMenu.setOnClickListener(this); + fileModifiedTimestamp.setOnClickListener(this); updateFileDetails(false, false); } @@ -452,6 +454,11 @@ public class FileDetailFragment extends FileFragment implements OnClickListener onOverflowIconClicked(v); break; } + case R.id.modified: { + boolean flag = !PreferenceManager.isShowDetailedTimestamp(getContext()); + PreferenceManager.setShowDetailedTimestamp(getContext(), flag); + setFileModificationTimestamp(getFile(), flag); + } default: Log_OC.e(TAG, "Incorrect view clicked!"); break; @@ -508,7 +515,10 @@ public class FileDetailFragment extends FileFragment implements OnClickListener fileName.setVisibility(View.GONE); } fileSize.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength())); - fileModifiedTimestamp.setText(DisplayUtils.getRelativeTimestamp(getContext(), file.getModificationTimestamp())); + + boolean showDetailedTimestamp = PreferenceManager.isShowDetailedTimestamp(getContext()); + setFileModificationTimestamp(file, showDetailedTimestamp); + setFilePreview(file); setFavoriteIconStatus(file.isFavorite()); @@ -536,6 +546,14 @@ public class FileDetailFragment extends FileFragment implements OnClickListener getView().invalidate(); } + private void setFileModificationTimestamp(OCFile file, boolean showDetailedTimestamp) { + if (showDetailedTimestamp) { + fileModifiedTimestamp.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp())); + } else { + fileModifiedTimestamp.setText(DisplayUtils.getRelativeTimestamp(getContext(), file.getModificationTimestamp())); + } + } + private void setFavoriteIconStatus(boolean isFavorite) { if (isFavorite) { favoriteIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_star));