Add theming for AlertDialogBuilder
This commit is contained in:
parent
859a984ec8
commit
7b8237afae
@ -4,18 +4,21 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.RowItem;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -28,7 +31,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
|
||||
private static final String SOURCE_CODE_URL = "https://github.com/topjohnwu/MagiskManager";
|
||||
private static final String XDA_THREAD = "http://forum.xda-developers.com/android/software/mod-magisk-v1-universal-systemless-t3432382";
|
||||
|
||||
private AlertDialog.Builder builder;
|
||||
@BindView(R.id.toolbar) Toolbar toolbar;
|
||||
|
||||
@BindView(R.id.app_version_info) RowItem appVersionInfo;
|
||||
@ -41,6 +44,11 @@ public class AboutActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "");
|
||||
Logger.dh("AboutActivity: Theme is " + theme);
|
||||
if (theme.equals("Dark")) {
|
||||
setTheme(R.style.AppTheme_dh);
|
||||
}
|
||||
setContentView(R.layout.activity_about);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
@ -72,14 +80,24 @@ public class AboutActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
appChangelog.removeSummary();
|
||||
if (theme.equals("Dark")) {
|
||||
builder = new AlertDialog.Builder(this,R.style.AlertDialog_dh);
|
||||
} else {
|
||||
builder = new AlertDialog.Builder(this);
|
||||
}
|
||||
if (changes == null) {
|
||||
appChangelog.setVisibility(View.GONE);
|
||||
} else {
|
||||
final String finalChanges = changes;
|
||||
Spanned result;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
result = Html.fromHtml(changes,Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
|
||||
} else {
|
||||
result = Html.fromHtml(changes);
|
||||
}
|
||||
appChangelog.setOnClickListener(v -> {
|
||||
AlertDialog d = new AlertDialog.Builder(AboutActivity.this)
|
||||
AlertDialog d = builder
|
||||
.setTitle(R.string.app_changelog)
|
||||
.setMessage(Html.fromHtml(finalChanges))
|
||||
.setMessage(result)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.create();
|
||||
|
||||
@ -92,9 +110,15 @@ public class AboutActivity extends AppCompatActivity {
|
||||
|
||||
appDevelopers.removeSummary();
|
||||
appDevelopers.setOnClickListener(view -> {
|
||||
AlertDialog d = new AlertDialog.Builder(AboutActivity.this)
|
||||
Spanned result;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
result = Html.fromHtml(getString(R.string.app_developers_),Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
|
||||
} else {
|
||||
result = Html.fromHtml(getString(R.string.app_developers_));
|
||||
}
|
||||
AlertDialog d = builder
|
||||
.setTitle(R.string.app_developers)
|
||||
.setMessage(Html.fromHtml(getString(R.string.app_developers_)))
|
||||
.setMessage(result)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.create();
|
||||
|
||||
@ -142,6 +166,5 @@ public class AboutActivity extends AppCompatActivity {
|
||||
setTitle("About");
|
||||
|
||||
|
||||
getWindow().setStatusBarColor(getResources().getColor(R.color.primary_dark));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import android.support.v4.content.FileProvider;
|
||||
@ -52,6 +53,7 @@ public class MagiskFragment extends Fragment {
|
||||
private int colorOK, colorWarn, colorNeutral;
|
||||
int statusOK = R.drawable.ic_check_circle;
|
||||
int statusUnknown = R.drawable.ic_help;
|
||||
private AlertDialog.Builder builder;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@ -91,6 +93,12 @@ public class MagiskFragment extends Fragment {
|
||||
@Override
|
||||
protected void onPostExecute(Void v) {
|
||||
super.onPostExecute(v);
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("theme", "");
|
||||
if (theme.equals("Dark")) {
|
||||
builder = new AlertDialog.Builder(getActivity(),R.style.AlertDialog_dh);
|
||||
} else {
|
||||
builder = new AlertDialog.Builder(getActivity());
|
||||
}
|
||||
|
||||
if (Utils.magiskVersion == -1) {
|
||||
magiskStatusContainer.setBackgroundColor(grey500);
|
||||
@ -123,7 +131,7 @@ public class MagiskFragment extends Fragment {
|
||||
magiskCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
|
||||
magiskCheckUpdatesStatus.setText(getString(R.string.magisk_update_available, String.valueOf(Utils.remoteMagiskVersion)));
|
||||
magiskCheckUpdatesStatus.setTextColor(colorNeutral);
|
||||
magiskUpdateView.setOnClickListener(view -> new AlertDialog.Builder(getActivity())
|
||||
magiskUpdateView.setOnClickListener(view -> builder
|
||||
.setTitle(getString(R.string.update_title, getString(R.string.magisk)))
|
||||
.setMessage(getString(R.string.update_msg, getString(R.string.magisk), String.valueOf(Utils.remoteMagiskVersion), Utils.magiskChangelog))
|
||||
.setCancelable(true)
|
||||
@ -150,7 +158,7 @@ public class MagiskFragment extends Fragment {
|
||||
appCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
|
||||
appCheckUpdatesStatus.setText(getString(R.string.app_update_available, String.valueOf(Utils.remoteAppVersion)));
|
||||
appCheckUpdatesStatus.setTextColor(colorNeutral);
|
||||
appUpdateView.setOnClickListener(view -> new AlertDialog.Builder(getActivity())
|
||||
appUpdateView.setOnClickListener(view -> builder
|
||||
.setTitle(getString(R.string.update_title, getString(R.string.app_name)))
|
||||
.setMessage(getString(R.string.update_msg, getString(R.string.app_name), String.valueOf(Utils.remoteAppVersion), Utils.appChangelog))
|
||||
.setCancelable(true)
|
||||
|
@ -127,8 +127,13 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
AlertDialog.Builder builder;
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(context).getString("theme", "");
|
||||
if (theme.equals("Dark")) {
|
||||
builder = new AlertDialog.Builder(context,R.style.AlertDialog_dh);
|
||||
} else {
|
||||
builder = new AlertDialog.Builder(context);
|
||||
}
|
||||
builder.setMessage("An update is available for " + mModule.getName() + ". Would you like to install it?").setPositiveButton("Yes", dialogClickListener)
|
||||
.setNegativeButton("No", dialogClickListener).show();
|
||||
mListToUpdate.remove(mModule);
|
||||
|
@ -4,6 +4,7 @@ import android.app.Fragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
@ -17,6 +18,7 @@ import android.widget.TextView;
|
||||
import com.topjohnwu.magisk.module.Repo;
|
||||
import com.topjohnwu.magisk.module.RepoHelper;
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
@ -42,6 +44,7 @@ public class ReposFragment extends Fragment {
|
||||
private boolean alertUpdate;
|
||||
private boolean ignoreAlertUpdate;
|
||||
private String alertPackage;
|
||||
private AlertDialog.Builder builder;
|
||||
// private SharedPreferences prefs;
|
||||
|
||||
@Nullable
|
||||
@ -132,10 +135,17 @@ public class ReposFragment extends Fragment {
|
||||
}
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage("An update is available for " + repo.getName() + ". Would you like to install it?").setPositiveButton("Yes", dialogClickListener)
|
||||
.setNegativeButton("No", dialogClickListener).show();
|
||||
iterRepo.remove();
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("theme", "");
|
||||
Logger.dh("ReposFragment: Theme is " + theme);
|
||||
if (theme.equals("Dark")) {
|
||||
builder = new AlertDialog.Builder(getActivity(),R.style.AlertDialog_dh);
|
||||
} else {
|
||||
builder = new AlertDialog.Builder(getActivity());
|
||||
}
|
||||
builder.setMessage("An update is available for " + repo.getName() + ". Would you like to install it?").setPositiveButton("Yes", dialogClickListener)
|
||||
.setNegativeButton("No", dialogClickListener).show();
|
||||
iterRepo.remove();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
@ -388,7 +389,14 @@ public class Async {
|
||||
}
|
||||
|
||||
protected void done() {
|
||||
new AlertDialog.Builder(mContext)
|
||||
AlertDialog.Builder builder;
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(mContext).getString("theme", "");
|
||||
if (theme.equals("Dark")) {
|
||||
builder = new AlertDialog.Builder(mContext,R.style.AlertDialog_dh);
|
||||
} else {
|
||||
builder = new AlertDialog.Builder(mContext);
|
||||
}
|
||||
builder
|
||||
.setTitle(R.string.reboot_title)
|
||||
.setMessage(R.string.reboot_msg)
|
||||
.setPositiveButton(R.string.reboot, (dialogInterface1, i) -> Shell.su("reboot"))
|
||||
|
@ -1,16 +1,24 @@
|
||||
package com.topjohnwu.magisk.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.topjohnwu.magisk.R;
|
||||
|
||||
public class WebWindow {
|
||||
|
||||
public WebWindow(String title, String url, Context context) {
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(context);
|
||||
AlertDialog.Builder alert;
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(context).getString("theme", "");
|
||||
if (theme.equals("Dark")) {
|
||||
alert = new AlertDialog.Builder(context, R.style.AlertDialog_dh);
|
||||
} else {
|
||||
alert = new AlertDialog.Builder(context);
|
||||
}
|
||||
alert.setTitle(title);
|
||||
|
||||
WebView wv = new WebView(context);
|
||||
|
@ -26,6 +26,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="8dp"
|
||||
style="?attr/cardStyle"
|
||||
app:cardUseCompatPadding="true">
|
||||
|
||||
<LinearLayout
|
||||
@ -100,6 +101,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="8dp"
|
||||
style="?attr/cardStyle"
|
||||
app:cardUseCompatPadding="true">
|
||||
|
||||
<com.topjohnwu.magisk.utils.RowItem
|
||||
|
@ -38,7 +38,8 @@
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:textColorPrimary">@color/dh_primary_text</item>
|
||||
<item name="android:textColorSecondary">@color/dh_primary_text</item>
|
||||
<item name="android:alertDialogTheme">@style/YourAlertDialogTheme</item>
|
||||
<item name="android:alertDialogTheme">@style/AlertDialog.dh</item>
|
||||
<item name="android:dialogTheme">@style/AlertDialog.dh</item>
|
||||
<item name="ColorOK">@color/dh_alertOk</item>
|
||||
<item name="ColorWarn">@color/dh_alertWarn</item>
|
||||
<item name="ColorFail">@color/dh_alertFail</item>
|
||||
@ -60,17 +61,49 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="YourAlertDialogTheme">
|
||||
<style name="AlertDialog.dh" parent="ThemeOverlay.AppCompat.Dark">
|
||||
<item name="android:textColor">@color/dh_primary_text</item>
|
||||
<item name="android:textColorSecondary">@color/dh_primary_text</item>
|
||||
<item name="colorAccent">@color/dh_accent</item>
|
||||
<item name="android:textColorPrimary">@color/dh_primary_text</item>
|
||||
<item name="android:background">@android:color/background_dark</item>
|
||||
<item name="android:textColorAlertDialogListItem">@color/dh_primary_text</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
|
||||
<item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
|
||||
<item name="android:windowTitleStyle">@style/MyTitleTextStyle</item>
|
||||
<item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
|
||||
<item name="android:alertDialogStyle">@style/ListPrefAlertDialogStyle</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="android:textAppearanceMedium">@style/MyAlertTextAppearance</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="MyAlertTextAppearance">
|
||||
<!-- Set text size and color of title and message here -->
|
||||
<item name="android:textColor">@color/dh_primary_text</item>
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<style name="ListPrefAlertDialogStyle">
|
||||
<item name="android:fullDark" >@android:color/transparent</item>
|
||||
<item name="android:topDark" >@android:color/transparent</item>
|
||||
<item name="android:centerDark" >@android:color/transparent</item>
|
||||
<item name="android:bottomDark" >@android:color/transparent</item>
|
||||
<item name="android:fullBright" >@android:color/transparent</item>
|
||||
<item name="android:topBright" >@android:color/transparent</item>
|
||||
<item name="android:centerBright">@android:color/transparent</item>
|
||||
<item name="android:bottomBright">@android:color/transparent</item>
|
||||
<item name="android:bottomMedium">@android:color/transparent</item>
|
||||
<item name="android:centerMedium">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="MyTitleTextStyle">
|
||||
<item name="android:textColor">@color/dh_primary_text</item>
|
||||
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Title</item>
|
||||
</style>
|
||||
|
||||
<style name="CardViewStyle.Light" parent="CardView">
|
||||
<item name="cardBackgroundColor">@android:color/background_light</item>
|
||||
|
Loading…
Reference in New Issue
Block a user