Add fragment transition animations to the Settings UI screen
This commit is contained in:
parent
6e13496d8d
commit
04974835d6
|
@ -1,10 +1,10 @@
|
||||||
package org.dolphinemu.dolphinemu.ui.settings;
|
package org.dolphinemu.dolphinemu.ui.settings;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.FragmentTransaction;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -45,16 +45,30 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
||||||
mPresenter.onStop(isFinishing());
|
mPresenter.onStop(isFinishing());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed()
|
||||||
|
{
|
||||||
|
mPresenter.onBackPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showSettingsFragment(String menuTag, boolean addToStack)
|
public void showSettingsFragment(String menuTag, boolean addToStack)
|
||||||
{
|
{
|
||||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction()
|
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||||
.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag), SettingsFragment.FRAGMENT_TAG);
|
|
||||||
|
|
||||||
if (addToStack)
|
if (addToStack)
|
||||||
{
|
{
|
||||||
|
transaction.setCustomAnimations(
|
||||||
|
R.animator.settings_enter,
|
||||||
|
R.animator.settings_exit,
|
||||||
|
R.animator.settings_pop_enter,
|
||||||
|
R.animator.setttings_pop_exit);
|
||||||
|
|
||||||
transaction.addToBackStack(null);
|
transaction.addToBackStack(null);
|
||||||
|
mPresenter.addToStack();
|
||||||
}
|
}
|
||||||
|
transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag), SettingsFragment.FRAGMENT_TAG);
|
||||||
|
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
}
|
}
|
||||||
|
@ -88,9 +102,15 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
||||||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void popBackStack()
|
||||||
|
{
|
||||||
|
getFragmentManager().popBackStackImmediate();
|
||||||
|
}
|
||||||
|
|
||||||
private SettingsFragment getFragment()
|
private SettingsFragment getFragment()
|
||||||
{
|
{
|
||||||
return (SettingsFragment) getSupportFragmentManager().findFragmentByTag(SettingsFragment.FRAGMENT_TAG);
|
return (SettingsFragment) getFragmentManager().findFragmentByTag(SettingsFragment.FRAGMENT_TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String ARGUMENT_FILE_NAME = BuildConfig.APPLICATION_ID + ".file_name";
|
public static final String ARGUMENT_FILE_NAME = BuildConfig.APPLICATION_ID + ".file_name";
|
||||||
|
|
|
@ -20,6 +20,8 @@ public final class SettingsActivityPresenter
|
||||||
private String mFileName;
|
private String mFileName;
|
||||||
private HashMap<String, SettingSection> mSettingsBySection;
|
private HashMap<String, SettingSection> mSettingsBySection;
|
||||||
|
|
||||||
|
private int mStackCount;
|
||||||
|
|
||||||
public SettingsActivityPresenter(SettingsActivityView view)
|
public SettingsActivityPresenter(SettingsActivityView view)
|
||||||
{
|
{
|
||||||
mView = view;
|
mView = view;
|
||||||
|
@ -94,4 +96,22 @@ public final class SettingsActivityPresenter
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addToStack()
|
||||||
|
{
|
||||||
|
mStackCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBackPressed()
|
||||||
|
{
|
||||||
|
if (mStackCount > 0)
|
||||||
|
{
|
||||||
|
mView.popBackStack();
|
||||||
|
mStackCount--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mView.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,4 +48,14 @@ public interface SettingsActivityView
|
||||||
* @param message The contents of the onscreen message.
|
* @param message The contents of the onscreen message.
|
||||||
*/
|
*/
|
||||||
void showToastMessage(String message);
|
void showToastMessage(String message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the previous fragment.
|
||||||
|
*/
|
||||||
|
void popBackStack();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End the activity.
|
||||||
|
*/
|
||||||
|
void finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package org.dolphinemu.dolphinemu.ui.settings;
|
package org.dolphinemu.dolphinemu.ui.settings;
|
||||||
|
|
||||||
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.dolphinemu.dolphinemu.ui.settings;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FrameLayout subclass with few Properties added to simplify animations.
|
||||||
|
*/
|
||||||
|
public final class SettingsFrameLayout extends FrameLayout
|
||||||
|
{
|
||||||
|
private float mVisibleness = 1.0f;
|
||||||
|
|
||||||
|
public SettingsFrameLayout(Context context)
|
||||||
|
{
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SettingsFrameLayout(Context context, AttributeSet attrs)
|
||||||
|
{
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SettingsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr)
|
||||||
|
{
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SettingsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
|
||||||
|
{
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getYFraction()
|
||||||
|
{
|
||||||
|
return getY() / getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYFraction(float yFraction)
|
||||||
|
{
|
||||||
|
final int height = getHeight();
|
||||||
|
setY((height > 0) ? (yFraction * height) : -9999);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getVisibleness()
|
||||||
|
{
|
||||||
|
return mVisibleness;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVisibleness(float visibleness)
|
||||||
|
{
|
||||||
|
setScaleX(visibleness);
|
||||||
|
setScaleY(visibleness);
|
||||||
|
setAlpha(visibleness);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"
|
||||||
|
android:interpolator="@android:interpolator/decelerate_cubic"
|
||||||
|
android:propertyName="yFraction"
|
||||||
|
android:startOffset="@android:integer/config_shortAnimTime"
|
||||||
|
android:valueFrom="1.0"
|
||||||
|
android:valueTo="0"/>
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"
|
||||||
|
android:interpolator="@android:interpolator/decelerate_cubic"
|
||||||
|
android:propertyName="translationZ"
|
||||||
|
android:startOffset="@android:integer/config_shortAnimTime"
|
||||||
|
android:valueFrom="100.0"
|
||||||
|
android:valueTo="0"/>
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"
|
||||||
|
android:interpolator="@android:interpolator/decelerate_cubic"
|
||||||
|
android:propertyName="elevation"
|
||||||
|
android:startOffset="@android:integer/config_shortAnimTime"
|
||||||
|
android:valueFrom="100.0"
|
||||||
|
android:valueTo="0"/>
|
||||||
|
</set>
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"
|
||||||
|
android:interpolator="@android:interpolator/accelerate_cubic"
|
||||||
|
android:propertyName="visibleness"
|
||||||
|
android:valueFrom="1.0f"
|
||||||
|
android:valueTo="0.6f"
|
||||||
|
android:valueType="floatType"/>
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"
|
||||||
|
android:interpolator="@android:interpolator/decelerate_cubic"
|
||||||
|
android:propertyName="translationZ"
|
||||||
|
android:startOffset="@android:integer/config_shortAnimTime"
|
||||||
|
android:valueFrom="0"
|
||||||
|
android:valueTo="-100.0"/>
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"
|
||||||
|
android:interpolator="@android:interpolator/decelerate_cubic"
|
||||||
|
android:propertyName="elevation"
|
||||||
|
android:startOffset="@android:integer/config_shortAnimTime"
|
||||||
|
android:valueFrom="0"
|
||||||
|
android:valueTo="-100.0"/>
|
||||||
|
</set>
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"
|
||||||
|
android:interpolator="@android:interpolator/decelerate_cubic"
|
||||||
|
android:propertyName="visibleness"
|
||||||
|
android:valueFrom="0.6f"
|
||||||
|
android:valueTo="1.0f"
|
||||||
|
android:valueType="floatType"/>
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"
|
||||||
|
android:interpolator="@android:interpolator/decelerate_cubic"
|
||||||
|
android:propertyName="translationZ"
|
||||||
|
android:startOffset="@android:integer/config_shortAnimTime"
|
||||||
|
android:valueFrom="-100.0"
|
||||||
|
android:valueTo="0"/>
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"
|
||||||
|
android:interpolator="@android:interpolator/decelerate_cubic"
|
||||||
|
android:propertyName="elevation"
|
||||||
|
android:startOffset="@android:integer/config_shortAnimTime"
|
||||||
|
android:valueFrom="-100.0"
|
||||||
|
android:valueTo="0"/>
|
||||||
|
|
||||||
|
</set>
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"
|
||||||
|
android:interpolator="@android:interpolator/accelerate_cubic"
|
||||||
|
android:propertyName="yFraction"
|
||||||
|
android:valueFrom="0"
|
||||||
|
android:valueTo="1.0"/>
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"
|
||||||
|
android:interpolator="@android:interpolator/decelerate_cubic"
|
||||||
|
android:propertyName="translationZ"
|
||||||
|
android:startOffset="@android:integer/config_shortAnimTime"
|
||||||
|
android:valueFrom="0.0"
|
||||||
|
android:valueTo="100"/>
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"
|
||||||
|
android:interpolator="@android:interpolator/decelerate_cubic"
|
||||||
|
android:propertyName="elevation"
|
||||||
|
android:startOffset="@android:integer/config_shortAnimTime"
|
||||||
|
android:valueFrom="0.0"
|
||||||
|
android:valueTo="100"/>
|
||||||
|
</set>
|
|
@ -1,11 +1,15 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<org.dolphinemu.dolphinemu.ui.settings.SettingsFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/list_settings"
|
android:id="@+id/list_settings"
|
||||||
|
android:background="@android:color/white"
|
||||||
|
android:elevation="@dimen/elevation_high"
|
||||||
|
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
</FrameLayout>
|
</org.dolphinemu.dolphinemu.ui.settings.SettingsFrameLayout>
|
Loading…
Reference in New Issue