Commit 13b7c02c authored by Christophe Henry's avatar Christophe Henry

Add hint text when a subscription section is empty + solves #28

parent a58c00dd
......@@ -64,7 +64,9 @@ class FreshRSSApplication: Application() {
val database get() = FreshRSSDabatabase.instance
fun getStringR(id: Int) = application.resources.getString(id)
fun getStringR(id: Int, vararg formatArgs: Any = arrayOf()) = if(formatArgs.isEmpty())
application.resources.getString(id) else
application.resources.getString(id, *formatArgs)
}
inner class RefresherServiceConnection: ServiceConnection {
......
......@@ -2,14 +2,14 @@ package fr.chenry.android.freshrss.components.subscriptions
import android.os.Bundle
import android.view.*
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.navigation.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import fr.chenry.android.freshrss.MainNavDirections
import fr.chenry.android.freshrss.R
import fr.chenry.android.freshrss.*
import fr.chenry.android.freshrss.components.subscriptions.SubscriptionSection.*
import fr.chenry.android.freshrss.store.Store
import fr.chenry.android.freshrss.store.database.models.*
......@@ -44,6 +44,16 @@ class SubscriptionsFragment: Fragment(), Observer<Subscriptions> {
it.adapter = this.adapter
}
when(subscriptionSection) {
ALL -> FreshRSSApplication.getStringR(R.string.empty_subscription_list_all)
UNREAD -> FreshRSSApplication.getStringR(R.string.empty_subscription_list_unread)
FAVORITES -> FreshRSSApplication.getStringR(R.string.empty_subscription_list_favorites)
}.let {
view
.findViewById<TextView>(R.id.fragment_subscriptions_empty_list)
.text = FreshRSSApplication.getStringR(R.string.empty_subscription_list, it)
}
return view
}
......@@ -63,9 +73,15 @@ class SubscriptionsFragment: Fragment(), Observer<Subscriptions> {
}
private fun toggleProgressCircle() {
subscriptions_list.visibility =
if(subscriptions.isEmpty() && Store.refreshingPromise.value != null)View.GONE else View.VISIBLE
fragment_subscriptions_waiting.visibility = if(subscriptions.isNotEmpty()) View.GONE else View.VISIBLE
if(Store.refreshingPromise.value == null) {
subscriptions_list.visibility = if(subscriptions.isNotEmpty()) View.VISIBLE else View.GONE
fragment_subscriptions_empty_list.visibility = if(subscriptions.isEmpty()) View.VISIBLE else View.GONE
fragment_subscriptions_waiting.visibility = View.GONE
} else {
subscriptions_list.visibility = if(subscriptions.isNotEmpty()) View.VISIBLE else View.GONE
fragment_subscriptions_waiting.visibility = if(subscriptions.isEmpty()) View.VISIBLE else View.GONE
fragment_subscriptions_empty_list.visibility = View.GONE
}
}
companion object {
......
......@@ -26,4 +26,15 @@
class="fr.chenry.android.freshrss.components.waiting.WaitingFragment"
android:layout_margin="0dp" />
</LinearLayout>
<TextView
android:id="@+id/fragment_subscriptions_empty_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/empty_subscription_list"
android:visibility="gone"
android:gravity="center|center_horizontal|center_vertical"
android:layout_gravity="center"
android:textColor="@color/light_grey"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
\ No newline at end of file
......@@ -4,6 +4,7 @@
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="black">#000</color>
<color name="grey">#666</color>
<color name="grey">#666666</color>
<color name="error">#A00</color>
<color name="light_grey">#9E9E9E</color>
</resources>
......@@ -45,7 +45,11 @@
<string name="notification_refresh_title">Refreshing your RSS feeds</string>
<string name="notification_refresh_description">FreshRSS is fetching your content from the server</string>
<string name="notification_refresh_failed_title">Refreshing failed</string>
<string name="notification_refresh_failed_description">FresshRSS failed to retrieve content from your FreshRSS server</string>
<string name="notification_refresh_failed_description">FreshRSS failed to retrieve content from your FreshRSS server</string>
<string name="notification_channel_refresh_title">Refresh events</string>
<string name="notification_channel_refresh_description">Events occuring when trying to fetch content from your FreshRSS server</string>
<string name="notification_channel_refresh_description">Events occurring when trying to fetch content from your FreshRSS server</string>
<string name="empty_subscription_list">You have no %s yet</string>
<string name="empty_subscription_list_favorites">favorites</string>
<string name="empty_subscription_list_all">subscriptions</string>
<string name="empty_subscription_list_unread">unread articles</string>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment