Skip to content

Commit

Permalink
Squashed 'libs/utils/' changes from 4c6e8c9234..a15de7604a
Browse files Browse the repository at this point in the history
a15de7604a Merge pull request #25 from wordpress-mobile/deprecate-buggy-date-time-utils-methods
5026dc0904 Mark DateTimeUtils.localDateToUTC and DateTimeUtils.nowUTC as deprecated
58cd5bf239 Mark DateTimeUtils.localDateToUTC and DateTimeUtils.nowUTC as deprecated
4360e5d41f Merge pull request #23 from wordpress-mobile/update-bintray-config
48277981d8 Bump version to 1.23
81f224bd56 Fix Javadoc lint build error when releasing to Bintray
240f2492fa Update Bintray plugin to latest
b6abdcae2a Merge pull request #22 from wordpress-mobile/merge-wpa
8260cdce57 Update style and lint configs
7c08103ff2 Update Gradle wrapper version
9666183e69 Merge commit 'a4a756b60bcbf144ed8527f693c4e974fa6e365d' into subtree-updates-v3
cdeb3eb7f1 Merge pull request #9215 from wordpress-mobile/feature/update-support-lib-28
e8dbd8f404 Revert update of targetSdkVersion
f7014365ea Update supportLib version to 28.0.0
b3ad4c795e Fix low hanging deprecation warnings
b028488305 Remove all instances of LOCATION
bd194edb49 Merge pull request #9114 from wordpress-mobile/issue/8177-applog-testing
e081d898e7 Merge pull request #9044 from wordpress-mobile/gradle-4-10
2ba6f52024 Move fake AppLog(the one for testing) from utils to the main project
3f74b509d0 Create copy of AppLog for unit testing purposes
78d9bfbf13 fixed merge conflict
b3b6665bfd fixed merge conflict
c2fa689153 Update to Gradle 4.10.3/Android Gradle plugin 3.2.1
62b03547dc Merge remote-tracking branch 'origin/develop' into feature/master-site-creation
f55c4c33b1 Removed duplicated dots from image URL
818c1691c7 Rename NewSiteCreationService props
ab051f9083 removed unused imports
0ea8d2aab7 moved unused getDate() method from MediaUtils to getFormattedDateForLastModified() in PostUtils
6e4cecb37b Make the progress of NewSiteCreationService indeterminate
4434057372 Merge branch 'develop' into feature/master-site-creation
e7e89ad67e Fix SiteCreation segment icon color tint
2259033733 Merge branch 'develop' into feature/deep-link-main-activity
0671724495 Merge remote-tracking branch 'origin/develop' into feature/deep-linking-improvements
8f5238e5ef Reorder repositories in build.gradle to fix Gradle
4f18db4eb3 Reorder repositories in build.gradle to fix Gradle
e695cb4a6b Refactor isDeepLinking to be outside MyProfileActivity
d85b6dbb16 Remove unused WPImageGetter
44d63ede88 Add a new type of log tag for pages
5b4a4f09ae Move the logging wrapper class to FluxCUtils for convenience
c7c1ff782a Add Crashlytics logging to make sure we're keeping track of problems uploading media
d12f32a4a7 Remove coroutines and replace them with standard event driven architecture
5580689d26 Remove unused code - ImageUtils.getThumbnail

git-subtree-dir: libs/utils
git-subtree-split: a15de7604a34a9e989884fb84b8c9adfaeeb97b0
  • Loading branch information
jd-alexander committed Dec 24, 2019
1 parent a4a756b commit 90001f8
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 276 deletions.
4 changes: 2 additions & 2 deletions .idea/checkstyle-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions WordPressUtils/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
repositories {
jcenter()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.novoda:bintray-release:0.8.1'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.novoda:bintray-release:0.9'
}
}

