Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5818e787 authored by Santiago Etchebehere's avatar Santiago Etchebehere
Browse files

Improve error handling when loading customizations

Add a loading indicator and an error message if there's
an issue retrieving content for any of the customization
tabs.

Bug: 133326909
Change-Id: I2da6309f5c2b369caffeec4e21c3aa856ddb4e4a
parent 9838514a
Loading
Loading
Loading
Loading
+76 −47
Original line number Original line Diff line number Diff line
@@ -23,7 +23,12 @@
    android:background="?android:colorPrimary">
    android:background="?android:colorPrimary">
    <include layout="@layout/section_header"/>
    <include layout="@layout/section_header"/>


    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.constraintlayout.widget.ConstraintLayout
        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/content_section"
            android:layout_width="match_parent"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            android:layout_height="match_parent">


@@ -31,7 +36,6 @@
                android:id="@+id/clock_preview_pager"
                android:id="@+id/clock_preview_pager"
                android:layout_width="match_parent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
                android:background="@color/secondary_color"
                android:background="@color/secondary_color"
                app:layout_constrainedHeight="true"
                app:layout_constrainedHeight="true"
                app:layout_constraintBottom_toTopOf="@id/options_container"
                app:layout_constraintBottom_toTopOf="@id/options_container"
@@ -60,6 +64,9 @@
                android:layout_width="match_parent"
                android:layout_width="match_parent"
                android:layout_height="@dimen/min_taptarget_height"
                android:layout_height="@dimen/min_taptarget_height"
                app:layout_constraintBottom_toTopOf="@id/apply_button"
                app:layout_constraintBottom_toTopOf="@id/apply_button"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHeight_min="@dimen/min_taptarget_height"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/options_container"
                app:layout_constraintTop_toBottomOf="@id/options_container"
                app:layout_constraintVertical_bias="1.0"/>
                app:layout_constraintVertical_bias="1.0"/>
@@ -75,8 +82,30 @@
                android:layout_weight="1"
                android:layout_weight="1"
                android:text="@string/apply_theme_btn"
                android:text="@string/apply_theme_btn"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintEnd_toEndOf="parent"/>
            app:layout_constraintTop_toBottomOf="@id/placeholder"/>

        </androidx.constraintlayout.widget.ConstraintLayout>
        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.core.widget.ContentLoadingProgressBar
            android:id="@+id/loading_indicator"
            style="@android:style/Widget.DeviceDefault.ProgressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="200dp"
            android:layout_gravity="center_horizontal|top"
            android:indeterminate="true"/>
        <FrameLayout
            android:id="@+id/error_section"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone">
            <TextView
                android:id="@+id/error_message"
                style="@style/HeaderTextAppearance"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="@string/something_went_wrong"/>
        </FrameLayout>
    </FrameLayout>
</LinearLayout>
</LinearLayout>
+75 −48
Original line number Original line Diff line number Diff line
@@ -23,7 +23,12 @@
    android:background="?android:colorPrimary">
    android:background="?android:colorPrimary">
    <include layout="@layout/section_header"/>
    <include layout="@layout/section_header"/>


    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.constraintlayout.widget.ConstraintLayout
        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/content_section"
            android:layout_width="match_parent"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            android:layout_height="match_parent">


@@ -31,7 +36,6 @@
                android:id="@+id/grid_preview_pager"
                android:id="@+id/grid_preview_pager"
                android:layout_width="match_parent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
                android:background="@color/secondary_color"
                android:background="@color/secondary_color"
                app:card_style="screen_aspect_ratio"
                app:card_style="screen_aspect_ratio"
                app:layout_constrainedHeight="true"
                app:layout_constrainedHeight="true"
@@ -76,8 +80,31 @@
                android:layout_weight="1"
                android:layout_weight="1"
                android:text="@string/apply_theme_btn"
                android:text="@string/apply_theme_btn"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintEnd_toEndOf="parent"/>
            app:layout_constraintTop_toBottomOf="@id/placeholder"/>


        </androidx.constraintlayout.widget.ConstraintLayout>
        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.core.widget.ContentLoadingProgressBar
            android:id="@+id/loading_indicator"
            style="@android:style/Widget.DeviceDefault.ProgressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="200dp"
            android:layout_gravity="center_horizontal|top"
            android:indeterminate="true"/>
        <FrameLayout
            android:id="@+id/error_section"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone">
            <TextView
                android:id="@+id/error_message"
                style="@style/HeaderTextAppearance"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="@string/something_went_wrong"/>
        </FrameLayout>
    </FrameLayout>
</LinearLayout>
</LinearLayout>
+81 −52
Original line number Original line Diff line number Diff line
@@ -23,7 +23,12 @@
    android:background="?android:colorPrimary">
    android:background="?android:colorPrimary">
    <include layout="@layout/section_header"/>
    <include layout="@layout/section_header"/>


    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.constraintlayout.widget.ConstraintLayout
        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/content_section"
            android:layout_width="match_parent"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            android:layout_height="match_parent">


@@ -83,6 +88,30 @@
                android:text="@string/apply_theme_btn"
                android:text="@string/apply_theme_btn"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"/>
                app:layout_constraintEnd_toEndOf="parent"/>

        </androidx.constraintlayout.widget.ConstraintLayout>
        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.core.widget.ContentLoadingProgressBar
            android:id="@+id/loading_indicator"
            style="@android:style/Widget.DeviceDefault.ProgressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="200dp"
            android:layout_gravity="center_horizontal|top"
            android:indeterminate="true"/>

        <FrameLayout
            android:id="@+id/error_section"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone">
            <TextView
                android:id="@+id/error_message"
                style="@style/HeaderTextAppearance"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="@string/something_went_wrong"/>
        </FrameLayout>
    </FrameLayout>
</LinearLayout>
</LinearLayout>
+3 −0
Original line number Original line Diff line number Diff line
@@ -187,4 +187,7 @@


    <!-- Content description for a screen showing the preview of a clock face. [CHAR_LIMIT=NONE] -->
    <!-- Content description for a screen showing the preview of a clock face. [CHAR_LIMIT=NONE] -->
    <string name="clock_preview_content_description"><xliff:g name="clock_name">%1$s</xliff:g> clock preview</string>
    <string name="clock_preview_content_description"><xliff:g name="clock_name">%1$s</xliff:g> clock preview</string>

    <!-- Generic error message [CHAR_LIMIT=NONE] -->
    <string name="something_went_wrong">Oops! Something went wrong.</string>
</resources>
</resources>
+12 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,9 @@
 */
 */
package com.android.customization.model;
package com.android.customization.model;


import android.util.Log;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.annotation.Nullable;


import java.util.List;
import java.util.List;
@@ -49,6 +52,15 @@ public interface CustomizationManager<T extends CustomizationOption> {
         * Called when the options have been retrieved.
         * Called when the options have been retrieved.
         */
         */
        void onOptionsLoaded(List<T> options);
        void onOptionsLoaded(List<T> options);

        /**
         * Called if there was an error loading grid options
         */
        default void onError(@Nullable Throwable throwable) {
            if (throwable != null) {
                Log.e("OptionsFecthedListener", "Error loading options", throwable);
            }
        }
    }
    }


    /**
    /**
Loading