Browse Source

Home now has fixed modules and scrollable bottom

master
Chris Smith 14 years ago
parent
commit
bc3acd7992

BIN
code/ContextHome/dist/ContextHome.apk View File


+ 23
- 0
code/ContextHome/res/layout/container.xml View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+        android:layout_width="fill_parent"
4
+        android:layout_height="fill_parent"
5
+        android:orientation="vertical">
6
+    <LinearLayout
7
+        android:id="@+id/fixedcontent"
8
+        android:layout_width="fill_parent"
9
+        android:layout_height="wrap_content"
10
+        android:orientation="vertical"/>
11
+    <ScrollView
12
+        android:id="@+id/scroll"
13
+        android:layout_width="fill_parent"
14
+        android:layout_height="fill_parent"
15
+        android:layout_weight="1"
16
+        android:scrollbars="none">
17
+        <LinearLayout
18
+            android:id="@+id/content"
19
+            android:layout_width="fill_parent"
20
+            android:layout_height="fill_parent"
21
+            android:orientation="vertical"/>
22
+    </ScrollView>
23
+</LinearLayout>

+ 16
- 9
code/ContextHome/src/uk/co/md87/android/contexthome/ContextHome.java View File

42
     private static final LayoutParams MODULE_PARAMS
42
     private static final LayoutParams MODULE_PARAMS
43
             = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
43
             = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
44
 
44
 
45
-    private LinearLayout layout;
45
+    private LinearLayout layout, fixedLayout;
46
+    private final Module[] fixedModules = new Module[] {
47
+        new ContactsModule(), new AppsModule()
48
+    };
49
+    
46
     private final Module[] modules = new Module[]{
50
     private final Module[] modules = new Module[]{
47
-        new ContactsModule(), new AppsModule(), new EmailModule(), new SmsModule(),
51
+        new EmailModule(), new SmsModule(),
48
     };
52
     };
49
 
53
 
50
     /** Called when the activity is first created. */
54
     /** Called when the activity is first created. */
51
     @Override
55
     @Override
52
     public void onCreate(Bundle icicle) {
56
     public void onCreate(Bundle icicle) {
53
         super.onCreate(icicle);
57
         super.onCreate(icicle);
58
+
59
+        setContentView(R.layout.container);
54
         
60
         
55
-        layout = new LinearLayout(this);
56
-        layout.setOrientation(LinearLayout.VERTICAL);
57
-        setContentView(layout);
61
+        layout = (LinearLayout) findViewById(R.id.content);
62
+        fixedLayout = (LinearLayout) findViewById(R.id.fixedcontent);
58
 
63
 
59
         initLayout();
64
         initLayout();
60
     }
65
     }
61
 
66
 
62
     private void initLayout() {
67
     private void initLayout() {
68
+        fixedLayout.removeAllViews();
63
         layout.removeAllViews();
69
         layout.removeAllViews();
64
 
70
 
65
-        int i = 1;
71
+        for (Module module : fixedModules) {
72
+            fixedLayout.addView(module.getView(this, 1), MODULE_PARAMS);
73
+        }
74
+
66
         for (Module module : modules) {
75
         for (Module module : modules) {
67
-            final LayoutParams params = new LayoutParams(MODULE_PARAMS);
68
-            params.weight = ++i > 3 ? (float) i / 11 : 1;
69
-            layout.addView(module.getView(this, i), params);
76
+            layout.addView(module.getView(this, 10), MODULE_PARAMS);
70
         }
77
         }
71
     }
78
     }
72
 
79
 

+ 9
- 6
code/ContextHome/src/uk/co/md87/android/contexthome/R.java View File

18
         public static final int pressed_application_background=0x7f020004;
18
         public static final int pressed_application_background=0x7f020004;
19
     }
19
     }
20
     public static final class id {
20
     public static final class id {
21
-        public static final int body=0x7f050003;
22
-        public static final int content=0x7f050000;
23
-        public static final int image=0x7f050001;
24
-        public static final int title=0x7f050002;
21
+        public static final int body=0x7f050005;
22
+        public static final int content=0x7f050002;
23
+        public static final int fixedcontent=0x7f050000;
24
+        public static final int image=0x7f050003;
25
+        public static final int scroll=0x7f050001;
26
+        public static final int title=0x7f050004;
25
     }
27
     }
26
     public static final class layout {
28
     public static final class layout {
27
-        public static final int scroller=0x7f030000;
28
-        public static final int titledimage=0x7f030001;
29
+        public static final int container=0x7f030000;
30
+        public static final int scroller=0x7f030001;
31
+        public static final int titledimage=0x7f030002;
29
     }
32
     }
30
     public static final class string {
33
     public static final class string {
31
         public static final int app_name=0x7f040000;
34
         public static final int app_name=0x7f040000;

+ 12
- 11
code/ContextHome/src/uk/co/md87/android/contexthome/modules/EmailModule.java View File

67
         params.weight = 1;
67
         params.weight = 1;
68
 
68
 
69
         boolean success = cursor.moveToFirst();
69
         boolean success = cursor.moveToFirst();
70
-        for (int i = 0; i < weight && success; i++) {
70
+        for (int i = 0; i < weight && success; ) {
71
             final long convId = cursor.getLong(convIdIndex);
71
             final long convId = cursor.getLong(convIdIndex);
72
             final Uri uri = inboxUri.buildUpon().appendEncodedPath(String.valueOf(convId)
72
             final Uri uri = inboxUri.buildUpon().appendEncodedPath(String.valueOf(convId)
73
                     + "/messages").build();
73
                     + "/messages").build();
75
             final Cursor messageCursor = context.getContentResolver().query(uri,
75
             final Cursor messageCursor = context.getContentResolver().query(uri,
76
                 new String[] { "fromAddress", "subject", "messageId" }, null, null, null);
76
                 new String[] { "fromAddress", "subject", "messageId" }, null, null, null);
77
 
77
 
78
-            messageCursor.moveToFirst();
78
+            if (messageCursor.moveToFirst()) {
79
+                final int subjectIndex = messageCursor.getColumnIndex("subject");
80
+                final int addressIndex = messageCursor.getColumnIndex("fromAddress");
81
+                final int messageIdIndex = messageCursor.getColumnIndex("messageId");
79
 
82
 
80
-            final int subjectIndex = messageCursor.getColumnIndex("subject");
81
-            final int addressIndex = messageCursor.getColumnIndex("fromAddress");
82
-            final int messageIdIndex = messageCursor.getColumnIndex("messageId");
83
+                final String body = messageCursor.getString(subjectIndex);
84
+                final String address = messageCursor.getString(addressIndex);
85
+                final int count = messageCursor.getCount();
86
+                final long messageId = messageCursor.getLong(messageIdIndex);
83
 
87
 
84
-            final String body = messageCursor.getString(subjectIndex);
85
-            final String address = messageCursor.getString(addressIndex);
86
-            final int count = messageCursor.getCount();
87
-            final long messageId = messageCursor.getLong(messageIdIndex);
88
+                layout.addView(getView(context, body, address, messageId, count), params);
88
 
89
 
89
-            layout.addView(getView(context, body, address, messageId, count), params);
90
+                i++;
91
+            }
90
 
92
 
91
             messageCursor.close();
93
             messageCursor.close();
92
-
93
             success = cursor.moveToNext();
94
             success = cursor.moveToNext();
94
         }
95
         }
95
         cursor.close();
96
         cursor.close();

Loading…
Cancel
Save