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 {
...
@@ -59,10 +59,6 @@ dependencies {
implementation
"com.github.topjohnwu.libsu:core:${libsuVersion}"
implementation
"com.github.topjohnwu.libsu:core:${libsuVersion}"
implementation
"com.github.topjohnwu.libsu:io:${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"
def
koin
=
"2.0.0-rc-2"
implementation
"org.koin:koin-core:${koin}"
implementation
"org.koin:koin-core:${koin}"
implementation
"org.koin:koin-android:${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;
...
@@ -4,18 +4,14 @@ import android.content.Context;
import
android.content.DialogInterface
;
import
android.content.DialogInterface
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
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.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.StringRes
;
import
androidx.annotation.StringRes
;
import
androidx.annotation.StyleRes
;
import
androidx.annotation.StyleRes
;
import
androidx.appcompat.app.AlertDialog
;
import
androidx.appcompat.app.AlertDialog
;
import
butterknife.BindView
;
import
com.topjohnwu.magisk.databinding.AlertDialogBinding
;
public
class
CustomAlertDialog
extends
AlertDialog
.
Builder
{
public
class
CustomAlertDialog
extends
AlertDialog
.
Builder
{
...
@@ -24,32 +20,16 @@ public class CustomAlertDialog extends AlertDialog.Builder {
...
@@ -24,32 +20,16 @@ public class CustomAlertDialog extends AlertDialog.Builder {
private
DialogInterface
.
OnClickListener
neutralListener
;
private
DialogInterface
.
OnClickListener
neutralListener
;
protected
AlertDialog
dialog
;
protected
AlertDialog
dialog
;
protected
ViewHolder
vh
;
protected
AlertDialogBinding
binding
;
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
);
}
}
{
{
View
v
=
LayoutInflater
.
from
(
getContext
()).
inflate
(
R
.
layout
.
alert_dialog
,
null
);
binding
=
AlertDialogBinding
.
inflate
(
LayoutInflater
.
from
(
getContext
()));
vh
=
new
ViewHolder
(
v
);
super
.
setView
(
binding
.
getRoot
());
super
.
setView
(
v
);
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
)
{
public
CustomAlertDialog
(
@NonNull
Context
context
)
{
...
@@ -60,10 +40,6 @@ public class CustomAlertDialog extends AlertDialog.Builder {
...
@@ -60,10 +40,6 @@ public class CustomAlertDialog extends AlertDialog.Builder {
super
(
context
,
themeResId
);
super
(
context
,
themeResId
);
}
}
public
ViewHolder
getViewHolder
()
{
return
vh
;
}
@Override
@Override
public
CustomAlertDialog
setView
(
int
layoutResId
)
{
return
this
;
}
public
CustomAlertDialog
setView
(
int
layoutResId
)
{
return
this
;
}
...
@@ -72,8 +48,8 @@ public class CustomAlertDialog extends AlertDialog.Builder {
...
@@ -72,8 +48,8 @@ public class CustomAlertDialog extends AlertDialog.Builder {
@Override
@Override
public
CustomAlertDialog
setMessage
(
@Nullable
CharSequence
message
)
{
public
CustomAlertDialog
setMessage
(
@Nullable
CharSequence
message
)
{
vh
.
messageView
.
setVisibility
(
View
.
VISIBLE
);
binding
.
message
.
setVisibility
(
View
.
VISIBLE
);
vh
.
messageView
.
setText
(
message
);
binding
.
message
.
setText
(
message
);
return
this
;
return
this
;
}
}
...
@@ -84,11 +60,11 @@ public class CustomAlertDialog extends AlertDialog.Builder {
...
@@ -84,11 +60,11 @@ public class CustomAlertDialog extends AlertDialog.Builder {
@Override
@Override
public
CustomAlertDialog
setPositiveButton
(
CharSequence
text
,
DialogInterface
.
OnClickListener
listener
)
{
public
CustomAlertDialog
setPositiveButton
(
CharSequence
text
,
DialogInterface
.
OnClickListener
listener
)
{
vh
.
buttons
.
setVisibility
(
View
.
VISIBLE
);
binding
.
buttonPanel
.
setVisibility
(
View
.
VISIBLE
);
vh
.
positive
.
setVisibility
(
View
.
VISIBLE
);
binding
.
positive
.
setVisibility
(
View
.
VISIBLE
);
vh
.
positive
.
setText
(
text
);
binding
.
positive
.
setText
(
text
);
positiveListener
=
listener
;
positiveListener
=
listener
;
vh
.
positive
.
setOnClickListener
(
v
->
{
binding
.
positive
.
setOnClickListener
(
v
->
{
if
(
positiveListener
!=
null
)
{
if
(
positiveListener
!=
null
)
{
positiveListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_POSITIVE
);
positiveListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_POSITIVE
);
}
}
...
@@ -104,11 +80,11 @@ public class CustomAlertDialog extends AlertDialog.Builder {
...
@@ -104,11 +80,11 @@ public class CustomAlertDialog extends AlertDialog.Builder {
@Override
@Override
public
CustomAlertDialog
setNegativeButton
(
CharSequence
text
,
DialogInterface
.
OnClickListener
listener
)
{
public
CustomAlertDialog
setNegativeButton
(
CharSequence
text
,
DialogInterface
.
OnClickListener
listener
)
{
vh
.
buttons
.
setVisibility
(
View
.
VISIBLE
);
binding
.
buttonPanel
.
setVisibility
(
View
.
VISIBLE
);
vh
.
negative
.
setVisibility
(
View
.
VISIBLE
);
binding
.
negative
.
setVisibility
(
View
.
VISIBLE
);
vh
.
negative
.
setText
(
text
);
binding
.
negative
.
setText
(
text
);
negativeListener
=
listener
;
negativeListener
=
listener
;
vh
.
negative
.
setOnClickListener
(
v
->
{
binding
.
negative
.
setOnClickListener
(
v
->
{
if
(
negativeListener
!=
null
)
{
if
(
negativeListener
!=
null
)
{
negativeListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_NEGATIVE
);
negativeListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_NEGATIVE
);
}
}
...
@@ -124,11 +100,11 @@ public class CustomAlertDialog extends AlertDialog.Builder {
...
@@ -124,11 +100,11 @@ public class CustomAlertDialog extends AlertDialog.Builder {
@Override
@Override
public
CustomAlertDialog
setNeutralButton
(
CharSequence
text
,
DialogInterface
.
OnClickListener
listener
)
{
public
CustomAlertDialog
setNeutralButton
(
CharSequence
text
,
DialogInterface
.
OnClickListener
listener
)
{
vh
.
buttons
.
setVisibility
(
View
.
VISIBLE
);
binding
.
buttonPanel
.
setVisibility
(
View
.
VISIBLE
);
vh
.
neutral
.
setVisibility
(
View
.
VISIBLE
);
binding
.
neutral
.
setVisibility
(
View
.
VISIBLE
);
vh
.
neutral
.
setText
(
text
);
binding
.
neutral
.
setText
(
text
);
neutralListener
=
listener
;
neutralListener
=
listener
;
vh
.
neutral
.
setOnClickListener
(
v
->
{
binding
.
neutral
.
setOnClickListener
(
v
->
{
if
(
neutralListener
!=
null
)
{
if
(
neutralListener
!=
null
)
{
neutralListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_NEUTRAL
);
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 {
...
@@ -36,9 +36,9 @@ public class FingerprintAuthDialog extends CustomAlertDialog {
TypedArray
ta
=
theme
.
obtainStyledAttributes
(
new
int
[]
{
R
.
attr
.
imageColorTint
});
TypedArray
ta
=
theme
.
obtainStyledAttributes
(
new
int
[]
{
R
.
attr
.
imageColorTint
});
fingerprint
.
setTint
(
ta
.
getColor
(
0
,
Color
.
GRAY
));
fingerprint
.
setTint
(
ta
.
getColor
(
0
,
Color
.
GRAY
));
ta
.
recycle
();
ta
.
recycle
();
vh
.
messageView
.
setCompoundDrawables
(
null
,
null
,
null
,
fingerprint
);
binding
.
message
.
setCompoundDrawables
(
null
,
null
,
null
,
fingerprint
);
vh
.
messageView
.
setCompoundDrawablePadding
(
Utils
.
dpInPx
(
20
));
binding
.
message
.
setCompoundDrawablePadding
(
Utils
.
dpInPx
(
20
));
vh
.
messageView
.
setGravity
(
Gravity
.
CENTER
);
binding
.
message
.
setGravity
(
Gravity
.
CENTER
);
setMessage
(
R
.
string
.
auth_fingerprint
);
setMessage
(
R
.
string
.
auth_fingerprint
);
setNegativeButton
(
R
.
string
.
close
,
(
d
,
w
)
->
{
setNegativeButton
(
R
.
string
.
close
,
(
d
,
w
)
->
{
helper
.
cancel
();
helper
.
cancel
();
...
@@ -81,20 +81,20 @@ public class FingerprintAuthDialog extends CustomAlertDialog {
...
@@ -81,20 +81,20 @@ public class FingerprintAuthDialog extends CustomAlertDialog {
@Override
@Override
public
void
onAuthenticationError
(
int
errorCode
,
CharSequence
errString
)
{
public
void
onAuthenticationError
(
int
errorCode
,
CharSequence
errString
)
{
vh
.
messageView
.
setTextColor
(
Color
.
RED
);
binding
.
message
.
setTextColor
(
Color
.
RED
);
vh
.
messageView
.
setText
(
errString
);
binding
.
message
.
setText
(
errString
);
}
}
@Override
@Override
public
void
onAuthenticationHelp
(
int
helpCode
,
CharSequence
helpString
)
{
public
void
onAuthenticationHelp
(
int
helpCode
,
CharSequence
helpString
)
{
vh
.
messageView
.
setTextColor
(
Color
.
RED
);
binding
.
message
.
setTextColor
(
Color
.
RED
);
vh
.
messageView
.
setText
(
helpString
);
binding
.
message
.
setText
(
helpString
);
}
}
@Override
@Override
public
void
onAuthenticationFailed
()
{
public
void
onAuthenticationFailed
()
{
vh
.
messageView
.
setTextColor
(
Color
.
RED
);
binding
.
message
.
setTextColor
(
Color
.
RED
);
vh
.
messageView
.
setText
(
R
.
string
.
auth_fail
);
binding
.
message
.
setText
(
R
.
string
.
auth_fail
);
}
}
@Override
@Override
...
...
app/src/main/res/layout/alert_dialog.xml
View file @
88c4f72b
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
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"
/>
<LinearLayout
<LinearLayout
android:id=
"@+id/button_panel"
android:id=
"@+id/dialog_layout"
style=
"?android:attr/buttonBarStyle"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:measureWithLargestChild=
"true"
android:orientation=
"vertical"
android:minHeight=
"54dp"
android:paddingTop=
"5dp"
>
android:orientation=
"horizontal"
android:padding=
"2dp"
>
<com.google.android.material.button.MaterialButton
<TextView
android:id=
"@+id/negative"
android:id=
"@+id/message"
style=
"@style/Widget.Button.Text"
style=
"?android:attr/textAppearanceMedium"
android:layout_width=
"0dp"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"start"
android:paddingStart=
"25dp"
android:layout_weight=
"1"
android:paddingTop=
"12dp"
android:maxLines=
"2"
android:paddingEnd=
"25dp"
tools:text=
"Negative"
/>
android:paddingBottom=
"12dp"
android:textColor=
"?android:attr/textColorPrimary"
/>
<
com.google.android.material.button.MaterialButton
<
LinearLayout
android:id=
"@+id/
neutra
l"
android:id=
"@+id/
button_pane
l"
style=
"
@style/Widget.Button.Text
"
style=
"
?android:attr/buttonBarStyle
"
android:layout_width=
"
0dp
"
android:layout_width=
"
match_parent
"
android:layout_height=
"
match_par
ent"
android:layout_height=
"
wrap_cont
ent"
android:
layout_gravity=
"center_horizontal
"
android:
measureWithLargestChild=
"true
"
android:
layout_weight=
"1
"
android:
minHeight=
"54dp
"
android:
maxLines=
"2
"
android:
orientation=
"horizontal
"
tools:text=
"Neutral"
/
>
android:padding=
"2dp"
>
<com.google.android.material.button.MaterialButton
<com.google.android.material.button.MaterialButton
android:id=
"@+id/posi
tive"
android:id=
"@+id/nega
tive"
style=
"@style/Widget.Button.Text"
style=
"@style/Widget.Button.Text"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"end
"
android:layout_gravity=
"start
"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:maxLines=
"2"
android:maxLines=
"2"
tools:text=
"Posi
tive"
/>
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