mirror of
				https://github.com/topjohnwu/Magisk.git
				synced 2025-10-31 17:50:45 +00:00 
			
		
		
		
	Remove Butterknife
This commit is contained in:
		| @@ -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,63 +1,65 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:id="@+id/dialog_layout" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="wrap_content" | ||||
|     android:orientation="vertical" | ||||
|     android:paddingTop="5dp"> | ||||
|  | ||||
|     <TextView | ||||
|         android:id="@+id/message" | ||||
|         style="?android:attr/textAppearanceMedium" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:paddingStart="25dp" | ||||
|         android:paddingTop="12dp" | ||||
|         android:paddingEnd="25dp" | ||||
|         android:paddingBottom="12dp" | ||||
|         android:textColor="?android:attr/textColorPrimary" /> | ||||
|  | ||||
| <layout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:tools="http://schemas.android.com/tools"> | ||||
|     <LinearLayout | ||||
|         android:id="@+id/button_panel" | ||||
|         style="?android:attr/buttonBarStyle" | ||||
|         android:id="@+id/dialog_layout" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:measureWithLargestChild="true" | ||||
|         android:minHeight="54dp" | ||||
|         android:orientation="horizontal" | ||||
|         android:padding="2dp"> | ||||
|         android:orientation="vertical" | ||||
|         android:paddingTop="5dp"> | ||||
|  | ||||
|         <com.google.android.material.button.MaterialButton | ||||
|             android:id="@+id/negative" | ||||
|             style="@style/Widget.Button.Text" | ||||
|             android:layout_width="0dp" | ||||
|             android:layout_height="match_parent" | ||||
|             android:layout_gravity="start" | ||||
|             android:layout_weight="1" | ||||
|             android:maxLines="2" | ||||
|             tools:text="Negative" /> | ||||
|         <TextView | ||||
|             android:id="@+id/message" | ||||
|             style="?android:attr/textAppearanceMedium" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:paddingStart="25dp" | ||||
|             android:paddingTop="12dp" | ||||
|             android:paddingEnd="25dp" | ||||
|             android:paddingBottom="12dp" | ||||
|             android:textColor="?android:attr/textColorPrimary" /> | ||||
|  | ||||
|         <com.google.android.material.button.MaterialButton | ||||
|             android:id="@+id/neutral" | ||||
|             style="@style/Widget.Button.Text" | ||||
|             android:layout_width="0dp" | ||||
|             android:layout_height="match_parent" | ||||
|             android:layout_gravity="center_horizontal" | ||||
|             android:layout_weight="1" | ||||
|             android:maxLines="2" | ||||
|             tools:text="Neutral" /> | ||||
|         <LinearLayout | ||||
|             android:id="@+id/button_panel" | ||||
|             style="?android:attr/buttonBarStyle" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:measureWithLargestChild="true" | ||||
|             android:minHeight="54dp" | ||||
|             android:orientation="horizontal" | ||||
|             android:padding="2dp"> | ||||
|  | ||||
|         <com.google.android.material.button.MaterialButton | ||||
|             android:id="@+id/positive" | ||||
|             style="@style/Widget.Button.Text" | ||||
|             android:layout_width="0dp" | ||||
|             android:layout_height="match_parent" | ||||
|             android:layout_gravity="end" | ||||
|             android:layout_weight="1" | ||||
|             android:maxLines="2" | ||||
|             tools:text="Positive" /> | ||||
|             <com.google.android.material.button.MaterialButton | ||||
|                 android:id="@+id/negative" | ||||
|                 style="@style/Widget.Button.Text" | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="match_parent" | ||||
|                 android:layout_gravity="start" | ||||
|                 android:layout_weight="1" | ||||
|                 android:maxLines="2" | ||||
|                 tools:text="Negative" /> | ||||
|  | ||||
|             <com.google.android.material.button.MaterialButton | ||||
|                 android:id="@+id/neutral" | ||||
|                 style="@style/Widget.Button.Text" | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="match_parent" | ||||
|                 android:layout_gravity="center_horizontal" | ||||
|                 android:layout_weight="1" | ||||
|                 android:maxLines="2" | ||||
|                 tools:text="Neutral" /> | ||||
|  | ||||
|             <com.google.android.material.button.MaterialButton | ||||
|                 android:id="@+id/positive" | ||||
|                 style="@style/Widget.Button.Text" | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="match_parent" | ||||
|                 android:layout_gravity="end" | ||||
|                 android:layout_weight="1" | ||||
|                 android:maxLines="2" | ||||
|                 tools:text="Positive" /> | ||||
|  | ||||
|         </LinearLayout> | ||||
|  | ||||
|     </LinearLayout> | ||||
|  | ||||
| </LinearLayout> | ||||
| </layout> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 topjohnwu
					topjohnwu