diff --git a/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java index c4a267dde..96fee9373 100644 --- a/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java +++ b/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java @@ -106,6 +106,7 @@ import org.w3c.dom.Text; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; import static org.kiwix.kiwixmobile.TableDrawerAdapter.DocumentSection; import static org.kiwix.kiwixmobile.TableDrawerAdapter.TableClickListener; +import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; public class KiwixMobileActivity extends AppCompatActivity implements WebViewCallback { @@ -448,7 +449,7 @@ public class KiwixMobileActivity extends AppCompatActivity implements WebViewCal String negative = getString(R.string.rate_dialog_negative); String neutral = getString(R.string.rate_dialog_neutral); - new AlertDialog.Builder(this) + new AlertDialog.Builder(this, dialogStyle()) .setTitle(title) .setMessage(message) .setPositiveButton(positive, (dialog, id) -> { @@ -909,7 +910,7 @@ public class KiwixMobileActivity extends AppCompatActivity implements WebViewCal newZimFile.setData(Uri.fromFile(file)); startActivity(newZimFile); } else { - AlertDialog.Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, dialogStyle()); builder.setMessage(getResources().getString(R.string.reboot_message)); AlertDialog dialog = builder.create(); dialog.show(); @@ -1175,7 +1176,7 @@ public class KiwixMobileActivity extends AppCompatActivity implements WebViewCal private void contentsDrawerHint() { drawerLayout.postDelayed(() -> drawerLayout.openDrawer(GravityCompat.END), 500); - AlertDialog.Builder builder = new AlertDialog.Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, dialogStyle()); builder.setMessage(getString(R.string.hint_contents_drawer_message)) .setPositiveButton(getString(R.string.got_it), (dialog, id) -> {}) .setTitle(getString(R.string.did_you_know)) @@ -1621,7 +1622,7 @@ public class KiwixMobileActivity extends AppCompatActivity implements WebViewCal if (!FileUtils.doesFileExist(filePath, Constants.CUSTOM_APP_ZIM_FILE_SIZE, false)) { - AlertDialog.Builder zimFileMissingBuilder = new AlertDialog.Builder(this); + AlertDialog.Builder zimFileMissingBuilder = new AlertDialog.Builder(this, dialogStyle()); zimFileMissingBuilder.setTitle(R.string.app_name); zimFileMissingBuilder.setMessage(R.string.customapp_missing_content); zimFileMissingBuilder.setIcon(R.mipmap.kiwix_icon); @@ -1747,7 +1748,7 @@ public class KiwixMobileActivity extends AppCompatActivity implements WebViewCal } if (handleEvent) { - AlertDialog.Builder builder = new AlertDialog.Builder(KiwixMobileActivity.this); + AlertDialog.Builder builder = new AlertDialog.Builder(KiwixMobileActivity.this, dialogStyle()); builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { diff --git a/src/org/kiwix/kiwixmobile/LibraryFragment.java b/src/org/kiwix/kiwixmobile/LibraryFragment.java index 631ae81b0..f839e6006 100644 --- a/src/org/kiwix/kiwixmobile/LibraryFragment.java +++ b/src/org/kiwix/kiwixmobile/LibraryFragment.java @@ -57,6 +57,7 @@ import rx.android.schedulers.AndroidSchedulers; import static org.kiwix.kiwixmobile.downloader.DownloadService.KIWIX_ROOT; import static org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity.*; +import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; public class LibraryFragment extends Fragment implements AdapterView.OnItemClickListener, StorageSelectDialog.OnSelectListener { @@ -269,7 +270,7 @@ public class LibraryFragment extends Fragment implements AdapterView.OnItemClick public void mobileDownloadDialog(int position, AdapterView parent) { - new AlertDialog.Builder(super.getActivity()) + new AlertDialog.Builder(super.getActivity(), dialogStyle()) .setMessage(getString(R.string.download_over_network)) .setPositiveButton(getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { diff --git a/src/org/kiwix/kiwixmobile/SearchActivity.java b/src/org/kiwix/kiwixmobile/SearchActivity.java index 2de006840..eef6b6985 100644 --- a/src/org/kiwix/kiwixmobile/SearchActivity.java +++ b/src/org/kiwix/kiwixmobile/SearchActivity.java @@ -34,6 +34,7 @@ import org.kiwix.kiwixmobile.utils.DimenUtils; import org.kiwix.kiwixmobile.views.AutoCompleteAdapter; import static android.provider.Settings.System.ALWAYS_FINISH_ACTIVITIES; +import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; public class SearchActivity extends AppCompatActivity implements AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener { @@ -169,7 +170,7 @@ public class SearchActivity extends AppCompatActivity } private void deleteSpecificSearchDialog(final String search) { - new AlertDialog.Builder(this) + new AlertDialog.Builder(this, dialogStyle()) .setMessage(getString(R.string.delete_recent_search_item)) .setPositiveButton(getResources().getString(R.string.delete), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { diff --git a/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java b/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java index 05ca9bf9c..668b1ebf3 100644 --- a/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java +++ b/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java @@ -56,6 +56,8 @@ import org.kiwix.kiwixmobile.utils.LanguageUtils; import org.kiwix.kiwixmobile.utils.files.FileSearch; import org.kiwix.kiwixmobile.utils.files.FileUtils; +import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; + public class ZimFileSelectFragment extends Fragment implements OnItemClickListener, AdapterView.OnItemLongClickListener { @@ -279,7 +281,7 @@ public class ZimFileSelectFragment extends Fragment } public void deleteSpecificZimDialog(int position) { - new AlertDialog.Builder(super.getActivity()) + new AlertDialog.Builder(super.getActivity(), dialogStyle()) .setMessage(getString(R.string.delete_specific_zim)) .setPositiveButton(getResources().getString(R.string.delete), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { diff --git a/src/org/kiwix/kiwixmobile/ZimManageActivity.java b/src/org/kiwix/kiwixmobile/ZimManageActivity.java index 07b140cbd..8a714599c 100644 --- a/src/org/kiwix/kiwixmobile/ZimManageActivity.java +++ b/src/org/kiwix/kiwixmobile/ZimManageActivity.java @@ -32,6 +32,8 @@ import org.kiwix.kiwixmobile.downloader.DownloadFragment; import org.kiwix.kiwixmobile.library.LibraryAdapter; import org.kiwix.kiwixmobile.utils.DimenUtils; +import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; + public class ZimManageActivity extends AppCompatActivity { public static final String TAB_EXTRA = "TAB"; @@ -240,7 +242,7 @@ public class ZimManageActivity extends AppCompatActivity { } LanguageArrayAdapter languageArrayAdapter = new LanguageArrayAdapter(this, 0, LibraryAdapter.mLanguages); listView.setAdapter(languageArrayAdapter); - new AlertDialog.Builder(this, R.style.Theme_AppCompat_Light_Dialog_Alert) + new AlertDialog.Builder(this, dialogStyle()) .setView(view) .setPositiveButton(android.R.string.ok, (dialogInterface, i) -> { LibraryAdapter.updateNetworklanguages(); diff --git a/src/org/kiwix/kiwixmobile/downloader/DownloadFragment.java b/src/org/kiwix/kiwixmobile/downloader/DownloadFragment.java index d3f6adcdc..a42df03ab 100644 --- a/src/org/kiwix/kiwixmobile/downloader/DownloadFragment.java +++ b/src/org/kiwix/kiwixmobile/downloader/DownloadFragment.java @@ -32,6 +32,8 @@ import org.kiwix.kiwixmobile.ZimManageActivity; import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity; import org.kiwix.kiwixmobile.utils.files.FileUtils; +import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; + public class DownloadFragment extends Fragment { @@ -183,7 +185,7 @@ public class DownloadFragment extends Fragment { ImageView stop = (ImageView) convertView.findViewById(R.id.stop); stop.setOnClickListener(v -> { - new AlertDialog.Builder(faActivity) + new AlertDialog.Builder(faActivity, dialogStyle()) .setTitle(R.string.confirm_stop_download_title) .setMessage(R.string.confirm_stop_download_msg) .setPositiveButton(R.string.yes, (dialog, i) -> { diff --git a/src/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java b/src/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java index 21491e8f2..4e442fcbf 100644 --- a/src/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java +++ b/src/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java @@ -53,6 +53,8 @@ import org.kiwix.kiwixmobile.utils.DimenUtils; import org.kiwix.kiwixmobile.utils.LanguageUtils; import org.kiwix.kiwixmobile.views.SliderPreference; +import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; + public class KiwixSettingsActivity extends AppCompatActivity { public static final int RESULT_RESTART = 1236; @@ -265,7 +267,7 @@ public class KiwixSettingsActivity extends AppCompatActivity { } private void clearAllHistoryDialog() { - new AlertDialog.Builder(getActivity()) + new AlertDialog.Builder(getActivity(), dialogStyle()) .setTitle(getResources().getString(R.string.clear_all_history_dialog_title)) .setMessage(getResources().getString(R.string.clear_recent_and_tabs_history_dialog)) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @@ -287,7 +289,7 @@ public class KiwixSettingsActivity extends AppCompatActivity { public void openCredits(){ WebView view = (WebView) LayoutInflater.from(getActivity()).inflate(R.layout.credits_webview, null); view.loadUrl("file:///android_res/raw/credits.html"); - AlertDialog mAlertDialog = new AlertDialog.Builder(getActivity(), R.style.Theme_AppCompat_Light_Dialog_Alert) + AlertDialog mAlertDialog = new AlertDialog.Builder(getActivity(), dialogStyle()) .setView(view) .setPositiveButton(android.R.string.ok, null) .show(); diff --git a/src/org/kiwix/kiwixmobile/utils/StyleUtils.java b/src/org/kiwix/kiwixmobile/utils/StyleUtils.java new file mode 100644 index 000000000..f432882d5 --- /dev/null +++ b/src/org/kiwix/kiwixmobile/utils/StyleUtils.java @@ -0,0 +1,33 @@ +/* + * Copyright 2017 Isaac Hutt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +package org.kiwix.kiwixmobile.utils; + +import org.kiwix.kiwixmobile.KiwixMobileActivity; +import org.kiwix.kiwixmobile.R; + +public class StyleUtils { + public static int dialogStyle() { + if (KiwixMobileActivity.nightMode) { + return android.R.style.Theme_Material_Dialog; + } else { + return android.R.style.Theme_Material_Light_Dialog; + } + } +}