Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Dark Theme start #3332

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind'

implementation 'org.slf4j:slf4j-api:2.0.9'
implementation "androidx.core:core-splashscreen:1.0.1"

// Http client
implementation "com.squareup.okhttp3:okhttp:4.11.0"
Expand Down
33 changes: 7 additions & 26 deletions app/src/main/java/com/alphawallet/app/web3/Web3View.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;

import com.alphawallet.app.BuildConfig;
import com.alphawallet.app.entity.TransactionReturn;
Expand Down Expand Up @@ -200,22 +202,11 @@ public void init()
innerOnEthCallListener,
innerAddChainListener,
innerOnWalletActionListener), "alpha");

// Removing this block for now.
// TODO: Figure out if we should support dark mode for external websites
// if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK))
// {
// switch (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK)
// {
// case Configuration.UI_MODE_NIGHT_YES:
// WebSettingsCompat.setForceDark(getSettings(), FORCE_DARK_ON);
// break;
// case Configuration.UI_MODE_NIGHT_NO:
// case Configuration.UI_MODE_NIGHT_UNDEFINED:
// WebSettingsCompat.setForceDark(getSettings(), FORCE_DARK_OFF);
// break;
// }
// }

if (WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING))
{
WebSettingsCompat.setAlgorithmicDarkeningAllowed(getSettings(), true);
}
}

@Nullable
Expand Down Expand Up @@ -391,15 +382,5 @@ public void onReceivedError(WebView view, WebResourceRequest request, WebResourc
if (externalClient != null)
externalClient.onReceivedError(view, request, error);
}

