Update StatusBanner with MD3 colors

This commit is contained in:
Torsten Grote
2025-01-25 10:26:25 -03:00
parent 3906cad5fc
commit 7f71c38e97
9 changed files with 42 additions and 40 deletions

View File

@@ -9,7 +9,6 @@ import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import androidx.lifecycle.Observer;
@@ -66,11 +65,6 @@ public class StatusBanner extends androidx.appcompat.widget.AppCompatTextView {
public StatusBanner(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
int padding = (int) getResources().getDimension(R.dimen.banner__padding);
setPadding(padding, padding, padding, padding);
setBackgroundColor(0xFF4A4A4A);
setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
setTextColor(0xFFFFFFFF);
preferences = PreferenceManager.getDefaultSharedPreferences(context);
repoUpdateManager = FDroidApp.getRepoUpdateManager(context);
@@ -113,7 +107,7 @@ public class StatusBanner extends androidx.appcompat.widget.AppCompatTextView {
* device, and users are generally not aware of them.
*/
private void setBannerTextAndVisibility() {
if (isUpdatingRepos) {
if (isInEditMode() || isUpdatingRepos) {
setText(R.string.banner_updating_repositories);
setVisibility(View.VISIBLE);
} else if (networkState == ConnectivityMonitorService.FLAG_NET_UNAVAILABLE
@@ -135,7 +129,7 @@ public class StatusBanner extends androidx.appcompat.widget.AppCompatTextView {
break; // only check the first segment NOPMD
}
}
if (localRepos.size() == 0 || !hasLocalNonSystemRepos) {
if (localRepos.isEmpty() || !hasLocalNonSystemRepos) {
setText(R.string.banner_no_data_or_wifi);
setVisibility(View.VISIBLE);
} else {

View File

@@ -2,14 +2,14 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_to_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/swipe_to_refresh">
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
@@ -17,46 +17,48 @@
<org.fdroid.fdroid.views.StatusBanner
android:id="@+id/banner_updating_repos"
style="@style/StatusBanner"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/banner_updating_repositories" />
<TextView
android:id="@+id/empty_state"
style="@style/AppListEmptyText"
android:layout_width="0dp"
android:layout_height="0dp"
style="@style/AppListEmptyText"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:text="@string/categories__empty_state__no_categories"
android:visibility="gone"
android:text="@string/categories__empty_state__no_categories" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/category_list"
android:layout_width="0dp"
android:layout_height="0dp"
tools:listitem="@layout/category_item"
app:layout_constraintTop_toBottomOf="@+id/banner_updating_repos"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:scrollbars="vertical"
tools:layout_editor_absoluteX="0dp" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/banner_updating_repos"
tools:layout_editor_absoluteX="0dp"
tools:listitem="@layout/category_item" />
<include
layout="@layout/fab_search"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginBottom="@dimen/fab_margin"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/fab_margin"
android:layout_marginRight="@dimen/fab_margin" />
android:layout_marginRight="@dimen/fab_margin"
android:layout_marginBottom="@dimen/fab_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@@ -16,9 +16,9 @@
android:orientation="vertical">
<org.fdroid.fdroid.views.StatusBanner
style="@style/StatusBanner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:background="#cdcdcd" />
android:layout_height="wrap_content" />
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/progress_bar"

View File

@@ -18,6 +18,7 @@
<org.fdroid.fdroid.views.StatusBanner
android:id="@+id/banner_updating_repos"
style="@style/StatusBanner"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"

View File

@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?appDetailsCardBackground">
android:background="?colorSurfaceBright">
<!-- Ignore ContentDescription because it is kind of meaningless to have TTS read out "App icon"
when it will inevitably read out the name of the app straight after. -->
@@ -105,4 +105,4 @@
app:layout_constraintBottom_toBottomOf="parent"
tools:text="Update" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -4,7 +4,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?appDetailsCardBackground">
android:background="?colorSurfaceBright">
<TextView
android:id="@+id/text_updates_available"
@@ -60,4 +60,4 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_apps_to_update" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -19,7 +19,6 @@
<!--Top level DayNight theme to be used in AndroidManifest.xml-->
<style name="Theme.App" parent="Base.Theme.App">
<item name="appDetailsBackground">?android:windowBackground</item>
<item name="appDetailsCardBackground">#424242</item>
<item name="categoryPreviewAppCardBackground">
@drawable/category_preview_app_card_background_dark
</item>

View File

@@ -143,4 +143,11 @@
<style name="Widget.App.Preference.DialogPreference.EditTextPreference" parent="Preference.DialogPreference.EditTextPreference.Material">
<item name="android:dialogLayout">@layout/preference_edit_text</item>
</style>
<style name="StatusBanner" parent="Widget.Material3.CardView.Elevated">
<item name="android:padding">@dimen/banner__padding</item>
<item name="android:gravity">center</item>
<item name="android:background">?colorSurfaceBright</item>
<item name="android:textColor">?colorOnSurface</item>
</style>
</resources>

View File

@@ -37,7 +37,6 @@
<!--and menus. colorError is used to indicate an error state for components such as-->
<!--text fields.-->
<item name="appDetailsBackground">#fcfcfc</item>
<item name="appDetailsCardBackground">#ffffff</item>
<item name="categoryPreviewAppCardBackground">
@drawable/category_preview_app_card_background_light
</item>