Commit 3faf932e authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Revert "Download location: fix storage summary string."

This reverts commit 0cc7b305.

Reason for revert: UX designer has new specification on this piece of UI, since we need to cherry-pick to M68, I'd revert this CL and include the new spec in another CL.

Original change's description:
> Download location: fix storage summary string.
> 
> The storage summary string under download home title currently uses
> SpannableString that can expand to multiple lines, and can only apply
> simple styles defined by Spannale.
> 
> This CL adds a view for the summary string.
> 
> 
> Bug: 849973
> Change-Id: If01d323022e0cc743540a02ba58801c664957aa4
> Reviewed-on: https://chromium-review.googlesource.com/1089815
> Reviewed-by: David Trainor <dtrainor@chromium.org>
> Commit-Queue: Xing Liu <xingliu@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#565309}

TBR=dtrainor@chromium.org,qinmin@chromium.org,xingliu@chromium.org

Change-Id: I7a1c678d8dadfe66ef95b044daffde67282922b8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 849973
Reviewed-on: https://chromium-review.googlesource.com/1091810Reviewed-by: default avatarXing Liu <xingliu@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565414}
parent 3d7f15c7
...@@ -3,24 +3,7 @@ ...@@ -3,24 +3,7 @@
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<LinearLayout <TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:chrome="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="0dp" android:textAppearance="@style/BlackHeadline1" />
android:paddingBottom="0dp" \ No newline at end of file
android:orientation="vertical" >
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/download_home_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/BlackHeadline1" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/download_storage_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textAppearance="@style/BlackDisabledText2" />
</LinearLayout>
...@@ -4,10 +4,16 @@ ...@@ -4,10 +4,16 @@
package org.chromium.chrome.browser.download.ui; package org.chromium.chrome.browser.download.ui;
import android.graphics.Typeface;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Environment; import android.os.Environment;
import android.support.annotation.LayoutRes; import android.support.annotation.LayoutRes;
import android.support.graphics.drawable.VectorDrawableCompat; import android.support.graphics.drawable.VectorDrawableCompat;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -66,8 +72,8 @@ class FilterAdapter ...@@ -66,8 +72,8 @@ class FilterAdapter
@Override @Override
public View getDropDownView(int position, View convertView, ViewGroup parent) { public View getDropDownView(int position, View convertView, ViewGroup parent) {
TextView labelView = (TextView) getViewFromResource( TextView labelView =
convertView, R.layout.download_manager_spinner_drop_down); getTextViewFromResource(convertView, R.layout.download_manager_spinner_drop_down);
labelView.setText(DownloadFilter.getStringIdForFilter(position)); labelView.setText(DownloadFilter.getStringIdForFilter(position));
int iconId = DownloadFilter.getDrawableForFilter(position); int iconId = DownloadFilter.getDrawableForFilter(position);
VectorDrawableCompat iconDrawable = VectorDrawableCompat iconDrawable =
...@@ -82,39 +88,58 @@ class FilterAdapter ...@@ -82,39 +88,58 @@ class FilterAdapter
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
View labelView = getViewFromResource(convertView, R.layout.download_manager_spinner); TextView labelView =
getTextViewFromResource(convertView, R.layout.download_manager_spinner);
SpannableStringBuilder titleBuilder = new SpannableStringBuilder();
CharSequence title = mManagerUi.getActivity().getResources().getText(position == 0 CharSequence title = mManagerUi.getActivity().getResources().getText(position == 0
? R.string.menu_downloads ? R.string.menu_downloads
: DownloadFilter.getStringIdForFilter(position)); : DownloadFilter.getStringIdForFilter(position));
titleBuilder.append(title);
TextView titleView = labelView.findViewById(R.id.download_home_title);
titleView.setText(title);
// Set the storage summary for download location change feature. // Set the storage summary for download location change feature.
TextView summaryView = labelView.findViewById(R.id.download_storage_summary);
if (ChromeFeatureList.isEnabled(ChromeFeatureList.DOWNLOADS_LOCATION_CHANGE) if (ChromeFeatureList.isEnabled(ChromeFeatureList.DOWNLOADS_LOCATION_CHANGE)
&& mDirectoryOption != null) { && mDirectoryOption != null) {
titleBuilder.append("\n");
String storageSummary = String storageSummary =
mManagerUi.getActivity().getString(R.string.download_manager_ui_space_using, mManagerUi.getActivity().getString(R.string.download_manager_ui_space_using,
DownloadUtils.getStringForBytes( DownloadUtils.getStringForBytes(
mManagerUi.getActivity(), mDirectoryOption.availableSpace), mManagerUi.getActivity(), mDirectoryOption.availableSpace),
DownloadUtils.getStringForBytes( DownloadUtils.getStringForBytes(
mManagerUi.getActivity(), mDirectoryOption.totalSpace)); mManagerUi.getActivity(), mDirectoryOption.totalSpace));
summaryView.setText(storageSummary); titleBuilder.append(storageSummary);
} else { @SuppressWarnings("deprecation")
summaryView.setVisibility(View.GONE); int color = mManagerUi.getActivity().getResources().getColor(R.color.black_alpha_38);
int start = title.length() + 1;
int end = title.length() + storageSummary.length() + 1;
titleBuilder.setSpan(
new ForegroundColorSpan(color), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
titleBuilder.setSpan(
new RelativeSizeSpan(0.65f), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
titleBuilder.setSpan(
new StyleSpan(Typeface.NORMAL), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
labelView.setText(titleBuilder);
if (!FeatureUtilities.isChromeModernDesignEnabled()) { if (!FeatureUtilities.isChromeModernDesignEnabled()) {
ApiCompatibilityUtils.setTextAppearance(titleView, R.style.BlackHeadline2); ApiCompatibilityUtils.setTextAppearance(labelView, R.style.BlackHeadline2);
} }
return labelView; return labelView;
} }
private View getViewFromResource(View convertView, @LayoutRes int resId) { private TextView getTextViewFromResource(View convertView, @LayoutRes int resId) {
if (convertView != null) return convertView; TextView labelView = null;
return LayoutInflater.from(mManagerUi.getActivity()).inflate(resId, null); if (convertView instanceof TextView) {
labelView = (TextView) convertView;
} else {
labelView =
(TextView) LayoutInflater.from(mManagerUi.getActivity()).inflate(resId, null);
}
return labelView;
} }
@Override @Override
......
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