Skip to content

Commit

Permalink
Merge pull request #1912 from benomaire/nightbg
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedre authored Mar 9, 2022
2 parents 5dc0b65 + c84fddf commit 1322a54
Show file tree
Hide file tree
Showing 28 changed files with 69 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ object Constants {

// Numerics
const val DEFAULT_NIGHT_MODE_TEXT_BRIGHTNESS = 255
const val DEFAULT_NIGHT_MODE_BACKGROUND_BRIGHTNESS = 0
const val DEFAULT_TEXT_SIZE = 15

// 10 days in ms
Expand Down Expand Up @@ -57,6 +58,7 @@ object Constants {
const val PREF_ACTIVE_TRANSLATIONS = "activeTranslations"
const val PREF_NIGHT_MODE = "nightMode"
const val PREF_NIGHT_MODE_TEXT_BRIGHTNESS = "nightModeTextBrightness"
const val PREF_NIGHT_MODE_BACKGROUND_BRIGHTNESS = "nightModeBackgroundBrightness"
const val PREF_DEFAULT_QARI = "defaultQari"
const val PREF_SHOULD_FETCH_PAGES = "shouldFetchPages"
const val PREF_OVERLAY_PAGE_INFO = "overlayPageInfo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public int getNightModeTextBrightness() {
Constants.DEFAULT_NIGHT_MODE_TEXT_BRIGHTNESS);
}

public int getNightModeBackgroundBrightness() {
return prefs.getInt(Constants.PREF_NIGHT_MODE_BACKGROUND_BRIGHTNESS,
Constants.DEFAULT_NIGHT_MODE_BACKGROUND_BRIGHTNESS);
}

