From: tobiasKaminsky Date: Wed, 12 Nov 2014 08:02:23 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/develop' into beautifyTimestamps X-Git-Tag: oc-android-1.7.0_signed~108^2~2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/79cb6106fd3fc83aa84d18fb472788833b980ea8?ds=inline;hp=-c Merge remote-tracking branch 'upstream/develop' into beautifyTimestamps Conflicts: src/com/owncloud/android/utils/DisplayUtils.java --- 79cb6106fd3fc83aa84d18fb472788833b980ea8 diff --combined res/values/strings.xml index 65ffc63d,2655e29f..d8f1e930 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@@ -39,7 -39,9 +39,9 @@@ Recommend to a friend Feedback Imprint - + Remember share location + Remember last share upload location + "Try %1$s on your smartphone!" "I want to invite you to use %1$s on your smartphone!\nDownload here: %2$s" @@@ -60,7 -62,6 +62,7 @@@ No content was received. Nothing to upload. %1$s is not allowed to access the shared content Uploading + seconds ago Nothing in here. Upload something! Loading... There are no files in this folder. @@@ -280,6 -281,7 +282,7 @@@ An error occurred while waiting for the server, the operation couldn\'t have been done An error occurred while waiting for the server, the operation couldn\'t have been done The operation couldn\'t be completed, server is unavailable + You do not have permission %s @@@ -314,5 -316,4 +317,4 @@@ Instant Uploads Security - diff --combined src/com/owncloud/android/ui/adapter/FileListListAdapter.java index 8283f366,e002efb7..10356320 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@@ -29,7 -29,6 +29,7 @@@ import android.content.Context import android.content.SharedPreferences; import android.graphics.Bitmap; import android.preference.PreferenceManager; +import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@@ -47,7 -46,6 +47,7 @@@ import com.owncloud.android.datamodel.T import com.owncloud.android.datamodel.ThumbnailsCacheManager.AsyncDrawable; import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; import com.owncloud.android.files.services.FileUploader.FileUploaderBinder; +import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.activity.ComponentsGetter; import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.FileStorageUtils; @@@ -84,10 -82,11 +84,11 @@@ public class FileListListAdapter extend Context context, ComponentsGetter transferServiceGetter ) { - + mJustFolders = justFolders; mContext = context; mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext); + mTransferServiceGetter = transferServiceGetter; mAppPreferences = PreferenceManager @@@ -100,6 -99,7 +101,7 @@@ // initialise thumbnails cache on background thread new ThumbnailsCacheManager.InitDiskCacheTask().execute(); + } @Override @@@ -183,7 -183,9 +185,7 @@@ fileSizeV.setVisibility(View.VISIBLE); fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength())); lastModV.setVisibility(View.VISIBLE); - lastModV.setText( - DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()) - ); + lastModV.setText(showRelativeTimestamp(file)); // this if-else is needed even thoe fav icon is visible by default // because android reuses views in listview if (!file.keepInSync()) { @@@ -217,7 -219,7 +219,7 @@@ if (ThumbnailsCacheManager.cancelPotentialWork(file, fileIcon)) { final ThumbnailsCacheManager.ThumbnailGenerationTask task = new ThumbnailsCacheManager.ThumbnailGenerationTask( - fileIcon, mStorageManager + fileIcon, mStorageManager, mAccount ); if (thumbnail == null) { thumbnail = ThumbnailsCacheManager.mDefaultImg; @@@ -251,7 -253,9 +253,7 @@@ // } lastModV.setVisibility(View.VISIBLE); - lastModV.setText( - DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()) - ); + lastModV.setText(showRelativeTimestamp(file)); checkBoxV.setVisibility(View.GONE); view.findViewById(R.id.imageView3).setVisibility(View.GONE); @@@ -513,10 -517,5 +515,10 @@@ mSortAscending = ascending; sortDirectory(); - } + } + + private CharSequence showRelativeTimestamp(OCFile file){ + return DisplayUtils.getRelativeDateTimeString(mContext, file.getModificationTimestamp(), + DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0); + } } diff --combined src/com/owncloud/android/utils/DisplayUtils.java index 3d51f1f6,804a4dd0..cdd86836 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@@ -18,8 -18,7 +18,7 @@@ package com.owncloud.android.utils; - import java.sql.Time; - import java.text.SimpleDateFormat; + import java.net.IDN; import java.util.Arrays; import java.util.Calendar; import java.util.Date; @@@ -27,12 -26,11 +26,14 @@@ import java.util.HashMap import java.util.HashSet; import java.util.Set; + import android.annotation.TargetApi; +import android.content.Context; + import android.os.Build; +import android.text.format.DateFormat; +import android.text.format.DateUtils; + import com.owncloud.android.MainApp; import com.owncloud.android.R; - import com.owncloud.android.lib.common.utils.Log_OC; /** * A helper class for some string operations. @@@ -42,6 -40,8 +43,8 @@@ */ public class DisplayUtils { + private static final String OWNCLOUD_APP_NAME = "ownCloud"; + //private static String TAG = DisplayUtils.class.getSimpleName(); private static final String[] sizeSuffixes = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; @@@ -236,21 -236,42 +239,53 @@@ public static int getSeasonalIconId() { - if (Calendar.getInstance().get(Calendar.DAY_OF_YEAR) >= 354) { + if (Calendar.getInstance().get(Calendar.DAY_OF_YEAR) >= 354 && + MainApp.getAppContext().getString(R.string.app_name).equals(OWNCLOUD_APP_NAME)) { return R.drawable.winter_holidays_icon; } else { return R.drawable.icon; } } + /** + * Converts an internationalized domain name (IDN) in an URL to and from ASCII/Unicode. + * @param url the URL where the domain name should be converted + * @param toASCII if true converts from Unicode to ASCII, if false converts from ASCII to Unicode + * @return the URL containing the converted domain name + */ + @TargetApi(Build.VERSION_CODES.GINGERBREAD) + public static String convertIdn(String url, boolean toASCII) { + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { + // Find host name after '//' or '@' + int hostStart = 0; + if (url.indexOf("//") != -1) { + hostStart = url.indexOf("//") + "//".length(); + } else if (url.indexOf("@") != -1) { + hostStart = url.indexOf("@") + "@".length(); + } + + int hostEnd = url.substring(hostStart).indexOf("/"); + // Handle URL which doesn't have a path (path is implicitly '/') + hostEnd = (hostEnd == -1 ? url.length() : hostStart + hostEnd); + + String host = url.substring(hostStart, hostEnd); + host = (toASCII ? IDN.toASCII(host) : IDN.toUnicode(host)); + + return url.substring(0, hostStart) + host + url.substring(hostEnd); + } else { + return url; + } + } ++ + public static CharSequence getRelativeDateTimeString(Context c, long time, long minResolution, long transitionResolution, int flags){ + if (time > System.currentTimeMillis()){ + return DisplayUtils.unixTimeToHumanReadable(time); + } else if ((System.currentTimeMillis() - time) < 60000) { + return c.getString(R.string.file_list_seconds_ago) + ", " + + DateFormat.getTimeFormat(c).format(new Date(time)); + } else { + return DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags); + } + } }