Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Show the header when the history is empty #2148

Merged
merged 1 commit into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,13 @@ private void updateHistory() {
date.set(Calendar.SECOND, 0);
date.set(Calendar.MILLISECOND, 0);

long currentTime = System.currentTimeMillis();
long todayLimit = date.getTimeInMillis();
long yesterdayLimit = todayLimit - SystemUtils.ONE_DAY_MILLIS;
long oneWeekLimit = todayLimit - SystemUtils.ONE_WEEK_MILLIS;

SessionStore.get().getHistoryStore().getDetailedHistory().thenAcceptAsync((items) -> {
List<VisitInfo> orderedItems = items.stream()
.sorted(Comparator.comparing((VisitInfo mps) -> mps.getVisitTime())
.sorted(Comparator.comparing(VisitInfo::getVisitTime)
.reversed())
.collect(Collectors.toList());

Expand Down
58 changes: 28 additions & 30 deletions app/src/main/res/layout/bookmarks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,34 @@
android:paddingTop="30dp"
android:paddingBottom="30dp">

<include layout="@layout/bookmarks_narrow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="20dp"
app:isEmpty="@{isEmpty}"
app:isSignedIn="@{isSignedIn}"
app:isSyncEnabled="@{isSyncEnabled}"
app:lastSync="@{lastSync}"
app:isSyncing="@{isSyncing}"
app:isNarrow="@{isNarrow}"
app:callback="@{callback}"/>

<include layout="@layout/bookmarks_wide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="20dp"
app:isEmpty="@{isEmpty}"
app:isSignedIn="@{isSignedIn}"
app:isSyncEnabled="@{isSyncEnabled}"
app:lastSync="@{lastSync}"
app:isSyncing="@{isSyncing}"
app:isNarrow="@{isNarrow}"
app:callback="@{callback}"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down Expand Up @@ -101,36 +129,6 @@
android:visibility="gone"
app:visibleGone="@{isLoading}" />

<include layout="@layout/bookmarks_narrow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="20dp"
app:isLoading="@{isLoading}"
app:isEmpty="@{isEmpty}"
app:isSignedIn="@{isSignedIn}"
app:isSyncEnabled="@{isSyncEnabled}"
app:lastSync="@{lastSync}"
app:isSyncing="@{isSyncing}"
app:isNarrow="@{isNarrow}"
app:callback="@{callback}"/>

<include layout="@layout/bookmarks_wide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="20dp"
app:isLoading="@{isLoading}"
app:isEmpty="@{isEmpty}"
app:isSignedIn="@{isSignedIn}"
app:isSyncEnabled="@{isSyncEnabled}"
app:lastSync="@{lastSync}"
app:isSyncing="@{isSyncing}"
app:isNarrow="@{isNarrow}"
app:callback="@{callback}"/>

<org.mozilla.vrbrowser.ui.views.CustomRecyclerView
android:id="@+id/bookmarks_list"
style="@style/customRecyclerViewStyle"
Expand Down
7 changes: 1 addition & 6 deletions app/src/main/res/layout/bookmarks_narrow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<variable
name="isLoading"
type="boolean" />

<variable
name="isEmpty"
type="boolean" />
Expand Down Expand Up @@ -41,7 +36,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:visibleGone="@{isNarrow &amp;&amp; !isLoading &amp;&amp; !isEmpty}">
app:visibleGone="@{isNarrow}">

<RelativeLayout
android:layout_width="match_parent"
Expand Down
7 changes: 1 addition & 6 deletions app/src/main/res/layout/bookmarks_wide.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<variable
name="isLoading"
type="boolean" />

<variable
name="isEmpty"
type="boolean" />
Expand Down Expand Up @@ -40,7 +35,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:visibleGone="@{!isNarrow &amp;&amp; !isLoading &amp;&amp; !isEmpty}">
app:visibleGone="@{!isNarrow}">

<FrameLayout
android:id="@+id/buttons_layout"
Expand Down
66 changes: 32 additions & 34 deletions app/src/main/res/layout/history.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,38 @@
android:paddingTop="30dp"
android:paddingBottom="30dp">

<include
android:id="@+id/history_narrow"
layout="@layout/history_narrow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="20dp"
app:isEmpty="@{isEmpty}"
app:isSignedIn="@{isSignedIn}"
app:isSyncEnabled="@{isSyncEnabled}"
app:lastSync="@{lastSync}"
app:isSyncing="@{isSyncing}"
app:isNarrow="@{isNarrow}"
app:callback="@{callback}" />

<include
android:id="@+id/history_wide"
layout="@layout/history_wide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="20dp"
app:isEmpty="@{isEmpty}"
app:isSignedIn="@{isSignedIn}"
app:isSyncEnabled="@{isSyncEnabled}"
app:lastSync="@{lastSync}"
app:isSyncing="@{isSyncing}"
app:isNarrow="@{isNarrow}"
app:callback="@{callback}" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down Expand Up @@ -97,40 +129,6 @@
android:visibility="gone"
app:visibleGone="@{isLoading}" />

<include
android:id="@+id/history_narrow"
layout="@layout/history_narrow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="20dp"
app:isLoading="@{isLoading}"
app:isEmpty="@{isEmpty}"
app:isSignedIn="@{isSignedIn}"
app:isSyncEnabled="@{isSyncEnabled}"
app:lastSync="@{lastSync}"
app:isSyncing="@{isSyncing}"
app:isNarrow="@{isNarrow}"
app:callback="@{callback}" />

<include
android:id="@+id/history_wide"
layout="@layout/history_wide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="20dp"
app:isLoading="@{isLoading}"
app:isEmpty="@{isEmpty}"
app:isSignedIn="@{isSignedIn}"
app:isSyncEnabled="@{isSyncEnabled}"
app:lastSync="@{lastSync}"
app:isSyncing="@{isSyncing}"
app:isNarrow="@{isNarrow}"
app:callback="@{callback}" />

<org.mozilla.vrbrowser.ui.views.CustomRecyclerView
android:id="@+id/history_list"
style="@style/customRecyclerViewStyle"
Expand Down
10 changes: 3 additions & 7 deletions app/src/main/res/layout/history_narrow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<variable
name="isLoading"
type="boolean" />

<variable
name="isEmpty"
type="boolean" />
Expand Down Expand Up @@ -41,7 +36,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:visibleGone="@{isNarrow &amp;&amp; !isLoading &amp;&amp; !isEmpty}">
app:visibleGone="@{isNarrow}">

<RelativeLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -87,7 +82,8 @@
android:text="@string/history_clear"
android:textColor="@color/library_panel_button_text_color"
android:textSize="18sp"
android:textStyle="bold" />
android:textStyle="bold"
android:enabled="@{!isEmpty}"/>
</RelativeLayout>

<LinearLayout
Expand Down
10 changes: 3 additions & 7 deletions app/src/main/res/layout/history_wide.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<variable
name="isLoading"
type="boolean" />

<variable
name="isEmpty"
type="boolean" />
Expand Down Expand Up @@ -41,7 +36,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:visibleGone="@{!isNarrow &amp;&amp; !isLoading &amp;&amp; !isEmpty}">
app:visibleGone="@{!isNarrow}">

<RelativeLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -174,7 +169,8 @@
android:text="@string/history_clear"
android:textColor="@color/library_panel_button_text_color"
android:textSize="18sp"
android:textStyle="bold" />
android:textStyle="bold"
android:enabled="@{!isEmpty}"/>
</RelativeLayout>

</LinearLayout>
Expand Down