diff options
author | Nicolas Roard <nicolas@android.com> | 2009-09-14 20:39:08 +0100 |
---|---|---|
committer | Nicolas Roard <nicolas@android.com> | 2009-09-14 20:59:13 +0100 |
commit | c5702320cd0c66520de57ce8fea9676476cc042a (patch) | |
tree | 6b70b56936b08e2b5aa0ede2a84bd42c36bf9e3c | |
parent | b9daacb7513c5a42000285ad456cc614af1915c0 (diff) | |
download | packages_apps_Browser-c5702320cd0c66520de57ce8fea9676476cc042a.zip packages_apps_Browser-c5702320cd0c66520de57ce8fea9676476cc042a.tar.gz packages_apps_Browser-c5702320cd0c66520de57ce8fea9676476cc042a.tar.bz2 |
Show icons for storage and geolocation
-rw-r--r-- | res/drawable/location.png | bin | 0 -> 2953 bytes | |||
-rw-r--r-- | res/drawable/usage_empty.png | bin | 0 -> 2909 bytes | |||
-rw-r--r-- | res/drawable/usage_high.png | bin | 0 -> 2201 bytes | |||
-rw-r--r-- | res/drawable/usage_low.png | bin | 0 -> 3023 bytes | |||
-rw-r--r-- | res/drawable/usage_medium.png | bin | 0 -> 2780 bytes | |||
-rw-r--r-- | res/layout/application.xml | 53 | ||||
-rw-r--r-- | res/layout/website_settings_row.xml | 75 | ||||
-rw-r--r-- | src/com/android/browser/WebsiteSettingsActivity.java | 52 |
8 files changed, 126 insertions, 54 deletions
diff --git a/res/drawable/location.png b/res/drawable/location.png Binary files differnew file mode 100644 index 0000000..c7eb1dc --- /dev/null +++ b/res/drawable/location.png diff --git a/res/drawable/usage_empty.png b/res/drawable/usage_empty.png Binary files differnew file mode 100644 index 0000000..6a7e2db --- /dev/null +++ b/res/drawable/usage_empty.png diff --git a/res/drawable/usage_high.png b/res/drawable/usage_high.png Binary files differnew file mode 100644 index 0000000..006e1ac --- /dev/null +++ b/res/drawable/usage_high.png diff --git a/res/drawable/usage_low.png b/res/drawable/usage_low.png Binary files differnew file mode 100644 index 0000000..828ffb2 --- /dev/null +++ b/res/drawable/usage_low.png diff --git a/res/drawable/usage_medium.png b/res/drawable/usage_medium.png Binary files differnew file mode 100644 index 0000000..dc37363 --- /dev/null +++ b/res/drawable/usage_medium.png diff --git a/res/layout/application.xml b/res/layout/application.xml deleted file mode 100644 index d8de265..0000000 --- a/res/layout/application.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2009 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:drawingCacheQuality="auto" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:gravity="center" - android:padding="0dip"> - - <ImageView android:id="@+id/icon" - android:layout_width="32px" - android:layout_height="32px" - android:padding="2dip" /> - - <TwoLineListItem - android:paddingTop="2dip" - android:paddingBottom="2dip" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:minHeight="?android:attr/listPreferredItemHeight" - android:mode="twoLine"> - - <TextView android:id="@+id/title" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:layout_marginLeft="6dip" - android:layout_marginTop="6dip" - android:textAppearance="?android:attr/textAppearanceLarge"/> - - <TextView android:id="@+id/subtitle" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:layout_below="@+id/title" - android:layout_alignLeft="@+id/title" - android:textAppearance="?android:attr/textAppearanceSmall"/> - - </TwoLineListItem> - -</LinearLayout> diff --git a/res/layout/website_settings_row.xml b/res/layout/website_settings_row.xml new file mode 100644 index 0000000..911e1d6 --- /dev/null +++ b/res/layout/website_settings_row.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:drawingCacheQuality="auto" + android:layout_width="fill_parent" + android:layout_height="?android:attr/listPreferredItemHeight" + android:gravity="center" + android:padding="0dip"> + + <ImageView android:id="@+id/icon" + android:layout_width="32px" + android:layout_height="32px" + android:layout_alignParentTop="true" + android:layout_alignParentLeft="true" + android:layout_alignParentBottom="true" + android:padding="2dip" /> + + <LinearLayout android:id="@+id/features" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_alignParentBottom="true" + android:layout_alignParentRight="true" + android:gravity="center" + android:padding="0dip" + android:layout_marginRight="2dip"> + + <ImageView android:id="@+id/location_icon" + android:layout_width="32px" + android:layout_height="32px" + android:padding="2dip" /> + + <ImageView android:id="@+id/usage_icon" + android:layout_width="32px" + android:layout_height="32px" + android:padding="2dip" /> + + </LinearLayout> + + <TextView android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_alignWithParentIfMissing="true" + android:layout_toRightOf="@id/icon" + android:layout_toLeftOf="@id/features" + android:layout_marginLeft="6dip" + android:layout_marginTop="6dip" + android:textAppearance="?android:attr/textAppearanceLarge"/> + + <TextView android:id="@+id/subtitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_toRightOf="@id/icon" + android:layout_toLeftOf="@id/features" + android:layout_below="@id/title" + android:layout_alignLeft="@id/title" + android:layout_marginBottom="2dip" + android:textAppearance="?android:attr/textAppearanceSmall"/> + +</RelativeLayout> diff --git a/src/com/android/browser/WebsiteSettingsActivity.java b/src/com/android/browser/WebsiteSettingsActivity.java index fc72b62..9c9b6ac 100644 --- a/src/com/android/browser/WebsiteSettingsActivity.java +++ b/src/com/android/browser/WebsiteSettingsActivity.java @@ -155,6 +155,11 @@ public class WebsiteSettingsActivity extends ListActivity { private int mResource; private LayoutInflater mInflater; private Bitmap mDefaultIcon; + private Bitmap mUsageEmptyIcon; + private Bitmap mUsageLowIcon; + private Bitmap mUsageMediumIcon; + private Bitmap mUsageHighIcon; + private Bitmap mLocationIcon; private Site mCurrentSite; public SiteAdapter(Context context, int rsc) { @@ -163,6 +168,16 @@ public class WebsiteSettingsActivity extends ListActivity { mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mDefaultIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_shortcut_browser_bookmark); + mUsageEmptyIcon = BitmapFactory.decodeResource(getResources(), + R.drawable.usage_empty); + mUsageLowIcon = BitmapFactory.decodeResource(getResources(), + R.drawable.usage_low); + mUsageMediumIcon = BitmapFactory.decodeResource(getResources(), + R.drawable.usage_medium); + mUsageHighIcon = BitmapFactory.decodeResource(getResources(), + R.drawable.usage_high); + mLocationIcon = BitmapFactory.decodeResource(getResources(), + R.drawable.location); populateOrigins(); } @@ -315,6 +330,8 @@ public class WebsiteSettingsActivity extends ListActivity { TextView title; TextView subtitle; ImageView icon; + ImageView usageIcon; + ImageView locationIcon; if (convertView == null) { view = mInflater.inflate(mResource, parent, false); @@ -325,6 +342,10 @@ public class WebsiteSettingsActivity extends ListActivity { title = (TextView) view.findViewById(R.id.title); subtitle = (TextView) view.findViewById(R.id.subtitle); icon = (ImageView) view.findViewById(R.id.icon); + usageIcon = (ImageView) view.findViewById(R.id.usage_icon); + locationIcon = (ImageView) view.findViewById(R.id.location_icon); + usageIcon.setVisibility(View.GONE); + locationIcon.setVisibility(View.GONE); if (mCurrentSite == null) { setTitle(getString(R.string.pref_extras_website_settings)); @@ -333,6 +354,8 @@ public class WebsiteSettingsActivity extends ListActivity { title.setText(site.getPrettyTitle()); subtitle.setText(site.getPrettyOrigin()); icon.setVisibility(View.VISIBLE); + usageIcon.setVisibility(View.INVISIBLE); + locationIcon.setVisibility(View.INVISIBLE); Bitmap bmp = site.getIcon(); if (bmp == null) { bmp = mDefaultIcon; @@ -341,6 +364,33 @@ public class WebsiteSettingsActivity extends ListActivity { // We set the site as the view's tag, // so that we can get it in onItemClick() view.setTag(site); + + if (site.hasFeature(Site.FEATURE_WEB_STORAGE)) { + String origin = site.getOrigin(); + long usageInBytes = WebStorage.getInstance().getUsageForOrigin(origin); + float usageInMegabytes = (float) usageInBytes / (1024.0F * 1024.0F); + usageIcon.setVisibility(View.VISIBLE); + + // We set the correct icon: + // 0 < empty < 0.1MB + // 0.1MB < low < 3MB + // 3MB < medium < 6MB + // 6MB < high + if (usageInMegabytes <= 0.1) { + usageIcon.setImageBitmap(mUsageEmptyIcon); + } else if (usageInMegabytes > 0.1 && usageInMegabytes <= 3) { + usageIcon.setImageBitmap(mUsageLowIcon); + } else if (usageInMegabytes > 3 && usageInMegabytes <= 6) { + usageIcon.setImageBitmap(mUsageMediumIcon); + } else if (usageInMegabytes > 6) { + usageIcon.setImageBitmap(mUsageHighIcon); + } + } + + if (site.hasFeature(Site.FEATURE_GEOLOCATION)) { + locationIcon.setVisibility(View.VISIBLE); + locationIcon.setImageBitmap(mLocationIcon); + } } else { setTitle(mCurrentSite.getPrettyTitle()); icon.setVisibility(View.GONE); @@ -432,7 +482,7 @@ public class WebsiteSettingsActivity extends ListActivity { if (sMBStored == null) { sMBStored = getString(R.string.webstorage_origin_summary_mb_stored); } - mAdapter = new SiteAdapter(this, R.layout.application); + mAdapter = new SiteAdapter(this, R.layout.website_settings_row); setListAdapter(mAdapter); getListView().setOnItemClickListener(mAdapter); } |