public boolean shouldOverlayPageInfo() {
return prefs.getBoolean(Constants.PREF_OVERLAY_PAGE_INFO, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import static com.quran.data.model.highlight.HighlightType.Mode.HIDE;
import static com.quran.data.model.highlight.HighlightType.Mode.HIGHLIGHT;
import static com.quran.data.model.highlight.HighlightType.Mode.UNDERLINE;
import java.lang.Math;

public class HighlightingImageView extends AppCompatImageView {
// for debugging / visualizing glyph bounds:
Expand All @@ -68,6 +69,7 @@ public class HighlightingImageView extends AppCompatImageView {
private boolean isNightMode;
private boolean isColorFilterOn;
private int nightModeTextBrightness = Constants.DEFAULT_NIGHT_MODE_TEXT_BRIGHTNESS;
private int nightModeBackgroundBrightness = Constants.DEFAULT_NIGHT_MODE_BACKGROUND_BRIGHTNESS;

// Params for drawing text
private int fontSize;
Expand Down Expand Up @@ -202,10 +204,13 @@ public void setAyahData(AyahCoordinates ayahCoordinates) {
}
}

public void setNightMode(boolean isNightMode, int textBrightness) {
public void setNightMode(boolean isNightMode, int textBrightness, int backgroundBrightness) {
this.isNightMode = isNightMode;
if (isNightMode) {
nightModeTextBrightness = textBrightness;
// avoid damaging the looks of the Quran page
nightModeTextBrightness = (int) (50*Math.log1p(backgroundBrightness)+textBrightness);
if (nightModeTextBrightness > 255) nightModeTextBrightness = 255;
nightModeBackgroundBrightness = backgroundBrightness;
// we need a new color filter now
isColorFilterOn = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ open class QuranImagePageLayout(context: Context) : QuranPageLayout(context) {

override fun updateView(quranSettings: QuranSettings) {
super.updateView(quranSettings)
imageView.setNightMode(quranSettings.isNightMode, quranSettings.nightModeTextBrightness)
imageView.setNightMode(quranSettings.isNightMode, quranSettings.nightModeTextBrightness, quranSettings.nightModeBackgroundBrightness)
}

override fun setPageController(controller: PageController?, pageNumber: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ public void updateView(@NonNull QuranSettings quranSettings) {

protected void updateBackground(boolean nightMode, QuranSettings quranSettings) {
if (nightMode) {
setBackgroundColor(Color.BLACK);
int bgColor = quranSettings.getNightModeBackgroundBrightness();
setBackgroundColor(Color.rgb(bgColor,bgColor,bgColor));
} else if (quranSettings.useNewBackground()) {
setBackgroundDrawable((pageNumber % 2 == 0 ? leftGradient : rightGradient));
} else {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
<string name="prefs_night_mode_summary">الخلفية باللون اﻷسود والخطوط باللون اﻷبيض</string>
<string name="prefs_night_mode_text_brightness_title">إضاءة الخط</string>
<string name="prefs_night_mode_text_brightness_summary">إضاءة الخط عند تفعيل القراءة الليلية</string>
<string name="prefs_night_mode_background_brightness_title">إضاءة الخلفية</string>
<string name="prefs_night_mode_background_brightness_summary">إضاءة الصفحة عند تفعيل القراءة الليلية</string>
<string name="prefs_overlay_page_info_title">عرض بيانات الصفحة</string>
<string name="prefs_overlay_page_info_summary">عرض رقم الصفحة، اسم السورة، ورقم الجزء أثناء القراءة</string>
<string name="prefs_display_marker_title">التنبيه</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-bs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
<string name="prefs_night_mode_summary">Koristite tamnu podlogu i svjetle fontove</string>
<string name="prefs_night_mode_text_brightness_title">Osvijetljenost teksta</string>
<string name="prefs_night_mode_text_brightness_summary">Osvijetljenost teksta kada je noćni način uključen</string>
<string name="prefs_night_mode_background_brightness_title">Pozadinska svjetlina</string>
<string name="prefs_night_mode_background_brightness_summary">Svjetlina stranice kada je noćni način uključen</string>
<string name="prefs_overlay_page_info_title">Prikaži informacije o stranici</string>
<string name="prefs_overlay_page_info_summary">Dodajte broj stranice, ime sure i broj džuza dok čitate</string>
<string name="prefs_display_marker_title">Prikažite marker notifikaciju</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
<string name="prefs_night_mode_text_brightness_title">Helligkeit des Textes</string>
<string name="prefs_night_mode_text_brightness_summary">Die Helligkeit des Textes im Nachtmodus.
</string>
<string name="prefs_night_mode_background_brightness_title">Helligkeit des Hintergrunds</string>
<string name="prefs_night_mode_background_brightness_summary">Helligkeit der Seite im Nachtmodus.</string>
<string name="prefs_overlay_page_info_title">Seiteninfo anzeigen</string>
<string name="prefs_overlay_page_info_summary">Blendet die Seitennummer, den Namen der Sure und
die Juz\' Nummer während dem Lesen ein.
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
<string name="prefs_night_mode_summary">Se utilizará fondo oscuro y fuentes claras</string>
<string name="prefs_night_mode_text_brightness_title">Texto Brillante</string>
<string name="prefs_night_mode_text_brightness_summary">Texto brillante cuando el modo nocturno está activo</string>
<string name="prefs_night_mode_background_brightness_title">Luminosidad de fondo</string>
<string name="prefs_night_mode_background_brightness_summary">Brillo de la página cuando se activa el modo nocturno</string>
<string name="prefs_overlay_page_info_title">Mostrar información de la página</string>
<string name="prefs_overlay_page_info_summary">Superposición del número de página, nombre del capítulo, y el número del yuz durante la lectura</string>
<string name="prefs_display_marker_title">Mostrar marcador de ventanas emergentes</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
<string name="prefs_night_mode_summary">استفاده از پس‌زمینه تاریک و نوشته‌های روشن</string>
<string name="prefs_night_mode_text_brightness_title">روشنایی متن</string>
<string name="prefs_night_mode_text_brightness_summary">میزان روشنایی متن در حالت شبانه</string>
<string name="prefs_night_mode_background_brightness_title">درخشش پس زمینه</string>
<string name="prefs_night_mode_background_brightness_summary">روشنایی صفحه زمانی که حالت شب فعال است</string>
<string name="prefs_display_marker_title">نمایش پیغام‌ها</string>
<string name="prefs_display_marker_summary">فعال‌سازی پیغام‌های رسیدن به جزء، حزب و …</string>
<string name="prefs_translation_text_title">اندازه قلم ترجمه</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
<string name="prefs_night_mode_summary">Un fond sombre et des polices lumineuses seront utilisés.</string>
<string name="prefs_night_mode_text_brightness_title">Luminosité du texte</string>
<string name="prefs_night_mode_text_brightness_summary">Luminosité du texte lorsque le mode nuit est actif</string>
<string name="prefs_night_mode_background_brightness_title">Luminosité de fond</string>
<string name="prefs_night_mode_background_brightness_summary">Luminosité de la page lorsque le mode nuit est actif</string>
<string name="prefs_overlay_page_info_title">Afficher des infos </string>
<string name="prefs_overlay_page_info_summary">Affiche le numéro de page, le nom de la sourate et le numéro du juz\' lors la lecture.</string>
<string name="prefs_display_marker_title">Montrer un popup de repère</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-hr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
<string name="prefs_night_mode_summary">Koristite tamnu podlogu i svjetle fontove</string>
<string name="prefs_night_mode_text_brightness_title">Osvijetljenost teksta</string>
<string name="prefs_night_mode_text_brightness_summary">Osvijetljenost teksta kada je noćni način uključen</string>
<string name="prefs_night_mode_background_brightness_title">Svjetlina pozadine</string>
<string name="prefs_night_mode_background_brightness_summary">Svjetlina stranice kada je noćni način rada aktivan</string>
<string name="prefs_overlay_page_info_title">Prikaži informacije o stranici</string>
<string name="prefs_overlay_page_info_summary">Dodajte broj stranice, ime sure i broj džuza dok čitate</string>
<string name="prefs_display_marker_title">Prikažite marker notifikaciju</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
<string name="prefs_night_mode_summary">Sötét háttér és világos betűk lesznek használva</string>
<string name="prefs_night_mode_text_brightness_title">Szöveg fényerőssége</string>
<string name="prefs_night_mode_text_brightness_summary">A szöveg fényerőssége éjszakai mód bekapcsolásánál</string>
<string name="prefs_night_mode_background_brightness_title">Háttér fényerő</string>
<string name="prefs_night_mode_background_brightness_summary">Az oldal fényereje, ha az éjszakai üzemmód aktív</string>
<string name="prefs_overlay_page_info_title">Oldalinfó megjelenítése</string>
<string name="prefs_overlay_page_info_summary">Oldalszám, szúranév és dzsuzszám megjelenítése olvasás közben</string>
<string name="prefs_display_marker_title">Felugró jelzés megjelenítése</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@
<string name="prefs_night_mode_summary">Menggunkan latar gelap dan tulisan terang</string>
<string name="prefs_night_mode_text_brightness_title">Kecerahan teks</string>
<string name="prefs_night_mode_text_brightness_summary">Kecerahan teks saat mode malam diaktifkan</string>
<string name="prefs_night_mode_background_brightness_title">Kecerahan latar belakang</string>
<string name="prefs_night_mode_background_brightness_summary">Kecerahan halaman saat mode malam aktif</string>
<string name="prefs_overlay_page_info_title">Tampilkan informasi halaman</string>
<string name="prefs_overlay_page_info_summary">Munculkan nomor halaman, nama surat, dan nomer juz saat membaca</string>
<string name="prefs_display_marker_title">Tampilkan munculan penanda</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-kk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
<string name="prefs_night_mode_summary">Қара фон мен ашық түсті шрифт қолданылады</string>
<string name="prefs_night_mode_text_brightness_title">Мәтін ашықтығы</string>
<string name="prefs_night_mode_text_brightness_summary">Түнгі режимдегі мәтін ашықтығы</string>
<string name="prefs_night_mode_background_brightness_title">Фондық жарықтық</string>
<string name="prefs_night_mode_background_brightness_summary">Түнгі режим белсенді болған кездегі беттің жарықтығы</string>
<string name="prefs_overlay_page_info_title">Бет деректері</string>
<string name="prefs_overlay_page_info_summary">Сүре аты, бет және пара ретін көрсету</string>
<string name="prefs_display_marker_title">Бөлім деректері</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ku/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
<string name="prefs_night_mode_summary">پشت شاشەی ڕەش و نوسینی سپی </string>
<string name="prefs_night_mode_text_brightness_title">ڕووناکی نوسین</string>
<string name="prefs_night_mode_text_brightness_summary">ڕووناکی نوسین کاتێک شیوازی شەو چالاککرا</string>
<string name="prefs_night_mode_background_brightness_title">درەوشانەوەی باکگراوند</string>
<string name="prefs_night_mode_background_brightness_summary">درەوشانەوەی لاپەڕە کاتێک مۆدی شەو چالاکە</string>
<string name="prefs_overlay_page_info_title">پیشاندانی زانیاری پەڕە </string>
<string name="prefs_overlay_page_info_summary">پیشاندانی ژمارەی پەڕە، ناوی سورەت، وە ژمارەی جوزئـ لەکاتی خوێندنەوەدا</string>
<string name="prefs_display_marker_title">ئاگادارکردنەوە لە بەشەکان</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-my/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
<string name="prefs_night_mode_summary">Menggunakan latar belakang gelap dan teks terang</string>
<string name="prefs_night_mode_text_brightness_title">Kecerahan teks</string>
<string name="prefs_night_mode_text_brightness_summary">Kecerahan teks ketika mod malam aktif</string>
<string name="prefs_night_mode_background_brightness_title">Kecerahan latar belakang</string>
<string name="prefs_night_mode_background_brightness_summary">Kecerahan halaman apabila mod malam aktif</string>
<string name="prefs_overlay_page_info_title">Papar maklumat halaman</string>
<string name="prefs_overlay_page_info_summary">Nombor halaman, nama surah dan nomor juz\' akan dipaparkan</string>
<string name="prefs_display_marker_title">Paparkan popup penanda</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ Voor de vertaalde pagina\'s (/voor vertalingen): Ga naar instellingen en wijzig
<string name="prefs_night_mode_summary">Gebruik een donkere achtergrond en een lichte lettertype</string>
<string name="prefs_night_mode_text_brightness_title">Tekst helderheid</string>
<string name="prefs_night_mode_text_brightness_summary">Helederheid van de tekst wanneer de nacht modus zijn ingeschakeld.</string>
<string name="prefs_night_mode_background_brightness_title">Achtergrond helderheid</string>
<string name="prefs_night_mode_background_brightness_summary">Helderheid van de pagina wanneer de nachtmodus actief is</string>
<string name="prefs_overlay_page_info_title">Toon pagina info</string>
<string name="prefs_overlay_page_info_summary">Overlay page number, sura name, and juz\' number while reading</string>
<string name="prefs_display_marker_title">Weergeef marker popups</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ escolher um leitor-qari diferente. Clique play para baixar e reproduzir a págin
<string name="prefs_night_mode_summary">Dark background and light fonts will be used</string>
<string name="prefs_night_mode_text_brightness_title">Text Brightness</string>
<string name="prefs_night_mode_text_brightness_summary">Brightness of the text when night mode is active</string>
<string name="prefs_night_mode_background_brightness_title">Brilho de fundo</string>
<string name="prefs_night_mode_background_brightness_summary">Luminosidade da página quando o modo nocturno está activo</string>
<string name="prefs_overlay_page_info_title">Show page info (beta)</string>
<string name="prefs_overlay_page_info_summary">sobreposicione númeoro da página, nome da sura, e número do juz\' durante a leitura</string>
<string name="prefs_display_marker_title">Mostarar popups do marcador</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@
<string name="prefs_night_mode_summary">Будет использован темный фон и светлый шрифт</string>
<string name="prefs_night_mode_text_brightness_title">Яркость текста</string>
<string name="prefs_night_mode_text_brightness_summary">Яркость текста при включенном ночном режиме</string>
<string name="prefs_night_mode_background_brightness_title">Яркость фона</string>
<string name="prefs_night_mode_background_brightness_summary">Яркость страницы при активном ночном режиме</string>
<string name="prefs_overlay_page_info_title">Показать инфо страницы</string>
<string name="prefs_overlay_page_info_summary">При чтении использовать наложение поверх экрана номера страницы, название суры и номера джуза</string>
<string name="prefs_display_marker_title">Всплывающие сообщения</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-sr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
<string name="prefs_night_mode_summary">Koristite tamnu podlogu i svetle fontove</string>
<string name="prefs_night_mode_text_brightness_title">Osvetljenost teksta</string>
<string name="prefs_night_mode_text_brightness_summary">Osvetljenost teksta kada je noćni način uključen</string>
<string name="prefs_night_mode_background_brightness_title">Svetlina pozadine</string>
<string name="prefs_night_mode_background_brightness_summary">Svetlina stranice kada je noćni režim aktivan</string>
<string name="prefs_overlay_page_info_title">Prikaži informacije o stranici</string>
<string name="prefs_overlay_page_info_summary">Dodajte broj stranice, ime sure i broj džuza dok čitate</string>
<string name="prefs_display_marker_title">Prikažite marker notifikaciju</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
<string name="prefs_overlay_page_info_summary">Cüz numarası, sure ismi ve sayfa numarası üstünde göster</string>
<string name="prefs_night_mode_text_brightness_title">Metin parlaklığı</string>
<string name="prefs_night_mode_text_brightness_summary">Gece modu açıkken metin parlaklığı</string>
<string name="prefs_night_mode_background_brightness_title">Arka plan parlaklığı</string>
<string name="prefs_night_mode_background_brightness_summary">Gece modu etkinken sayfanın parlaklığı</string>
<string name="prefs_new_background_title">Yeni arkaplan</string>
<string name="prefs_download_amount_title">İndirme miktarı</string>
<string name="prefs_download_amount_summary">Ayrık olan ses dosyaları için indrime miktarı</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ug/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
<string name="prefs_night_mode_summary">قارا تەگلىك يورۇق خەت نۇسخىسى ئىشلىتىلىدۇ</string>
<string name="prefs_night_mode_text_brightness_title">تېكىست يورۇقلۇقى</string>
<string name="prefs_night_mode_text_brightness_summary">كېچە ھالىتى قوزغىتىلغان ۋاقىتتىكى تېكىستنىڭ يورۇقلۇقى</string>
<string name="prefs_night_mode_background_brightness_title">تەگلىك يورۇقلۇقى</string>
<string name="prefs_night_mode_background_brightness_summary">كەچلىك ھالەت ئاكتىپ بولغاندا بەتنىڭ يورۇقلۇقى</string>
<string name="prefs_overlay_page_info_title">بەت ئۇچۇرىنى كۆرسەت</string>
<string name="prefs_overlay_page_info_summary">قىرائەت قىلىۋاتقاندا بەت سانى، سۈرە ئىسمى ۋە پارە سانىنى كۆرسىتىدۇ</string>
<string name="prefs_display_marker_title">بەلگە قاڭقىش كۆزنىكىنى كۆرسەت</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-uz/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
<string name="prefs_night_mode_summary">Qora fon va porloq shriftlardan foydalaniladi</string>
<string name="prefs_night_mode_text_brightness_title">Matn porloqliligi</string>
<string name="prefs_night_mode_text_brightness_summary">Tunggi rejim ishga tushirilgan paytdagi matn porloqliligi</string>
<string name="prefs_night_mode_background_brightness_title">Fon yorqinligi</string>
<string name="prefs_night_mode_background_brightness_summary">Tungi rejim faol boʼlganda sahifaning yorqinligi</string>
<string name="prefs_overlay_page_info_title">Sahifa maʼlumotlari</string>
<string name="prefs_overlay_page_info_summary">Sura nomi, sahifa va juz raqamlarini koʻrsatish</string>
<string name="prefs_display_marker_title">Boʻlim maʼlumotlari</string>
Expand Down
Loading

0 comments on commit 1322a54

Please sign in to comment.