Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from RxJava2 to RxJava3 for the whole project and migrate to AndroidX for sample app #152

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ proguard/
# Ignore gradle files
.gradle/
build/
gradle.properties
16 changes: 10 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ buildscript {
jcenter()
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -19,13 +20,16 @@ allprojects {
repositories {
jcenter()
google()
maven { url "https://jitpack.io" }
}
}

ext {
permissionsDispatcherVersion = '2.4.0'
permissionsDispatcherVersion = '4.8.0'
supportLibraryVersion = '28.0.0-rc02'
rxPermissionsVersion = '0.9.4@aar'
rxJavaVersion = '2.1.10'
rxAndroidVersion = '2.0.2'
rxPermissionsVersion = '0.12'
rxJavaVersion = '3.0.8'
rxAndroidVersion = '3.0.0'
androidAnnotation = '1.1.0'
androidAppCompat = '1.2.0-rc01'
}
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 @@
#Mon Sep 17 15:51:05 JST 2018
#Sun Dec 27 18:54:48 CET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
27 changes: 17 additions & 10 deletions simplecropview-sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion '28.0.2'
compileSdkVersion 30
buildToolsVersion '30.0.3'

defaultConfig {
applicationId "com.example.simplecropviewsample"
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 30
versionCode 1
versionName "1.0.0"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -38,10 +43,12 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':simplecropview')

implementation "com.github.hotchemi:permissionsdispatcher:$permissionsDispatcherVersion"
annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:$permissionsDispatcherVersion"
implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
implementation "com.tbruyelle.rxpermissions2:rxpermissions:$rxPermissionsVersion"
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
}
implementation "org.permissionsdispatcher:permissionsdispatcher:$permissionsDispatcherVersion"
annotationProcessor "org.permissionsdispatcher:permissionsdispatcher-processor:$permissionsDispatcherVersion"

implementation "androidx.annotation:annotation:$androidAnnotation"
implementation "androidx.appcompat:appcompat:$androidAppCompat"
implementation "com.github.tbruyelle:rxpermissions:$rxPermissionsVersion"
implementation "io.reactivex.rxjava3:rxjava:$rxJavaVersion"
implementation "io.reactivex.rxjava3:rxandroid:$rxAndroidVersion"
}
2 changes: 2 additions & 0 deletions simplecropview-sample/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.gradle.caching=true
android.useAndroidX=true
1 change: 1 addition & 0 deletions simplecropview-sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<application
android:name=".AppController"
android:allowBackup="true"
android:requestLegacyExternalStorage="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

