Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
88c4f72b
Commit
88c4f72b
authored
May 02, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Butterknife
parent
abbcdf91
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
115 deletions
+89
-115
build.gradle
app/build.gradle
+0
-4
CustomAlertDialog.java
.../com/topjohnwu/magisk/view/dialogs/CustomAlertDialog.java
+24
-48
FingerprintAuthDialog.java
.../topjohnwu/magisk/view/dialogs/FingerprintAuthDialog.java
+9
-9
alert_dialog.xml
app/src/main/res/layout/alert_dialog.xml
+56
-54
No files found.
app/build.gradle
View file @
88c4f72b
...
...
@@ -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}"
...
...
app/src/main/java/com/topjohnwu/magisk/view/dialogs/CustomAlertDialog.java
View file @
88c4f72b
...
...
@@ -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
);
}
...
...
app/src/main/java/com/topjohnwu/magisk/view/dialogs/FingerprintAuthDialog.java
View file @
88c4f72b
...
...
@@ -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
...
...
app/src/main/res/layout/alert_dialog.xml
View file @
88c4f72b
<?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/
neutra
l"
style=
"
@style/Widget.Button.Text
"
android:layout_width=
"
0dp
"
android:layout_height=
"
match_par
ent"
android:
layout_gravity=
"center_horizontal
"
android:
layout_weight=
"1
"
android:
maxLines=
"2
"
tools:text=
"Neutral"
/
>
<
LinearLayout
android:id=
"@+id/
button_pane
l"
style=
"
?android:attr/buttonBarStyle
"
android:layout_width=
"
match_parent
"
android:layout_height=
"
wrap_cont
ent"
android:
measureWithLargestChild=
"true
"
android:
minHeight=
"54dp
"
android:
orientation=
"horizontal
"
android:padding=
"2dp"
>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/posi
tive"
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=
"Posi
tive"
/>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/nega
tive"
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=
"Nega
tive"
/>
</LinearLayout>
<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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment