mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
enhance(android): adjust soft input mode and set navigation bar color based on theme
This commit is contained in:
@@ -21,8 +21,6 @@ dependencies {
|
||||
implementation project(':capacitor-share')
|
||||
implementation project(':capacitor-splash-screen')
|
||||
implementation project(':capacitor-status-bar')
|
||||
implementation project(':capawesome-capacitor-background-task')
|
||||
implementation project(':capgo-capacitor-navigation-bar')
|
||||
implementation project(':capacitor-voice-recorder')
|
||||
implementation project(':send-intent')
|
||||
implementation project(':jcesarmobile-ssl-skip')
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
android:name="com.logseq.app.MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation"
|
||||
android:exported="true"
|
||||
android:windowSoftInputMode="adjustNothing"
|
||||
android:label="@string/title_activity_main"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/AppTheme.NoActionBarLaunch">
|
||||
|
||||
@@ -47,14 +47,6 @@
|
||||
"pkg": "@capacitor/status-bar",
|
||||
"classpath": "com.capacitorjs.plugins.statusbar.StatusBarPlugin"
|
||||
},
|
||||
{
|
||||
"pkg": "@capawesome/capacitor-background-task",
|
||||
"classpath": "io.capawesome.capacitorjs.plugins.backgroundtask.BackgroundTaskPlugin"
|
||||
},
|
||||
{
|
||||
"pkg": "@capgo/capacitor-navigation-bar",
|
||||
"classpath": "ee.forgr.capacitor_navigation_bar.NavigationBarPlugin"
|
||||
},
|
||||
{
|
||||
"pkg": "capacitor-voice-recorder",
|
||||
"classpath": "com.tchvu3.capacitorvoicerecorder.VoiceRecorder"
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.logseq.app;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebView;
|
||||
|
||||
@@ -23,6 +26,8 @@ public class MainActivity extends BridgeActivity {
|
||||
webView.getSettings().setUseWideViewPort(true);
|
||||
webView.getSettings().setLoadWithOverviewMode(true);
|
||||
|
||||
setNavigationBarColorBasedOnTheme();
|
||||
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -57,4 +62,22 @@ public class MainActivity extends BridgeActivity {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void setNavigationBarColorBasedOnTheme() {
|
||||
Window window = getWindow();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // API 26及以上支持
|
||||
// 根据主题选择颜色
|
||||
int navBarColor = isDarkMode()
|
||||
? getResources().getColor(R.color.colorPrimaryDark, getTheme())
|
||||
: getResources().getColor(R.color.colorPrimary, getTheme());
|
||||
|
||||
// 设置导航栏颜色
|
||||
window.setNavigationBarColor(navBarColor);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDarkMode() {
|
||||
int nightModeFlags = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
return nightModeFlags == Configuration.UI_MODE_NIGHT_YES;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,12 +38,6 @@ project(':capacitor-splash-screen').projectDir = new File('../node_modules/@capa
|
||||
include ':capacitor-status-bar'
|
||||
project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacitor/status-bar/android')
|
||||
|
||||
include ':capawesome-capacitor-background-task'
|
||||
project(':capawesome-capacitor-background-task').projectDir = new File('../node_modules/@capawesome/capacitor-background-task/android')
|
||||
|
||||
include ':capgo-capacitor-navigation-bar'
|
||||
project(':capgo-capacitor-navigation-bar').projectDir = new File('../node_modules/@capgo/capacitor-navigation-bar/android')
|
||||
|
||||
include ':capacitor-voice-recorder'
|
||||
project(':capacitor-voice-recorder').projectDir = new File('../node_modules/capacitor-voice-recorder/android')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user