mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-24 20:37:39 +00:00
Make advanced settings expandable
This commit is contained in:
parent
28d7a7a6d2
commit
6e7b90a184
@ -5,8 +5,6 @@ import android.content.pm.PackageManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -16,6 +14,7 @@ import com.topjohnwu.magisk.container.Policy;
|
||||
import com.topjohnwu.magisk.database.MagiskDB;
|
||||
import com.topjohnwu.magisk.dialogs.CustomAlertDialog;
|
||||
import com.topjohnwu.magisk.dialogs.FingerprintAuthDialog;
|
||||
import com.topjohnwu.magisk.uicomponents.ArrowExpandedViewHolder;
|
||||
import com.topjohnwu.magisk.uicomponents.ExpandableViewHolder;
|
||||
import com.topjohnwu.magisk.uicomponents.SnackbarMaker;
|
||||
import com.topjohnwu.magisk.utils.FingerprintHelper;
|
||||
@ -156,33 +155,7 @@ public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
new PolicyAdapter$ViewHolder_ViewBinding(this, itemView);
|
||||
settings = new ExpandableViewHolder(expandLayout) {
|
||||
@Override
|
||||
public void setExpanded(boolean expanded) {
|
||||
super.setExpanded(expanded);
|
||||
arrow.setRotation(expanded ? 180 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand() {
|
||||
super.expand();
|
||||
setRotate(new RotateAnimation(0, 180,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collapse() {
|
||||
super.collapse();
|
||||
setRotate(new RotateAnimation(180, 0,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void setRotate(RotateAnimation rotate) {
|
||||
rotate.setDuration(300);
|
||||
rotate.setFillAfter(true);
|
||||
arrow.startAnimation(rotate);
|
||||
settings = new ArrowExpandedViewHolder(expandLayout, arrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.topjohnwu.magisk.fragments;
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.topjohnwu.magisk.BuildConfig;
|
||||
@ -20,6 +19,8 @@ import com.topjohnwu.magisk.dialogs.MagiskInstallDialog;
|
||||
import com.topjohnwu.magisk.dialogs.ManagerInstallDialog;
|
||||
import com.topjohnwu.magisk.dialogs.UninstallDialog;
|
||||
import com.topjohnwu.magisk.tasks.CheckUpdates;
|
||||
import com.topjohnwu.magisk.uicomponents.ArrowExpandedViewHolder;
|
||||
import com.topjohnwu.magisk.uicomponents.ExpandableViewHolder;
|
||||
import com.topjohnwu.magisk.uicomponents.SafetyNet;
|
||||
import com.topjohnwu.magisk.uicomponents.UpdateCardHolder;
|
||||
import com.topjohnwu.magisk.utils.Topic;
|
||||
@ -53,6 +54,9 @@ public class MagiskFragment extends BaseFragment
|
||||
@BindView(R.id.install_option_card) CardView installOptionCard;
|
||||
@BindView(R.id.keep_force_enc) CheckBox keepEncChkbox;
|
||||
@BindView(R.id.keep_verity) CheckBox keepVerityChkbox;
|
||||
@BindView(R.id.install_option_expand) ViewGroup optionExpandLayout;
|
||||
@BindView(R.id.arrow) ImageView arrow;
|
||||
|
||||
@BindView(R.id.uninstall_button) CardView uninstallButton;
|
||||
|
||||
@BindColor(R.color.red500) int colorBad;
|
||||
@ -65,6 +69,7 @@ public class MagiskFragment extends BaseFragment
|
||||
private UpdateCardHolder manager;
|
||||
private SafetyNet safetyNet;
|
||||
private Transition transition;
|
||||
private ExpandableViewHolder optionExpand;
|
||||
|
||||
private void magiskInstall(View v) {
|
||||
// Show Manager update first
|
||||
@ -84,6 +89,13 @@ public class MagiskFragment extends BaseFragment
|
||||
new UninstallDialog(requireActivity()).show();
|
||||
}
|
||||
|
||||
@OnClick(R.id.arrow)
|
||||
void expandOptions() {
|
||||
if (optionExpand.isExpanded())
|
||||
optionExpand.collapse();
|
||||
else optionExpand.expand();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@ -92,6 +104,7 @@ public class MagiskFragment extends BaseFragment
|
||||
unbinder = new MagiskFragment_ViewBinding(this, v);
|
||||
requireActivity().setTitle(R.string.magisk);
|
||||
|
||||
optionExpand = new ArrowExpandedViewHolder(optionExpandLayout, arrow);
|
||||
safetyNet = new SafetyNet(v);
|
||||
magisk = new UpdateCardHolder(inflater, root);
|
||||
manager = new UpdateCardHolder(inflater, root);
|
||||
@ -167,17 +180,6 @@ public class MagiskFragment extends BaseFragment
|
||||
updateCheckUI();
|
||||
}
|
||||
|
||||
private boolean hasGms() {
|
||||
PackageManager pm = app.getPackageManager();
|
||||
PackageInfo info;
|
||||
try {
|
||||
info = pm.getPackageInfo("com.google.android.gms", 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
return info.applicationInfo.enabled;
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
((MainActivity) requireActivity()).checkHideSection();
|
||||
int image, color;
|
||||
|
@ -0,0 +1,43 @@
|
||||
package com.topjohnwu.magisk.uicomponents;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.RotateAnimation;
|
||||
|
||||
public class ArrowExpandedViewHolder extends ExpandableViewHolder {
|
||||
|
||||
private View arrow;
|
||||
|
||||
public ArrowExpandedViewHolder(ViewGroup viewGroup, View arrow) {
|
||||
super(viewGroup);
|
||||
this.arrow = arrow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpanded(boolean expanded) {
|
||||
super.setExpanded(expanded);
|
||||
if (arrow != null)
|
||||
arrow.setRotation(expanded ? 180 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand() {
|
||||
super.expand();
|
||||
setRotate(new RotateAnimation(0, 180,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collapse() {
|
||||
super.collapse();
|
||||
setRotate(new RotateAnimation(180, 0,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
|
||||
}
|
||||
|
||||
private void setRotate(RotateAnimation rotate) {
|
||||
rotate.setDuration(300);
|
||||
rotate.setFillAfter(true);
|
||||
arrow.startAnimation(rotate);
|
||||
}
|
||||
}
|
@ -150,42 +150,68 @@
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:visibility="gone"
|
||||
app:cardCornerRadius="@dimen/card_corner_radius"
|
||||
app:cardElevation="@dimen/card_elevation">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp">
|
||||
|
||||
<TextView
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/advanced_settings_title"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/arrow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:tint="?attr/imageColorTint"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/title"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_arrow" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/install_option_expand"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="10dp"
|
||||
android:text="@string/advanced_settings_title"
|
||||
android:textStyle="bold" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/keep_force_enc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:text="@string/keep_force_encryption" />
|
||||
<CheckBox
|
||||
android:id="@+id/keep_force_enc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:text="@string/keep_force_encryption" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/keep_verity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:text="@string/keep_dm_verity" />
|
||||
<CheckBox
|
||||
android:id="@+id/keep_verity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="50dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:text="@string/keep_dm_verity" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
Loading…
x
Reference in New Issue
Block a user