Expand All @@ -20,21 +20,24 @@ repositories {
dependencies {
implementation 'org.apache.commons:commons-text:1.1'
implementation 'com.mcxiaoke.volley:library:1.0.18'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'org.greenrobot:eventbus:3.0.0'

testImplementation 'junit:junit:4.12'
testImplementation 'org.assertj:assertj-core:3.11.1'

lintChecks 'org.wordpress:lint:1.0.1'
}

android {
useLibrary 'org.apache.http.legacy'

compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
versionName "1.22"
versionName "1.24"
minSdkVersion 15
targetSdkVersion 26
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
Expand Down Expand Up @@ -46,4 +47,8 @@ public static void showKeyboard(@Nullable final View view) {
(InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}

public static boolean isDeepLinking(Intent intent) {
return Intent.ACTION_VIEW.equals(intent.getAction());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public enum T {
NOTIFS,
DB,
POSTS,
PAGES,
COMMENTS,
THEMES,
TESTS,
Expand All @@ -48,7 +49,9 @@ public enum T {
SHARING,
PLUGINS,
ACTIVITY_LOG,
SUPPORT
JETPACK_REMOTE_INSTALL,
SUPPORT,
SITE_CREATION
}

public static final String TAG = "WordPress";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected void setState(StateClass newState) {
}
}

private void track(ServiceState state) {
protected void track(ServiceState state) {
Map<String, Object> props = new HashMap<>();
props.put("login_phase", state == null ? "null" : state.getStepName());
props.put("login_service_is_foreground", isForeground());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public static Notification progress(Context context, String channelId, int progr
.build();
}

public static Notification progressIndeterminate(Context context, String channelId, @StringRes int title,
@StringRes int content, @DrawableRes int icon,
@ColorRes int accentColor) {
return getNotificationBuilder(context, channelId, NOTIFICATION_ID_PROGRESS, title, content, icon, accentColor)
.setProgress(0, 0, true)
.build();
}

public static Notification success(Context context, String channelId, @StringRes int title, @StringRes int content,
@DrawableRes int icon, @ColorRes int accentColor) {
return getNotificationBuilder(context, channelId, NOTIFICATION_ID_SUCCESS, title, content, icon, accentColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,25 @@ public static String iso8601UTCFromDate(Date date) {
}

/**
* Returns the current UTC date
* Returns the current UTC date.
*
* @deprecated This method doesn't work as expected and shouldn't be used in production code. It doesn't take
* into account that `Date` class uses TimeZone.getDefault(). It substracts the currentOffsetFromUTC, but the
* final date still uses system default timezone.
*/
@Deprecated
public static Date nowUTC() {
Date dateTimeNow = new Date();
return localDateToUTC(dateTimeNow);
}

/**
*
* @deprecated This method doesn't work as expected and shouldn't be used in production code. It doesn't take
* into account that `Date` class uses TimeZone.getDefault(). It substracts the currentOffsetFromUTC, but the
* final date still uses system default timezone.
*/
@Deprecated
public static Date localDateToUTC(Date dtLocal) {
if (dtLocal == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ private static long availableSpaceAtFilePath(File path) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
return stat.getBlockSizeLong() * stat.getAvailableBlocksLong();
} else {
//noinspection deprecation - Deprecated calls properly handled
bytesAvailable = (long) stat.getBlockSize() * (long) stat.getAvailableBlocks();
}
return bytesAvailable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -847,43 +847,6 @@ public static String rotateImageIfNecessary(Context context, String path) {
return null;
}

/**
* This is a wrapper around MediaStore.Images.Thumbnails.getThumbnail that takes in consideration
* the orientation of the picture.
*
* @param contentResolver ContentResolver used to dispatch queries to MediaProvider.
* @param id Original image id associated with thumbnail of interest.
* @param kind The type of thumbnail to fetch. Should be either MINI_KIND or MICRO_KIND.
*
* @return A Bitmap instance. It could be null if the original image
* associated with origId doesn't exist or memory is not enough.
*/
public static Bitmap getThumbnail(ContentResolver contentResolver, long id, int kind) {
Cursor cursor = contentResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Images.Media.DATA}, // Which columns to return
MediaStore.Images.Media._ID + "=?", // Which rows to return
new String[]{String.valueOf(id)}, // Selection arguments
null); // order

if (cursor != null && cursor.getCount() > 0) {
cursor.moveToFirst();
String filepath = cursor.getString(0);
cursor.close();
int rotation = getExifOrientation(filepath);
Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(contentResolver, id, kind, null);

if (rotation != 0 && bitmap != null) {
Matrix matrix = new Matrix();
matrix.setRotate(rotation);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}

return bitmap;
}

return null;
}

// determine correct scale value (should be power of 2)
// http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue/3549021#3549021
protected static int getScaleForResizing(int maxSize, BitmapFactory.Options optBounds) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -97,19 +94,6 @@ public static boolean isGif(String url) {
return "gif".equals(MimeTypeMap.getFileExtensionFromUrl(url));
}

/**
* E.g. Jul 2, 2013 @ 21:57
*/
public static String getDate(long ms) {
Date date = new Date(ms);
SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy '@' HH:mm", Locale.ENGLISH);

// The timezone on the website is at GMT
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));

return sdf.format(date);
}

public static boolean isLocalFile(String state) {
if (state == null) {
return false;
Expand Down Expand Up @@ -208,7 +192,7 @@ public static Uri downloadExternalMedia(Context context, Uri imageUri) {
if (context == null || imageUri == null) {
return null;
}
String mimeType = context.getContentResolver().getType(imageUri);
String mimeType = UrlUtils.getUrlMimeType(imageUri.toString());
File cacheDir = context.getCacheDir();

if (cacheDir != null && !cacheDir.exists()) {
Expand Down Expand Up @@ -404,6 +388,7 @@ public static String getRealPathFromURI(final Context context, Uri uri) {
} else {
path = uri.toString();
}

return path;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,4 @@ public static boolean checkAndRequestStoragePermission(Fragment fragment, int re
permission.WRITE_EXTERNAL_STORAGE
});
}

public static boolean checkLocationPermissions(Activity activity, int requestCode) {
return checkAndRequestPermissions(activity, requestCode, new String[]{
permission.ACCESS_FINE_LOCATION,
permission.ACCESS_COARSE_LOCATION
});
}

public static boolean checkLocationPermissions(Fragment fragment, int requestCode) {
return checkAndRequestPermissions(fragment, requestCode, new String[]{
permission.ACCESS_FINE_LOCATION,
permission.ACCESS_COARSE_LOCATION
});
}
}
Loading

0 comments on commit 90001f8

Please sign in to comment.