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

Fixed bottomBar Slide Animation #2925

Open
wants to merge 7 commits into
base: development
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: 1 addition & 0 deletions app/src/main/java/org/fossasia/phimpme/MyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class MyApplication extends Application {
private HandlingAlbums albums = null;
public static Context applicationContext;
private RefWatcher refWatcher;
public int NavItem = 1;

public Album getAlbum() {
return albums.dispAlbums.size() > 0 ? albums.getCurrentAlbum() : Album.getEmptyAlbum();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.twitter.sdk.android.core.identity.TwitterAuthClient;
import io.realm.RealmQuery;
import java.util.ArrayList;
import org.fossasia.phimpme.MyApplication;
import org.fossasia.phimpme.R;
import org.fossasia.phimpme.base.PhimpmeProgressBarHandler;
import org.fossasia.phimpme.base.RecyclerItemClickListner;
Expand Down Expand Up @@ -92,7 +93,7 @@ public void onCreate(Bundle savedInstanceState) {
ActivitySwitchHelper.setContext(this);
setSupportActionBar(toolbar);
parentLayout.setBackgroundColor(getBackgroundColor());
overridePendingTransition(R.anim.right_to_left, R.anim.left_to_right);
startSlideAnimation(2);
phimpmeProgressBarHandler = new PhimpmeProgressBarHandler(this);
ThemeHelper themeHelper = new ThemeHelper(this);
toolbar.setPopupTheme(getPopupToolbarStyle());
Expand All @@ -110,6 +111,15 @@ public void onCreate(Bundle savedInstanceState) {
initObserver();
}

private void startSlideAnimation(int currentMenuItem) {
if (((MyApplication) this.getApplication()).NavItem > currentMenuItem)
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
else if (((MyApplication) this.getApplication()).NavItem < currentMenuItem)
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
// Update the Global NavItem
((MyApplication) this.getApplication()).NavItem = currentMenuItem;
}

private void initObserver() {
accountViewModel.error.observe(
this,
Expand Down Expand Up @@ -348,7 +358,6 @@ public void onBackPressed() {
Intent intent = new Intent(this, LFMainActivity.class);
startActivity(intent);
finish();
overridePendingTransition(R.anim.left_to_right, R.anim.right_to_left);
}

private void boxAuthentication() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
break;
}
finish();
overridePendingTransition(R.anim.left_to_right, R.anim.right_to_left);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
import java.util.Locale;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.fossasia.phimpme.MyApplication;
import org.fossasia.phimpme.R;
import org.fossasia.phimpme.base.SharedMediaActivity;
import org.fossasia.phimpme.data.local.FavouriteImagesModel;
Expand Down Expand Up @@ -661,7 +662,7 @@ public void onCreate(Bundle savedInstanceState) {
rvAlbums = findViewById(R.id.grid_albums);
rvMedia = findViewById(R.id.grid_photos);

overridePendingTransition(R.anim.right_to_left, R.anim.left_to_right);
startSlideAnimation(1);
SP = PreferenceUtil.getInstance(getApplicationContext());
albumsMode = true;
editMode = false;
Expand Down Expand Up @@ -730,6 +731,15 @@ public void onResume() {
firstLaunch = false;
}

private void startSlideAnimation(int currentMenuItem) {
if (((MyApplication) this.getApplication()).NavItem > currentMenuItem)
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
else if (((MyApplication) this.getApplication()).NavItem < currentMenuItem)
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
// Update the Global NavItem
((MyApplication) this.getApplication()).NavItem = currentMenuItem;
}

private void displayCurrentAlbumMedia(boolean reload) {
toolbar.setTitle(getAlbum().getName());
toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_arrow_back));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.fossasia.phimpme.MyApplication;
import org.fossasia.phimpme.R;
import org.fossasia.phimpme.base.ThemedActivity;
import org.fossasia.phimpme.gallery.activities.LFMainActivity;
Expand Down Expand Up @@ -180,7 +181,7 @@ public void onCreate(Bundle savedInstanceState) {
}
super.onCreate(savedInstanceState);
ButterKnife.bind(this);
overridePendingTransition(R.anim.right_to_left, R.anim.left_to_right);
startSlideAnimation(0);
ButterKnife.bind(this);
PreferenceManager.setDefaultValues(
this, R.xml.preferences, false); // initialise any unset preferences to their default values
Expand Down Expand Up @@ -886,6 +887,16 @@ public void onResume() {
}
}

private void startSlideAnimation(int currentMenuItem) {

if (((MyApplication) this.getApplication()).NavItem > currentMenuItem)
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
else if (((MyApplication) this.getApplication()).NavItem < currentMenuItem)
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
// Update the Global NavItem
((MyApplication) this.getApplication()).NavItem = currentMenuItem;
}

private void defaultBrightness() {
WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
Expand Down Expand Up @@ -1404,7 +1415,6 @@ public void onBackPressed() {
Intent intent = new Intent(this, LFMainActivity.class);
startActivity(intent);
finish();
overridePendingTransition(R.anim.left_to_right, R.anim.right_to_left);
}

public boolean usingKitKatImmersiveMode() {
Expand Down
8 changes: 0 additions & 8 deletions app/src/main/res/anim/left_to_right.xml

This file was deleted.

8 changes: 0 additions & 8 deletions app/src/main/res/anim/right_to_left.xml

This file was deleted.

8 changes: 8 additions & 0 deletions app/src/main/res/anim/slide_in_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="-100%p"
android:toXDelta="0" />
</set>
8 changes: 8 additions & 0 deletions app/src/main/res/anim/slide_in_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="100%p"
android:toXDelta="0" />
</set>
8 changes: 8 additions & 0 deletions app/src/main/res/anim/slide_out_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="0"
android:toXDelta="-100%p" />
</set>
8 changes: 8 additions & 0 deletions app/src/main/res/anim/slide_out_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="0"
android:toXDelta="100%p" />
</set>