summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlambroslambrou <lambroslambrou@chromium.org>2015-04-03 14:42:36 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-03 21:43:03 +0000
commitc2e6516482a66a39deff2915ff81e04dcd65f8d2 (patch)
tree3c9c17335820a60faf3f511cd8ab55cb1ab02d52
parentb5c7856450665449c80598b1cb50a579f6517b48 (diff)
downloadchromium_src-c2e6516482a66a39deff2915ff81e04dcd65f8d2.zip
chromium_src-c2e6516482a66a39deff2915ff81e04dcd65f8d2.tar.gz
chromium_src-c2e6516482a66a39deff2915ff81e04dcd65f8d2.tar.bz2
Android Chromoting: Remove custom touch feedback from host list.
This also applies Material styling, and ripple feedback, to the list. BUG=430328 Review URL: https://codereview.chromium.org/1054303002 Cr-Commit-Position: refs/heads/master@{#323822}
-rw-r--r--remoting/android/java/res/drawable/list_item_disabled_selector.xml14
-rw-r--r--remoting/android/java/res/drawable/list_item_selector.xml14
-rw-r--r--remoting/android/java/res/layout/host.xml3
-rw-r--r--remoting/android/java/res/values/colors.xml4
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/Chromoting.java38
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/HostListAdapter.java48
6 files changed, 44 insertions, 77 deletions
diff --git a/remoting/android/java/res/drawable/list_item_disabled_selector.xml b/remoting/android/java/res/drawable/list_item_disabled_selector.xml
deleted file mode 100644
index 3f991bd..0000000
--- a/remoting/android/java/res/drawable/list_item_disabled_selector.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?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/android/java/res/drawable/list_item_selector.xml b/remoting/android/java/res/drawable/list_item_selector.xml
deleted file mode 100644
index c4b17a8..0000000
--- a/remoting/android/java/res/drawable/list_item_selector.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?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_pressed"
- android:state_pressed="true"/>
-
- <!-- Default used for all other states. -->
- <item android:drawable="@android:color/transparent"/>
-</selector>
diff --git a/remoting/android/java/res/layout/host.xml b/remoting/android/java/res/layout/host.xml
index 2226a8b..ba689d5 100644
--- a/remoting/android/java/res/layout/host.xml
+++ b/remoting/android/java/res/layout/host.xml
@@ -6,7 +6,6 @@
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:background="@drawable/list_item_selector"
android:drawablePadding="16sp"
android:gravity="center_vertical"
android:id="@+id/host_label"
@@ -16,4 +15,4 @@
android:paddingStart="16sp"
android:paddingEnd="16sp"
android:paddingTop="20sp"
- style="@android:style/TextAppearance.Holo.Medium"/>
+ style="?android:attr/textAppearanceMedium"/>
diff --git a/remoting/android/java/res/values/colors.xml b/remoting/android/java/res/values/colors.xml
index 0d7b817..2e79358 100644
--- a/remoting/android/java/res/values/colors.xml
+++ b/remoting/android/java/res/values/colors.xml
@@ -6,7 +6,5 @@
-->
<resources>
- <color name="list_item_disabled_pressed">#171717</color>
- <color name="list_item_pressed">#444444</color>
- <color name="host_offline_text">#636363</color>
+ <color name="host_offline_text">#9E9E9E</color>
</resources>
diff --git a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
index 15a8b15..72e8c2a 100644
--- a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
+++ b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
@@ -17,12 +17,14 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
+import android.content.res.Resources;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
+import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -37,6 +39,7 @@ import org.chromium.chromoting.jni.JniInterface;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Locale;
/**
* The user interface for querying and displaying a user's host list from the directory server. It
@@ -176,6 +179,15 @@ public class Chromoting extends ActionBarActivity implements JniInterface.Connec
// Get ahold of our view widgets.
mHostListView = (ListView) findViewById(R.id.hostList_chooser);
mHostListView.setEmptyView(findViewById(R.id.hostList_empty));
+ mHostListView.setOnItemClickListener(
+ new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position,
+ long id) {
+ onHostClicked(position);
+ }
+ });
+
mProgressView = findViewById(R.id.hostList_progress);
findViewById(R.id.host_setup_link_android).setOnClickListener(this);
@@ -314,7 +326,31 @@ public class Chromoting extends ActionBarActivity implements JniInterface.Connec
}
/** Called when the user taps on a host entry. */
- public void connectToHost(HostInfo host) {
+ private void onHostClicked(int index) {
+ HostInfo host = mHosts[index];
+ if (host.isOnline) {
+ connectToHost(host);
+ } else {
+ String tooltip = getHostOfflineTooltip(host.hostOfflineReason);
+ Toast.makeText(this, tooltip, Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ private String getHostOfflineTooltip(String hostOfflineReason) {
+ if (TextUtils.isEmpty(hostOfflineReason)) {
+ return getString(R.string.host_offline_tooltip);
+ }
+ try {
+ String resourceName = "offline_reason_" + hostOfflineReason.toLowerCase(Locale.ENGLISH);
+ int resourceId = getResources().getIdentifier(resourceName, "string",
+ getPackageName());
+ return getString(resourceId);
+ } catch (Resources.NotFoundException ignored) {
+ return getString(R.string.offline_reason_unknown, hostOfflineReason);
+ }
+ }
+
+ private void connectToHost(HostInfo host) {
mProgressIndicator = ProgressDialog.show(
this,
host.name,
diff --git a/remoting/android/java/src/org/chromium/chromoting/HostListAdapter.java b/remoting/android/java/src/org/chromium/chromoting/HostListAdapter.java
index 437d2e0..f1d7b78 100644
--- a/remoting/android/java/src/org/chromium/chromoting/HostListAdapter.java
+++ b/remoting/android/java/src/org/chromium/chromoting/HostListAdapter.java
@@ -4,38 +4,16 @@
package org.chromium.chromoting;
-import android.content.res.Resources;
-import android.text.TextUtils;
+import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
-import android.widget.Toast;
-
-import java.util.Locale;
/** Describes the appearance and behavior of each host list entry. */
class HostListAdapter extends ArrayAdapter<HostInfo> {
- private Chromoting mChromoting;
-
- /** Constructor. */
- public HostListAdapter(Chromoting chromoting, int textViewResourceId, HostInfo[] hosts) {
- super(chromoting, textViewResourceId, hosts);
- mChromoting = chromoting;
- }
-
- private String getHostOfflineTooltip(String hostOfflineReason) {
- if (TextUtils.isEmpty(hostOfflineReason)) {
- return mChromoting.getString(R.string.host_offline_tooltip);
- }
- try {
- String resourceName = "offline_reason_" + hostOfflineReason.toLowerCase(Locale.ENGLISH);
- int resourceId = mChromoting.getResources().getIdentifier(
- resourceName, "string", mChromoting.getPackageName());
- return mChromoting.getString(resourceId);
- } catch (Resources.NotFoundException ignored) {
- return mChromoting.getString(R.string.offline_reason_unknown, hostOfflineReason);
- }
+ public HostListAdapter(Context context, int textViewResourceId, HostInfo[] hosts) {
+ super(context, textViewResourceId, hosts);
}
/** Generates a View corresponding to this particular host. */
@@ -49,24 +27,8 @@ class HostListAdapter extends ArrayAdapter<HostInfo> {
target.setCompoundDrawablesWithIntrinsicBounds(
host.isOnline ? R.drawable.ic_host_online : R.drawable.ic_host_offline, 0, 0, 0);
- if (host.isOnline) {
- target.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mChromoting.connectToHost(host);
- }
- });
- } else {
- target.setTextColor(mChromoting.getResources().getColor(R.color.host_offline_text));
- target.setBackgroundResource(R.drawable.list_item_disabled_selector);
-
- final String tooltip = getHostOfflineTooltip(host.hostOfflineReason);
- target.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Toast.makeText(mChromoting, tooltip, Toast.LENGTH_SHORT).show();
- }
- });
+ if (!host.isOnline) {
+ target.setTextColor(getContext().getResources().getColor(R.color.host_offline_text));
}
return target;