public class BasicActivity extends AppCompatActivity {
private static final String TAG = BasicActivity.class.getSimpleName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.isseiaoki.simplecropview.CropImageView;
import com.isseiaoki.simplecropview.callback.CropCallback;
import com.isseiaoki.simplecropview.callback.LoadCallback;
Expand Down Expand Up @@ -72,7 +74,7 @@ public static BasicFragment newInstance() {
return inflater.inflate(R.layout.fragment_basic, null, false);
}

@Override public void onViewCreated(View view, Bundle savedInstanceState) {
@Override public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// bind Views
bindViews(view);
Expand All @@ -87,7 +89,7 @@ public static BasicFragment newInstance() {

if (mSourceUri == null) {
// default data
mSourceUri = getUriFromDrawableResId(getContext(), R.drawable.sample5);
mSourceUri = getUriFromDrawableResId(requireContext(), R.drawable.sample5);
Log.e("aoki", "mSourceUri = "+mSourceUri);
}
// load image
Expand All @@ -97,7 +99,7 @@ public static BasicFragment newInstance() {
.execute(mLoadCallback);
}

@Override public void onSaveInstanceState(Bundle outState) {
@Override public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
// save data
outState.putParcelable(KEY_FRAME_RECT, mCropView.getActualCropRect());
Expand Down Expand Up @@ -154,6 +156,7 @@ private void bindViews(View view) {
view.findViewById(R.id.buttonShowCircleButCropAsSquare).setOnClickListener(btnListener);
}

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE) public void pickImage() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
startActivityForResult(new Intent(Intent.ACTION_GET_CONTENT).setType("image/*"),
Expand All @@ -171,6 +174,7 @@ private void bindViews(View view) {
mCropView.crop(mSourceUri).execute(mCropCallback);
}

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@OnShowRationale(Manifest.permission.READ_EXTERNAL_STORAGE)
public void showRationaleForPick(PermissionRequest request) {
showRationaleDialog(R.string.permission_pick_rationale, request);
Expand All @@ -183,16 +187,15 @@ public void showRationaleForCrop(PermissionRequest request) {

public void showProgress() {
ProgressDialogFragment f = ProgressDialogFragment.getInstance();
getFragmentManager().beginTransaction().add(f, PROGRESS_DIALOG).commitAllowingStateLoss();
getParentFragmentManager().beginTransaction().add(f, PROGRESS_DIALOG).commitAllowingStateLoss();
}

public void dismissProgress() {
if (!isResumed()) return;
android.support.v4.app.FragmentManager manager = getFragmentManager();
if (manager == null) return;
FragmentManager manager = getParentFragmentManager();
ProgressDialogFragment f = (ProgressDialogFragment) manager.findFragmentByTag(PROGRESS_DIALOG);
if (f != null) {
getFragmentManager().beginTransaction().remove(f).commitAllowingStateLoss();
getParentFragmentManager().beginTransaction().remove(f).commitAllowingStateLoss();
}
}

Expand Down Expand Up @@ -272,7 +275,7 @@ public static Uri createTempUri(Context context) {
}

private void showRationaleDialog(@StringRes int messageResId, final PermissionRequest request) {
new AlertDialog.Builder(getActivity()).setPositiveButton(R.string.button_allow,
new AlertDialog.Builder(requireActivity()).setPositiveButton(R.string.button_allow,
new DialogInterface.OnClickListener() {
@Override public void onClick(@NonNull DialogInterface dialog, int which) {
request.proceed();
Expand All @@ -290,7 +293,7 @@ private void showRationaleDialog(@StringRes int messageResId, final PermissionRe
@Override public void onClick(View v) {
switch (v.getId()) {
case R.id.buttonDone:
BasicFragmentPermissionsDispatcher.cropImageWithCheck(BasicFragment.this);
BasicFragmentPermissionsDispatcher.cropImageWithPermissionCheck(BasicFragment.this);
break;
case R.id.buttonFitImage:
mCropView.setCropMode(CropImageView.CropMode.FIT_IMAGE);
Expand Down Expand Up @@ -329,7 +332,7 @@ private void showRationaleDialog(@StringRes int messageResId, final PermissionRe
mCropView.rotateImage(CropImageView.RotateDegrees.ROTATE_90D);
break;
case R.id.buttonPickImage:
BasicFragmentPermissionsDispatcher.pickImageWithCheck(BasicFragment.this);
BasicFragmentPermissionsDispatcher.pickImageWithPermissionCheck(BasicFragment.this);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import android.content.Context;
import android.graphics.Typeface;
import android.support.v7.app.ActionBar;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.TypefaceSpan;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.appcompat.app.ActionBar;
import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.example.simplecropviewsample;

import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ProgressBar;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

public class ProgressDialogFragment extends DialogFragment {
public static final String TAG = ProgressDialogFragment.class.getSimpleName();
Expand All @@ -30,17 +30,19 @@ public static ProgressDialogFragment getInstance() {
return fragment;
}

@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@Nullable
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_progress_dialog, null, false);
ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progress);
progressBar.getIndeterminateDrawable()
.setColorFilter(getContext().getResources().getColor(R.color.colorAccent),
.setColorFilter(requireContext().getResources().getColor(R.color.colorAccent),
PorterDuff.Mode.SRC_IN);
return view;
}

@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
@NonNull
@Override public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.isseiaoki.simplecropview.util.Utils;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

public class RxActivity extends AppCompatActivity {
private static final String TAG = RxActivity.class.getSimpleName();
Expand Down
Loading