リビジョン | 41ea52e96b862187f37f7b95ee2b52a8b1fb8bf4 (tree) |
---|---|
日時 | 2012-11-01 17:04:14 |
作者 | Masahiko, SAWAI <say@user...> |
コミッター | Masahiko, SAWAI |
Intent 詳細表示画面にフラグ一覧表示を追加
@@ -14,7 +14,7 @@ | ||
14 | 14 | android:layout_height="wrap_content" |
15 | 15 | android:text="ACTION_NAME" |
16 | 16 | android:textSize="18sp" |
17 | - android:textColor="@android:color/white" | |
17 | + android:textColor="?android:textColorPrimary" | |
18 | 18 | android:singleLine="true" |
19 | 19 | android:ellipsize="marquee" |
20 | 20 | /> |
@@ -21,7 +21,7 @@ | ||
21 | 21 | android:layout_height="wrap_content" |
22 | 22 | android:text="ACTION_NAME" |
23 | 23 | android:textSize="18sp" |
24 | - android:textColor="@android:color/white" | |
24 | + android:textColor="?android:textColorPrimary" | |
25 | 25 | android:singleLine="true" |
26 | 26 | android:ellipsize="marquee" |
27 | 27 | /> |
@@ -1,12 +1,20 @@ | ||
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | -<TextView xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | - android:id="@+id/category_textview" | |
2 | +<LinearLayout | |
3 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
4 | 4 | android:layout_width="fill_parent" |
5 | 5 | android:layout_height="wrap_content" |
6 | + android:orientation="vertical" | |
6 | 7 | android:paddingLeft="@dimen/list_item_paddingLeft" |
7 | 8 | android:paddingRight="@dimen/list_item_paddingRight" |
8 | 9 | android:paddingTop="@dimen/list_item_paddingTop" |
9 | 10 | android:paddingBottom="@dimen/list_item_paddingBottom" |
10 | - android:text="CATEGORY" | |
11 | - android:textSize="16sp" | |
12 | -/> | |
\ No newline at end of file | ||
11 | +> | |
12 | + <TextView | |
13 | + android:id="@+id/category_textview" | |
14 | + android:layout_width="fill_parent" | |
15 | + android:layout_height="wrap_content" | |
16 | + android:text="CATEGORY" | |
17 | + android:textSize="16sp" | |
18 | + android:textColor="?android:textColorPrimary" | |
19 | + /> | |
20 | +</LinearLayout> | |
\ No newline at end of file |
@@ -37,6 +37,6 @@ | ||
37 | 37 | android:gravity="right" |
38 | 38 | android:text="VALUE" |
39 | 39 | android:textSize="20sp" |
40 | - android:textColor="@android:color/white" | |
40 | + android:textColor="?android:textColorPrimary" | |
41 | 41 | /> |
42 | 42 | </LinearLayout> |
\ No newline at end of file |
@@ -1,5 +1,6 @@ | ||
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
2 | +<LinearLayout | |
3 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | 4 | android:layout_width="fill_parent" |
4 | 5 | android:layout_height="wrap_content" |
5 | 6 | android:orientation="vertical" |
@@ -8,9 +9,12 @@ | ||
8 | 9 | android:paddingTop="@dimen/list_item_paddingTop" |
9 | 10 | android:paddingBottom="@dimen/list_item_paddingBottom" |
10 | 11 | > |
11 | - <TextView | |
12 | - style="@style/key" | |
12 | + <TextView | |
13 | 13 | android:id="@+id/flag_name_textview" |
14 | + android:layout_width="fill_parent" | |
15 | + android:layout_height="wrap_content" | |
16 | + android:gravity="left" | |
14 | 17 | android:textSize="14sp" |
18 | + android:textColor="?android:textColorPrimary" | |
15 | 19 | /> |
16 | 20 | </LinearLayout> |
\ No newline at end of file |
@@ -123,12 +123,23 @@ | ||
123 | 123 | style="@style/key" |
124 | 124 | android:text="@string/categories" |
125 | 125 | /> |
126 | - <TextView | |
127 | - style="@style/value" | |
128 | - android:id="@+id/categories_textview" | |
129 | - android:hint="@string/categories" | |
130 | - android:lineSpacingMultiplier="1.4" | |
131 | - /> | |
126 | + <FrameLayout | |
127 | + android:layout_width="fill_parent" | |
128 | + android:layout_height="wrap_content" | |
129 | + > | |
130 | + <LinearLayout | |
131 | + android:id="@+id/categories_container" | |
132 | + android:layout_width="fill_parent" | |
133 | + android:layout_height="wrap_content" | |
134 | + android:orientation="vertical" | |
135 | + /> | |
136 | + <TextView | |
137 | + android:id="@+id/no_category_textview" | |
138 | + style="@style/value" | |
139 | + android:hint="@string/no_category" | |
140 | + android:text="" | |
141 | + /> | |
142 | + </FrameLayout> | |
132 | 143 | </LinearLayout> |
133 | 144 | |
134 | 145 | <!-- Extras --> |
@@ -142,18 +153,53 @@ | ||
142 | 153 | style="@style/key" |
143 | 154 | android:text="@string/extras" |
144 | 155 | /> |
145 | - <LinearLayout | |
146 | - android:id="@+id/extras_container" | |
156 | + <FrameLayout | |
147 | 157 | android:layout_width="fill_parent" |
148 | 158 | android:layout_height="wrap_content" |
149 | - android:orientation="vertical" | |
150 | 159 | > |
160 | + <LinearLayout | |
161 | + android:id="@+id/extras_container" | |
162 | + android:layout_width="fill_parent" | |
163 | + android:layout_height="wrap_content" | |
164 | + android:orientation="vertical" | |
165 | + /> | |
151 | 166 | <TextView |
167 | + android:id="@+id/no_extra_textview" | |
152 | 168 | style="@style/value" |
153 | 169 | android:hint="@string/no_extra" |
154 | 170 | android:text="" |
155 | 171 | /> |
156 | - </LinearLayout> | |
172 | + </FrameLayout> | |
173 | + </LinearLayout> | |
174 | + | |
175 | + <!-- Flags --> | |
176 | + <LinearLayout | |
177 | + android:id="@+id/intent_detail_item_flags" | |
178 | + android:layout_width="fill_parent" | |
179 | + android:layout_height="wrap_content" | |
180 | + android:orientation="vertical" | |
181 | + > | |
182 | + <TextView | |
183 | + style="@style/key" | |
184 | + android:text="@string/flags" | |
185 | + /> | |
186 | + <FrameLayout | |
187 | + android:layout_width="fill_parent" | |
188 | + android:layout_height="wrap_content" | |
189 | + > | |
190 | + <LinearLayout | |
191 | + android:id="@+id/flags_container" | |
192 | + android:layout_width="fill_parent" | |
193 | + android:layout_height="wrap_content" | |
194 | + android:orientation="vertical" | |
195 | + /> | |
196 | + <TextView | |
197 | + android:id="@+id/no_flag_textview" | |
198 | + style="@style/value" | |
199 | + android:hint="@string/no_flag" | |
200 | + android:text="" | |
201 | + /> | |
202 | + </FrameLayout> | |
157 | 203 | </LinearLayout> |
158 | 204 | |
159 | 205 | </FrameLayout> |
\ No newline at end of file |
@@ -32,7 +32,8 @@ public class IntentDetailActivity2 extends ListActivity | ||
32 | 32 | private static final int POSITION_DATA_URI = 3; |
33 | 33 | private static final int POSITION_DATA_TYPE = 4; |
34 | 34 | private static final int POSITION_CATEGORIES = 5; |
35 | - private static final int POSITION_EXTRAS = 6; | |
35 | + private static final int POSITION_FLAGS = 6; | |
36 | + private static final int POSITION_EXTRAS = 7; | |
36 | 37 | // data |
37 | 38 | private Uri targetUri; |
38 | 39 | private String targetName; |
@@ -114,67 +115,6 @@ public class IntentDetailActivity2 extends ListActivity | ||
114 | 115 | return title; |
115 | 116 | } |
116 | 117 | |
117 | - private void bindExtras(ViewGroup extraContainer, Bundle extras) | |
118 | - { | |
119 | - Log.v(LOG_TAG, "Hello"); | |
120 | - | |
121 | - Log.d(LOG_TAG, "extras => " + extras); | |
122 | - if (extras != null) | |
123 | - { | |
124 | - extraContainer.removeAllViews(); | |
125 | - | |
126 | - LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); | |
127 | - for (String key : extras.keySet()) | |
128 | - { | |
129 | - Object value = extras.get(key); | |
130 | - String type = value.getClass().getSimpleName(); | |
131 | - Log.d(LOG_TAG, "extra key => " + key); | |
132 | - Log.d(LOG_TAG, "extra value => " + value); | |
133 | - | |
134 | - View extraItem = inflater.inflate(R.layout.extra_list_item, null); | |
135 | - TextView keyTextView = (TextView) extraItem.findViewById(R.id.extra_key_textview); | |
136 | - TextView typeTextView = (TextView) extraItem.findViewById(R.id.extra_type_textview); | |
137 | - TextView valueTextView = (TextView) extraItem.findViewById(R.id.extra_value_textview); | |
138 | - | |
139 | - keyTextView.setText(key); | |
140 | - typeTextView.setText(type); | |
141 | - valueTextView.setText(value.toString()); | |
142 | - extraContainer.addView(extraItem); | |
143 | - } | |
144 | - } | |
145 | - Log.v(LOG_TAG, "Bye"); | |
146 | - } | |
147 | - | |
148 | - /* | |
149 | - private void initializeFlags(Intent targetIntent) | |
150 | - { | |
151 | - Log.v(LOG_TAG, "Hello"); | |
152 | - | |
153 | - int flags = targetIntent.getFlags(); | |
154 | - Log.d(LOG_TAG, "flags => " + flags); | |
155 | - if (flags != 0) | |
156 | - { | |
157 | - ViewGroup flagsViewGroup = (ViewGroup) findViewById(R.id.flags_section); | |
158 | - flagsViewGroup.removeAllViews(); | |
159 | - | |
160 | - LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); | |
161 | - for (int i = 0; i < IntentFlags.FLAG_VALUES.length; i++) | |
162 | - { | |
163 | - int flagValue = IntentFlags.FLAG_VALUES[i]; | |
164 | - String flagName = IntentFlags.FLAG_NAMES[i]; | |
165 | - if ((flags & flagValue) != 0) | |
166 | - { | |
167 | - Log.d(LOG_TAG, "flag name => " + flagName); | |
168 | - View flagItem = inflater.inflate(R.layout.flag_list_item, flagsViewGroup, true); | |
169 | - TextView flagNameTextView = (TextView) flagItem.findViewById(R.id.flag_name_textview); | |
170 | - flagNameTextView.setText(flagName); | |
171 | - } | |
172 | - } | |
173 | - } | |
174 | - | |
175 | - Log.v(LOG_TAG, "Bye"); | |
176 | - } | |
177 | - */ | |
178 | 118 | class IntentDetailListAdapter extends BaseAdapter |
179 | 119 | { |
180 | 120 |
@@ -187,7 +127,7 @@ public class IntentDetailActivity2 extends ListActivity | ||
187 | 127 | |
188 | 128 | public int getCount() |
189 | 129 | { |
190 | - return 7; | |
130 | + return 8; | |
191 | 131 | } |
192 | 132 | |
193 | 133 | public Object getItem(int position) |
@@ -213,6 +153,9 @@ public class IntentDetailActivity2 extends ListActivity | ||
213 | 153 | case POSITION_CATEGORIES: |
214 | 154 | result = targetIntent.getCategories(); |
215 | 155 | break; |
156 | + case POSITION_FLAGS: | |
157 | + result = targetIntent.getFlags(); | |
158 | + break; | |
216 | 159 | case POSITION_EXTRAS: |
217 | 160 | result = targetIntent.getExtras(); |
218 | 161 | break; |
@@ -245,6 +188,7 @@ public class IntentDetailActivity2 extends ListActivity | ||
245 | 188 | View dataTypeView = itemView.findViewById(R.id.intent_detail_item_data_type); |
246 | 189 | View categoriesView = itemView.findViewById(R.id.intent_detail_item_categories); |
247 | 190 | View extrasView = itemView.findViewById(R.id.intent_detail_item_extras); |
191 | + View flagsView = itemView.findViewById(R.id.intent_detail_item_flags); | |
248 | 192 | |
249 | 193 | nameView.setVisibility(View.GONE); |
250 | 194 | actionView.setVisibility(View.GONE); |
@@ -253,6 +197,7 @@ public class IntentDetailActivity2 extends ListActivity | ||
253 | 197 | dataTypeView.setVisibility(View.GONE); |
254 | 198 | categoriesView.setVisibility(View.GONE); |
255 | 199 | extrasView.setVisibility(View.GONE); |
200 | + flagsView.setVisibility(View.GONE); | |
256 | 201 | |
257 | 202 | Object item = getItem(position); |
258 | 203 | switch (position) |
@@ -313,31 +258,24 @@ public class IntentDetailActivity2 extends ListActivity | ||
313 | 258 | dataTypeView.setVisibility(View.VISIBLE); |
314 | 259 | break; |
315 | 260 | case POSITION_CATEGORIES: |
316 | - String categoriesText = null; | |
317 | 261 | if (item instanceof Set) |
318 | 262 | { |
319 | 263 | Set<String> categoriesSet = (Set<String>) item; |
320 | - StringBuilder buffer = new StringBuilder(); | |
321 | - for (String category : categoriesSet) | |
322 | - { | |
323 | - buffer.append(category); | |
324 | - buffer.append("\n"); | |
325 | - } | |
326 | - if (buffer.length() > 0) | |
327 | - { | |
328 | - buffer.delete(buffer.length() - 1, buffer.length()); | |
329 | - } | |
330 | - categoriesText = buffer.toString(); | |
264 | + bindCategories(categoriesView, categoriesSet); | |
331 | 265 | } |
332 | - TextView categoriesTextView = (TextView) categoriesView.findViewById(R.id.categories_textview); | |
333 | - categoriesTextView.setText(categoriesText); | |
334 | 266 | categoriesView.setVisibility(View.VISIBLE); |
335 | 267 | break; |
268 | + case POSITION_FLAGS: | |
269 | + if (item instanceof Integer) | |
270 | + { | |
271 | + bindFlags(flagsView, (Integer) item); | |
272 | + } | |
273 | + flagsView.setVisibility(View.VISIBLE); | |
274 | + break; | |
336 | 275 | case POSITION_EXTRAS: |
337 | 276 | if (item instanceof Bundle) |
338 | 277 | { |
339 | - LinearLayout extraContainer = (LinearLayout) extrasView.findViewById(R.id.extras_container); | |
340 | - bindExtras(extraContainer, (Bundle) item); | |
278 | + bindExtras(extrasView, (Bundle) item); | |
341 | 279 | } |
342 | 280 | extrasView.setVisibility(View.VISIBLE); |
343 | 281 | break; |
@@ -346,5 +284,121 @@ public class IntentDetailActivity2 extends ListActivity | ||
346 | 284 | Log.d(LOG_TAG, "Bye"); |
347 | 285 | return itemView; |
348 | 286 | } |
287 | + | |
288 | + private void bindCategories(View categoriesView, Set<String> categories) | |
289 | + { | |
290 | + Log.v(LOG_TAG, "Hello"); | |
291 | + Log.d(LOG_TAG, "categories => " + categories); | |
292 | + | |
293 | + LinearLayout categoriesContainer = (LinearLayout) categoriesView.findViewById(R.id.categories_container); | |
294 | + TextView noCategoryTextView = (TextView) categoriesView.findViewById(R.id.no_category_textview); | |
295 | + | |
296 | + if (categories != null && categories.size() > 0) | |
297 | + { | |
298 | + Log.d(LOG_TAG, "categories.size() => " + categories.size()); | |
299 | + categoriesContainer.removeAllViews(); | |
300 | + | |
301 | + for (String category : categories) | |
302 | + { | |
303 | + View categoryItem = inflater.inflate(R.layout.category_list_item, null); | |
304 | + TextView categoryTextView = (TextView) categoryItem.findViewById(R.id.category_textview); | |
305 | + Log.d(LOG_TAG, "categoryTextView=> " + categoryTextView); | |
306 | + categoryTextView.setText(category); | |
307 | + | |
308 | + categoriesContainer.addView(categoryItem); | |
309 | + } | |
310 | + | |
311 | + categoriesContainer.setVisibility(View.VISIBLE); | |
312 | + noCategoryTextView.setVisibility(View.GONE); | |
313 | + } | |
314 | + else | |
315 | + { | |
316 | + categoriesContainer.setVisibility(View.GONE); | |
317 | + noCategoryTextView.setVisibility(View.VISIBLE); | |
318 | + } | |
319 | + | |
320 | + Log.v(LOG_TAG, "Bye"); | |
321 | + } | |
322 | + | |
323 | + private void bindFlags(View flagsView, int flags) | |
324 | + { | |
325 | + Log.v(LOG_TAG, "Hello"); | |
326 | + | |
327 | + LinearLayout flagsContainer = (LinearLayout) flagsView.findViewById(R.id.flags_container); | |
328 | + TextView noFlagTextView = (TextView) flagsView.findViewById(R.id.no_flag_textview); | |
329 | + | |
330 | + Log.d(LOG_TAG, "flags => " + flags); | |
331 | + if (flags != 0) | |
332 | + { | |
333 | + flagsContainer.removeAllViews(); | |
334 | + | |
335 | + for (int i = 0; i < IntentFlags.FLAG_VALUES.length; i++) | |
336 | + { | |
337 | + int flagValue = IntentFlags.FLAG_VALUES[i]; | |
338 | + String flagName = IntentFlags.FLAG_NAMES[i]; | |
339 | + if ((flags & flagValue) != 0) | |
340 | + { | |
341 | + Log.d(LOG_TAG, "flag name => " + flagName); | |
342 | + View flagItemView = inflater.inflate(R.layout.flag_list_item, null); | |
343 | + TextView flagNameTextView = (TextView) flagItemView.findViewById(R.id.flag_name_textview); | |
344 | + flagNameTextView.setText(flagName); | |
345 | + | |
346 | + flagsContainer.addView(flagItemView); | |
347 | + } | |
348 | + } | |
349 | + | |
350 | + noFlagTextView.setVisibility(View.GONE); | |
351 | + flagsContainer.setVisibility(View.VISIBLE); | |
352 | + } | |
353 | + else | |
354 | + { | |
355 | + noFlagTextView.setVisibility(View.VISIBLE); | |
356 | + flagsContainer.setVisibility(View.GONE); | |
357 | + } | |
358 | + | |
359 | + Log.v(LOG_TAG, "Bye"); | |
360 | + } | |
361 | + | |
362 | + private void bindExtras(View extrasView, Bundle extras) | |
363 | + { | |
364 | + Log.v(LOG_TAG, "Hello"); | |
365 | + | |
366 | + LinearLayout extraContainer = (LinearLayout) extrasView.findViewById(R.id.extras_container); | |
367 | + TextView noExtraTextView = (TextView) extrasView.findViewById(R.id.no_extra_textview); | |
368 | + | |
369 | + Log.d(LOG_TAG, "extras => " + extras); | |
370 | + if (extras != null) | |
371 | + { | |
372 | + extraContainer.removeAllViews(); | |
373 | + | |
374 | + for (String key : extras.keySet()) | |
375 | + { | |
376 | + Object value = extras.get(key); | |
377 | + String type = value.getClass().getSimpleName(); | |
378 | + Log.d(LOG_TAG, "extra key => " + key); | |
379 | + Log.d(LOG_TAG, "extra value => " + value); | |
380 | + | |
381 | + View extraItem = inflater.inflate(R.layout.extra_list_item, null); | |
382 | + TextView keyTextView = (TextView) extraItem.findViewById(R.id.extra_key_textview); | |
383 | + TextView typeTextView = (TextView) extraItem.findViewById(R.id.extra_type_textview); | |
384 | + TextView valueTextView = (TextView) extraItem.findViewById(R.id.extra_value_textview); | |
385 | + | |
386 | + keyTextView.setText(key); | |
387 | + typeTextView.setText(type); | |
388 | + valueTextView.setText(value.toString()); | |
389 | + extraContainer.addView(extraItem); | |
390 | + } | |
391 | + | |
392 | + extraContainer.setVisibility(View.VISIBLE); | |
393 | + noExtraTextView.setVisibility(View.GONE); | |
394 | + } | |
395 | + else | |
396 | + { | |
397 | + extraContainer.setVisibility(View.GONE); | |
398 | + noExtraTextView.setVisibility(View.VISIBLE); | |
399 | + } | |
400 | + | |
401 | + Log.v(LOG_TAG, "Bye"); | |
402 | + } | |
349 | 403 | } |
350 | 404 | } |