Commit e9ab1c0b authored by ianwen's avatar ianwen Committed by Commit bot

[Android] Implement empty view for download manager ui

When there is no download item available, there should be a View telling
the user that the list is empty. Currently the download manger ui only
shows a blank screen if there are no items. This CL fixes this.

BUG=616324

Review-Url: https://codereview.chromium.org/2270233003
Cr-Commit-Position: refs/heads/master@{#414321}
parent 0ed4e89d
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="60dp"
android:height="60dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:pathData="M19,9h-4V3H9v6H5l7,7 7,-7zM5,18v2h14v-2H5z"
android:fillColor="#5A5A5A"/>
</vector>
......@@ -28,34 +28,6 @@
android:dividerHeight="0dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical" >
<org.chromium.chrome.browser.download.ui.DownloadManagerToolbar
android:id="@id/action_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/appbar_background" >
<include layout="@layout/number_roll_view" />
</org.chromium.chrome.browser.download.ui.DownloadManagerToolbar>
<org.chromium.chrome.browser.widget.FadingShadowView
android:id="@+id/shadow"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginBottom="-10dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<include layout="@layout/download_content" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical" >
<org.chromium.chrome.browser.download.ui.DownloadManagerToolbar
android:id="@+id/action_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/appbar_background"
android:layout_alignParentTop="true" >
<include layout="@layout/number_roll_view" />
</org.chromium.chrome.browser.download.ui.DownloadManagerToolbar>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@id/action_bar" />
<org.chromium.chrome.browser.widget.FadingShadowView
android:id="@+id/shadow"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_below="@id/action_bar" />
<LinearLayout
android:id="@+id/empty_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:gravity="center"
android:visibility="gone" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
app:srcCompat="@drawable/downloads_big" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/download_manager_ui_empty"
android:textColor="#5B5B5B"
android:textSize="16sp" />
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
......@@ -9,36 +9,7 @@
android:layout_height="match_parent" >
<!-- MAIN CONTENT -->
<LinearLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical" >
<org.chromium.chrome.browser.download.ui.DownloadManagerToolbar
android:id="@id/action_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/appbar_background" >
<include layout="@layout/number_roll_view" />
</org.chromium.chrome.browser.download.ui.DownloadManagerToolbar>
<org.chromium.chrome.browser.widget.FadingShadowView
android:id="@+id/shadow"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginBottom="-10dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<include layout="@layout/download_content" />
<!-- NAVIGATION DRAWER
We can't assign a paddingStart or paddingEnd because the section highlights are full-bleed.
......
......@@ -14,6 +14,7 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.DrawerLayout.DrawerListener;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.AdapterDataObserver;
import android.support.v7.widget.Toolbar.OnMenuItemClickListener;
import android.text.TextUtils;
import android.view.Gravity;
......@@ -115,10 +116,24 @@ public class DownloadManagerUi implements OnMenuItemClickListener {
private final SpaceDisplay mSpaceDisplay;
private final ListView mFilterView;
private final RecyclerView mRecyclerView;
private final View mEmptyView;
private BasicNativePage mNativePage;
private final AtomicInteger mNumberOfFilesBeingDeleted = new AtomicInteger();
private final AdapterDataObserver mAdapterObserver = new AdapterDataObserver() {
@Override
public void onChanged() {
if (mHistoryAdapter.getItemCount() == 0) {
mEmptyView.setVisibility(View.VISIBLE);
mRecyclerView.setVisibility(View.GONE);
} else {
mEmptyView.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);
}
}
};
public DownloadManagerUi(
Activity activity, boolean isOffTheRecord, ComponentName parentComponent) {
mActivity = activity;
......@@ -131,6 +146,9 @@ public class DownloadManagerUi implements OnMenuItemClickListener {
mHistoryAdapter = new DownloadHistoryAdapter(isOffTheRecord, parentComponent);
mHistoryAdapter.initialize(mBackendProvider);
addObserver(mHistoryAdapter);
mHistoryAdapter.registerAdapterDataObserver(mAdapterObserver);
mEmptyView = mMainView.findViewById(R.id.empty_view);
mSpaceDisplay = new SpaceDisplay(mMainView, mHistoryAdapter);
mHistoryAdapter.registerAdapterDataObserver(mSpaceDisplay);
......@@ -190,6 +208,7 @@ public class DownloadManagerUi implements OnMenuItemClickListener {
mBackendProvider.getOfflinePageBridge().destroy();
mHistoryAdapter.unregisterAdapterDataObserver(mAdapterObserver);
mHistoryAdapter.unregisterAdapterDataObserver(mSpaceDisplay);
}
......
......@@ -1801,6 +1801,9 @@ To obtain new licenses, connect to the internet and play your downloaded content
<message name="IDS_DOWNLOAD_MANAGER_UI_DELETED" desc="Indicates that a downloaded file has been deleted.">
Deleted
</message>
<message name="IDS_DOWNLOAD_MANAGER_UI_EMPTY" desc="Indicates that there are no downloaded items.">
No downloads here
</message>
<!-- Document mode messages -->
<message name="IDS_CLOSE_ALL_INCOGNITO_NOTIFICATION" desc="Message on the notification that closes all incognito tabs in document mode">
......
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