@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
{
redirect = true;

return externalClient.shouldOverrideUrlLoading(view, request)
|| internalClient.shouldOverrideUrlLoading(view, request);
}
}
}
24 changes: 24 additions & 0 deletions app/src/main/res/drawable-night/ic_aw.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="240"
android:viewportHeight="240">
<path
android:pathData="M146.75,117.74C146.75,122.21 143.13,125.85 138.69,125.85C134.24,125.85 130.65,122.21 130.65,117.74C130.65,113.26 134.26,109.63 138.69,109.63C143.15,109.63 146.75,113.26 146.75,117.74Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M154.12,113.71C154.02,113.86 153.92,114.02 153.84,114.16C153.92,114.02 154.02,113.88 154.12,113.71Z"
android:fillColor="#81BA28"/>
<path
android:pathData="M154.12,113.71C154.02,113.86 153.92,114.02 153.84,114.16C153.92,114.02 154.02,113.88 154.12,113.71Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M173.35,83.27C172.23,85.06 157.18,108.89 155.72,111.16C155.4,111.69 155.05,112.2 154.75,112.71C154.55,113.04 154.32,113.36 154.12,113.69C152.56,107.58 147.48,102.88 141.19,101.88C141.47,101.43 150.3,87.37 152.54,83.8C152.78,83.39 153.02,83.08 153.57,83.08C160.07,83.1 166.54,83.1 173.04,83.1C173.1,83.14 173.16,83.2 173.35,83.27Z"
android:fillColor="#3268FF"/>
<path
android:pathData="M177.1,152.31C173.85,156.19 170.2,158.93 165.55,160.04C159.15,161.55 153.08,160.85 147.62,156.89C143.66,154.01 141.25,149.96 139.48,145.47C139.42,145.32 139.36,145.18 139.3,145C139.28,144.96 139.28,144.91 139.26,144.87C138.81,143.67 138.02,141.48 137.25,139.13C136.62,137.21 136.01,135.17 135.6,133.43C136.62,133.63 137.65,133.74 138.73,133.74C143.46,133.74 147.7,131.65 150.61,128.36L150.65,128.32C151.72,131 152.84,135.19 153.9,138.44V138.46C154.18,139.36 154.46,140.17 154.75,140.87C155.93,143.81 157.16,146.71 159.52,148.9C159.68,149.04 159.85,149.18 160.01,149.33C163.07,151.88 166.75,152.56 170.59,152.68C172.66,152.78 174.73,152.49 177.1,152.31Z"
android:fillColor="#0019FF"/>
<path
android:pathData="M125.23,126.28C121.45,131.59 117.37,136.64 112.56,141.11C108.5,144.89 104.17,148.27 98.97,150.31C96.98,151.09 94.93,151.51 92.78,151.49C86.73,151.51 82.39,147.69 81.09,141.32C79.95,135.66 80.52,130.06 82.1,124.6C85.03,114.49 90.16,105.54 96.98,97.59C100.07,93.99 103.62,90.91 108.25,89.42C111.52,88.37 114.81,88.07 118.02,89.72C120.48,90.99 122.2,93.05 123.56,95.4C125.51,98.75 126.73,102.37 127.76,106.07C130.61,103.35 134.46,101.7 138.69,101.7C139.54,101.7 140.35,101.76 141.16,101.88C141.23,101.8 141.57,101.25 142.12,100.37C141.39,98.69 140.78,97.16 140.09,95.67C137.92,91.03 134.97,87.03 130.71,84.12C125.67,80.71 120.05,79.61 114.02,80.12C106.32,80.77 99.16,83.02 92.62,87.09C82.2,93.56 74.02,102.23 68.3,113.12C64.62,120.09 62.51,127.5 63.1,135.49C63.85,145.79 69.01,153.17 78.18,157.66C85.33,161.18 92.92,161.49 100.62,160.53C107.01,159.73 113.04,157.62 118.61,154.38C125.35,150.45 131.2,145.32 136.66,139.74C136.84,139.54 136.96,139.25 137.23,139.13C136.6,137.21 135.99,135.17 135.58,133.43C131.24,132.57 127.52,129.94 125.23,126.28Z"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning ⚠️  
📚 Very long vector path (1042 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector.
🛠️ VectorPath

by Android Lint 🤖

android:fillColor="#0019FF"/>
</vector>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/ic_aw.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector android:height="200dp" android:viewportHeight="240"
android:viewportWidth="240" android:width="200dp" xmlns:android="http://schemas.android.com/apk/res/android">
<group>
<clip-path android:pathData="M63,80h114v81h-114z"/>
<path android:fillColor="#000000" android:pathData="M146.75,117.74C146.75,122.22 143.14,125.85 138.69,125.85C134.24,125.85 130.65,122.22 130.65,117.74C130.65,113.27 134.26,109.63 138.69,109.63C143.16,109.63 146.75,113.27 146.75,117.74Z"/>
<path android:fillColor="#ffffff" android:pathData="M154.12,113.72C154.02,113.86 153.92,114.02 153.84,114.17C153.92,114.02 154.02,113.88 154.12,113.72Z"/>
<path android:fillColor="#3268FF" android:pathData="M173.35,83.27C172.23,85.07 157.19,108.89 155.73,111.16C155.4,111.69 155.06,112.2 154.75,112.71C154.55,113.04 154.32,113.37 154.12,113.69C152.56,107.59 147.48,102.89 141.19,101.89C141.47,101.43 150.3,87.38 152.54,83.8C152.78,83.39 153.03,83.09 153.57,83.09C160.07,83.11 166.55,83.11 173.04,83.11C173.11,83.15 173.17,83.21 173.35,83.27Z"/>
<path android:fillColor="#0019FF" android:pathData="M177.11,152.32C173.86,156.2 170.2,158.94 165.55,160.04C159.16,161.55 153.09,160.86 147.63,156.89C143.67,154.01 141.25,149.97 139.48,145.47C139.42,145.33 139.36,145.18 139.3,145C139.28,144.96 139.28,144.92 139.26,144.88C138.81,143.67 138.02,141.49 137.25,139.14C136.62,137.21 136.01,135.17 135.6,133.43C136.62,133.64 137.66,133.74 138.73,133.74C143.46,133.74 147.71,131.66 150.61,128.37L150.65,128.33C151.73,131 152.84,135.19 153.9,138.44V138.46C154.18,139.36 154.47,140.18 154.75,140.87C155.93,143.82 157.17,146.72 159.52,148.9C159.68,149.05 159.85,149.19 160.01,149.33C163.08,151.89 166.75,152.56 170.59,152.68C172.66,152.79 174.73,152.5 177.11,152.32Z"/>
<path android:fillColor="#0019FF" android:pathData="M125.23,126.28C121.45,131.6 117.37,136.64 112.56,141.12C108.5,144.9 104.18,148.27 98.98,150.31C96.99,151.09 94.94,151.52 92.78,151.5C86.73,151.52 82.39,147.7 81.09,141.32C79.95,135.66 80.52,130.06 82.1,124.61C85.03,114.49 90.17,105.54 96.99,97.59C100.07,94 103.63,90.91 108.26,89.42C111.53,88.38 114.81,88.07 118.02,89.73C120.48,90.99 122.2,93.06 123.57,95.41C125.51,98.76 126.73,102.38 127.77,106.07C130.61,103.36 134.47,101.7 138.69,101.7C139.54,101.7 140.36,101.76 141.17,101.89C141.23,101.8 141.57,101.25 142.12,100.37C141.39,98.7 140.78,97.16 140.09,95.67C137.92,91.03 134.98,87.03 130.71,84.13C125.68,80.72 120.05,79.61 114.02,80.12C106.33,80.78 99.16,83.02 92.62,87.09C82.21,93.57 74.02,102.23 68.3,113.12C64.62,120.09 62.51,127.51 63.1,135.5C63.85,145.8 69.01,153.17 78.19,157.67C85.33,161.18 92.93,161.49 100.62,160.53C107.02,159.73 113.05,157.63 118.61,154.38C125.35,150.46 131.2,145.33 136.66,139.75C136.84,139.54 136.96,139.26 137.23,139.14C136.6,137.21 135.99,135.17 135.58,133.43C131.24,132.58 127.52,129.94 125.23,126.28Z"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning ⚠️  
📚 Very long vector path (1036 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector.
🛠️ VectorPath

by Android Lint 🤖

</group>
</vector>
Binary file removed app/src/main/res/mipmap-hdpi/ic_alpha.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-mdpi/ic_alpha.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_alpha.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xxhdpi/ic_alpha.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xxxhdpi/ic_alpha.png
Binary file not shown.
7 changes: 7 additions & 0 deletions app/src/main/res/values-v31/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme.NoActionBar.Splash">
<item name="android:windowSplashScreenBackground">?android:colorBackground</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_aw</item>
</style>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values-v33/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme.NoActionBar.Splash">
<item name="android:windowSplashScreenBackground">?android:colorBackground</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_aw</item>
</style>
</resources>
Loading