For #1249 - Create Empty History State

nightly-build-test
Emily Kager 5 years ago committed by Jeff Boek
parent a169019426
commit fd4de3509d

@ -62,6 +62,8 @@ private class HistoryList(val history: List<HistoryItem>) {
items.addAll(groups.adapterItemsForRange(Range.ThisWeek)) items.addAll(groups.adapterItemsForRange(Range.ThisWeek))
items.addAll(groups.adapterItemsForRange(Range.ThisMonth)) items.addAll(groups.adapterItemsForRange(Range.ThisMonth))
items.addAll(groups.adapterItemsForRange(Range.Older)) items.addAll(groups.adapterItemsForRange(Range.Older))
// No history only the delete button, so let's clear the list to show the empty text
if (items.size == 1) items.clear()
this.items = items this.items = items
} }

@ -7,17 +7,20 @@ package org.mozilla.fenix.library.history
import android.graphics.PorterDuff import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter import android.graphics.PorterDuffColorFilter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import android.widget.ImageButton import android.widget.ImageButton
import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.Observer import io.reactivex.Observer
import io.reactivex.functions.Consumer import io.reactivex.functions.Consumer
import kotlinx.android.synthetic.main.component_history.*
import kotlinx.android.synthetic.main.component_history.view.* import kotlinx.android.synthetic.main.component_history.view.*
import kotlinx.android.synthetic.main.delete_history_button.*
import mozilla.components.support.base.feature.BackHandler import mozilla.components.support.base.feature.BackHandler
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.asActivity import org.mozilla.fenix.ext.asActivity
@ -42,7 +45,7 @@ class HistoryUIView(
fun getSelected(): List<HistoryItem> = historyAdapter.selected fun getSelected(): List<HistoryItem> = historyAdapter.selected
override val view: LinearLayout = LayoutInflater.from(container.context) override val view: FrameLayout = LayoutInflater.from(container.context)
.inflate(R.layout.component_history, container, true) .inflate(R.layout.component_history, container, true)
.findViewById(R.id.history_wrapper) .findViewById(R.id.history_wrapper)
@ -63,7 +66,7 @@ class HistoryUIView(
items = it.items items = it.items
when (val modeCopy = mode) { when (val modeCopy = mode) {
is HistoryState.Mode.Normal -> setUIForNormalMode() is HistoryState.Mode.Normal -> setUIForNormalMode(items.isEmpty())
is HistoryState.Mode.Editing -> setUIForSelectingMode(modeCopy) is HistoryState.Mode.Editing -> setUIForSelectingMode(modeCopy)
} }
} }
@ -79,8 +82,10 @@ class HistoryUIView(
) )
} }
private fun setUIForNormalMode() { private fun setUIForNormalMode(isEmpty: Boolean) {
(activity as? AppCompatActivity)?.title = context.getString(R.string.library_history) (activity as? AppCompatActivity)?.title = context.getString(R.string.library_history)
delete_history_button?.visibility = if (isEmpty) View.GONE else View.VISIBLE
history_empty_view.visibility = if (isEmpty) View.VISIBLE else View.GONE
setToolbarColors( setToolbarColors(
R.attr.primaryText.getColorIntFromAttr(context!!), R.attr.primaryText.getColorIntFromAttr(context!!),
R.attr.foundation.getColorIntFromAttr(context) R.attr.foundation.getColorIntFromAttr(context)
@ -127,7 +132,7 @@ class HistoryUIView(
mode is HistoryState.Mode.Editing -> { mode is HistoryState.Mode.Editing -> {
mode = HistoryState.Mode.Normal mode = HistoryState.Mode.Normal
historyAdapter.updateData(items, mode) historyAdapter.updateData(items, mode)
setUIForNormalMode() setUIForNormalMode(items.isEmpty())
actionEmitter.onNext(HistoryAction.SwitchMode) actionEmitter.onNext(HistoryAction.SwitchMode)
true true
} }

@ -22,7 +22,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:text="@string/bookmarks_empty_message" android:text="@string/bookmarks_empty_message"
android:visibility="gone" android:textColor="?secondaryText"
android:textColor="?primaryText"/> android:textSize="16sp"
android:visibility="gone" />
</FrameLayout> </FrameLayout>

@ -3,14 +3,23 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<LinearLayout <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/history_wrapper" android:id="@+id/history_wrapper"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:orientation="vertical">
<TextView
android:id="@+id/history_empty_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/history_empty_message"
android:textColor="?secondaryText"
android:textSize="16sp"
android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/history_list" android:id="@+id/history_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</LinearLayout> </FrameLayout>

@ -315,6 +315,8 @@
<string name="history_this_month">This month</string> <string name="history_this_month">This month</string>
<!-- Text for the header that groups the history older than the last month --> <!-- Text for the header that groups the history older than the last month -->
<string name="history_older">Older</string> <string name="history_older">Older</string>
<!-- Text shown when no history exists -->
<string name="history_empty_message">No history here</string>
<!-- Crashes --> <!-- Crashes -->
<!-- Title text displayed on the tab crash page. This first parameter is the name of the application (For example: Fenix) --> <!-- Title text displayed on the tab crash page. This first parameter is the name of the application (For example: Fenix) -->

Loading…
Cancel
Save