mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
apply app/system theme to WebView (#1972)
This commit is contained in:
committed by
GitHub
parent
623976424e
commit
4dce3734ff
@@ -28,6 +28,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.webkit:webkit:1.4.0'
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.2.0'
|
||||
|
||||
@@ -15,6 +15,8 @@ import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.webkit.WebSettingsCompat;
|
||||
import androidx.webkit.WebViewFeature;
|
||||
|
||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
@@ -41,6 +43,10 @@ public class WebViewActivity extends PassphraseRequiredActionBarActivity
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
webView = findViewById(R.id.webview);
|
||||
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
|
||||
WebSettingsCompat.setForceDark(webView.getSettings(),
|
||||
DynamicTheme.isDarkTheme(this) ? WebSettingsCompat.FORCE_DARK_ON : WebSettingsCompat.FORCE_DARK_OFF);
|
||||
}
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
// `shouldOverrideUrlLoading()` is called when the user clicks a URL,
|
||||
// returning `true` means, the URL is passed to `loadUrl()`, `false` aborts loading.
|
||||
|
||||
Reference in New Issue
Block a user