Skip to content

Commit

Permalink
Merge pull request #107 from yukuku/revert-106-develop
Browse files Browse the repository at this point in the history
Revert "Add option to follow system theme & implement dark mode everywhere"
  • Loading branch information
yukuku authored Jul 1, 2024
2 parents 8d8c4f2 + 2bb97dc commit f1c743c
Show file tree
Hide file tree
Showing 52 changed files with 234 additions and 496 deletions.
10 changes: 3 additions & 7 deletions Alkitab/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

<activity
android:name="yuku.alkitab.base.IsiActivity"
android:configChanges="colorMode|uiMode"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -249,8 +248,7 @@
android:windowSoftInputMode="adjustResize" />
<activity
android:name="yuku.alkitab.base.ac.DevotionActivity"
android:label="@string/menuDevotion"
android:configChanges="colorMode|uiMode">
android:label="@string/menuDevotion">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="yuku.alkitab.base.IsiActivity" />
Expand All @@ -277,8 +275,7 @@
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name="yuku.alkitab.songs.SongViewActivity"
android:label="@string/sn_songs_activity_title"
android:configChanges="colorMode|uiMode" />
android:label="@string/sn_songs_activity_title" />
<activity
android:name="yuku.alkitab.base.ac.SecretSettingsActivity"
android:label="Secret settings" />
Expand All @@ -288,8 +285,7 @@
<activity android:name="yuku.alkitab.base.ac.ReadingPlanActivity" />
<activity
android:name="yuku.alkitab.base.ac.PatchTextActivity"
android:windowSoftInputMode="adjustResize"
android:configChanges="colorMode|uiMode" />
android:windowSoftInputMode="adjustResize" />
<activity
android:name="yuku.alkitab.base.sync.SyncSettingsActivity"
android:label="@string/sync_status_activity_title" />
Expand Down
5 changes: 0 additions & 5 deletions Alkitab/src/main/assets/templates/song.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@

body {
margin: 0;
padding: 24px 16px;
}

.code {
font-family: sans-serif;
font-weight: bold;
Expand Down
8 changes: 4 additions & 4 deletions Alkitab/src/main/assets/templates/song.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
</script>
</head>

<body onload="body_load()">
<body onload="body_load()" style="padding: 16px 8px">
<div class='song'>
{{div:code}}
{{div:title}}
Expand Down
76 changes: 67 additions & 9 deletions Alkitab/src/main/java/yuku/alkitab/base/IsiActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion Alkitab/src/main/java/yuku/alkitab/base/S.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ object S {
return null // not known
}

@JvmStatic
fun recalculateAppliedValuesBasedOnPreferences() {
CalculatedDimensionsHolder.applied = calculateDimensionsFromPreferences()
}
Expand Down
41 changes: 12 additions & 29 deletions Alkitab/src/main/java/yuku/alkitab/base/ac/DevotionActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -223,7 +210,6 @@ public int getPrefetchDays() {
DrawerLayout drawerLayout;
LeftDrawer.Devotion leftDrawer;

FrameLayout overlayContainer;
TwofingerLinearLayout root;
TextView lContent;
NestedScrollView scrollContent;
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
17 changes: 0 additions & 17 deletions Alkitab/src/main/java/yuku/alkitab/base/ac/PatchTextActivity.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
Loading

0 comments on commit f1c743c

Please sign in to comment.