mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Resolves #3389 show complete date on click
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
a201dae5e2
commit
4ca0f921a7
2 changed files with 29 additions and 2 deletions
|
@ -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();
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue