Introduce menu
|
@ -112,5 +112,5 @@ dependencies {
|
|||
implementation "info.guardianproject.netcipher:netcipher-okhttp3:$netCipherVersion"
|
||||
|
||||
implementation 'com.github.adrielcafe:AndroidAudioRecorder:0.3.0'
|
||||
implementation 'com.github.yalantis:Side-Menu.Android:1.0.2'
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.content.res.Configuration;
|
|||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -41,12 +42,12 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.animatemenu.interfaces.Resourceble;
|
||||
import app.fedilab.android.animatemenu.interfaces.ScreenShotable;
|
||||
import app.fedilab.android.animatemenu.model.SlideMenuItem;
|
||||
import app.fedilab.android.animatemenu.util.ViewAnimator;
|
||||
import app.fedilab.android.fragments.ContentSettingsFragment;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import yalantis.com.sidemenu.interfaces.Resourceble;
|
||||
import yalantis.com.sidemenu.interfaces.ScreenShotable;
|
||||
import yalantis.com.sidemenu.model.SlideMenuItem;
|
||||
import yalantis.com.sidemenu.util.ViewAnimator;
|
||||
|
||||
/**
|
||||
* Created by Thomas on 01/07/2019.
|
||||
|
@ -216,7 +217,7 @@ public class SettingsActivity extends BaseActivity implements ViewAnimator.ViewA
|
|||
}
|
||||
|
||||
|
||||
private ScreenShotable replaceFragment(ScreenShotable screenShotable, int topPosition) {
|
||||
private ScreenShotable replaceFragment(ScreenShotable screenShotable, String type, int topPosition) {
|
||||
this.res = this.res == R.drawable.ic_timeline_menu_s ? R.drawable.ic_notifications_menu : R.drawable.ic_timeline_menu_s;
|
||||
View view = findViewById(R.id.content_frame);
|
||||
int finalRadius = Math.max(view.getWidth(), view.getHeight());
|
||||
|
@ -232,6 +233,9 @@ public class SettingsActivity extends BaseActivity implements ViewAnimator.ViewA
|
|||
|
||||
|
||||
ContentSettingsFragment contentSettingsFragment = ContentSettingsFragment.newInstance(this.res);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("type",type);
|
||||
contentSettingsFragment.setArguments(bundle);
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, contentSettingsFragment).commit();
|
||||
return contentSettingsFragment;
|
||||
}
|
||||
|
@ -239,11 +243,13 @@ public class SettingsActivity extends BaseActivity implements ViewAnimator.ViewA
|
|||
|
||||
@Override
|
||||
public ScreenShotable onSwitch(Resourceble slideMenuItem, ScreenShotable screenShotable, int position) {
|
||||
if (ContentSettingsFragment.CLOSE.equals(slideMenuItem.getName())) {
|
||||
|
||||
String type = slideMenuItem.getName();
|
||||
if (ContentSettingsFragment.CLOSE.equals(type)) {
|
||||
finish();
|
||||
return null;
|
||||
}
|
||||
return replaceFragment(screenShotable, position);
|
||||
return replaceFragment(screenShotable, type, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package app.fedilab.android.animatemenu.animation;
|
||||
|
||||
import android.graphics.Camera;
|
||||
import android.graphics.Matrix;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
/**
|
||||
* Created by Konstantin on 22.12.2014.
|
||||
*/
|
||||
public class FlipAnimation extends Animation {
|
||||
private final float mFromDegrees;
|
||||
private final float mToDegrees;
|
||||
private final float mCenterX;
|
||||
private final float mCenterY;
|
||||
private Camera mCamera;
|
||||
|
||||
public FlipAnimation(float fromDegrees, float toDegrees,
|
||||
float centerX, float centerY) {
|
||||
mFromDegrees = fromDegrees;
|
||||
mToDegrees = toDegrees;
|
||||
mCenterX = centerX;
|
||||
mCenterY = centerY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(int width, int height, int parentWidth, int parentHeight) {
|
||||
super.initialize(width, height, parentWidth, parentHeight);
|
||||
mCamera = new Camera();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
final float fromDegrees = mFromDegrees;
|
||||
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
|
||||
|
||||
final float centerX = mCenterX;
|
||||
final float centerY = mCenterY;
|
||||
final Camera camera = mCamera;
|
||||
|
||||
final Matrix matrix = t.getMatrix();
|
||||
|
||||
camera.save();
|
||||
|
||||
camera.rotateY(degrees);
|
||||
|
||||
camera.getMatrix(matrix);
|
||||
camera.restore();
|
||||
|
||||
matrix.preTranslate(-centerX, -centerY);
|
||||
matrix.postTranslate(centerX, centerY);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package app.fedilab.android.animatemenu.interfaces;
|
||||
|
||||
/**
|
||||
* Created by Konstantin on 12.01.2015.
|
||||
*/
|
||||
public interface Resourceble {
|
||||
public int getImageRes();
|
||||
|
||||
public String getName();
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package app.fedilab.android.animatemenu.interfaces;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/**
|
||||
* Created by Konstantin on 12.01.2015.
|
||||
*/
|
||||
public interface ScreenShotable {
|
||||
public void takeScreenShot();
|
||||
|
||||
public Bitmap getBitmap();
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package app.fedilab.android.animatemenu.model;
|
||||
|
||||
|
||||
import app.fedilab.android.animatemenu.interfaces.Resourceble;
|
||||
|
||||
/**
|
||||
* Created by Konstantin on 23.12.2014.
|
||||
*/
|
||||
public class SlideMenuItem implements Resourceble {
|
||||
private String name;
|
||||
private int imageRes;
|
||||
|
||||
public SlideMenuItem(String name, int imageRes) {
|
||||
this.name = name;
|
||||
this.imageRes = imageRes;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getImageRes() {
|
||||
return imageRes;
|
||||
}
|
||||
|
||||
public void setImageRes(int imageRes) {
|
||||
this.imageRes = imageRes;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,197 @@
|
|||
package app.fedilab.android.animatemenu.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.Animation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.animatemenu.animation.FlipAnimation;
|
||||
import app.fedilab.android.animatemenu.interfaces.Resourceble;
|
||||
import app.fedilab.android.animatemenu.interfaces.ScreenShotable;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Konstantin on 12.01.2015.
|
||||
*/
|
||||
public class ViewAnimator<T extends Resourceble> {
|
||||
private final int ANIMATION_DURATION = 175;
|
||||
public static final int CIRCULAR_REVEAL_ANIMATION_DURATION = 500;
|
||||
|
||||
private AppCompatActivity appCompatActivity;
|
||||
|
||||
private List<T> list;
|
||||
|
||||
private List<View> viewList = new ArrayList<>();
|
||||
private ScreenShotable screenShotable;
|
||||
private DrawerLayout drawerLayout;
|
||||
private ViewAnimatorListener animatorListener;
|
||||
|
||||
|
||||
public ViewAnimator(AppCompatActivity activity,
|
||||
List<T> items,
|
||||
ScreenShotable screenShotable,
|
||||
final DrawerLayout drawerLayout,
|
||||
ViewAnimatorListener animatorListener) {
|
||||
this.appCompatActivity = activity;
|
||||
|
||||
this.list = items;
|
||||
this.screenShotable = screenShotable;
|
||||
this.drawerLayout = drawerLayout;
|
||||
this.animatorListener = animatorListener;
|
||||
}
|
||||
|
||||
public void setMenuItemSelector(int drawableSelector){
|
||||
RelativeLayout menu_item_container = appCompatActivity.findViewById(R.id.menu_item_container);
|
||||
menu_item_container.setBackgroundResource(drawableSelector);
|
||||
}
|
||||
|
||||
|
||||
public void showMenuContent() {
|
||||
setViewsClickable(false);
|
||||
viewList.clear();
|
||||
double size = list.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
@SuppressLint("InflateParams") View viewMenu = appCompatActivity.getLayoutInflater().inflate(R.layout.menu_list_item, null);
|
||||
|
||||
final int finalI = i;
|
||||
viewMenu.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int[] location = {0, 0};
|
||||
v.getLocationOnScreen(location);
|
||||
switchItem(list.get(finalI), location[1] + v.getHeight() / 2);
|
||||
}
|
||||
});
|
||||
((ImageView) viewMenu.findViewById(R.id.menu_item_image)).setImageResource(list.get(i).getImageRes());
|
||||
viewMenu.setVisibility(View.GONE);
|
||||
viewMenu.setEnabled(false);
|
||||
viewList.add(viewMenu);
|
||||
animatorListener.addViewToContainer(viewMenu);
|
||||
final double position = i;
|
||||
final double delay = 3 * ANIMATION_DURATION * (position / size);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
if (position < viewList.size()) {
|
||||
animateView((int) position);
|
||||
}
|
||||
if (position == viewList.size() - 1) {
|
||||
screenShotable.takeScreenShot();
|
||||
setViewsClickable(true);
|
||||
}
|
||||
}
|
||||
}, (long) delay);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void hideMenuContent() {
|
||||
setViewsClickable(false);
|
||||
double size = list.size();
|
||||
for (int i = list.size(); i >= 0; i--) {
|
||||
final double position = i;
|
||||
final double delay = 3 * ANIMATION_DURATION * (position / size);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
if (position < viewList.size()) {
|
||||
animateHideView((int) position);
|
||||
}
|
||||
}
|
||||
}, (long) delay);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setViewsClickable(boolean clickable) {
|
||||
animatorListener.disableHomeButton();
|
||||
for (View view : viewList) {
|
||||
view.setEnabled(clickable);
|
||||
}
|
||||
}
|
||||
|
||||
private void animateView(int position) {
|
||||
final View view = viewList.get(position);
|
||||
view.setVisibility(View.VISIBLE);
|
||||
FlipAnimation rotation =
|
||||
new FlipAnimation(90, 0, 0.0f, view.getHeight() / 2.0f);
|
||||
rotation.setDuration(ANIMATION_DURATION);
|
||||
rotation.setFillAfter(true);
|
||||
rotation.setInterpolator(new AccelerateInterpolator());
|
||||
rotation.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
view.clearAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
view.startAnimation(rotation);
|
||||
}
|
||||
|
||||
private void animateHideView(final int position) {
|
||||
final View view = viewList.get(position);
|
||||
FlipAnimation rotation =
|
||||
new FlipAnimation(0, 90, 0.0f, view.getHeight() / 2.0f);
|
||||
rotation.setDuration(ANIMATION_DURATION);
|
||||
rotation.setFillAfter(true);
|
||||
rotation.setInterpolator(new AccelerateInterpolator());
|
||||
rotation.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
view.clearAnimation();
|
||||
view.setVisibility(View.INVISIBLE);
|
||||
if (position == viewList.size() - 1) {
|
||||
animatorListener.enableHomeButton();
|
||||
drawerLayout.closeDrawers();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
view.startAnimation(rotation);
|
||||
}
|
||||
|
||||
private void switchItem(Resourceble slideMenuItem, int topPosition) {
|
||||
this.screenShotable = animatorListener.onSwitch(slideMenuItem, screenShotable, topPosition);
|
||||
hideMenuContent();
|
||||
}
|
||||
|
||||
public interface ViewAnimatorListener {
|
||||
|
||||
public ScreenShotable onSwitch(Resourceble slideMenuItem, ScreenShotable screenShotable, int position);
|
||||
|
||||
public void disableHomeButton();
|
||||
|
||||
public void enableHomeButton();
|
||||
|
||||
public void addViewToContainer(View view);
|
||||
|
||||
}
|
||||
}
|
|
@ -33,10 +33,8 @@ import androidx.fragment.app.Fragment;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.SettingsActivity;
|
||||
import app.fedilab.android.activities.TagCacheActivity;
|
||||
import app.fedilab.android.animatemenu.interfaces.ScreenShotable;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import yalantis.com.sidemenu.interfaces.ScreenShotable;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
|
@ -46,7 +44,7 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable
|
|||
private View containerView;
|
||||
protected int res;
|
||||
private Bitmap bitmap;
|
||||
|
||||
private String type;
|
||||
private Context context;
|
||||
public static final String CLOSE = "Close";
|
||||
public static final String TIMELINES = "Timelines";
|
||||
|
@ -86,6 +84,10 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable
|
|||
View rootView = inflater.inflate(R.layout.fragment_settings_reveal, container, false);
|
||||
FrameLayout containerFrame = rootView.findViewById(R.id.container);
|
||||
|
||||
Bundle bundle = this.getArguments();
|
||||
if (bundle != null) {
|
||||
type = bundle.getString("type", null);
|
||||
}
|
||||
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
|
@ -102,7 +104,6 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable
|
|||
default:
|
||||
containerFrame.setBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC1));
|
||||
}
|
||||
|
||||
LinearLayout settings_timeline = rootView.findViewById(R.id.settings_timeline);
|
||||
LinearLayout settings_notifications = rootView.findViewById(R.id.settings_notifications);
|
||||
LinearLayout settings_admin = rootView.findViewById(R.id.settings_admin);
|
||||
|
@ -111,24 +112,22 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable
|
|||
LinearLayout settings_hidden = rootView.findViewById(R.id.settings_hidden);
|
||||
LinearLayout settings_to_do = rootView.findViewById(R.id.settings_to_do);
|
||||
|
||||
if( res == R.drawable.ic_timeline_menu_s){
|
||||
if(type == null || type.equals(TIMELINES)){
|
||||
settings_timeline.setVisibility(View.VISIBLE);
|
||||
}else if( res == R.drawable.ic_notifications_menu){
|
||||
}else if( type.equals(NOTIFICATIONS)){
|
||||
settings_notifications.setVisibility(View.VISIBLE);
|
||||
}else if( res == R.drawable.ic_security_admin_menu){
|
||||
}else if( type.equals(ADMIN)){
|
||||
settings_admin.setVisibility(View.VISIBLE);
|
||||
}else if( res == R.drawable.ic_tablet_menu){
|
||||
}else if(type.equals(INTERFACE)){
|
||||
settings_interface.setVisibility(View.VISIBLE);
|
||||
}else if( res == R.drawable.ic_edit_black_menu){
|
||||
}else if(type.equals(COMPOSE)){
|
||||
settings_compose.setVisibility(View.VISIBLE);
|
||||
}else if( res == R.drawable.ic_visibility_off_menu){
|
||||
}else if( type.equals(HIDDEN)){
|
||||
settings_hidden.setVisibility(View.VISIBLE);
|
||||
}else if( res == R.drawable.ic_all_inclusive_menu){
|
||||
}else if( type.equals(TODO)){
|
||||
settings_to_do.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else if( res == R.drawable.ic_close){
|
||||
|
||||
}
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
|
After Width: | Height: | Size: 291 B |
After Width: | Height: | Size: 291 B |
After Width: | Height: | Size: 209 B |
After Width: | Height: | Size: 209 B |
After Width: | Height: | Size: 370 B |
After Width: | Height: | Size: 370 B |
After Width: | Height: | Size: 577 B |
After Width: | Height: | Size: 577 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 798 B |
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@drawable/item_down"/>
|
||||
<item android:state_selected="true" android:drawable="@drawable/item_down"/>
|
||||
<item android:state_focused="true" android:drawable="@drawable/item_down"/>
|
||||
<item android:drawable="@drawable/item_up"/>
|
||||
</selector>
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
@ -11,10 +11,12 @@
|
|||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/content_overlay"
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"/>
|
||||
<LinearLayout
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
android:id="@+id/content_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/menu_item_container"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:clickable="true"
|
||||
android:background="@drawable/menu_item_selector">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/menu_item_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"/>
|
||||
|
||||
|
||||
</RelativeLayout>
|