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

Fixes home screen banner issue #1027

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -18,6 +18,8 @@
package org.kiwix.kiwixmobile.main;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.net.Uri;
import android.util.Log;
import android.view.LayoutInflater;
Expand All @@ -26,6 +28,11 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import androidx.appcompat.widget.AppCompatButton;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import butterknife.BindView;
import butterknife.ButterKnife;
import java.util.HashMap;
import org.kiwix.kiwixmobile.BuildConfig;
import org.kiwix.kiwixmobile.KiwixApplication;
Expand All @@ -45,6 +52,14 @@ public class KiwixWebViewClient extends WebViewClient {
new SharedPreferenceUtil(KiwixApplication.getInstance());
private final WebViewCallback callback;
private View home;
@BindView(R.id.content_side_image)
ImageView sideImage;
@BindView(R.id.content_main_card_image)
ImageView cardImage;
@BindView(R.id.constraint_main)
ConstraintLayout constraintLayout;
@BindView(R.id.content_main_card_download_button)
AppCompatButton downloadButton;

KiwixWebViewClient(WebViewCallback callback) {
this.callback = callback;
Expand Down Expand Up @@ -108,9 +123,17 @@ private void inflateHomeView(WebView view) {
LayoutInflater inflater = LayoutInflater.from(view.getContext());
home = inflater.inflate(R.layout.content_main, view, false);
callback.setHomePage(home);
ButterKnife.bind(this, home);

if (sharedPreferenceUtil.nightMode()) {
ImageView cardImage = home.findViewById(R.id.content_main_card_image);
cardImage.setImageResource(R.drawable.ic_home_kiwix_banner_night);
constraintLayout.setBackgroundResource(R.drawable.back_cover_night);
sideImage.setImageResource(R.drawable.home_side_cover_night);
cardImage.setImageResource(R.drawable.kiwix_logo_night);
downloadButton.setTextColor(Color.parseColor("#000000"));
downloadButton.getBackground()
.setColorFilter(
ContextCompat.getColor(downloadButton.getContext(), R.color.complement_blue800),
PorterDuff.Mode.MULTIPLY);
}
view.removeAllViews();
view.addView(home);
Expand Down
Expand Up @@ -1393,6 +1393,9 @@ void backToTop() {
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
toggleActionItemsConfig();
if (getCurrentWebView().getUrl().equalsIgnoreCase(HOME_URL)) {
showHomePage();
}
}

private void toggleActionItemsConfig() {
Expand Down
Binary file added app/src/main/res/drawable-hdpi/back_cover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/back_cover_night.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added app/src/main/res/drawable-hdpi/kiwix_logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added app/src/main/res/drawable-mdpi/kiwix_logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Binary file added app/src/main/res/drawable-xhdpi/kiwix_logo.png
Diff not rendered.
Diff not rendered.
Binary file added app/src/main/res/drawable-xxhdpi/kiwix_logo.png
Diff not rendered.
Diff not rendered.
Binary file added app/src/main/res/drawable-xxxhdpi/kiwix_logo.png
19 changes: 16 additions & 3 deletions app/src/main/res/layout/content_main.xml
Expand Up @@ -20,19 +20,32 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/constraint_main"
android:background="@drawable/back_cover"
>

<ImageView
android:id="@+id/content_main_card_image"
android:layout_width="0dp"
android:layout_height="144dp"
android:contentDescription="@string/kiwi"
android:scaleType="fitXY"
android:src="@drawable/ic_home_kiwix_banner"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:src="@drawable/kiwix_logo"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toStartOf="@id/content_main_card_download_button"
/>

<ImageView
android:id="@+id/content_side_image"
android:layout_width="0dp"
android:layout_height="144dp"
android:contentDescription="@null"
android:scaleType="fitEnd"
android:src="@drawable/home_side_cover"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>

<androidx.appcompat.widget.AppCompatButton
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Expand Up @@ -26,5 +26,6 @@
<color name="blue800">#1565c0</color>
<color name="blueTransparent">#962e7ac4</color>
<color name="actionModeBackground">#4285F4</color>
<color name="complement_blue800">#c06f15</color>
<color name="titleBar">#000000</color>
</resources>