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
c4afa069
Commit
c4afa069
authored
Feb 13, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add custom AlertDialog
parent
1bfafdb4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
210 additions
and
5 deletions
+210
-5
AlertDialogBuilder.java
...a/com/topjohnwu/magisk/components/AlertDialogBuilder.java
+129
-0
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+7
-5
alert_dialog.xml
app/src/main/res/layout/alert_dialog.xml
+74
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/components/AlertDialogBuilder.java
0 → 100644
View file @
c4afa069
package
com
.
topjohnwu
.
magisk
.
components
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.StringRes
;
import
android.support.annotation.StyleRes
;
import
android.support.v7.app.AlertDialog
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.R
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
public
class
AlertDialogBuilder
extends
AlertDialog
.
Builder
{
@BindView
(
R
.
id
.
negative
)
Button
negative
;
@BindView
(
R
.
id
.
positive
)
Button
positive
;
@BindView
(
R
.
id
.
neutral
)
Button
neutral
;
@BindView
(
R
.
id
.
message
)
TextView
messageView
;
private
DialogInterface
.
OnClickListener
positiveListener
;
private
DialogInterface
.
OnClickListener
negativeListener
;
private
DialogInterface
.
OnClickListener
neutralListener
;
private
AlertDialog
dialog
;
public
AlertDialogBuilder
(
@NonNull
Context
context
)
{
super
(
context
);
setup
();
}
public
AlertDialogBuilder
(
@NonNull
Context
context
,
@StyleRes
int
themeResId
)
{
super
(
context
,
themeResId
);
setup
();
}
private
void
setup
()
{
View
v
=
LayoutInflater
.
from
(
getContext
()).
inflate
(
R
.
layout
.
alert_dialog
,
null
);
ButterKnife
.
bind
(
this
,
v
);
super
.
setView
(
v
);
negative
.
setVisibility
(
View
.
GONE
);
positive
.
setVisibility
(
View
.
GONE
);
neutral
.
setVisibility
(
View
.
GONE
);
}
@Override
public
AlertDialog
.
Builder
setMessage
(
@Nullable
CharSequence
message
)
{
messageView
.
setText
(
message
);
return
this
;
}
@Override
public
AlertDialog
.
Builder
setMessage
(
@StringRes
int
messageId
)
{
return
setMessage
(
getContext
().
getString
(
messageId
));
}
@Override
public
AlertDialog
.
Builder
setPositiveButton
(
CharSequence
text
,
DialogInterface
.
OnClickListener
listener
)
{
positive
.
setVisibility
(
View
.
VISIBLE
);
positive
.
setText
(
text
);
positiveListener
=
listener
;
positive
.
setOnClickListener
((
v
)
->
{
if
(
positiveListener
!=
null
)
positiveListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_POSITIVE
);
dialog
.
dismiss
();
});
return
this
;
}
@Override
public
AlertDialog
.
Builder
setPositiveButton
(
@StringRes
int
textId
,
DialogInterface
.
OnClickListener
listener
)
{
return
setPositiveButton
(
getContext
().
getString
(
textId
),
listener
);
}
@Override
public
AlertDialog
.
Builder
setNegativeButton
(
CharSequence
text
,
DialogInterface
.
OnClickListener
listener
)
{
negative
.
setVisibility
(
View
.
VISIBLE
);
negative
.
setText
(
text
);
negativeListener
=
listener
;
negative
.
setOnClickListener
((
v
)
->
{
if
(
negativeListener
!=
null
)
negativeListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_NEGATIVE
);
dialog
.
dismiss
();
});
return
this
;
}
@Override
public
AlertDialog
.
Builder
setNegativeButton
(
@StringRes
int
textId
,
DialogInterface
.
OnClickListener
listener
)
{
return
setNegativeButton
(
getContext
().
getString
(
textId
),
listener
);
}
@Override
public
AlertDialog
.
Builder
setNeutralButton
(
CharSequence
text
,
DialogInterface
.
OnClickListener
listener
)
{
neutral
.
setVisibility
(
View
.
VISIBLE
);
neutral
.
setText
(
text
);
neutralListener
=
listener
;
neutral
.
setOnClickListener
((
v
)
->
{
if
(
neutralListener
!=
null
)
neutralListener
.
onClick
(
dialog
,
DialogInterface
.
BUTTON_NEUTRAL
);
dialog
.
dismiss
();
});
return
this
;
}
@Override
public
AlertDialog
.
Builder
setNeutralButton
(
@StringRes
int
textId
,
DialogInterface
.
OnClickListener
listener
)
{
return
setNeutralButton
(
getContext
().
getString
(
textId
),
listener
);
}
@Override
public
AlertDialog
create
()
{
dialog
=
super
.
create
();
return
dialog
;
}
@Override
public
AlertDialog
show
()
{
create
();
dialog
.
show
();
return
dialog
;
}
}
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
c4afa069
...
@@ -17,6 +17,7 @@ import android.widget.Toast;
...
@@ -17,6 +17,7 @@ import android.widget.Toast;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.asyncs.LoadRepos
;
import
com.topjohnwu.magisk.asyncs.LoadRepos
;
import
com.topjohnwu.magisk.components.AlertDialogBuilder
;
import
com.topjohnwu.magisk.database.RepoDatabaseHelper
;
import
com.topjohnwu.magisk.database.RepoDatabaseHelper
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
...
@@ -117,11 +118,12 @@ public class Utils {
...
@@ -117,11 +118,12 @@ public class Utils {
}
}
public
static
AlertDialog
.
Builder
getAlertDialogBuilder
(
Context
context
)
{
public
static
AlertDialog
.
Builder
getAlertDialogBuilder
(
Context
context
)
{
if
(((
MagiskManager
)
context
.
getApplicationContext
()).
isDarkTheme
)
{
// if (((MagiskManager) context.getApplicationContext()).isDarkTheme) {
return
new
AlertDialog
.
Builder
(
context
,
R
.
style
.
AlertDialog_dh
);
// return new AlertDialog.Builder(context, R.style.AlertDialog_dh);
}
else
{
// } else {
return
new
AlertDialog
.
Builder
(
context
);
// return new AlertDialog.Builder(context);
}
// }
return
new
AlertDialogBuilder
(
context
);
}
}
public
static
boolean
lowercaseContains
(
CharSequence
string
,
CharSequence
nonNullLowercaseSearch
)
{
public
static
boolean
lowercaseContains
(
CharSequence
string
,
CharSequence
nonNullLowercaseSearch
)
{
...
...
app/src/main/res/layout/alert_dialog.xml
0 → 100644
View file @
c4afa069
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<ScrollView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:overScrollMode=
"ifContentScrolls"
android:paddingBottom=
"12dip"
android:paddingEnd=
"20dip"
android:paddingStart=
"20dip"
android:paddingTop=
"12dip"
>
<TextView
android:id=
"@+id/message"
style=
"?android:attr/textAppearanceMedium"
android:textColor=
"?android:attr/textColorPrimary"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:padding=
"5dip"
/>
</ScrollView>
</LinearLayout>
<LinearLayout
style=
"?android:attr/buttonBarStyle"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"54dip"
android:measureWithLargestChild=
"true"
android:orientation=
"horizontal"
android:paddingEnd=
"2dip"
android:paddingStart=
"2dip"
android:paddingTop=
"4dip"
>
<Button
android:id=
"@+id/negative"
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dip"
android:layout_height=
"wrap_content"
android:layout_gravity=
"start"
android:layout_weight=
"1"
android:maxLines=
"2"
/>
<Button
android:id=
"@+id/neutral"
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dip"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_weight=
"1"
android:maxLines=
"2"
/>
<Button
android:id=
"@+id/positive"
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dip"
android:layout_height=
"wrap_content"
android:layout_gravity=
"end"
android:layout_weight=
"1"
android:maxLines=
"2"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
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