From 04170de4f8524ec6e1180f4d5b3a04e0a8f10800 Mon Sep 17 00:00:00 2001 From: stom79 Date: Sat, 14 Apr 2018 09:46:03 +0200 Subject: [PATCH 1/2] Animate fragment transitions --- .../exodusprivacy/MainActivity.java | 26 ++++++++++--------- .../fragments/AppListFragment.java | 7 +---- .../fragments/ReportFragment.java | 6 +---- app/src/main/res/anim/slide_in_left.xml | 8 ++++++ app/src/main/res/anim/slide_in_right.xml | 8 ++++++ app/src/main/res/anim/slide_out_left.xml | 8 ++++++ app/src/main/res/anim/slide_out_right.xml | 8 ++++++ 7 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 app/src/main/res/anim/slide_in_left.xml create mode 100644 app/src/main/res/anim/slide_in_right.xml create mode 100644 app/src/main/res/anim/slide_out_left.xml create mode 100644 app/src/main/res/anim/slide_out_right.xml diff --git a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/MainActivity.java b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/MainActivity.java index 82aa28c..408e01d 100644 --- a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/MainActivity.java +++ b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/MainActivity.java @@ -18,10 +18,10 @@ package org.eu.exodus_privacy.exodusprivacy; -import android.app.FragmentManager; -import android.app.FragmentTransaction; +import android.support.v4.app.FragmentManager; import android.databinding.DataBindingUtil; import android.support.design.widget.Snackbar; +import android.support.v4.app.FragmentTransaction; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; @@ -70,26 +70,28 @@ public class MainActivity extends AppCompatActivity { ApplicationListAdapter.OnAppClickListener onAppClickListener = packageInfo -> { report = ReportFragment.newInstance(getPackageManager(),packageInfo); - FragmentManager manager = getFragmentManager(); + FragmentManager manager = getSupportFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); - transaction.addToBackStack(null); - transaction.replace(R.id.fragment_container,report); - transaction.commit(); + transaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_right, R.anim.slide_in_left, R.anim.slide_out_left) + .replace(R.id.fragment_container,report) + .addToBackStack(null) + .commit(); }; appList = AppListFragment.newInstance(networkListener,onAppClickListener); - FragmentManager manager = getFragmentManager(); + FragmentManager manager = getSupportFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); - transaction.replace(R.id.fragment_container,appList); - transaction.commit(); + transaction.replace(R.id.fragment_container,appList) + .commit(); } @Override public void onBackPressed() { - super.onBackPressed(); - if(report != null) - report = null; + if (getSupportFragmentManager().getBackStackEntryCount() == 0) + finish(); + else + getSupportFragmentManager().popBackStack(); } } diff --git a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/AppListFragment.java b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/AppListFragment.java index 5a674ff..6ae6eb9 100644 --- a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/AppListFragment.java +++ b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/AppListFragment.java @@ -19,22 +19,17 @@ package org.eu.exodus_privacy.exodusprivacy.fragments; import android.app.Activity; -import android.app.Fragment; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.databinding.DataBindingUtil; import android.os.Bundle; import android.support.annotation.Nullable; -import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.LinearLayout; -import android.widget.ProgressBar; -import android.widget.TextView; import org.eu.exodus_privacy.exodusprivacy.R; import org.eu.exodus_privacy.exodusprivacy.adapters.ApplicationListAdapter; diff --git a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/ReportFragment.java b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/ReportFragment.java index 2bd26c3..db9194d 100644 --- a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/ReportFragment.java +++ b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/ReportFragment.java @@ -19,20 +19,17 @@ package org.eu.exodus_privacy.exodusprivacy.fragments; -import android.app.Fragment; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PermissionInfo; import android.databinding.DataBindingUtil; import android.os.Bundle; +import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.webkit.WebView; -import android.widget.ImageView; -import android.widget.TextView; import org.eu.exodus_privacy.exodusprivacy.R; import org.eu.exodus_privacy.exodusprivacy.adapters.PermissionListAdapter; @@ -44,7 +41,6 @@ import org.eu.exodus_privacy.exodusprivacy.objects.Report; import org.eu.exodus_privacy.exodusprivacy.objects.Tracker; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Set; diff --git a/app/src/main/res/anim/slide_in_left.xml b/app/src/main/res/anim/slide_in_left.xml new file mode 100644 index 0000000..c5c5d5d --- /dev/null +++ b/app/src/main/res/anim/slide_in_left.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_in_right.xml b/app/src/main/res/anim/slide_in_right.xml new file mode 100644 index 0000000..92ce94c --- /dev/null +++ b/app/src/main/res/anim/slide_in_right.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_out_left.xml b/app/src/main/res/anim/slide_out_left.xml new file mode 100644 index 0000000..c5c5d5d --- /dev/null +++ b/app/src/main/res/anim/slide_out_left.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_out_right.xml b/app/src/main/res/anim/slide_out_right.xml new file mode 100644 index 0000000..eb6553f --- /dev/null +++ b/app/src/main/res/anim/slide_out_right.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file From fa59e10890fb874bcdd74800fe5a3f86893b6de4 Mon Sep 17 00:00:00 2001 From: stom79 Date: Sat, 14 Apr 2018 09:57:34 +0200 Subject: [PATCH 2/2] Changes delay + left anim --- app/src/main/res/anim/slide_in_left.xml | 6 +++--- app/src/main/res/anim/slide_in_right.xml | 2 +- app/src/main/res/anim/slide_out_left.xml | 2 +- app/src/main/res/anim/slide_out_right.xml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/anim/slide_in_left.xml b/app/src/main/res/anim/slide_in_left.xml index c5c5d5d..bd9bc9e 100644 --- a/app/src/main/res/anim/slide_in_left.xml +++ b/app/src/main/res/anim/slide_in_left.xml @@ -1,8 +1,8 @@ + android:duration="500"/> \ No newline at end of file diff --git a/app/src/main/res/anim/slide_in_right.xml b/app/src/main/res/anim/slide_in_right.xml index 92ce94c..44351ee 100644 --- a/app/src/main/res/anim/slide_in_right.xml +++ b/app/src/main/res/anim/slide_in_right.xml @@ -4,5 +4,5 @@ android:fromXDelta="100%" android:toXDelta="0" android:interpolator="@android:anim/decelerate_interpolator" - android:duration="300"/> + android:duration="500"/> \ No newline at end of file diff --git a/app/src/main/res/anim/slide_out_left.xml b/app/src/main/res/anim/slide_out_left.xml index c5c5d5d..e95d387 100644 --- a/app/src/main/res/anim/slide_out_left.xml +++ b/app/src/main/res/anim/slide_out_left.xml @@ -4,5 +4,5 @@ android:fromXDelta="0%" android:toXDelta="100%" android:interpolator="@android:anim/decelerate_interpolator" - android:duration="300"/> + android:duration="500"/> \ No newline at end of file diff --git a/app/src/main/res/anim/slide_out_right.xml b/app/src/main/res/anim/slide_out_right.xml index eb6553f..55a56bc 100644 --- a/app/src/main/res/anim/slide_out_right.xml +++ b/app/src/main/res/anim/slide_out_right.xml @@ -4,5 +4,5 @@ android:fromXDelta="0%" android:toXDelta="-100%" android:interpolator="@android:anim/decelerate_interpolator" - android:duration="300"/> + android:duration="500"/> \ No newline at end of file