Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/download/ui/OfflineGroupHeaderView.java

Issue 2670083002: [Download Home] Displaying offline page bundle per day (Closed)
Patch Set: Dan's comments on new approach Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.download.ui;
6
7 import android.content.Context;
8 import android.text.format.Formatter;
9 import android.util.AttributeSet;
10 import android.view.View;
11 import android.widget.FrameLayout;
12 import android.widget.ImageView;
13 import android.widget.TextView;
14
15 import org.chromium.chrome.R;
16
17 import java.util.Date;
18
19 /** A header that presents users the option to view or hide the suggested offlin e pages. */
20 public class OfflineGroupHeaderView extends FrameLayout {
Theresa 2017/02/16 17:48:17 Have you asked UX whether this should be selectabl
shaktisahu 2017/02/16 21:15:11 Haven't got detailed feedback from UX yet, but yes
21 private Date mDate;
22 private DownloadHistoryAdapter mAdapter;
23
24 private TextView mPageCountHeader;
25 private TextView mFileSizeView;
26 private ImageView mImageView;
27
28 public OfflineGroupHeaderView(Context context, AttributeSet attrs) {
29 super(context, attrs);
30 setOnClickListener(new View.OnClickListener() {
31 @Override
32 public void onClick(View v) {
33 boolean newState = !mAdapter.isSubsectionExpanded(mDate);
34 mAdapter.setSubsectionExpanded(mDate, newState);
35 updateImageView(newState);
36 }
37 });
38 }
39
40 @Override
41 protected void onFinishInflate() {
42 super.onFinishInflate();
43 mPageCountHeader = (TextView) findViewById(R.id.page_count_text);
44 mFileSizeView = (TextView) findViewById(R.id.filesize_view);
45 mImageView = (ImageView) findViewById(R.id.expand_icon);
46 }
47
48 /**
49 * @param adapter The adapter associated with this header.
50 */
51 public void setAdapter(DownloadHistoryAdapter adapter) {
52 mAdapter = adapter;
53 }
54
55 /**
56 * Updates the properties of this header.
57 * @param date The date associated with this header.
58 * @param expanded Whether the items should be expanded or not.
59 * @param pageCount The total number of associated pages.
60 * @param fileSize The total file size of all the associated pages.
61 */
62 public void update(Date date, boolean expanded, int pageCount, long fileSize ) {
63 mDate = date;
64 mPageCountHeader.setText(getResources().getString(
65 R.string.download_manager_offline_header_title, pageCount));
66 mFileSizeView.setText(Formatter.formatFileSize(getContext(), fileSize));
67 updateImageView(expanded);
68 }
69
70 private void updateImageView(boolean expanded) {
71 mImageView.setImageResource(expanded ? R.drawable.ic_collapsed : R.drawa ble.ic_expanded);
72 mImageView.setContentDescription(
73 getResources().getString(expanded ? R.string.accessibility_colla pse_offline_pages
74 : R.string.accessibility_expan d_offline_pages));
75 }
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698