diff --git a/Alkitab/src/main/AndroidManifest.xml b/Alkitab/src/main/AndroidManifest.xml index 05557c7ab..a605a35ca 100644 --- a/Alkitab/src/main/AndroidManifest.xml +++ b/Alkitab/src/main/AndroidManifest.xml @@ -43,7 +43,6 @@ @@ -249,8 +248,7 @@ android:windowSoftInputMode="adjustResize" /> + android:label="@string/menuDevotion"> @@ -277,8 +275,7 @@ android:windowSoftInputMode="adjustResize|stateHidden" /> + android:label="@string/sn_songs_activity_title" /> @@ -288,8 +285,7 @@ + android:windowSoftInputMode="adjustResize" /> diff --git a/Alkitab/src/main/assets/templates/song.css b/Alkitab/src/main/assets/templates/song.css index 191c21fdf..901bc63ed 100644 --- a/Alkitab/src/main/assets/templates/song.css +++ b/Alkitab/src/main/assets/templates/song.css @@ -1,9 +1,4 @@ -body { - margin: 0; - padding: 24px 16px; -} - .code { font-family: sans-serif; font-weight: bold; diff --git a/Alkitab/src/main/assets/templates/song.html b/Alkitab/src/main/assets/templates/song.html index ec043973a..804d21696 100644 --- a/Alkitab/src/main/assets/templates/song.html +++ b/Alkitab/src/main/assets/templates/song.html @@ -21,19 +21,19 @@ function body_load() { var test_tobehidden = document.getElementById('test_tobehidden'); var test_line = document.getElementById('test_line'); - + var h = test_line.clientHeight; var lh = (h * {{$line_spacing_mult}}) + 'px'; - + var lines = document.getElementsByClassName('line'); for (var i = 0; i < lines.length; i++) lines[i].style.lineHeight = lh; - + test_tobehidden.parentNode.removeChild(test_tobehidden); } - +
{{div:code}} {{div:title}} diff --git a/Alkitab/src/main/java/yuku/alkitab/base/IsiActivity.kt b/Alkitab/src/main/java/yuku/alkitab/base/IsiActivity.kt index dfb1b27cb..664a99d9c 100644 --- a/Alkitab/src/main/java/yuku/alkitab/base/IsiActivity.kt +++ b/Alkitab/src/main/java/yuku/alkitab/base/IsiActivity.kt @@ -28,6 +28,7 @@ import android.view.View import android.view.ViewGroup import android.view.ViewTreeObserver import android.view.WindowManager +import android.widget.FrameLayout import android.widget.ImageButton import android.widget.LinearLayout import android.widget.TextView @@ -241,10 +242,10 @@ class IsiActivity : BaseLeftDrawerActivity(), LeftDrawer.Text.Listener { } private lateinit var drawerLayout: DrawerLayout - override lateinit var leftDrawer: LeftDrawer.Text + lateinit var leftDrawer: LeftDrawer.Text - override lateinit var overlayContainer: ViewGroup - override lateinit var root: ViewGroup + private lateinit var overlayContainer: FrameLayout + lateinit var root: ViewGroup lateinit var toolbar: Toolbar private lateinit var nontoolbar: View lateinit var lsSplit0: VersesController @@ -290,6 +291,7 @@ class IsiActivity : BaseLeftDrawerActivity(), LeftDrawer.Text.Listener { var actionMode: ActionMode? = null private var dictionaryMode = false + var textAppearancePanel: TextAppearancePanel? = null /** * The following "esvsbasal" thing is a personal thing by yuku that doesn't matter to anyone else. @@ -1726,9 +1728,14 @@ class IsiActivity : BaseLeftDrawerActivity(), LeftDrawer.Text.Listener { return arrayOf(res0.toString(), res1.toString()) } - override fun applyPreferences() { - super.applyPreferences() + fun applyPreferences() { + // make sure S applied variables are set first + S.recalculateAppliedValuesBasedOnPreferences() + + // apply background color, and clear window background to prevent overdraw + window.setBackgroundDrawableResource(android.R.color.transparent) val backgroundColor = S.applied().backgroundColor + root.setBackgroundColor(backgroundColor) // scrollbar must be visible! val thumb = if (ColorUtils.calculateLuminance(backgroundColor) > 0.5) { @@ -2026,10 +2033,47 @@ class IsiActivity : BaseLeftDrawerActivity(), LeftDrawer.Text.Listener { } } - override fun createTextAppearancePanel(): TextAppearancePanel? { - val panel = super.createTextAppearancePanel() - configureTextAppearancePanelForSplitVersion() - return panel + private fun setShowTextAppearancePanel(yes: Boolean) { + if (!yes) { + textAppearancePanel?.hide() + textAppearancePanel = null + return + } + + if (textAppearancePanel == null) { // not showing yet + textAppearancePanel = TextAppearancePanel( + this, + overlayContainer, + object : TextAppearancePanel.Listener { + override fun onValueChanged() { + applyPreferences() + } + + override fun onCloseButtonClick() { + textAppearancePanel?.hide() + textAppearancePanel = null + } + }, + RequestCodes.FromActivity.TextAppearanceGetFonts, + RequestCodes.FromActivity.TextAppearanceCustomColors + ) + configureTextAppearancePanelForSplitVersion() + textAppearancePanel?.show() + } + } + + private fun setNightMode(yes: Boolean) { + val previousValue = Preferences.getBoolean(Prefkey.is_night_mode, false) + if (previousValue == yes) return + + Preferences.setBoolean(Prefkey.is_night_mode, yes) + + applyPreferences() + applyNightModeColors() + + textAppearancePanel?.displayValues() + + App.getLbm().sendBroadcast(Intent(ACTION_NIGHT_MODE_CHANGED)) } private fun openVersionsDialog() { @@ -2366,6 +2410,10 @@ class IsiActivity : BaseLeftDrawerActivity(), LeftDrawer.Text.Listener { return super.onKeyUp(keyCode, event) } + override fun getLeftDrawer(): LeftDrawer { + return leftDrawer + } + fun bLeft_click() { Tracker.trackEvent("nav_left_click") val currentBook = activeSplit0.book @@ -2778,11 +2826,21 @@ class IsiActivity : BaseLeftDrawerActivity(), LeftDrawer.Text.Listener { startActivity(MarkersActivity.createIntent()) } + override fun bDisplay_click() { + Tracker.trackEvent("left_drawer_display_click") + setShowTextAppearancePanel(textAppearancePanel == null) + } + override fun cFullScreen_checkedChange(isChecked: Boolean) { Tracker.trackEvent("left_drawer_full_screen_click") setFullScreen(isChecked) } + override fun cNightMode_checkedChange(isChecked: Boolean) { + Tracker.trackEvent("left_drawer_night_mode_click") + setNightMode(isChecked) + } + override fun cSplitVersion_checkedChange(cSplitVersion: SwitchCompat, isChecked: Boolean) { Tracker.trackEvent("left_drawer_split_click") if (isChecked) { diff --git a/Alkitab/src/main/java/yuku/alkitab/base/S.kt b/Alkitab/src/main/java/yuku/alkitab/base/S.kt index edfcb3ee7..1f8c57971 100644 --- a/Alkitab/src/main/java/yuku/alkitab/base/S.kt +++ b/Alkitab/src/main/java/yuku/alkitab/base/S.kt @@ -167,7 +167,6 @@ object S { return null // not known } - @JvmStatic fun recalculateAppliedValuesBasedOnPreferences() { CalculatedDimensionsHolder.applied = calculateDimensionsFromPreferences() } diff --git a/Alkitab/src/main/java/yuku/alkitab/base/ac/DevotionActivity.java b/Alkitab/src/main/java/yuku/alkitab/base/ac/DevotionActivity.java index d6779ce45..ee03554fc 100644 --- a/Alkitab/src/main/java/yuku/alkitab/base/ac/DevotionActivity.java +++ b/Alkitab/src/main/java/yuku/alkitab/base/ac/DevotionActivity.java @@ -14,8 +14,6 @@ import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; -import android.view.ViewGroup; -import android.widget.FrameLayout; import android.widget.TextView; import androidx.annotation.Keep; import androidx.annotation.NonNull; @@ -109,22 +107,11 @@ public void cbKind_itemSelected(final DevotionKind kind) { display(); } - @NonNull @Override protected LeftDrawer getLeftDrawer() { return leftDrawer; } - @Nullable - @Override - protected ViewGroup getOverlayContainer() { return overlayContainer; } - - @NonNull - @Override - public DrawerLayout getRoot() { - return drawerLayout; - } - public enum DevotionKind { SH("sh", "Santapan Harian", "Persekutuan Pembaca Alkitab") { @Override @@ -223,7 +210,6 @@ public int getPrefetchDays() { DrawerLayout drawerLayout; LeftDrawer.Devotion leftDrawer; - FrameLayout overlayContainer; TwofingerLinearLayout root; TextView lContent; NestedScrollView scrollContent; @@ -319,7 +305,6 @@ protected void onCreate(Bundle savedInstanceState) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp); - overlayContainer = findViewById(R.id.overlayContainer); root = findViewById(R.id.root); lContent = findViewById(R.id.lContent); scrollContent = findViewById(R.id.scrollContent); @@ -341,27 +326,25 @@ protected void onCreate(Bundle savedInstanceState) { protected void onStart() { super.onStart(); - applyPreferences(); - - final Rect padding = SettingsActivity.getPaddingBasedOnPreferences(); - lContent.setPadding(padding.left, padding.top, padding.right, padding.bottom); - - getWindow().getDecorView().setKeepScreenOn(Preferences.getBoolean(getString(R.string.pref_keepScreenOn_key), getResources().getBoolean(R.bool.pref_keepScreenOn_default))); - - App.getLbm().registerReceiver(br, new IntentFilter(DevotionDownloader.ACTION_DOWNLOADED)); - } - - @Override - public void applyPreferences() { - super.applyPreferences(); - final S.CalculatedDimensions applied = S.applied(); + { // apply background color, and clear window background to prevent overdraw + getWindow().setBackgroundDrawableResource(android.R.color.transparent); + scrollContent.setBackgroundColor(applied.backgroundColor); + } + // text formats lContent.setTextColor(applied.fontColor); lContent.setTypeface(applied.fontFace, applied.fontBold); lContent.setTextSize(TypedValue.COMPLEX_UNIT_DIP, applied.fontSize2dp); lContent.setLineSpacing(0, applied.lineSpacingMult); + + final Rect padding = SettingsActivity.getPaddingBasedOnPreferences(); + lContent.setPadding(padding.left, padding.top, padding.right, padding.bottom); + + getWindow().getDecorView().setKeepScreenOn(Preferences.getBoolean(getString(R.string.pref_keepScreenOn_key), getResources().getBoolean(R.bool.pref_keepScreenOn_default))); + + App.getLbm().registerReceiver(br, new IntentFilter(DevotionDownloader.ACTION_DOWNLOADED)); } @Override diff --git a/Alkitab/src/main/java/yuku/alkitab/base/ac/PatchTextActivity.java b/Alkitab/src/main/java/yuku/alkitab/base/ac/PatchTextActivity.java index c4b7c06e9..3fa6b8bf9 100644 --- a/Alkitab/src/main/java/yuku/alkitab/base/ac/PatchTextActivity.java +++ b/Alkitab/src/main/java/yuku/alkitab/base/ac/PatchTextActivity.java @@ -1,7 +1,6 @@ package yuku.alkitab.base.ac; import android.content.Intent; -import android.content.res.Configuration; import android.net.Uri; import android.os.Bundle; import android.util.TypedValue; @@ -15,11 +14,9 @@ import com.example.android.wizardpager.AlkitabFeedbackActivity; import java.util.LinkedList; import name.fraser.neil.plaintext.diff_match_patch; -import yuku.afw.storage.Preferences; import yuku.alkitab.base.App; import yuku.alkitab.base.S; import yuku.alkitab.base.ac.base.BaseActivity; -import yuku.alkitab.base.storage.Prefkey; import yuku.alkitab.base.widget.MaterialDialogJavaHelper; import yuku.alkitab.debug.R; @@ -99,20 +96,6 @@ public boolean onOptionsItemSelected(final MenuItem item) { return super.onOptionsItemSelected(item); } - @Override - public void onConfigurationChanged(@NonNull Configuration newConfig) { - super.onConfigurationChanged(newConfig); - final boolean followSystemTheme = Preferences.getBoolean(Prefkey.follow_system_theme, true); - if (followSystemTheme) { - Preferences.setBoolean(Prefkey.is_night_mode, (newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES); - S.recalculateAppliedValuesBasedOnPreferences(); - applyNightModeColors(); - final S.CalculatedDimensions applied = S.applied(); - tBody.setTextColor(applied.fontColor); - tBody.setBackgroundColor(applied.backgroundColor); - } - } - void menuSend_click() { final String baseText = baseBody.toString(); final String currentText = tBody.getText().toString(); diff --git a/Alkitab/src/main/java/yuku/alkitab/base/ac/ReadingPlanActivity.java b/Alkitab/src/main/java/yuku/alkitab/base/ac/ReadingPlanActivity.java index 217285e40..9ef857ab5 100644 --- a/Alkitab/src/main/java/yuku/alkitab/base/ac/ReadingPlanActivity.java +++ b/Alkitab/src/main/java/yuku/alkitab/base/ac/ReadingPlanActivity.java @@ -24,7 +24,6 @@ import android.widget.ProgressBar; import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.Toolbar; @@ -540,22 +539,11 @@ public void bRestart_click() { leftDrawer.closeDrawer(); } - @NonNull @Override protected LeftDrawer getLeftDrawer() { return leftDrawer; } - @Nullable - @Override - protected ViewGroup getOverlayContainer() { return null; } - - @NonNull - @Override - public DrawerLayout getRoot() { - return drawerLayout; - } - private void openDownloadReadingPlanPage() { startActivityForResult( HelpActivity.createIntent( diff --git a/Alkitab/src/main/java/yuku/alkitab/base/ac/base/BaseLeftDrawerActivity.java b/Alkitab/src/main/java/yuku/alkitab/base/ac/base/BaseLeftDrawerActivity.java new file mode 100644 index 000000000..4e8f4a5b1 --- /dev/null +++ b/Alkitab/src/main/java/yuku/alkitab/base/ac/base/BaseLeftDrawerActivity.java @@ -0,0 +1,21 @@ +package yuku.alkitab.base.ac.base; + +import android.view.KeyEvent; +import yuku.alkitab.base.widget.LeftDrawer; + +public abstract class BaseLeftDrawerActivity extends BaseActivity { + @Override + public boolean onKeyUp(final int keyCode, final KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_MENU) { + openOrCloseLeftDrawer(); + return true; + } + return super.onKeyUp(keyCode, event); + } + + private void openOrCloseLeftDrawer() { + getLeftDrawer().toggleDrawer(); + } + + protected abstract LeftDrawer getLeftDrawer(); +} diff --git a/Alkitab/src/main/java/yuku/alkitab/base/ac/base/BaseLeftDrawerActivity.kt b/Alkitab/src/main/java/yuku/alkitab/base/ac/base/BaseLeftDrawerActivity.kt deleted file mode 100644 index c8e6d5aeb..000000000 --- a/Alkitab/src/main/java/yuku/alkitab/base/ac/base/BaseLeftDrawerActivity.kt +++ /dev/null @@ -1,137 +0,0 @@ -package yuku.alkitab.base.ac.base - -import android.content.Intent -import android.content.pm.ActivityInfo -import android.content.res.Configuration -import android.view.KeyEvent -import android.view.ViewGroup -import androidx.appcompat.widget.SwitchCompat -import yuku.afw.storage.Preferences -import yuku.alkitab.base.App -import yuku.alkitab.base.S -import yuku.alkitab.base.storage.Prefkey -import yuku.alkitab.base.util.RequestCodes -import yuku.alkitab.base.widget.LeftDrawer -import yuku.alkitab.base.widget.TextAppearancePanel -import yuku.alkitab.tracking.Tracker - - -abstract class BaseLeftDrawerActivity : BaseActivity(), LeftDrawer.Listener { - protected abstract val overlayContainer: ViewGroup? - private lateinit var mPrevConfig: Configuration - protected var textAppearancePanel: TextAppearancePanel? = null - protected abstract val leftDrawer: LeftDrawer - abstract val root: ViewGroup - - override fun onCreate(savedInstanceState: android.os.Bundle?) { - super.onCreate(savedInstanceState) - mPrevConfig = Configuration(resources.configuration) - } - - override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean { - if (keyCode == KeyEvent.KEYCODE_MENU) { - openOrCloseLeftDrawer() - return true - } - return super.onKeyUp(keyCode, event) - } - - private fun openOrCloseLeftDrawer() { - leftDrawer.toggleDrawer() - } - - override fun onConfigurationChanged(newConfig: Configuration) { - super.onConfigurationChanged(newConfig) - if (newConfig.diff(mPrevConfig) and ActivityInfo.CONFIG_UI_MODE != 0) { - leftDrawer.checkSystemTheme() - mPrevConfig = Configuration(newConfig) - } - } - - open fun applyPreferences() { - // make sure S applied variables are set first - S.recalculateAppliedValuesBasedOnPreferences() - - // apply background color, and clear window background to prevent overdraw - window.setBackgroundDrawableResource(android.R.color.transparent) - val backgroundColor = S.applied().backgroundColor - root.setBackgroundColor(backgroundColor) - } - - override fun cNightMode_checkedChange(isChecked: Boolean) { - Tracker.trackEvent("left_drawer_night_mode_click") - setNightMode(isChecked) - } - - override fun cFollowSystemTheme_checkedChange(isChecked: Boolean, cNightMode: SwitchCompat) { - Tracker.trackEvent("left_drawer_follow_system_theme_click") - cNightMode.setEnabled(!isChecked) - setFollowSystemTheme(isChecked, cNightMode) - } - - private fun setNightMode(yes: Boolean) { - val previousValue = Preferences.getBoolean(Prefkey.is_night_mode, false) - if (previousValue == yes) return - - Preferences.setBoolean(Prefkey.is_night_mode, yes) - - applyPreferences() - applyNightModeColors() - - textAppearancePanel?.displayValues() - - App.getLbm().sendBroadcast(Intent(ACTION_NIGHT_MODE_CHANGED)) - } - - private fun setFollowSystemTheme(yes: Boolean, cNightMode: SwitchCompat) { - Preferences.setBoolean(Prefkey.follow_system_theme, yes) - - if (yes) { - val systemTheme = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK - cNightMode.isChecked = systemTheme == Configuration.UI_MODE_NIGHT_YES - setNightMode(systemTheme == Configuration.UI_MODE_NIGHT_YES) - } - } - - private fun setShowTextAppearancePanel(yes: Boolean) { - if (!yes) { - textAppearancePanel?.hide() - textAppearancePanel = null - return - } - - if (textAppearancePanel == null) { // not showing yet - textAppearancePanel = createTextAppearancePanel() - textAppearancePanel?.show() - } - } - - protected open fun createTextAppearancePanel(): TextAppearancePanel? { - if (overlayContainer == null) return null - return TextAppearancePanel( - this, - overlayContainer, - object : TextAppearancePanel.Listener { - override fun onValueChanged() { - applyPreferences() - } - - override fun onCloseButtonClick() { - textAppearancePanel?.hide() - textAppearancePanel = null - } - }, - RequestCodes.FromActivity.TextAppearanceGetFonts, - RequestCodes.FromActivity.TextAppearanceCustomColors - ) - } - - override fun bDisplay_click() { - Tracker.trackEvent("left_drawer_display_click") - setShowTextAppearancePanel(textAppearancePanel == null) - } - - companion object { - const val ACTION_NIGHT_MODE_CHANGED = "yuku.alkitab.base.IsiActivity.action.NIGHT_MODE_CHANGED" - } -} diff --git a/Alkitab/src/main/java/yuku/alkitab/base/storage/Prefkey.kt b/Alkitab/src/main/java/yuku/alkitab/base/storage/Prefkey.kt index 8f563a937..2b91b49f3 100644 --- a/Alkitab/src/main/java/yuku/alkitab/base/storage/Prefkey.kt +++ b/Alkitab/src/main/java/yuku/alkitab/base/storage/Prefkey.kt @@ -35,9 +35,6 @@ enum class Prefkey { /** Night mode activated (boolean) */ is_night_mode, - /** Night mode follows system theme (boolean) */ - follow_system_theme, - /** marker (bookmark) list selected sorting option */ marker_list_sort_column, marker_list_sort_ascending, diff --git a/Alkitab/src/main/java/yuku/alkitab/base/widget/LeftDrawer.java b/Alkitab/src/main/java/yuku/alkitab/base/widget/LeftDrawer.java index fefc302c5..1f00ec8f7 100644 --- a/Alkitab/src/main/java/yuku/alkitab/base/widget/LeftDrawer.java +++ b/Alkitab/src/main/java/yuku/alkitab/base/widget/LeftDrawer.java @@ -6,7 +6,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.res.Configuration; import android.graphics.Typeface; import androidx.annotation.NonNull; import androidx.core.content.res.ResourcesCompat; @@ -57,7 +56,6 @@ public abstract class LeftDrawer extends NestedScrollView { TextView bDevotion; TextView bReadingPlan; TextView bSongs; - View bDisplay; View bSettings; View bHelp; @@ -65,36 +63,10 @@ public abstract class LeftDrawer extends NestedScrollView { final Activity activity; // for closing drawer DrawerLayout drawerLayout; - SwitchCompat cNightMode; - SwitchCompat cFollowSystemTheme; - final Listener listener; - CompoundButton.OnCheckedChangeListener cNightMode_checkedChange = new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { - assert listener != null; - listener.cNightMode_checkedChange(isChecked); - } - }; - CompoundButton.OnCheckedChangeListener cFollowSystemTheme_checkedChange = new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { - assert listener != null; - listener.cFollowSystemTheme_checkedChange(isChecked, cNightMode); - } - }; - - public interface Listener { - void bDisplay_click(); - - void cNightMode_checkedChange(boolean isChecked); - - void cFollowSystemTheme_checkedChange(boolean isChecked, SwitchCompat cNightMode); - } public LeftDrawer(final Context context, final AttributeSet attrs) { super(context, attrs); activity = isInEditMode() ? null : (Activity) context; - listener = (Listener) context; } @Override @@ -110,9 +82,6 @@ protected void onFinishInflate() { bDevotion = findViewById(R.id.bDevotion); bReadingPlan = findViewById(R.id.bReadingPlan); bSongs = findViewById(R.id.bSongs); - bDisplay = findViewById(R.id.bDisplay); - cNightMode = findViewById(R.id.cNightMode); - cFollowSystemTheme = findViewById(R.id.cFollowSystemTheme); bSettings = findViewById(R.id.bSettings); bHelp = findViewById(R.id.bHelp); @@ -147,19 +116,6 @@ protected void onFinishInflate() { closeDrawer(); }); - bDisplay.setOnClickListener(v -> { - listener.bDisplay_click(); - closeDrawer(); - }); - - if (cNightMode != null) { - cNightMode.setOnCheckedChangeListener(cNightMode_checkedChange); - } - - if (cFollowSystemTheme != null) { - cFollowSystemTheme.setOnCheckedChangeListener(cFollowSystemTheme_checkedChange); - } - bSettings.setOnClickListener(v -> { bSettings_click(); closeDrawer(); @@ -171,16 +127,6 @@ protected void onFinishInflate() { }); } - @Override - public void onAttachedToWindow() { - super.onAttachedToWindow(); - - if (cFollowSystemTheme != null) { - final boolean followSystemTheme = checkSystemTheme(); - cFollowSystemTheme.setChecked(followSystemTheme); - } - } - void setDrawerItemSelected(@NonNull TextView drawerItem) { final int selectedTextColor = ResourcesCompat.getColor(getResources(), R.color.accent, getContext().getTheme()); drawerItem.setTextColor(selectedTextColor); @@ -271,17 +217,6 @@ void bDevotion_click() { } } - public boolean checkSystemTheme() { - final boolean followSystemTheme = Preferences.getBoolean(Prefkey.follow_system_theme, true); - if (followSystemTheme) { - final int systemTheme = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; - cNightMode.setChecked(!isInEditMode() && systemTheme == Configuration.UI_MODE_NIGHT_YES); - } else { - cNightMode.setChecked(!isInEditMode() && Preferences.getBoolean(Prefkey.is_night_mode, false)); - } - return followSystemTheme; - } - /** * This clears all activity on this stack and starts {@link yuku.alkitab.base.IsiActivity}. */ @@ -293,11 +228,15 @@ void bBible_click() { } public static class Text extends LeftDrawer { - public interface Listener extends LeftDrawer.Listener { + public interface Listener { void bMarkers_click(); + void bDisplay_click(); + void cFullScreen_checkedChange(boolean isChecked); + void cNightMode_checkedChange(boolean isChecked); + void cSplitVersion_checkedChange(final SwitchCompat cSplitVersion, boolean isChecked); void bProgressMarkList_click(); @@ -316,7 +255,9 @@ public interface Handle { } View bMarkers; + View bDisplay; SwitchCompat cFullScreen; + SwitchCompat cNightMode; SwitchCompat cSplitVersion; View bProgressMarkList; @@ -362,6 +303,7 @@ protected void onFinishInflate() { bMarkers = findViewById(R.id.bMarkers); bDisplay = findViewById(R.id.bDisplay); cFullScreen = findViewById(R.id.cFullScreen); + cNightMode = findViewById(R.id.cNightMode); cSplitVersion = findViewById(R.id.cSplitVersion); bProgressMarkList = findViewById(R.id.bProgressMarkList); @@ -375,6 +317,8 @@ protected void onFinishInflate() { bCurrentReadingClose = findViewById(R.id.bCurrentReadingClose); bCurrentReadingReference = findViewById(R.id.bCurrentReadingReference); + cNightMode.setChecked(!isInEditMode() && Preferences.getBoolean(Prefkey.is_night_mode, false)); + bProgressMarkList.setOnClickListener(v -> listener.bProgressMarkList_click()); final View[] views = new View[]{bProgress1, bProgress2, bProgress3, bProgress4, bProgress5}; @@ -402,8 +346,15 @@ protected void onFinishInflate() { closeDrawer(); }); + bDisplay.setOnClickListener(v -> { + listener.bDisplay_click(); + closeDrawer(); + }); + cFullScreen.setOnCheckedChangeListener(cFullScreen_checkedChange); + cNightMode.setOnCheckedChangeListener(cNightMode_checkedChange); + cSplitVersion.setOnCheckedChangeListener(cSplitVersion_checkedChange); bCurrentReadingClose.setOnClickListener(v -> listener.bCurrentReadingClose_click()); @@ -456,6 +407,13 @@ public void onCheckedChanged(final CompoundButton buttonView, final boolean isCh } }; + CompoundButton.OnCheckedChangeListener cNightMode_checkedChange = new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { + listener.cNightMode_checkedChange(isChecked); + } + }; + CompoundButton.OnCheckedChangeListener cSplitVersion_checkedChange = new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { @@ -479,7 +437,7 @@ public static class Devotion extends LeftDrawer { DevotionKindAdapter adapter; - public interface Listener extends LeftDrawer.Listener { + public interface Listener { void bPrev_click(); void bNext_click(); @@ -535,6 +493,7 @@ protected void onFinishInflate() { bNext = findViewById(R.id.bNext); bReload = findViewById(R.id.bReload); + cbKind.setAdapter(adapter = new DevotionKindAdapter()); cbKind.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override @@ -547,6 +506,7 @@ public void onNothingSelected(final AdapterView parent) { } }); + bPrev.setOnClickListener(v -> listener.bPrev_click()); bNext.setOnClickListener(v -> listener.bNext_click()); @@ -618,7 +578,7 @@ public int getPositionForKind(final DevotionActivity.DevotionKind kind) { } public static class ReadingPlan extends LeftDrawer { - public interface Listener extends LeftDrawer.Listener { + public interface Listener { void bRestart_click(); } @@ -677,7 +637,7 @@ public void configure(T listener, DrawerLayout d } public static class Songs extends LeftDrawer { - public interface Listener extends LeftDrawer.Listener { + public interface Listener { void songKeypadButton_click(View v); void songBookSelected(String name); diff --git a/Alkitab/src/main/java/yuku/alkitab/base/widget/TextAppearancePanel.java b/Alkitab/src/main/java/yuku/alkitab/base/widget/TextAppearancePanel.java index f4879d3c1..050fb3ba8 100644 --- a/Alkitab/src/main/java/yuku/alkitab/base/widget/TextAppearancePanel.java +++ b/Alkitab/src/main/java/yuku/alkitab/base/widget/TextAppearancePanel.java @@ -43,7 +43,7 @@ public interface Listener { } final Activity activity; - final ViewGroup parent; + final FrameLayout parent; final Listener listener; final View content; final int reqcodeGetFonts; @@ -67,7 +67,7 @@ public interface Listener { String splitVersionId; String splitVersionLongName; - public TextAppearancePanel(Activity activity, ViewGroup parent, Listener listener, int reqcodeGetFonts, int reqcodeCustomColors) { + public TextAppearancePanel(Activity activity, FrameLayout parent, Listener listener, int reqcodeGetFonts, int reqcodeCustomColors) { this.activity = activity; this.parent = parent; this.listener = listener; diff --git a/Alkitab/src/main/java/yuku/alkitab/songs/SongFragment.kt b/Alkitab/src/main/java/yuku/alkitab/songs/SongFragment.kt index a768f0458..d7cf5811b 100644 --- a/Alkitab/src/main/java/yuku/alkitab/songs/SongFragment.kt +++ b/Alkitab/src/main/java/yuku/alkitab/songs/SongFragment.kt @@ -120,19 +120,6 @@ class SongFragment : BaseFragment() { return template.replace("{{$$name}}", value?.toString() ?: "") } - fun updateTheme(customVars: Bundle) { - val font = if (customVars.getString("text_font") == "DEFAULT") "sans-serif" else customVars.getString("text_font") - arguments = Bundle().apply { - webview.evaluateJavascript(""" - document.body.style.backgroundColor = '${customVars.getString("background_color")}'; - document.body.style.color = '${customVars.getString("text_color")}'; - document.body.style.fontSize = '${customVars.getString("text_size")}'; - Array.from(document.getElementsByClassName('line')).forEach(x => x.style.lineHeight = '${customVars.getString("line_spacing_mult")}'); - document.body.style.fontFamily = '${font}'; - """, null) - } - } - var webViewTextZoom: Int get() { return if (view == null) 0 else webview.settings.textZoom diff --git a/Alkitab/src/main/java/yuku/alkitab/songs/SongViewActivity.kt b/Alkitab/src/main/java/yuku/alkitab/songs/SongViewActivity.kt index c7ab29a04..c2f6d8d73 100644 --- a/Alkitab/src/main/java/yuku/alkitab/songs/SongViewActivity.kt +++ b/Alkitab/src/main/java/yuku/alkitab/songs/SongViewActivity.kt @@ -71,10 +71,9 @@ private const val FRAGMENT_TAG_SONG = "song" class SongViewActivity : BaseLeftDrawerActivity(), SongFragment.ShouldOverrideUrlLoadingHandler, LeftDrawer.Songs.Listener, MediaStateListener { private lateinit var drawerLayout: DrawerLayout - override lateinit var leftDrawer: LeftDrawer.Songs + private lateinit var leftDrawer: LeftDrawer.Songs - override lateinit var overlayContainer: ViewGroup - override lateinit var root: TwofingerLinearLayout + private lateinit var root: TwofingerLinearLayout private lateinit var no_song_data_container: ViewGroup private lateinit var bDownload: View private lateinit var circular_progress: View @@ -129,6 +128,8 @@ class SongViewActivity : BaseLeftDrawerActivity(), SongFragment.ShouldOverrideUr private val mediaState = MediaState() + override fun getLeftDrawer() = leftDrawer + inner class MediaState { var enabled = false @@ -267,7 +268,6 @@ class SongViewActivity : BaseLeftDrawerActivity(), SongFragment.ShouldOverrideUr } }) - overlayContainer = findViewById(R.id.overlayContainer) root = findViewById(R.id.root) no_song_data_container = findViewById(R.id.no_song_data_container) bDownload = findViewById(R.id.bDownload) @@ -315,26 +315,10 @@ class SongViewActivity : BaseLeftDrawerActivity(), SongFragment.ShouldOverrideUr override fun onStart() { super.onStart() - applyPreferences() - - // show latest viewed song - val bookName = Preferences.getString(Prefkey.song_last_bookName, null) - val code = Preferences.getString(Prefkey.song_last_code, null) - - if (bookName == null || code == null) { - displaySong(null, null, true) - } else { - displaySong(bookName, S.songDb.getSong(bookName, code), true) - } - - window.decorView.keepScreenOn = Preferences.getBoolean(getString(R.string.pref_keepScreenOn_key), resources.getBoolean(R.bool.pref_keepScreenOn_default)) - } - - override fun applyPreferences() { - super.applyPreferences() - val applied = S.applied() + // apply background color, and clear window background to prevent overdraw + window.setBackgroundDrawableResource(android.R.color.transparent) findViewById(android.R.id.content).setBackgroundColor(applied.backgroundColor) templateCustomVars.clear() @@ -357,10 +341,17 @@ class SongViewActivity : BaseLeftDrawerActivity(), SongFragment.ShouldOverrideUr } templateCustomVars.putString("text_font", fontName) - val fragment = supportFragmentManager.findFragmentByTag(FRAGMENT_TAG_SONG) - if (fragment != null) { - (fragment as SongFragment).updateTheme(templateCustomVars) + // show latest viewed song + val bookName = Preferences.getString(Prefkey.song_last_bookName, null) + val code = Preferences.getString(Prefkey.song_last_code, null) + + if (bookName == null || code == null) { + displaySong(null, null, true) + } else { + displaySong(bookName, S.songDb.getSong(bookName, code), true) } + + window.decorView.keepScreenOn = Preferences.getBoolean(getString(R.string.pref_keepScreenOn_key), resources.getBoolean(R.bool.pref_keepScreenOn_default)) } /** diff --git a/Alkitab/src/main/res/layout/activity_devotion_content.xml b/Alkitab/src/main/res/layout/activity_devotion_content.xml index 52d9ef846..6e147cf92 100644 --- a/Alkitab/src/main/res/layout/activity_devotion_content.xml +++ b/Alkitab/src/main/res/layout/activity_devotion_content.xml @@ -1,42 +1,35 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> - + android:layout_height="?attr/actionBarSize" + android:background="?attr/colorPrimary" /> - + - - - - - + + - - - \ No newline at end of file + + \ No newline at end of file diff --git a/Alkitab/src/main/res/layout/activity_song_view_content.xml b/Alkitab/src/main/res/layout/activity_song_view_content.xml index d2eae6a60..f8594b640 100644 --- a/Alkitab/src/main/res/layout/activity_song_view_content.xml +++ b/Alkitab/src/main/res/layout/activity_song_view_content.xml @@ -1,49 +1,42 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> - - - + android:layout_height="?attr/actionBarSize" + android:background="?attr/colorPrimary"> - + - + - + - + -