mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 12:05:30 +00:00
Remove Butterknife
This commit is contained in:
parent
abbcdf91a5
commit
88c4f72b37
@ -59,10 +59,6 @@ dependencies {
|
||||
implementation "com.github.topjohnwu.libsu:core:${libsuVersion}"
|
||||
implementation "com.github.topjohnwu.libsu:io:${libsuVersion}"
|
||||
|
||||
def butterKnifeVersion = '10.1.0'
|
||||
implementation "com.jakewharton:butterknife-runtime:${butterKnifeVersion}"
|
||||
kapt "com.jakewharton:butterknife-compiler:${butterKnifeVersion}"
|
||||
|
||||
def koin = "2.0.0-rc-2"
|
||||
implementation "org.koin:koin-core:${koin}"
|
||||
implementation "org.koin:koin-android:${koin}"
|
||||
|
@ -4,18 +4,14 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.topjohnwu.magisk.R;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import butterknife.BindView;
|
||||
|
||||
import com.topjohnwu.magisk.databinding.AlertDialogBinding;
|
||||
|
||||
public class CustomAlertDialog extends AlertDialog.Builder {
|
||||
|
||||
@ -24,32 +20,16 @@ public class CustomAlertDialog extends AlertDialog.Builder {
|
||||
private DialogInterface.OnClickListener neutralListener;
|
||||
|
||||
protected AlertDialog dialog;
|
||||
protected ViewHolder vh;
|
||||
|
||||
public class ViewHolder {
|
||||
@BindView(R.id.dialog_layout) public LinearLayout dialogLayout;
|
||||
@BindView(R.id.button_panel) public LinearLayout buttons;
|
||||
|
||||
@BindView(R.id.message) public TextView messageView;
|
||||
@BindView(R.id.negative) public Button negative;
|
||||
@BindView(R.id.positive) public Button positive;
|
||||
@BindView(R.id.neutral) public Button neutral;
|
||||
|
||||
ViewHolder(View v) {
|
||||
new CustomAlertDialog$ViewHolder_ViewBinding(this, v);
|
||||
messageView.setVisibility(View.GONE);
|
||||
negative.setVisibility(View.GONE);
|
||||
positive.setVisibility(View.GONE);
|
||||
neutral.setVisibility(View.GONE);
|
||||
buttons.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
protected AlertDialogBinding binding;
|
||||
|
||||
{
|
||||
View v = LayoutInflater.from(getContext()).inflate(R.layout.alert_dialog, null);
|
||||
vh = new ViewHolder(v);
|
||||
super.setView(v);
|
||||
|
||||
binding = AlertDialogBinding.inflate(LayoutInflater.from(getContext()));
|
||||
super.setView(binding.getRoot());
|
||||
binding.message.setVisibility(View.GONE);
|
||||
binding.negative.setVisibility(View.GONE);
|
||||
binding.positive.setVisibility(View.GONE);
|
||||
binding.neutral.setVisibility(View.GONE);
|
||||
binding.buttonPanel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public CustomAlertDialog(@NonNull Context context) {
|
||||
@ -60,10 +40,6 @@ public class CustomAlertDialog extends AlertDialog.Builder {
|
||||
super(context, themeResId);
|
||||
}
|
||||
|
||||
public ViewHolder getViewHolder() {
|
||||
return vh;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomAlertDialog setView(int layoutResId) { return this; }
|
||||
|
||||
@ -72,8 +48,8 @@ public class CustomAlertDialog extends AlertDialog.Builder {
|
||||
|
||||
@Override
|
||||
public CustomAlertDialog setMessage(@Nullable CharSequence message) {
|
||||
vh.messageView.setVisibility(View.VISIBLE);
|
||||
vh.messageView.setText(message);
|
||||
binding.message.setVisibility(View.VISIBLE);
|
||||
binding.message.setText(message);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -84,11 +60,11 @@ public class CustomAlertDialog extends AlertDialog.Builder {
|
||||
|
||||
@Override
|
||||
public CustomAlertDialog setPositiveButton(CharSequence text, DialogInterface.OnClickListener listener) {
|
||||
vh.buttons.setVisibility(View.VISIBLE);
|
||||
vh.positive.setVisibility(View.VISIBLE);
|
||||
vh.positive.setText(text);
|
||||
binding.buttonPanel.setVisibility(View.VISIBLE);
|
||||
binding.positive.setVisibility(View.VISIBLE);
|
||||
binding.positive.setText(text);
|
||||
positiveListener = listener;
|
||||
vh.positive.setOnClickListener(v -> {
|
||||
binding.positive.setOnClickListener(v -> {
|
||||
if (positiveListener != null) {
|
||||
positiveListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
|
||||
}
|
||||
@ -104,11 +80,11 @@ public class CustomAlertDialog extends AlertDialog.Builder {
|
||||
|
||||
@Override
|
||||
public CustomAlertDialog setNegativeButton(CharSequence text, DialogInterface.OnClickListener listener) {
|
||||
vh.buttons.setVisibility(View.VISIBLE);
|
||||
vh.negative.setVisibility(View.VISIBLE);
|
||||
vh.negative.setText(text);
|
||||
binding.buttonPanel.setVisibility(View.VISIBLE);
|
||||
binding.negative.setVisibility(View.VISIBLE);
|
||||
binding.negative.setText(text);
|
||||
negativeListener = listener;
|
||||
vh.negative.setOnClickListener(v -> {
|
||||
binding.negative.setOnClickListener(v -> {
|
||||
if (negativeListener != null) {
|
||||
negativeListener.onClick(dialog, DialogInterface.BUTTON_NEGATIVE);
|
||||
}
|
||||
@ -124,11 +100,11 @@ public class CustomAlertDialog extends AlertDialog.Builder {
|
||||
|
||||
@Override
|
||||
public CustomAlertDialog setNeutralButton(CharSequence text, DialogInterface.OnClickListener listener) {
|
||||
vh.buttons.setVisibility(View.VISIBLE);
|
||||
vh.neutral.setVisibility(View.VISIBLE);
|
||||
vh.neutral.setText(text);
|
||||
binding.buttonPanel.setVisibility(View.VISIBLE);
|
||||
binding.neutral.setVisibility(View.VISIBLE);
|
||||
binding.neutral.setText(text);
|
||||
neutralListener = listener;
|
||||
vh.neutral.setOnClickListener(v -> {
|
||||
binding.neutral.setOnClickListener(v -> {
|
||||
if (neutralListener != null) {
|
||||
neutralListener.onClick(dialog, DialogInterface.BUTTON_NEUTRAL);
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ public class FingerprintAuthDialog extends CustomAlertDialog {
|
||||
TypedArray ta = theme.obtainStyledAttributes(new int[] {R.attr.imageColorTint});
|
||||
fingerprint.setTint(ta.getColor(0, Color.GRAY));
|
||||
ta.recycle();
|
||||
vh.messageView.setCompoundDrawables(null, null, null, fingerprint);
|
||||
vh.messageView.setCompoundDrawablePadding(Utils.dpInPx(20));
|
||||
vh.messageView.setGravity(Gravity.CENTER);
|
||||
binding.message.setCompoundDrawables(null, null, null, fingerprint);
|
||||
binding.message.setCompoundDrawablePadding(Utils.dpInPx(20));
|
||||
binding.message.setGravity(Gravity.CENTER);
|
||||
setMessage(R.string.auth_fingerprint);
|
||||
setNegativeButton(R.string.close, (d, w) -> {
|
||||
helper.cancel();
|
||||
@ -81,20 +81,20 @@ public class FingerprintAuthDialog extends CustomAlertDialog {
|
||||
|
||||
@Override
|
||||
public void onAuthenticationError(int errorCode, CharSequence errString) {
|
||||
vh.messageView.setTextColor(Color.RED);
|
||||
vh.messageView.setText(errString);
|
||||
binding.message.setTextColor(Color.RED);
|
||||
binding.message.setText(errString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationHelp(int helpCode, CharSequence helpString) {
|
||||
vh.messageView.setTextColor(Color.RED);
|
||||
vh.messageView.setText(helpString);
|
||||
binding.message.setTextColor(Color.RED);
|
||||
binding.message.setText(helpString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationFailed() {
|
||||
vh.messageView.setTextColor(Color.RED);
|
||||
vh.messageView.setText(R.string.auth_fail);
|
||||
binding.message.setTextColor(Color.RED);
|
||||
binding.message.setText(R.string.auth_fail);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<LinearLayout
|
||||
android:id="@+id/dialog_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -61,3 +62,4 @@
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user