Przeglądaj źródła

Proper selection highlighting

master
Chris Smith 14 lat temu
rodzic
commit
5e29d71517

BIN
code/ContextHome/dist/ContextHome.apk Wyświetl plik


BIN
code/ContextHome/res/drawable/focused_application_background.9.png Wyświetl plik


+ 25
- 0
code/ContextHome/res/drawable/grid_selector.xml Wyświetl plik

@@ -0,0 +1,25 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<!--
3
+/*
4
+**
5
+** Copyright 2007, The Android Open Source Project
6
+**
7
+** Licensed under the Apache License, Version 2.0 (the "License");
8
+** you may not use this file except in compliance with the License.
9
+** You may obtain a copy of the License at
10
+**
11
+**     http://www.apache.org/licenses/LICENSE-2.0
12
+**
13
+** Unless required by applicable law or agreed to in writing, software
14
+** distributed under the License is distributed on an "AS IS" BASIS,
15
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+** See the License for the specific language governing permissions and
17
+** limitations under the License.
18
+*/
19
+-->
20
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
21
+    <item android:state_pressed="true" android:drawable="@drawable/pressed_application_background" />
22
+    <item android:state_focused="false" android:drawable="@android:color/transparent" />
23
+    <item android:state_window_focused="true" android:drawable="@drawable/focused_application_background" />
24
+    <item android:state_window_focused="false" android:drawable="@android:color/transparent" />
25
+</selector>

BIN
code/ContextHome/res/drawable/pressed_application_background.9.png Wyświetl plik


+ 10
- 3
code/ContextHome/res/layout/titledimage.xml Wyświetl plik

@@ -1,6 +1,11 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
-        android:layout_width="fill_parent" android:layout_height="wrap_content">
3
+        android:layout_width="fill_parent"
4
+        android:layout_height="wrap_content"
5
+        android:focusable="true"
6
+        android:background="@drawable/grid_selector"
7
+        android:paddingLeft="5px"
8
+        android:paddingRight="5px">
4 9
     <ImageView
5 10
         android:id="@+id/image"
6 11
         android:layout_width="14pt"
@@ -13,12 +18,14 @@
13 18
         android:layout_toRightOf="@id/image"
14 19
         android:layout_width="wrap_content"
15 20
         android:singleLine="true"
16
-        android:layout_height="wrap_content"/>
21
+        android:layout_height="wrap_content"
22
+        android:textColor="#fff"/>
17 23
     <TextView
18 24
         android:id="@+id/body"
19 25
         android:layout_below="@id/title"
20 26
         android:layout_toRightOf="@id/image"
21 27
         android:layout_width="wrap_content"
22 28
         android:singleLine="true"
23
-        android:layout_height="wrap_content"/>
29
+        android:layout_height="wrap_content"
30
+        android:textColor="#fff"/>
24 31
 </RelativeLayout>

+ 4
- 1
code/ContextHome/src/uk/co/md87/android/contexthome/R.java Wyświetl plik

@@ -12,7 +12,10 @@ public final class R {
12 12
     }
13 13
     public static final class drawable {
14 14
         public static final int blank=0x7f020000;
15
-        public static final int icon=0x7f020001;
15
+        public static final int focused_application_background=0x7f020001;
16
+        public static final int grid_selector=0x7f020002;
17
+        public static final int icon=0x7f020003;
18
+        public static final int pressed_application_background=0x7f020004;
16 19
     }
17 20
     public static final class id {
18 21
         public static final int body=0x7f050003;

+ 3
- 1
code/ContextHome/src/uk/co/md87/android/contexthome/modules/AppsModule.java Wyświetl plik

@@ -70,7 +70,9 @@ public class AppsModule implements Module {
70 70
             image.setClickable(true);
71 71
             image.setTag(res.activityInfo);
72 72
             image.setOnClickListener(listener);
73
-            layout.addView(image, 48, 48);
73
+            image.setPadding(2, 2, 2, 2);
74
+            image.setBackgroundResource(R.drawable.grid_selector);
75
+            layout.addView(image, 52, 52);
74 76
         }
75 77
 
76 78
         return view;

+ 4
- 9
code/ContextHome/src/uk/co/md87/android/contexthome/modules/ContactsModule.java Wyświetl plik

@@ -22,24 +22,17 @@
22 22
 
23 23
 package uk.co.md87.android.contexthome.modules;
24 24
 
25
-import android.content.ComponentName;
26 25
 import android.content.ContentUris;
27 26
 import android.content.Context;
28 27
 import android.content.Intent;
29
-import android.content.pm.ActivityInfo;
30
-import android.content.pm.PackageInfo;
31
-import android.content.pm.PackageManager;
32
-import android.content.pm.ResolveInfo;
33 28
 import android.database.Cursor;
34 29
 import android.net.Uri;
35
-import android.provider.Contacts;
36 30
 import android.provider.Contacts.People;
37 31
 import android.provider.Contacts.Photos;
38
-import android.util.Log;
39 32
 import android.view.View;
40 33
 import android.widget.ImageView;
41 34
 import android.widget.LinearLayout;
42
-import java.util.Arrays;
35
+
43 36
 import uk.co.md87.android.contexthome.Module;
44 37
 import uk.co.md87.android.contexthome.R;
45 38
 
@@ -73,7 +66,7 @@ public class ContactsModule implements Module {
73 66
         final int column = cursor.getColumnIndex("person");
74 67
         if (cursor.moveToFirst()) {
75 68
             do {
76
-                layout.addView(getView(context, listener, cursor.getLong(column)));
69
+                layout.addView(getView(context, listener, cursor.getLong(column)), 52, 52);
77 70
             } while (cursor.moveToNext());
78 71
         }
79 72
 
@@ -90,6 +83,8 @@ public class ContactsModule implements Module {
90 83
         image.setImageBitmap(People.loadContactPhoto(context,
91 84
                     uri, R.drawable.blank, null));
92 85
         image.setOnClickListener(listener);
86
+        image.setBackgroundResource(R.drawable.grid_selector);
87
+        image.setPadding(2, 2, 2, 2);
93 88
 
94 89
         return image;
95 90
     }

Ładowanie…
Anuluj
Zapisz