Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstefan-niedermann <info@niedermann.it>2019-12-12 19:52:56 +0300
committerNiedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com>2019-12-12 19:54:19 +0300
commit6bb1e1cd4bc517b03acef51ba509d927ee233225 (patch)
tree1b9f17dbd8b56e15421dc17d66a05dd73a736bec /app/src/main
parent93f2af2a7e8fe56e7d220e04f831e2302d28cbda (diff)
#224 Make reusable component for empty content views
Default value handling
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/helper/emptycontentview/EmptyContentView.java17
-rw-r--r--app/src/main/res/layout/activity_main.xml1
-rw-r--r--app/src/main/res/layout/fragment_stack.xml1
-rw-r--r--app/src/main/res/layout/widget_empty_content_view.xml12
-rw-r--r--app/src/main/res/values/strings.xml1
5 files changed, 21 insertions, 11 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/helper/emptycontentview/EmptyContentView.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/helper/emptycontentview/EmptyContentView.java
index 8c98d359f..8b03545e1 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/helper/emptycontentview/EmptyContentView.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/helper/emptycontentview/EmptyContentView.java
@@ -4,11 +4,13 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
+import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
+import androidx.annotation.StringRes;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -16,6 +18,8 @@ import it.niedermann.nextcloud.deck.R;
public class EmptyContentView extends RelativeLayout {
+ private static final int NO_DESCRIPTION = -1;
+
@BindView(R.id.title)
TextView title;
@BindView(R.id.description)
@@ -34,9 +38,16 @@ public class EmptyContentView extends RelativeLayout {
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.EmptyContentView, 0, 0);
- title.setText(getResources().getString(a.getResourceId(R.styleable.EmptyContentView_title, R.string.app_name_short)));
- description.setText(getResources().getString(a.getResourceId(R.styleable.EmptyContentView_description, R.string.app_name)));
- image.setImageDrawable(getResources().getDrawable(a.getResourceId(R.styleable.EmptyContentView_image, R.drawable.ic_launcher_foreground)));
+
+ @StringRes int descriptionRes = a.getResourceId(R.styleable.EmptyContentView_description, NO_DESCRIPTION);
+
+ title.setText(getResources().getString(a.getResourceId(R.styleable.EmptyContentView_title, R.string.no_content)));
+ if (descriptionRes == NO_DESCRIPTION) {
+ description.setVisibility(View.GONE);
+ } else {
+ description.setText(getResources().getString(descriptionRes));
+ }
+ image.setImageDrawable(getResources().getDrawable(a.getResourceId(R.styleable.EmptyContentView_image, R.drawable.ic_app_logo)));
a.recycle();
}
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 66b2e5fd0..5cb12593d 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -24,7 +24,6 @@
android:layout_height="match_parent"
android:visibility="gone"
app:description="@string/add_a_new_column_using_the_three_dots_menu"
- app:image="@drawable/ic_app_logo"
app:title="@string/no_columns"
tools:visibility="visible" />
diff --git a/app/src/main/res/layout/fragment_stack.xml b/app/src/main/res/layout/fragment_stack.xml
index 022487281..93544cb09 100644
--- a/app/src/main/res/layout/fragment_stack.xml
+++ b/app/src/main/res/layout/fragment_stack.xml
@@ -12,7 +12,6 @@
android:layout_height="match_parent"
android:visibility="gone"
app:description="@string/add_a_new_card_using_the_button"
- app:image="@drawable/ic_app_logo"
app:title="@string/no_cards" />
<androidx.recyclerview.widget.RecyclerView
diff --git a/app/src/main/res/layout/widget_empty_content_view.xml b/app/src/main/res/layout/widget_empty_content_view.xml
index 54142cab8..9c88c9b9e 100644
--- a/app/src/main/res/layout/widget_empty_content_view.xml
+++ b/app/src/main/res/layout/widget_empty_content_view.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:hint="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -14,7 +14,7 @@
android:layout_gravity="center"
android:contentDescription="@null"
android:tint="@color/fg_secondary"
- app:srcCompat="@drawable/ic_app_logo" />
+ hint:src="@drawable/ic_app_logo" />
<TextView
android:id="@+id/title"
@@ -24,9 +24,9 @@
android:gravity="center"
android:paddingTop="16dp"
android:paddingBottom="16dp"
- android:text="@string/app_name_short"
android:textAlignment="center"
- android:textSize="@dimen/empty_content_font_size" />
+ android:textSize="@dimen/empty_content_font_size"
+ hint:text="@string/app_name_short" />
<TextView
android:id="@+id/description"
@@ -38,6 +38,6 @@
android:paddingLeft="@dimen/standard_padding"
android:paddingEnd="@dimen/standard_padding"
android:paddingRight="@dimen/standard_padding"
- android:text="@string/app_name"
- android:textAlignment="center" />
+ android:textAlignment="center"
+ hint:text="@string/app_name" />
</RelativeLayout> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 07c2e4bc0..4e4fd8693 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -147,4 +147,5 @@
<string name="simple_comment">Comment</string>
<string name="attachment_delete_message">This will permanently delete this attachment.</string>
<string name="delete_attachment">Delete %1$s</string>
+ <string name="no_content">No content yet</string>
</resources>