diff options
| author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-26 05:25:02 +0000 | 
|---|---|---|
| committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-26 05:25:02 +0000 | 
| commit | 439be42cd51dfdd2544c7f4d77e167a8142bb35b (patch) | |
| tree | 7c981c6aa51ca7219ccfaf63122643b9e9b270d3 | |
| parent | 522a5bb8e2e22bb226f6c882839c37324e7c76d2 (diff) | |
| download | chromium_src-439be42cd51dfdd2544c7f4d77e167a8142bb35b.zip chromium_src-439be42cd51dfdd2544c7f4d77e167a8142bb35b.tar.gz chromium_src-439be42cd51dfdd2544c7f4d77e167a8142bb35b.tar.bz2 | |
Improve host-list appearance in Chromoting Android client.
This removes the non-localized ONLINE/OFFLINE text, and adds new
styling to distinguish offline hosts.
This also adds toast to indicate a host is offline.
BUG=331103,355868
Review URL: https://codereview.chromium.org/211953002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259511 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 40 insertions, 17 deletions
| diff --git a/remoting/android/java/src/org/chromium/chromoting/HostListAdapter.java b/remoting/android/java/src/org/chromium/chromoting/HostListAdapter.java index 28c6e43..1d38ec8 100644 --- a/remoting/android/java/src/org/chromium/chromoting/HostListAdapter.java +++ b/remoting/android/java/src/org/chromium/chromoting/HostListAdapter.java @@ -4,11 +4,11 @@  package org.chromium.chromoting; -import android.text.Html;  import android.view.View;  import android.view.ViewGroup;  import android.widget.ArrayAdapter;  import android.widget.TextView; +import android.widget.Toast;  /** Describes the appearance and behavior of each host list entry. */  class HostListAdapter extends ArrayAdapter<HostInfo> { @@ -33,11 +33,9 @@ class HostListAdapter extends ArrayAdapter<HostInfo> {          final HostInfo host = getItem(position); -        // TODO(lambroslambrou): Don't use hardcoded ONLINE/OFFLINE strings here. -        // See http://crbug.com/331103 -        target.setText(Html.fromHtml(host.name + " (<font color=\"" + -                (host.isOnline ? HOST_COLOR_ONLINE : HOST_COLOR_OFFLINE) + "\">" + -                (host.isOnline ? "ONLINE" : "OFFLINE") + "</font>)")); +        target.setText(host.name); +        target.setCompoundDrawablesWithIntrinsicBounds( +                host.isOnline ? R.drawable.icon_host : R.drawable.icon_host_offline, 0, 0, 0);          if (host.isOnline) {              target.setOnClickListener(new View.OnClickListener() { @@ -47,8 +45,16 @@ class HostListAdapter extends ArrayAdapter<HostInfo> {                      }              });          } else { -            // Disallow interaction with this entry. -            target.setEnabled(false); +            target.setTextColor(mChromoting.getResources().getColor(R.color.host_offline_text)); +            target.setBackgroundResource(R.drawable.list_item_disabled_selector); +            target.setOnClickListener(new View.OnClickListener() { +                    @Override +                    public void onClick(View v) { +                        Toast.makeText(mChromoting, +                                mChromoting.getString(R.string.host_offline_tooltip), +                                Toast.LENGTH_SHORT).show(); +                    } +            });          }          return target; diff --git a/remoting/resources/android/drawable/list_item_disabled_selector.xml b/remoting/resources/android/drawable/list_item_disabled_selector.xml new file mode 100644 index 0000000..3f991bd --- /dev/null +++ b/remoting/resources/android/drawable/list_item_disabled_selector.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- Copyright 2014 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. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> +    <item android:drawable="@color/list_item_disabled_pressed" +            android:state_pressed="true"/> + +    <!-- Default used for all other states. --> +    <item android:drawable="@android:color/transparent"/> +</selector> diff --git a/remoting/resources/android/drawable/list_item_selector.xml b/remoting/resources/android/drawable/list_item_selector.xml index 5e93ecc..c4b17a8 100644 --- a/remoting/resources/android/drawable/list_item_selector.xml +++ b/remoting/resources/android/drawable/list_item_selector.xml @@ -6,11 +6,7 @@  -->  <selector xmlns:android="http://schemas.android.com/apk/res/android"> -    <item android:drawable="@color/list_item_disabled_pressed" -            android:state_enabled="false" -            android:state_pressed="true"/>      <item android:drawable="@color/list_item_pressed" -            android:state_enabled="true"              android:state_pressed="true"/>      <!-- Default used for all other states. --> diff --git a/remoting/resources/android/layout/host.xml b/remoting/resources/android/layout/host.xml index f1b1f4f..1a37741 100644 --- a/remoting/resources/android/layout/host.xml +++ b/remoting/resources/android/layout/host.xml @@ -6,11 +6,14 @@  -->  <TextView xmlns:android="http://schemas.android.com/apk/res/android" -        android:id="@+id/host_label"          android:background="@drawable/list_item_selector" +        android:drawablePadding="16sp" +        android:gravity="center_vertical" +        android:id="@+id/host_label"          android:layout_height="wrap_content"          android:layout_width="match_parent" -        android:drawableLeft="@drawable/icon_host" -        android:drawablePadding="15sp" -        android:padding="15sp" -        android:gravity="center_vertical"/> +        android:paddingBottom="20sp" +        android:paddingLeft="16sp" +        android:paddingRight="16sp" +        android:paddingTop="20sp" +        style="@android:style/TextAppearance.Holo.Medium"/> diff --git a/remoting/resources/android/values/colors.xml b/remoting/resources/android/values/colors.xml index 4e70228..0d7b817 100644 --- a/remoting/resources/android/values/colors.xml +++ b/remoting/resources/android/values/colors.xml @@ -8,4 +8,5 @@  <resources>      <color name="list_item_disabled_pressed">#171717</color>      <color name="list_item_pressed">#444444</color> +    <color name="host_offline_text">#636363</color>  </resources> diff --git a/remoting/resources/remoting_strings.grd b/remoting/resources/remoting_strings.grd index 467caa4..2432415 100644 --- a/remoting/resources/remoting_strings.grd +++ b/remoting/resources/remoting_strings.grd @@ -420,6 +420,9 @@          <message desc="Error that is shown if a network error occurs, including the case where the device is off-line." name="IDS_ERROR_NETWORK_ERROR" formatter_data="android_java">            A network error occurred. Please check that your device is on-line and try again.          </message> +        <message desc="Text shown in tooltip when user touches an offline host on the device." name="IDS_HOST_OFFLINE_TOOLTIP" formatter_data="android_java"> +          Host is offline. +        </message>        </if>        <message desc="Label for the access code entry box. This is where the client user enters the code that permits access to the host." name="IDS_ACCESS_CODE"> | 
