+ // Workaround 2.x bug (see https://github.com/owncloud/android/issues/716)\r
+ if ( Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB && \r
+ (System.currentTimeMillis() - time) > 24 * 60 * 60 * 1000 ) {\r
+ Date date = new Date(time);\r
+ date.setHours(0);\r
+ date.setMinutes(0);\r
+ date.setSeconds(0);\r
+ dateString = DateUtils.getRelativeDateTimeString(\r
+ c, date.getTime(), minResolution, transitionResolution, flags\r
+ );\r
+ } else {\r
+ dateString = DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags);\r
+ }\r
+ }\r
+ \r
+ return dateString.toString().split(",")[0];\r
+ }\r
+\r
+ /**\r
+ * Update the passed path removing the last "/" if it is not the root folder\r
+ * @param path\r
+ */\r
+ public static String getPathWithoutLastSlash(String path) {\r
+\r
+ // Remove last slash from path\r
+ if (path.length() > 1 && path.charAt(path.length()-1) == OCFile.PATH_SEPARATOR.charAt(0)) {\r
+ path = path.substring(0, path.length()-1);\r
+ }\r
+ return path;\r
+ }\r
+\r
+\r
+ /**\r
+ * Gets the screen size in pixels in a backwards compatible way\r
+ *\r
+ * @param caller Activity calling; needed to get access to the {@link android.view.WindowManager}\r
+ * @return Size in pixels of the screen, or default {@link Point} if caller is null\r
+ */\r
+ public static Point getScreenSize(Activity caller) {\r
+ Point size = new Point();\r
+ if (caller != null) {\r
+ Display display = caller.getWindowManager().getDefaultDisplay();\r
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {\r
+ display.getSize(size);\r
+ } else {\r
+ size.set(display.getWidth(), display.getHeight());\r
+ }\r
+ }\r
+ return size;\r
+ }\r
+\r
+ /**\r
+ * sets the coloring of the given progress bar to color_accent.\r
+ *\r
+ * @param progressBar the progress bar to be colored\r
+ */\r
+ public static void colorPreLollipopHorizontalProgressBar(ProgressBar progressBar) {\r
+ if (progressBar != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {\r
+ int color = progressBar.getResources().getColor(R.color.color_accent);\r
+ progressBar.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);\r
+ progressBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * sets the coloring of the given seek bar to color_accent.\r
+ *\r
+ * @param seekBar the seek bar to be colored\r
+ */\r
+ public static void colorPreLollipopHorizontalSeekBar(SeekBar seekBar) {\r
+ if (seekBar != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {\r
+ colorPreLollipopHorizontalProgressBar(seekBar);\r
+\r
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {\r
+ int color = seekBar.getResources().getColor(R.color.color_accent);\r
+ seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);\r
+ seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);\r
+ }\r