Skip to content

Commit

Permalink
Merge branch 'android-x'
Browse files Browse the repository at this point in the history
  • Loading branch information
k3b committed May 7, 2019
2 parents 36e99b7 + 50fb937 commit 14a876e
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 40 deletions.
18 changes: 9 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ android {
targetSdkVersion 28

// 1.0.0.190425 (1) initial version
versionCode 1
versionName "1.0.0.190425"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// 1.0.1.190507 (2) Bugfix: missing read permission; port to android-x
versionCode 2
versionName "1.0.1.190507"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

// all supported locales. Note: the lib has more translations which are supressed here
// resConfigs "ar","de","es","fr","hi","in","it","ja","nl","pl","ro","ru","tr","uk","zz","pt-rBR","zh-rCN","zh-rTW"
Expand All @@ -35,14 +36,13 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// implementation "com.android.support:appcompat-v7:$support"
implementation "com.android.support:support-v4:$support"
implementation "com.android.support:support-annotations:$support"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.annotation:annotation:1.0.0'

implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
// implements lossless croppig
// implementation 'com.facebook.spectrum:spectrum-default:1.0.0'
implementation 'com.facebook.spectrum:spectrum-core:1.0.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.k3b.android.lossless_jpg_crop;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:theme="@style/AppTheme">

<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="de.k3b.llCrop"
android:exported="false"
android:grantUriPermissions="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;

/**
* Created by Oleksii Shliama (https://github.com/shliama).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package de.k3b.android.lossless_jpg_crop;

import android.Manifest;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.FileProvider;
import androidx.core.app.ActivityCompat;
import androidx.core.content.FileProvider;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -24,8 +22,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import static android.content.Intent.EXTRA_STREAM;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;

public class CropAreasChooseActivity extends BaseActivity {
private static final String TAG = "llCrop";
Expand Down Expand Up @@ -178,6 +177,7 @@ private void onGetPictureResult(int resultCode, Intent data) {

Intent intent = new Intent(Intent.ACTION_VIEW, selectedUri, this, CropAreasChooseActivity.class);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

this.startActivity(intent);
finish();
return;
Expand Down Expand Up @@ -230,13 +230,19 @@ private void onOpenPublicOutputUriPickerResult(int resultCode, Uri outUri) {
InputStream inStream = null;
OutputStream outStream = null;

final String context_message = "Cropping '" + inUri + "'(" + rect + ") => '" + outUri + "'";
final String context_message = "Cropping '" + inUri + "'(" + rect + ") => '"
+ outUri + "' ('" + toString(outUri) + "')";
Log.i(TAG, context_message);

try {
inStream = getContentResolver().openInputStream(inUri);
outStream = getContentResolver().openOutputStream(outUri, "w");
this.mSpectrum.crop(inStream, outStream, rect, 0);

String message = getString(R.string.toast_saved_as,
toString(outUri));
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();

finish();
return;
} catch (Exception e) {
Expand All @@ -251,6 +257,15 @@ private void onOpenPublicOutputUriPickerResult(int resultCode, Uri outUri) {
}
}

private String toString(Uri outUri) {
if (outUri == null) return "";
try {
return URLDecoder.decode(outUri.toString(), StandardCharsets.UTF_8.toString());
} catch (UnsupportedEncodingException e) {
return outUri.toString();
}
}

private static void close(Closeable stream, Object source) {
if (stream != null) {
try {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<string name="permission_write_storage_rationale">Benötige Datei-Schreibrechte um ein Photo zu speichern.</string>

<string name="toast_cannot_retrieve_selected_image">Beende app: Kein Quell Photo ausgewählt</string>
<string name="toast_saved_as">Gespeichert als \'%1$s\'</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<string name="permission_write_storage_rationale">Storage write permission is needed to save the image.</string>

<string name="toast_cannot_retrieve_selected_image">Quitting: No source image selected</string>
<string name="toast_saved_as">Saved as \'%1$s\'</string>
</resources>
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.4.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
ext {
support = '28.0.0'
constraints = '1.0.2'
// constraints = '1.0.2'
}
}

Expand All @@ -29,7 +28,6 @@ allprojects {
ext {
compileSdkVersion = 28
buildToolsVersion = '28.0.3'
supportLibraryVersion = '28.0.0'

PUBLISH_GROUP_ID = 'net.realify.lib'
PUBLISH_ARTIFACT_ID = 'android-image-cropper'
Expand Down
6 changes: 3 additions & 3 deletions cropper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ repositories {
}

dependencies {
api "com.android.support:support-v4:$supportLibraryVersion"
api "com.android.support:exifinterface:$supportLibraryVersion"
api "com.android.support:support-annotations:$support"
api 'androidx.legacy:legacy-support-v4:1.0.0'
api 'androidx.exifinterface:exifinterface:1.0.0'
api 'androidx.annotation:annotation:1.0.0'

// implementation 'com.github.Realify:Android-Image-Cropper:master'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import android.graphics.Rect;
import android.graphics.RectF;
import android.net.Uri;
import android.support.media.ExifInterface;
import androidx.exifinterface.media.ExifInterface;
import android.util.Log;
import android.util.Pair;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.app.Fragment;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;

import java.io.File;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
// import android.support.v7.app.ActionBar;
// import android.support.v7.app.AppCompatActivity;
import android.util.Log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.media.ExifInterface;
import androidx.exifinterface.media.ExifInterface;
import android.util.AttributeSet;
import android.util.Pair;
import android.view.LayoutInflater;
Expand Down
4 changes: 4 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Bugfix: missing read permission
Added: success message
ported to android-x

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Apr 09 17:59:42 CEST 2019
#Tue May 07 10:19:25 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

0 comments on commit 14a876e

Please sign in to comment.