From 2f57685610b17f8f7246025a06ebd23e040f23ec Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Tue, 30 Aug 2016 21:11:28 -0400 Subject: [PATCH] Correctly size dialogs across the app --- .../lightning/activity/BrowserActivity.java | 5 ++- .../lightning/activity/ReadingActivity.java | 6 ++- .../lightning/activity/TabsManager.java | 5 ++- .../lightning/dialog/BrowserDialog.java | 25 +++++++---- .../dialog/LightningDialogBuilder.java | 4 +- .../lightning/download/DownloadHandler.java | 5 ++- .../download/LightningDownloadListener.java | 5 ++- .../fragment/AdvancedSettingsFragment.java | 17 +++++--- .../fragment/BookmarkSettingsFragment.java | 22 +++++++--- .../fragment/DisplaySettingsFragment.java | 10 +++-- .../fragment/GeneralSettingsFragment.java | 43 ++++++++++++------- .../fragment/PrivacySettingsFragment.java | 5 ++- .../browser/lightning/utils/ProxyUtils.java | 7 ++- .../acr/browser/lightning/utils/Utils.java | 2 + .../lightning/view/LightningChromeClient.java | 2 + .../lightning/view/LightningWebClient.java | 8 +++- 16 files changed, 122 insertions(+), 49 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java index 2d93e95..88fcd42 100644 --- a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java @@ -5,6 +5,7 @@ package acr.browser.lightning.activity; import android.app.Activity; +import android.app.Dialog; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -982,12 +983,14 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @Override public void showBlockedLocalFileDialog(DialogInterface.OnClickListener listener) { AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setCancelable(true) + Dialog dialog = builder.setCancelable(true) .setTitle(R.string.title_warning) .setMessage(R.string.message_blocked_local) .setNegativeButton(android.R.string.cancel, null) .setPositiveButton(R.string.action_open, listener) .show(); + + BrowserDialog.setDialogSize(this, dialog); } @Override diff --git a/app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java b/app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java index d8b918a..90b943e 100644 --- a/app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java @@ -1,6 +1,7 @@ package acr.browser.lightning.activity; import android.animation.ObjectAnimator; +import android.app.Dialog; import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; @@ -27,6 +28,7 @@ import javax.inject.Inject; import acr.browser.lightning.R; import acr.browser.lightning.app.BrowserApp; import acr.browser.lightning.constant.Constants; +import acr.browser.lightning.dialog.BrowserDialog; import acr.browser.lightning.preference.PreferenceManager; import com.anthonycr.bonsai.Action; import com.anthonycr.bonsai.Observable; @@ -159,6 +161,7 @@ public class ReadingActivity extends AppCompatActivity { mProgressDialog.setIndeterminate(true); mProgressDialog.setMessage(getString(R.string.loading)); mProgressDialog.show(); + BrowserDialog.setDialogSize(ReadingActivity.this, mProgressDialog); } @Override @@ -321,7 +324,8 @@ public class ReadingActivity extends AppCompatActivity { } }); - builder.show(); + Dialog dialog = builder.show(); + BrowserDialog.setDialogSize(this, dialog); break; default: finish(); diff --git a/app/src/main/java/acr/browser/lightning/activity/TabsManager.java b/app/src/main/java/acr/browser/lightning/activity/TabsManager.java index fb814cb..37ddf9f 100644 --- a/app/src/main/java/acr/browser/lightning/activity/TabsManager.java +++ b/app/src/main/java/acr/browser/lightning/activity/TabsManager.java @@ -2,6 +2,7 @@ package acr.browser.lightning.activity; import android.app.Activity; import android.app.Application; +import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -27,6 +28,7 @@ import acr.browser.lightning.constant.HistoryPage; import acr.browser.lightning.constant.StartPage; import acr.browser.lightning.database.BookmarkManager; import acr.browser.lightning.database.HistoryDatabase; +import acr.browser.lightning.dialog.BrowserDialog; import acr.browser.lightning.preference.PreferenceManager; import com.anthonycr.bonsai.Action; @@ -169,7 +171,7 @@ public class TabsManager { if (url != null) { if (url.startsWith(Constants.FILE)) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); - builder.setCancelable(true) + Dialog dialog = builder.setCancelable(true) .setTitle(R.string.title_warning) .setMessage(R.string.message_blocked_local) .setOnDismissListener(new DialogInterface.OnDismissListener() { @@ -189,6 +191,7 @@ public class TabsManager { newTab(activity, url, false); } }).show(); + BrowserDialog.setDialogSize(activity, dialog); } else { newTab(activity, url, false); if (mTabList.isEmpty()) { diff --git a/app/src/main/java/acr/browser/lightning/dialog/BrowserDialog.java b/app/src/main/java/acr/browser/lightning/dialog/BrowserDialog.java index c6bb1cb..dae8072 100644 --- a/app/src/main/java/acr/browser/lightning/dialog/BrowserDialog.java +++ b/app/src/main/java/acr/browser/lightning/dialog/BrowserDialog.java @@ -2,6 +2,7 @@ package acr.browser.lightning.dialog; import android.app.Activity; import android.app.Dialog; +import android.content.Context; import android.content.DialogInterface; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -122,15 +123,9 @@ public class BrowserDialog { listView.setDivider(null); builder.setView(layout); - int maxWidth = ResourceUtils.dimen(activity, R.dimen.dialog_max_size); - int padding = ResourceUtils.dimen(activity, R.dimen.dialog_padding); - int screenSize = DeviceUtils.getScreenWidth(activity); - if (maxWidth > screenSize - 2 * padding) { - maxWidth = screenSize - 2 * padding; - } - final Dialog dialog = builder.show(); - dialog.getWindow().setLayout(maxWidth, ViewGroup.LayoutParams.WRAP_CONTENT); + + setDialogSize(activity, dialog); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override @@ -172,7 +167,19 @@ public class BrowserDialog { listener.onClick(editText.getText().toString()); } }); - editorDialog.show(); + + Dialog dialog = editorDialog.show(); + setDialogSize(activity, dialog); + } + + public static void setDialogSize(@NonNull Context context, @NonNull Dialog dialog) { + int maxWidth = ResourceUtils.dimen(context, R.dimen.dialog_max_size); + int padding = ResourceUtils.dimen(context, R.dimen.dialog_padding); + int screenSize = DeviceUtils.getScreenWidth(context); + if (maxWidth > screenSize - 2 * padding) { + maxWidth = screenSize - 2 * padding; + } + dialog.getWindow().setLayout(maxWidth, ViewGroup.LayoutParams.WRAP_CONTENT); } } diff --git a/app/src/main/java/acr/browser/lightning/dialog/LightningDialogBuilder.java b/app/src/main/java/acr/browser/lightning/dialog/LightningDialogBuilder.java index b1a3fb7..13b52aa 100644 --- a/app/src/main/java/acr/browser/lightning/dialog/LightningDialogBuilder.java +++ b/app/src/main/java/acr/browser/lightning/dialog/LightningDialogBuilder.java @@ -1,6 +1,7 @@ package acr.browser.lightning.dialog; import android.app.Activity; +import android.app.Dialog; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -156,7 +157,8 @@ public class LightningDialogBuilder { mEventBus.post(new BookmarkEvents.BookmarkChanged(item, editedItem)); } }); - editBookmarkDialog.show(); + Dialog dialog = editBookmarkDialog.show(); + BrowserDialog.setDialogSize(activity, dialog); } public void showBookmarkFolderLongPressedDialog(@NonNull final Activity activity, @NonNull final HistoryItem item) { diff --git a/app/src/main/java/acr/browser/lightning/download/DownloadHandler.java b/app/src/main/java/acr/browser/lightning/download/DownloadHandler.java index 03350fb..563abdb 100644 --- a/app/src/main/java/acr/browser/lightning/download/DownloadHandler.java +++ b/app/src/main/java/acr/browser/lightning/download/DownloadHandler.java @@ -3,6 +3,7 @@ */ package acr.browser.lightning.download; +import android.app.Dialog; import android.app.DownloadManager; import android.content.ActivityNotFoundException; import android.content.Context; @@ -31,6 +32,7 @@ import acr.browser.lightning.activity.MainActivity; import acr.browser.lightning.app.BrowserApp; import acr.browser.lightning.bus.BrowserEvents; import acr.browser.lightning.constant.Constants; +import acr.browser.lightning.dialog.BrowserDialog; import acr.browser.lightning.preference.PreferenceManager; /** @@ -157,9 +159,10 @@ public class DownloadHandler { title = R.string.download_no_sdcard_dlg_title; } - new AlertDialog.Builder(context).setTitle(title) + Dialog dialog = new AlertDialog.Builder(context).setTitle(title) .setIcon(android.R.drawable.ic_dialog_alert).setMessage(msg) .setPositiveButton(R.string.action_ok, null).show(); + BrowserDialog.setDialogSize(context, dialog); return; } diff --git a/app/src/main/java/acr/browser/lightning/download/LightningDownloadListener.java b/app/src/main/java/acr/browser/lightning/download/LightningDownloadListener.java index e018fe9..95a3ecf 100644 --- a/app/src/main/java/acr/browser/lightning/download/LightningDownloadListener.java +++ b/app/src/main/java/acr/browser/lightning/download/LightningDownloadListener.java @@ -5,6 +5,7 @@ package acr.browser.lightning.download; import android.Manifest; import android.app.Activity; +import android.app.Dialog; import android.content.DialogInterface; import android.support.v7.app.AlertDialog; import android.util.Log; @@ -14,6 +15,7 @@ import android.webkit.URLUtil; import acr.browser.lightning.R; import acr.browser.lightning.app.BrowserApp; import acr.browser.lightning.constant.Constants; +import acr.browser.lightning.dialog.BrowserDialog; import acr.browser.lightning.preference.PreferenceManager; import com.anthonycr.grant.PermissionsManager; @@ -56,12 +58,13 @@ public class LightningDownloadListener implements DownloadListener { }; AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog - builder.setTitle(fileName) + Dialog dialog = builder.setTitle(fileName) .setMessage(mActivity.getResources().getString(R.string.dialog_download)) .setPositiveButton(mActivity.getResources().getString(R.string.action_download), dialogClickListener) .setNegativeButton(mActivity.getResources().getString(R.string.action_cancel), dialogClickListener).show(); + BrowserDialog.setDialogSize(mActivity, dialog); Log.i(Constants.TAG, "Downloading" + fileName); } diff --git a/app/src/main/java/acr/browser/lightning/fragment/AdvancedSettingsFragment.java b/app/src/main/java/acr/browser/lightning/fragment/AdvancedSettingsFragment.java index 2b4fcd5..ba5d7da 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/AdvancedSettingsFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/AdvancedSettingsFragment.java @@ -4,6 +4,7 @@ package acr.browser.lightning.fragment; import android.app.Activity; +import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.preference.CheckBoxPreference; @@ -16,6 +17,7 @@ import java.util.List; import acr.browser.lightning.R; import acr.browser.lightning.constant.Constants; +import acr.browser.lightning.dialog.BrowserDialog; public class AdvancedSettingsFragment extends LightningPreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { @@ -167,8 +169,9 @@ public class AdvancedSettingsFragment extends LightningPreferenceFragment implem } } }); - picker.setNeutralButton(getResources().getString(R.string.action_ok), null); - picker.show(); + picker.setPositiveButton(getResources().getString(R.string.action_ok), null); + Dialog dialog = picker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void textEncodingPicker() { @@ -184,8 +187,9 @@ public class AdvancedSettingsFragment extends LightningPreferenceFragment implem textEncoding.setSummary(Constants.TEXT_ENCODINGS[which]); } }); - picker.setNeutralButton(getResources().getString(R.string.action_ok), null); - picker.show(); + picker.setPositiveButton(getResources().getString(R.string.action_ok), null); + Dialog dialog = picker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void urlBoxPicker() { @@ -203,7 +207,8 @@ public class AdvancedSettingsFragment extends LightningPreferenceFragment implem } } }); - picker.setNeutralButton(getResources().getString(R.string.action_ok), null); - picker.show(); + picker.setPositiveButton(getResources().getString(R.string.action_ok), null); + Dialog dialog = picker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } } diff --git a/app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java b/app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java index 999db35..0a8a5db 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java @@ -5,6 +5,7 @@ package acr.browser.lightning.fragment; import android.Manifest; import android.app.Activity; +import android.app.Dialog; import android.content.DialogInterface; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; @@ -41,6 +42,8 @@ import acr.browser.lightning.database.BookmarkManager; import acr.browser.lightning.database.HistoryItem; import com.anthonycr.bonsai.OnSubscribe; import com.anthonycr.bonsai.Schedulers; + +import acr.browser.lightning.dialog.BrowserDialog; import acr.browser.lightning.utils.Preconditions; import acr.browser.lightning.utils.Utils; @@ -245,7 +248,8 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref mBookmarkManager.deleteAllBookmarks(); } }); - builder.show(); + Dialog dialog = builder.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } @NonNull @@ -310,7 +314,8 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref } } }); - builder.show(); + Dialog dialog = builder.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } @Nullable @@ -379,12 +384,17 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref } private void createDialog() { + if(mActivity == null){ + return; + } final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); final String title = getString(R.string.title_chooser); builder.setTitle(title + ": " + Environment.getExternalStorageDirectory()); if (mFileList == null) { - builder.show(); + Dialog dialog = builder.show(); + BrowserDialog.setDialogSize(mActivity, dialog); + return; } builder.setItems(mFileNameList, new DialogInterface.OnClickListener() { @@ -394,13 +404,15 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref builder.setTitle(title + ": " + mFileList[which]); loadFileList(mFileList[which]); builder.setItems(mFileNameList, this); - builder.show(); + Dialog dialog1 = builder.show(); + BrowserDialog.setDialogSize(mActivity, dialog1); } else { mBookmarkManager.importBookmarksFromFile(mFileList[which], getActivity()); } } }); - builder.show(); + Dialog dialog = builder.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } } diff --git a/app/src/main/java/acr/browser/lightning/fragment/DisplaySettingsFragment.java b/app/src/main/java/acr/browser/lightning/fragment/DisplaySettingsFragment.java index 772d135..32fe36c 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/DisplaySettingsFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/DisplaySettingsFragment.java @@ -4,6 +4,7 @@ package acr.browser.lightning.fragment; import android.app.Activity; +import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.preference.CheckBoxPreference; @@ -19,6 +20,7 @@ import android.widget.SeekBar; import android.widget.TextView; import acr.browser.lightning.R; +import acr.browser.lightning.dialog.BrowserDialog; public class DisplaySettingsFragment extends LightningPreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { @@ -150,7 +152,8 @@ public class DisplaySettingsFragment extends LightningPreferenceFragment impleme } }); - builder.show(); + Dialog dialog = builder.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private static float getTextSize(int size) { @@ -187,7 +190,7 @@ public class DisplaySettingsFragment extends LightningPreferenceFragment impleme } } }); - picker.setNeutralButton(getResources().getString(R.string.action_ok), + picker.setPositiveButton(getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override @@ -205,7 +208,8 @@ public class DisplaySettingsFragment extends LightningPreferenceFragment impleme } } }); - picker.show(); + Dialog dialog = picker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private static class TextSeekBarListener implements SeekBar.OnSeekBarChangeListener { diff --git a/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java b/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java index 5896f50..9bb0419 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java @@ -4,6 +4,7 @@ package acr.browser.lightning.fragment; import android.app.Activity; +import android.app.Dialog; import android.content.DialogInterface; import android.os.Build; import android.os.Bundle; @@ -23,6 +24,7 @@ import android.widget.LinearLayout; import acr.browser.lightning.R; import acr.browser.lightning.constant.Constants; +import acr.browser.lightning.dialog.BrowserDialog; import acr.browser.lightning.download.DownloadHandler; import acr.browser.lightning.utils.ProxyUtils; import acr.browser.lightning.utils.ThemeUtils; @@ -167,7 +169,8 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme + text); } }); - urlPicker.show(); + Dialog dialog = urlPicker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void getFlashChoice() { @@ -199,6 +202,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme }); AlertDialog alert = builder.create(); alert.show(); + BrowserDialog.setDialogSize(mActivity, alert); } private void proxyChoicePicker() { @@ -212,8 +216,9 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme setProxyChoice(which); } }); - picker.setNeutralButton(getResources().getString(R.string.action_ok), null); - picker.show(); + picker.setPositiveButton(getResources().getString(R.string.action_ok), null); + Dialog dialog = picker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void setProxyChoice(int choice) { @@ -250,7 +255,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme eProxyHost.setText(mPreferenceManager.getProxyHost()); eProxyPort.setText(Integer.toString(mPreferenceManager.getProxyPort())); - new AlertDialog.Builder(mActivity) + Dialog dialog = new AlertDialog.Builder(mActivity) .setTitle(R.string.manual_proxy) .setView(v) .setPositiveButton(R.string.action_ok, new DialogInterface.OnClickListener() { @@ -270,6 +275,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme proxy.setSummary(proxyHost + ':' + proxyPort); } }).show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void searchDialog() { @@ -290,8 +296,9 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme setSearchEngineSummary(which); } }); - picker.setNeutralButton(getResources().getString(R.string.action_ok), null); - picker.show(); + picker.setPositiveButton(getResources().getString(R.string.action_ok), null); + Dialog dialog = picker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void homepageDialog() { @@ -332,8 +339,9 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme } } }); - picker.setNeutralButton(getResources().getString(R.string.action_ok), null); - picker.show(); + picker.setPositiveButton(getResources().getString(R.string.action_ok), null); + Dialog dialog = picker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void homePicker() { @@ -357,7 +365,8 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme home.setSummary(text); } }); - homePicker.show(); + Dialog dialog = homePicker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void downloadLocDialog() { @@ -386,8 +395,9 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme } } }); - picker.setNeutralButton(getResources().getString(R.string.action_ok), null); - picker.show(); + picker.setPositiveButton(getResources().getString(R.string.action_ok), null); + Dialog dialog = picker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void agentDialog() { @@ -416,8 +426,9 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme } } }); - agentPicker.setNeutralButton(getResources().getString(R.string.action_ok), null); - agentPicker.show(); + agentPicker.setPositiveButton(getResources().getString(R.string.action_ok), null); + Dialog dialog = agentPicker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void agentPicker() { @@ -434,7 +445,8 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme useragent.setSummary(getResources().getString(R.string.agent_custom)); } }); - agentStringPicker.show(); + Dialog dialog = agentStringPicker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void downPicker() { @@ -463,7 +475,8 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme downloadloc.setSummary(text); } }); - downLocationPicker.show(); + Dialog dialog = downLocationPicker.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void setSearchEngineSummary(int which) { diff --git a/app/src/main/java/acr/browser/lightning/fragment/PrivacySettingsFragment.java b/app/src/main/java/acr/browser/lightning/fragment/PrivacySettingsFragment.java index 24162a1..5d1ca65 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/PrivacySettingsFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/PrivacySettingsFragment.java @@ -4,6 +4,7 @@ package acr.browser.lightning.fragment; import android.app.Activity; +import android.app.Dialog; import android.content.DialogInterface; import android.os.Build; import android.os.Bundle; @@ -20,6 +21,7 @@ import javax.inject.Inject; import acr.browser.lightning.R; import acr.browser.lightning.app.BrowserApp; import acr.browser.lightning.database.HistoryDatabase; +import acr.browser.lightning.dialog.BrowserDialog; import acr.browser.lightning.utils.Utils; import acr.browser.lightning.utils.WebUtils; import acr.browser.lightning.view.LightningView; @@ -154,7 +156,7 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme private void clearHistoryDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setTitle(getResources().getString(R.string.title_clear_history)); - builder.setMessage(getResources().getString(R.string.dialog_history)) + Dialog dialog = builder.setMessage(getResources().getString(R.string.dialog_history)) .setPositiveButton(getResources().getString(R.string.action_yes), new DialogInterface.OnClickListener() { @Override @@ -168,6 +170,7 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme } }) .setNegativeButton(getResources().getString(R.string.action_no), null).show(); + BrowserDialog.setDialogSize(mActivity, dialog); } private void clearCookiesDialog() { diff --git a/app/src/main/java/acr/browser/lightning/utils/ProxyUtils.java b/app/src/main/java/acr/browser/lightning/utils/ProxyUtils.java index a703737..5e5410d 100644 --- a/app/src/main/java/acr/browser/lightning/utils/ProxyUtils.java +++ b/app/src/main/java/acr/browser/lightning/utils/ProxyUtils.java @@ -1,6 +1,7 @@ package acr.browser.lightning.utils; import android.app.Activity; +import android.app.Dialog; import android.content.DialogInterface; import android.support.annotation.NonNull; import android.support.v7.app.AlertDialog; @@ -17,6 +18,7 @@ import acr.browser.lightning.R; import acr.browser.lightning.app.BrowserApp; import acr.browser.lightning.bus.BrowserEvents; import acr.browser.lightning.constant.Constants; +import acr.browser.lightning.dialog.BrowserDialog; import acr.browser.lightning.preference.PreferenceManager; import info.guardianproject.netcipher.proxy.OrbotHelper; import info.guardianproject.netcipher.web.WebkitProxy; @@ -67,7 +69,7 @@ public class ProxyUtils { mPreferences.setProxyChoice(which); } }) - .setNeutralButton(activity.getResources().getString(R.string.action_ok), + .setPositiveButton(activity.getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -96,7 +98,8 @@ public class ProxyUtils { .setPositiveButton(R.string.yes, dialogClickListener) .setNegativeButton(R.string.no, dialogClickListener); } - builder.show(); + Dialog dialog = builder.show(); + BrowserDialog.setDialogSize(activity, dialog); } } diff --git a/app/src/main/java/acr/browser/lightning/utils/Utils.java b/app/src/main/java/acr/browser/lightning/utils/Utils.java index 2b69c28..f76356d 100644 --- a/app/src/main/java/acr/browser/lightning/utils/Utils.java +++ b/app/src/main/java/acr/browser/lightning/utils/Utils.java @@ -49,6 +49,7 @@ import acr.browser.lightning.R; import acr.browser.lightning.activity.MainActivity; import acr.browser.lightning.constant.Constants; import acr.browser.lightning.database.HistoryItem; +import acr.browser.lightning.dialog.BrowserDialog; import acr.browser.lightning.download.DownloadHandler; import acr.browser.lightning.preference.PreferenceManager; @@ -132,6 +133,7 @@ public final class Utils { }); AlertDialog alert = builder.create(); alert.show(); + BrowserDialog.setDialogSize(activity, alert); } /** diff --git a/app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java b/app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java index 0bbef7e..d28cdde 100644 --- a/app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java +++ b/app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java @@ -25,6 +25,7 @@ import com.anthonycr.grant.PermissionsResultAction; import acr.browser.lightning.R; import acr.browser.lightning.app.BrowserApp; import acr.browser.lightning.controller.UIController; +import acr.browser.lightning.dialog.BrowserDialog; import acr.browser.lightning.utils.Preconditions; class LightningChromeClient extends WebChromeClient { @@ -120,6 +121,7 @@ class LightningChromeClient extends WebChromeClient { }); AlertDialog alert = builder.create(); alert.show(); + BrowserDialog.setDialogSize(mActivity, alert); } @Override diff --git a/app/src/main/java/acr/browser/lightning/view/LightningWebClient.java b/app/src/main/java/acr/browser/lightning/view/LightningWebClient.java index fe80d20..7f0a0de 100644 --- a/app/src/main/java/acr/browser/lightning/view/LightningWebClient.java +++ b/app/src/main/java/acr/browser/lightning/view/LightningWebClient.java @@ -2,6 +2,7 @@ package acr.browser.lightning.view; import android.annotation.TargetApi; import android.app.Activity; +import android.app.Dialog; import android.content.ActivityNotFoundException; import android.content.DialogInterface; import android.content.Intent; @@ -38,6 +39,7 @@ import acr.browser.lightning.R; import acr.browser.lightning.app.BrowserApp; import acr.browser.lightning.constant.Constants; import acr.browser.lightning.controller.UIController; +import acr.browser.lightning.dialog.BrowserDialog; import acr.browser.lightning.utils.AdBlock; import acr.browser.lightning.utils.IntentUtils; import acr.browser.lightning.utils.Preconditions; @@ -160,7 +162,7 @@ public class LightningWebClient extends WebViewClient { }); AlertDialog alert = builder.create(); alert.show(); - + BrowserDialog.setDialogSize(mActivity, alert); } private volatile boolean mIsRunning = false; @@ -247,7 +249,8 @@ public class LightningWebClient extends WebViewClient { handler.cancel(); } }); - builder.create().show(); + Dialog dialog = builder.show(); + BrowserDialog.setDialogSize(mActivity, dialog); } @Override @@ -272,6 +275,7 @@ public class LightningWebClient extends WebViewClient { }); AlertDialog alert = builder.create(); alert.show(); + BrowserDialog.setDialogSize(mActivity, alert); } @Override