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

Merge 24.4 final to trunk #20485

Merged
merged 10 commits into from
Mar 15, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import android.view.MenuItem
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import androidx.core.view.isGone
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
Expand Down Expand Up @@ -312,14 +315,14 @@ class StatsListFragment : ViewPagerFragment(R.layout.stats_list_fragment) {
updateInsights(it.data)
}
is Error, null -> {
recyclerView.visibility = View.GONE
errorView.statsErrorView.visibility = View.VISIBLE
emptyView.statsEmptyView.visibility = View.GONE
recyclerView.isGone = true
emptyView.statsEmptyView.isGone = true
errorView.statsErrorView.isVisible = true
}
is Empty -> {
recyclerView.visibility = View.GONE
emptyView.statsEmptyView.visibility = View.VISIBLE
errorView.statsErrorView.visibility = View.GONE
recyclerView.isInvisible = true
errorView.statsErrorView.isGone = true
emptyView.statsEmptyView.isVisible = true
emptyView.statsEmptyView.title.setText(it.title)
if (it.subtitle != null) {
emptyView.statsEmptyView.subtitle.setText(it.subtitle)
Expand All @@ -337,10 +340,6 @@ class StatsListFragment : ViewPagerFragment(R.layout.stats_list_fragment) {
}

private fun StatsListFragmentBinding.updateInsights(statsState: List<StatsBlock>) {
recyclerView.visibility = View.VISIBLE
errorView.statsErrorView.visibility = View.GONE
emptyView.statsEmptyView.visibility = View.GONE

val adapter: StatsBlockAdapter
if (recyclerView.adapter == null) {
adapter = StatsBlockAdapter(imageManager, statsTrafficTabFeatureConfig.isEnabled())
Expand All @@ -353,6 +352,11 @@ class StatsListFragment : ViewPagerFragment(R.layout.stats_list_fragment) {
val recyclerViewState = layoutManager?.onSaveInstanceState()
adapter.update(statsState)
recyclerView.scrollToPosition(0)

errorView.statsErrorView.isGone = true
emptyView.statsEmptyView.isGone = true
recyclerView.isVisible = true

layoutManager?.onRestoreInstanceState(recyclerViewState)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.wordpress.android.ui.stats.refresh.utils

import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import org.wordpress.android.R
import org.wordpress.android.databinding.StatsListFragmentBinding
import org.wordpress.android.ui.stats.refresh.StatsViewModel.DateSelectorUiModel

Expand All @@ -28,7 +30,17 @@ fun StatsListFragmentBinding.drawDateSelector(dateSelectorUiModel: DateSelectorU
nextDateButton.isEnabled = enableNextButton
}
granularitySpinner.isVisible = dateSelectorUiModel?.isGranularitySpinnerVisible == true
granularitySpace.isVisible = dateSelectorUiModel?.isGranularitySpinnerVisible == true
dateSpace.isVisible = dateSelectorUiModel?.isGranularitySpinnerVisible != true

if (dateSelectorUiModel?.isGranularitySpinnerVisible != true) {
// StatsTrafficTabFeatureConfig is disabled.
with(selectedDateTextView.layoutParams as ConstraintLayout.LayoutParams) {
horizontalBias = 0f
marginStart = selectedDateTextView.resources.getDimensionPixelSize(R.dimen.margin_small)
}
with(currentSiteTimeZone.layoutParams as ConstraintLayout.LayoutParams) {
horizontalBias = 0f
marginStart = selectedDateTextView.resources.getDimensionPixelSize(R.dimen.margin_small)
}
}
}
}
97 changes: 49 additions & 48 deletions WordPress/src/main/res/layout/stats_date_selector.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/date_selector_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="52dp"
android:orientation="horizontal"
android:paddingEnd="@dimen/margin_extra_large"
android:paddingStart="@dimen/margin_large"
android:paddingVertical="@dimen/margin_extra_small"
tools:ignore="RtlSymmetry">

Expand All @@ -18,62 +17,64 @@
android:layout_height="wrap_content"
android:minHeight="@dimen/min_touch_target_sz"
android:overlapAnchor="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:popupTheme="@style/ThemeOverlay.AppCompat.DayNight" />

<Space
android:id="@+id/granularity_space"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />

<LinearLayout
<ImageButton
android:id="@+id/nextDateButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">

<org.wordpress.android.widgets.MaterialTextViewWithNumerals
android:id="@+id/selectedDateTextView"
style="@style/StatsDateSelectorTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/unknown" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/currentSiteTimeZone"
style="@style/StatsDateTimeZone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/unknown"
android:visibility="gone" />
</LinearLayout>

<Space
android:id="@+id/date_space"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
android:visibility="gone" />
android:layout_height="@dimen/min_touch_target_sz"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/stats_select_next_period_description"
android:src="@drawable/ic_chevron_right_white_24dp"
android:tintMode="src_in"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/on_surface_disabled_selector" />

<ImageButton
android:id="@+id/previousDateButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/margin_medium"
android:layout_height="@dimen/min_touch_target_sz"
android:layout_marginEnd="@dimen/margin_large"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/stats_select_previous_period_description"
android:src="@drawable/ic_chevron_left_white_24dp"
android:tintMode="src_in"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/nextDateButton"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/on_surface_disabled_selector" />

<ImageButton
android:id="@+id/nextDateButton"
<org.wordpress.android.widgets.MaterialTextViewWithNumerals
android:id="@+id/selectedDateTextView"
style="@style/StatsDateSelectorTitle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/margin_medium"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/stats_select_next_period_description"
android:src="@drawable/ic_chevron_right_white_24dp"
android:tintMode="src_in"
app:tint="@color/on_surface_disabled_selector" />
</LinearLayout>
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/margin_medium"
android:text="@string/unknown"
app:layout_constraintBottom_toTopOf="@id/currentSiteTimeZone"
app:layout_constraintEnd_toStartOf="@id/previousDateButton"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toEndOf="@id/granularity_spinner"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth="wrap_content_constrained" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/currentSiteTimeZone"
style="@style/StatsDateTimeZone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/margin_medium"
android:text="@string/unknown"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/previousDateButton"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toEndOf="@id/granularity_spinner"
app:layout_constraintTop_toBottomOf="@id/selectedDateTextView"
app:layout_constraintWidth="wrap_content_constrained" />
</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
Translation-Revision-Date: 2024-03-11 15:54:08+0000
Plural-Forms: nplurals=6; plural=(n == 0) ? 0 : ((n == 1) ? 1 : ((n == 2) ? 2 : ((n % 100 >= 3 && n % 100 <= 10) ? 3 : ((n % 100 >= 11 && n % 100 <= 99) ? 4 : 5))));
Generator: GlotPress/4.0.0-rc.1
Generator: GlotPress/4.0.0
Language: ar
-->
<resources>
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values-az/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
Translation-Revision-Date: 2015-12-08 01:00:08+0000
Plural-Forms: nplurals=2; plural=n != 1;
Generator: GlotPress/4.0.0-rc.1
Generator: GlotPress/4.0.0
Language: az
-->
<resources>
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
Translation-Revision-Date: 2018-12-10 19:56:03+0000
Plural-Forms: nplurals=2; plural=n != 1;
Generator: GlotPress/4.0.0-rc.1
Generator: GlotPress/4.0.0
Language: bg
-->
<resources>
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
Translation-Revision-Date: 2024-02-29 12:55:08+0000
Plural-Forms: nplurals=3; plural=(n == 1) ? 0 : ((n >= 2 && n <= 4) ? 1 : 2);
Generator: GlotPress/4.0.0-rc.1
Generator: GlotPress/4.0.0
Language: cs_CZ
-->
<resources>
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values-cy/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
Translation-Revision-Date: 2017-03-25 17:35:05+0000
Plural-Forms: nplurals=4; plural=(n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3;
Generator: GlotPress/4.0.0-rc.1
Generator: GlotPress/4.0.0
Language: cy_GB
-->
<resources>
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
Translation-Revision-Date: 2021-08-01 11:11:29+0000
Plural-Forms: nplurals=2; plural=n != 1;
Generator: GlotPress/4.0.0-rc.1
Generator: GlotPress/4.0.0
Language: da_DK
-->
<resources>
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
Translation-Revision-Date: 2024-03-04 22:42:31+0000
Plural-Forms: nplurals=2; plural=n != 1;
Generator: GlotPress/4.0.0-rc.1
Generator: GlotPress/4.0.0
Language: de
-->
<resources>
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
Translation-Revision-Date: 2023-06-13 08:27:23+0000
Plural-Forms: nplurals=2; plural=n != 1;
Generator: GlotPress/4.0.0-rc.1
Generator: GlotPress/4.0.0
Language: el_GR
-->
<resources>
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values-en-rCA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
Translation-Revision-Date: 2024-03-10 17:22:35+0000
Plural-Forms: nplurals=2; plural=n != 1;
Generator: GlotPress/4.0.0-rc.1
Generator: GlotPress/4.0.0
Language: en_CA
-->
<resources>
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values-en-rGB/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
Translation-Revision-Date: 2024-03-04 22:08:04+0000
Plural-Forms: nplurals=2; plural=n != 1;
Generator: GlotPress/4.0.0-rc.1
Generator: GlotPress/4.0.0
Language: en_GB
-->
<resources>
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values-es-rCL/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
Translation-Revision-Date: 2020-05-09 06:46:56+0000
Plural-Forms: nplurals=2; plural=n != 1;
Generator: GlotPress/4.0.0-rc.1
Generator: GlotPress/4.0.0
Language: es_CL
-->
<resources>
Expand Down
Loading
Loading