Commit bdf153cf authored by shaktisahu's avatar shaktisahu Committed by Commit bot

Download Home : Remove drawer UI

Removed navigation drawer from the download home. The drawer was replaced
by a spinner. Space display moved in-page as a header in the download
history adapter.

BUG=712912

Review-Url: https://codereview.chromium.org/2834453007
Cr-Commit-Position: refs/heads/master@{#467752}
parent 9ff35446
<?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. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/drawer_layout"
android:layout_width="256dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:orientation="vertical"
android:background="@android:color/white"
android:clickable="true" >
<include layout="@layout/download_manager_ui_space_widget" />
<ListView
android:id="@+id/section_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:divider="@null"
android:dividerHeight="0dp" />
</LinearLayout>
<org.chromium.chrome.browser.widget.selection.SelectableListLayout
android:id="@+id/selectable_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" />
</LinearLayout>
\ No newline at end of file
......@@ -3,39 +3,9 @@
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<android.support.v4.widget.DrawerLayout
<org.chromium.chrome.browser.widget.selection.SelectableListLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/selectable_list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- MAIN CONTENT -->
<org.chromium.chrome.browser.widget.selection.SelectableListLayout
android:id="@+id/selectable_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/default_primary_color" />
<!-- NAVIGATION DRAWER
We can't assign a paddingStart or paddingEnd because the section highlights are full-bleed.
-->
<LinearLayout
android:id="@+id/drawer_layout"
android:layout_width="@dimen/drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:orientation="vertical"
android:background="@android:color/white"
android:clickable="true" >
<include layout="@layout/download_manager_ui_space_widget"/>
<ListView
android:id="@+id/section_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:divider="@null"
android:dividerHeight="0dp" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
android:layout_height="match_parent"
android:background="@color/default_primary_color"/>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 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. -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@color/black_alpha_87" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 The Chromium Authors. All rights reserved.
<!-- Copyright 2017 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. -->
<!-- Represents a single filter in the drawer. See DownloadManagerUi#FilterAdapter. -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:minWidth="176dp"
android:minHeight="48dp"
android:drawablePadding="@dimen/drawer_drawable_padding"
android:paddingStart="@dimen/drawer_margin_large"
android:paddingEnd="@dimen/drawer_margin_large"
android:textColor="@color/default_text_color"
android:gravity="center_vertical" />
\ No newline at end of file
android:paddingStart="16dp"
android:textSize="16sp"
android:textColor="@color/black_alpha_87" />
......@@ -3,56 +3,51 @@
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:chrome="http://schemas.android.com/apk/res-auto" >
<!-- Widget style adapted from the UX spec:
https://bugs.chromium.org/p/chromium/issues/detail?id=658246&desc=2#c18
-->
<LinearLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:chrome="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/downloads_item_margin"
android:paddingEnd="14dp"
android:paddingTop="26dp"
android:paddingBottom="6dp"
android:orientation="vertical" >
<TextView
android:id="@+id/size_downloaded"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/drawer_margin_large"
android:layout_marginEnd="@dimen/drawer_margin_large"
android:paddingTop="26dp"
android:paddingBottom="24dp"
android:orientation="vertical" >
<TextView
android:id="@+id/size_downloaded"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/light_active_color"
android:textSize="20sp" />
<!-- The progress bar uses 32dp of space, vertically, including spacing. -->
<org.chromium.chrome.browser.widget.MaterialProgressBar
android:id="@+id/space_bar"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_marginTop="14dp"
android:layout_marginBottom="14dp"
chrome:colorBackground="@color/google_grey_400"
chrome:colorProgress="@color/light_active_color"
chrome:colorSecondaryProgress="@color/google_grey_600" />
<TextView
android:id="@+id/size_other_apps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/google_grey_600"
android:textSize="12sp" />
<TextView
android:id="@+id/size_free"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/google_grey_400"
android:textSize="12sp" />
android:singleLine="true"
android:textColor="@color/google_blue_500"
android:textSize="16sp"
android:textStyle="bold" />
<!-- The progress bar uses 20dp of space, vertically, including spacing. -->
<org.chromium.chrome.browser.widget.MaterialProgressBar
android:id="@+id/space_bar"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
chrome:colorBackground="@color/black_alpha_38"
chrome:colorProgress="@color/google_blue_500"
chrome:colorSecondaryProgress="@color/black_alpha_87" />
<TextView
android:id="@+id/size_other_apps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/black_alpha_87"
android:textSize="14sp" />
</LinearLayout>
<TextView
android:id="@+id/size_free"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/black_alpha_54"
android:textSize="14sp" />
</merge>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
......@@ -31,12 +31,17 @@
<color name="toolbar_shadow_color">#1d000000</color>
<color name="white_alpha_50">#80ffffff</color>
<color name="white_alpha_70">#B3FFFFFF</color>
<color name="black_alpha_30">#4d000000</color>
<color name="black_alpha_40">#66000000</color>
<color name="toolbar_light_tint">#A3000000</color>
<color name="light_grey">#ccc</color>
<color name="modal_dialog_scrim_color">#7f000000</color>
<!-- New list of common text colors -->
<color name="black_alpha_30">#4d000000</color>
<color name="black_alpha_38">#61000000</color>
<color name="black_alpha_40">#66000000</color>
<color name="black_alpha_54">#8a000000</color>
<color name="black_alpha_87">#de000000</color>
<!-- Infobar colors -->
<color name="infobar_accent_blue">#4285f4</color>
<color name="infobar_descriptive_text_color">#646464</color>
......
......@@ -43,7 +43,7 @@ public class DownloadPage extends BasicNativePage {
mManager = new DownloadManagerUi(activity, host.isIncognito(), activity.getComponentName(),
false, ((SnackbarManageable) activity).getSnackbarManager());
mManager.setBasicNativePage(this);
mTitle = activity.getString(R.string.download_manager_ui_all_downloads);
mTitle = activity.getString(R.string.menu_downloads);
// #destroy() unregisters the ActivityStateListener to avoid checking for externally removed
// downloads after the downloads page is closed. This requires each DownloadPage to have its
......
......@@ -155,6 +155,7 @@ public class DownloadHistoryAdapter extends DateDividedAdapter
private OfflinePageDownloadBridge.Observer mOfflinePageObserver;
private int mFilter = DownloadFilter.FILTER_ALL;
private String mSearchQuery = EMPTY_QUERY;
private SpaceDisplay mSpaceDisplay;
DownloadHistoryAdapter(boolean showOffTheRecord, ComponentName parentComponent) {
mShowOffTheRecord = showOffTheRecord;
......@@ -328,6 +329,17 @@ public class DownloadHistoryAdapter extends DateDividedAdapter
return new DownloadItemGroup(timeStamp);
}
@Override
protected BasicViewHolder createHeader(ViewGroup parent) {
if (mSpaceDisplay == null) {
mSpaceDisplay = new SpaceDisplay(parent, this);
registerAdapterDataObserver(mSpaceDisplay);
}
mSpaceDisplay.onChanged();
return new BasicViewHolder(mSpaceDisplay.getView());
}
/** Called when a new DownloadItem has been created by the native DownloadManager. */
public void onDownloadItemCreated(DownloadItem item) {
boolean isOffTheRecord = item.getDownloadInfo().isOffTheRecord();
......@@ -420,6 +432,7 @@ public class DownloadHistoryAdapter extends DateDividedAdapter
getDownloadDelegate().removeDownloadHistoryAdapter(this);
getOfflinePageBridge().removeObserver(mOfflinePageObserver);
sDeletedFileTracker.decrementInstanceCount();
if (mSpaceDisplay != null) unregisterAdapterDataObserver(mSpaceDisplay);
}
@Override
......@@ -510,6 +523,7 @@ public class DownloadHistoryAdapter extends DateDividedAdapter
}
clear(false);
if (!filteredTimedItems.isEmpty()) addHeader();
loadItems(filteredTimedItems);
}
......@@ -696,4 +710,9 @@ public class DownloadHistoryAdapter extends DateDividedAdapter
RecordHistogram.recordCountHistogram("Android.DownloadManager.InitialCount.Total",
mRegularDownloadItems.size() + mOfflinePageItems.size());
}
/** Returns the {@link SpaceDisplay}. */
public SpaceDisplay getSpaceDisplayForTests() {
return mSpaceDisplay;
}
}
......@@ -5,9 +5,12 @@
package org.chromium.chrome.browser.download.ui;
import android.content.Context;
import android.support.v7.widget.AppCompatSpinner;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Spinner;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.ui.DownloadManagerUi.DownloadUiObserver;
......@@ -20,13 +23,24 @@ import java.util.List;
*/
public class DownloadManagerToolbar extends SelectableListToolbar<DownloadHistoryItemWrapper>
implements DownloadUiObserver {
private int mFilter = DownloadFilter.FILTER_ALL;
private Spinner mSpinner;
public DownloadManagerToolbar(Context context, AttributeSet attrs) {
super(context, attrs);
inflateMenu(R.menu.download_manager_menu);
}
/**
* Initializes the spinner for the download filter.
* @param adapter The adapter associated with the spinner.
*/
public void initializeFilterSpinner(FilterAdapter adapter) {
mSpinner = new AppCompatSpinner(this.getContext());
mSpinner.setAdapter(adapter);
mSpinner.setOnItemSelectedListener(adapter);
addView(mSpinner);
}
/**
* Removes the close button from the toolbar.
*/
......@@ -36,8 +50,7 @@ public class DownloadManagerToolbar extends SelectableListToolbar<DownloadHistor
@Override
public void onFilterChanged(int filter) {
mFilter = filter;
if (!mIsSelectionEnabled) updateTitle();
mSpinner.setSelection(filter);
}
@Override
......@@ -45,9 +58,8 @@ public class DownloadManagerToolbar extends SelectableListToolbar<DownloadHistor
boolean wasSelectionEnabled = mIsSelectionEnabled;
super.onSelectionStateChange(selectedItems);
if (!mIsSelectionEnabled) {
updateTitle();
} else {
mSpinner.setVisibility((mIsSelectionEnabled || mIsSearching) ? GONE : VISIBLE);
if (mIsSelectionEnabled) {
int numSelected = mSelectionDelegate.getSelectedItems().size();
// If the share or delete menu items are shown in the overflow menu instead of as an
......@@ -75,17 +87,21 @@ public class DownloadManagerToolbar extends SelectableListToolbar<DownloadHistor
@Override
public void onManagerDestroyed() { }
@Override
public void showSearchView() {
super.showSearchView();
mSpinner.setVisibility(GONE);
}
@Override
public void hideSearchView() {
super.hideSearchView();
updateTitle();
mSpinner.setVisibility(VISIBLE);
}
private void updateTitle() {
if (mFilter == DownloadFilter.FILTER_ALL) {
setTitle(R.string.menu_downloads);
} else {
setTitle(DownloadFilter.getStringIdForFilter(mFilter));
}
/** Returns the {@link Spinner}. */
@VisibleForTesting
public Spinner getSpinnerForTests() {
return mSpinner;
}
}
......@@ -10,17 +10,11 @@ import android.content.Intent;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.DrawerLayout.DrawerListener;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar.OnMenuItemClickListener;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import org.chromium.base.ContextUtils;
import org.chromium.base.FileUtils;
......@@ -41,7 +35,6 @@ import org.chromium.chrome.browser.widget.selection.SelectableListLayout;
import org.chromium.chrome.browser.widget.selection.SelectableListToolbar;
import org.chromium.chrome.browser.widget.selection.SelectableListToolbar.SearchDelegate;
import org.chromium.chrome.browser.widget.selection.SelectionDelegate;
import org.chromium.ui.base.DeviceFormFactor;
import java.io.File;
import java.util.ArrayList;
......@@ -168,8 +161,6 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegat
private final BackendProvider mBackendProvider;
private final SnackbarManager mSnackbarManager;
private final SpaceDisplay mSpaceDisplay;
private final ListView mFilterView;
private final UndoDeletionSnackbarController mUndoDeletionSnackbarController;
private final RecyclerView mRecyclerView;
......@@ -200,12 +191,6 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegat
mMainView = (ViewGroup) LayoutInflater.from(activity).inflate(R.layout.download_main, null);
DrawerLayout drawerLayout = null;
if (!DeviceFormFactor.isLargeTablet(activity)) {
drawerLayout = (DrawerLayout) mMainView;
addDrawerListener(drawerLayout);
}
mSelectableListLayout = (SelectableListLayout<DownloadHistoryItemWrapper>)
mMainView.findViewById(R.id.selectable_list);
......@@ -223,26 +208,17 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegat
mHistoryAdapter.initialize(mBackendProvider);
addObserver(mHistoryAdapter);
mSpaceDisplay = new SpaceDisplay(mMainView, mHistoryAdapter);
mHistoryAdapter.registerAdapterDataObserver(mSpaceDisplay);
mSpaceDisplay.onChanged();
mFilterAdapter = new FilterAdapter();
mFilterAdapter.initialize(this);
addObserver(mFilterAdapter);
mToolbar = (DownloadManagerToolbar) mSelectableListLayout.initializeToolbar(
R.layout.download_manager_toolbar, mBackendProvider.getSelectionDelegate(),
0, drawerLayout, R.id.normal_menu_group, R.id.selection_mode_menu_group, null, true,
this);
mToolbar.setTitle(R.string.menu_downloads);
R.layout.download_manager_toolbar, mBackendProvider.getSelectionDelegate(), 0, null,
R.id.normal_menu_group, R.id.selection_mode_menu_group, null, true, this);
mToolbar.initializeFilterSpinner(mFilterAdapter);
mToolbar.initializeSearchView(this, R.string.download_manager_search, R.id.search_menu_id);
addObserver(mToolbar);
mFilterView = (ListView) mMainView.findViewById(R.id.section_list);
mFilterView.setAdapter(mFilterAdapter);
mFilterView.setOnItemClickListener(mFilterAdapter);
mUndoDeletionSnackbarController = new UndoDeletionSnackbarController();
mIsSeparateActivity = isSeparateActivity;
......@@ -269,8 +245,6 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegat
mBackendProvider.destroy();
mHistoryAdapter.unregisterAdapterDataObserver(mSpaceDisplay);
mSelectableListLayout.onDestroyed();
}
......@@ -280,13 +254,6 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegat
* @return Whether the back button was handled.
*/
public boolean onBackPressed() {
if (mMainView instanceof DrawerLayout) {
DrawerLayout drawerLayout = (DrawerLayout) mMainView;
if (drawerLayout.isDrawerOpen(Gravity.START)) {
closeDrawer();
return true;
}
}
if (mBackendProvider.getSelectionDelegate().isSelectionEnabled()) {
mBackendProvider.getSelectionDelegate().clearSelection();
return true;
......@@ -343,16 +310,6 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegat
return false;
}
/**
* @see DrawerLayout#openDrawer(int)
*/
@VisibleForTesting
public void openDrawer() {
if (mMainView instanceof DrawerLayout) {
((DrawerLayout) mMainView).openDrawer(GravityCompat.START);
}
}
/**
* Adds a {@link DownloadUiObserver} to observe the changes in the download manager.
*/
......@@ -368,15 +325,6 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegat
mObservers.removeObserver(observer);
}
/**
* @see DrawerLayout#closeDrawer(int)
*/
void closeDrawer() {
if (mMainView instanceof DrawerLayout) {
((DrawerLayout) mMainView).closeDrawer(GravityCompat.START);
}
}
/**
* @return The activity that holds the download UI.
*/
......@@ -488,27 +436,6 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegat
return itemsToRemove;
}
private void addDrawerListener(DrawerLayout drawer) {
drawer.addDrawerListener(new DrawerListener() {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
}
@Override
public void onDrawerOpened(View drawerView) {
RecordUserAction.record("Android.DownloadManager.OpenDrawer");
}
@Override
public void onDrawerClosed(View drawerView) {
}
@Override
public void onDrawerStateChanged(int newState) {
}
});
}
private void dismissUndoDeletionSnackbars() {
mSnackbarManager.dismissSnackbars(mUndoDeletionSnackbarController);
}
......@@ -530,11 +457,6 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegat
return mHistoryAdapter;
}
/** Returns the {@link SpaceDisplay}. */
public SpaceDisplay getSpaceDisplayForTests() {
return mSpaceDisplay;
}
/** Sets a BackendProvider that is used in place of a real one. */
@VisibleForTesting
public static void setProviderForTests(BackendProvider provider) {
......
......@@ -4,8 +4,7 @@
package org.chromium.chrome.browser.download.ui;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.support.annotation.LayoutRes;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -13,18 +12,13 @@ import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.ui.DownloadManagerUi.DownloadUiObserver;
import org.chromium.chrome.browser.widget.TintedDrawable;
/** An adapter that allows selecting an item from a list displayed in the drawer. */
class FilterAdapter extends BaseAdapter
implements AdapterView.OnItemClickListener, DownloadUiObserver {
private int mSelectedBackgroundColor;
/** An adapter that allows selecting an item from a dropdown spinner. */
class FilterAdapter
extends BaseAdapter implements AdapterView.OnItemSelectedListener, DownloadUiObserver {
private DownloadManagerUi mManagerUi;
private int mSelectedIndex;
@Override
public int getCount() {
......@@ -41,63 +35,52 @@ class FilterAdapter extends BaseAdapter
return position;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
TextView labelView =
getTextViewFromResource(convertView, R.layout.download_manager_spinner_drop_down);
labelView.setText(DownloadFilter.getStringIdForFilter(position));
return labelView;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Resources resources = mManagerUi.getActivity().getResources();
TextView labelView =
getTextViewFromResource(convertView, R.layout.download_manager_spinner);
labelView.setText(position == 0 ? R.string.menu_downloads
: DownloadFilter.getStringIdForFilter(position));
return labelView;
}
private TextView getTextViewFromResource(View convertView, @LayoutRes int resId) {
TextView labelView = null;
if (convertView instanceof TextView) {
labelView = (TextView) convertView;
} else {
labelView = (TextView) LayoutInflater.from(mManagerUi.getActivity()).inflate(
R.layout.download_manager_ui_drawer_filter, null);
labelView =
(TextView) LayoutInflater.from(mManagerUi.getActivity()).inflate(resId, null);
}
int iconId = DownloadFilter.getDrawableForFilter(position);
labelView.setText(DownloadFilter.getStringIdForFilter(position));
Drawable iconDrawable = null;
if (position == mSelectedIndex) {
// Highlight the selected item by changing the foreground and background colors.
labelView.setBackgroundColor(mSelectedBackgroundColor);
iconDrawable = TintedDrawable.constructTintedDrawable(
resources, iconId, R.color.light_active_color);
labelView.setTextColor(
ApiCompatibilityUtils.getColor(resources, R.color.light_active_color));
} else {
// Draw the item normally.
labelView.setBackground(null);
iconDrawable = TintedDrawable.constructTintedDrawable(
resources, iconId, R.color.descriptive_text_color);
labelView.setTextColor(
ApiCompatibilityUtils.getColor(resources, R.color.default_text_color));
}
labelView.setCompoundDrawablesWithIntrinsicBounds(iconDrawable, null, null, null);
return labelView;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mManagerUi.onFilterChanged(position);
}
public void initialize(DownloadManagerUi manager) {
mManagerUi = manager;
mSelectedBackgroundColor = ApiCompatibilityUtils
.getColor(mManagerUi.getActivity().getResources(), R.color.default_primary_color);
}
@Override
public void onFilterChanged(int filter) {
if (mSelectedIndex == filter) return;
mSelectedIndex = filter;
notifyDataSetChanged();
mManagerUi.closeDrawer();
}
public void onFilterChanged(int filter) {}
@Override
public void onManagerDestroyed() {
mManagerUi = null;
}
@Override
public void onNothingSelected(AdapterView<?> parent) {}
}
......@@ -9,6 +9,8 @@ import android.os.AsyncTask;
import android.os.Environment;
import android.os.StatFs;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
......@@ -103,6 +105,7 @@ public class SpaceDisplay extends RecyclerView.AdapterDataObserver {
private AsyncTask<Void, Void, Long> mFreeBytesTask;
private DownloadHistoryAdapter mHistoryAdapter;
private View mView;
private TextView mSpaceUsedByDownloadsTextView;
private TextView mSpaceUsedByOtherAppsTextView;
private TextView mSpaceFreeTextView;
......@@ -111,14 +114,21 @@ public class SpaceDisplay extends RecyclerView.AdapterDataObserver {
SpaceDisplay(final ViewGroup parent, DownloadHistoryAdapter historyAdapter) {
mHistoryAdapter = historyAdapter;
mSpaceUsedByDownloadsTextView = (TextView) parent.findViewById(R.id.size_downloaded);
mSpaceUsedByOtherAppsTextView = (TextView) parent.findViewById(R.id.size_other_apps);
mSpaceFreeTextView = (TextView) parent.findViewById(R.id.size_free);
mSpaceBar = (MaterialProgressBar) parent.findViewById(R.id.space_bar);
mView = (ViewGroup) LayoutInflater.from(parent.getContext())
.inflate(R.layout.download_manager_ui_space_widget, null);
mSpaceUsedByDownloadsTextView = (TextView) mView.findViewById(R.id.size_downloaded);
mSpaceUsedByOtherAppsTextView = (TextView) mView.findViewById(R.id.size_other_apps);
mSpaceFreeTextView = (TextView) mView.findViewById(R.id.size_free);
mSpaceBar = (MaterialProgressBar) mView.findViewById(R.id.space_bar);
mFileSystemBytesTask =
new StorageSizeTask(true).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
/** Returns the view. */
public View getView() {
return mView;
}
@Override
public void onChanged() {
// Record how much the user has downloaded relative to the size of their storage.
......
......@@ -2003,7 +2003,7 @@ To obtain new licenses, connect to the internet and play your downloaded content
<ph name="gigabytes">%1$3.2f<ex>0.3</ex></ph> GB downloaded
</message>
<message name="IDS_DOWNLOAD_MANAGER_UI_ALL_DOWNLOADS" desc="Indicates that clicking on this button shows all of your downloads.">
All downloads
All
</message>
<message name="IDS_DOWNLOAD_MANAGER_UI_PAGES" desc="Indicates that clicking on this button shows only offline pages.">
Pages
......
......@@ -545,17 +545,23 @@ public class DownloadHistoryAdapterTest {
/** Checks that the adapter has the correct items in the right places. */
private void checkAdapterContents(Object... expectedItems) {
Assert.assertEquals(expectedItems.length, mAdapter.getItemCount());
if (expectedItems.length == 0) {
Assert.assertEquals(0, mAdapter.getItemCount());
return;
}
// Leave the first element of the adapter which is the space usage header.
Assert.assertEquals(expectedItems.length + 1, mAdapter.getItemCount());
for (int i = 0; i < expectedItems.length; i++) {
if (expectedItems[i] == null) {
// Expect a date.
// TODO(dfalcantara): Check what date the header is showing.
Assert.assertEquals(TYPE_DATE, mAdapter.getItemViewType(i));
Assert.assertEquals(TYPE_DATE, mAdapter.getItemViewType(i + 1));
} else {
// Expect a particular item.
Assert.assertEquals(TYPE_NORMAL, mAdapter.getItemViewType(i));
Assert.assertEquals(TYPE_NORMAL, mAdapter.getItemViewType(i + 1));
Assert.assertEquals(expectedItems[i],
((DownloadHistoryItemWrapper) mAdapter.getItemAt(i).second).getItem());
((DownloadHistoryItemWrapper) mAdapter.getItemAt(i + 1).second).getItem());
}
}
}
......
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