diff options
| author | Scott Main <smain@google.com> | 2011-12-12 14:27:23 -0800 |
|---|---|---|
| committer | Scott Main <smain@google.com> | 2011-12-12 16:28:27 -0800 |
| commit | 442088151c335ce8047183b76a8b8a4a2109ba12 (patch) | |
| tree | ecf365d5d188d97c7673f70d7f449e4eb5f3a578 /samples | |
| parent | 4ea24bff40770c987add689970c64cf63077dd3f (diff) | |
| download | android_development-442088151c335ce8047183b76a8b8a4a2109ba12.tar.gz android_development-442088151c335ce8047183b76a8b8a4a2109ba12.tar.bz2 android_development-442088151c335ce8047183b76a8b8a4a2109ba12.zip | |
revisions to NewsReader sample app for AndroidU.
Clean up XML markup for clean rendering in HTML docs;
Change string resources for two-pane mode to bools;
Rename resource files w/ layout info from main.xml to layouts.xml.
Add support lib
Add HTML page
Change-Id: I88fc5cedb8f11dae9de019ba75593de2027de231
Diffstat (limited to 'samples')
16 files changed, 116 insertions, 66 deletions
diff --git a/samples/training/multiscreen/newsreader/AndroidManifest.xml b/samples/training/multiscreen/newsreader/AndroidManifest.xml index 04ddf292f..9d92ba606 100644 --- a/samples/training/multiscreen/newsreader/AndroidManifest.xml +++ b/samples/training/multiscreen/newsreader/AndroidManifest.xml @@ -19,6 +19,11 @@ android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="14" /> + <supports-screens + android:smallScreens="true" + android:normalScreens="true" + android:largeScreens="true" + android:xlargeScreens="true" /> <application android:icon="@drawable/icon" android:label="@string/app_name" android:logo="@drawable/logo" android:theme="@style/NewsReaderStyle"> @@ -31,10 +36,4 @@ <activity android:name=".ArticleActivity" android:theme="@style/NewsReaderStyle_NoActionBar" /> </application> - <supports-screens - android:smallScreens="true" - android:normalScreens="true" - android:largeScreens="true" - android:xlargeScreens="true" - /> </manifest> diff --git a/samples/training/multiscreen/newsreader/_index.html b/samples/training/multiscreen/newsreader/_index.html new file mode 100644 index 000000000..6ddaf6cfe --- /dev/null +++ b/samples/training/multiscreen/newsreader/_index.html @@ -0,0 +1,12 @@ +<p>A sample app demonstrating best practices to support multiple screen sizes and densities.</p> +<p>This sample is a companion to the Training class about <a +href="../../../training/multiscreen/index.html">Designing for Multiple +Screens</a>.</p> + +<p class="note"><strong>Note:</strong> This sample uses the Android Support Library. To build the +app, be sure to add the <code>libs/android-support-v4.jar</code> file to the project build path. In +Eclipse, right-click the JAR file in the Package Explorer and select <b>Build Path > Add to Build +Path</b>.</p> + + +<img alt="" src="../images/NewsReader.png" />
\ No newline at end of file diff --git a/samples/training/multiscreen/newsreader/libs/android-support-v4.jar b/samples/training/multiscreen/newsreader/libs/android-support-v4.jar Binary files differnew file mode 100644 index 000000000..b254ef5f3 --- /dev/null +++ b/samples/training/multiscreen/newsreader/libs/android-support-v4.jar diff --git a/samples/training/multiscreen/newsreader/res/layout/actionbar_list_item.xml b/samples/training/multiscreen/newsreader/res/layout/actionbar_list_item.xml index 452d16b29..6c860de68 100644 --- a/samples/training/multiscreen/newsreader/res/layout/actionbar_list_item.xml +++ b/samples/training/multiscreen/newsreader/res/layout/actionbar_list_item.xml @@ -14,11 +14,11 @@ limitations under the License. --> -<TextView - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textSize="14sp" - android:textColor="#01511a" - android:padding="5dp"> -</TextView> +<!-- BEGIN_INCLUDE(all) --> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textSize="14sp" + android:textColor="#01511a" + android:padding="5dp" /> +<!-- END_INCLUDE(all) --> diff --git a/samples/training/multiscreen/newsreader/res/layout/headline_item.xml b/samples/training/multiscreen/newsreader/res/layout/headline_item.xml index 980e43c4e..dc3fd5960 100644 --- a/samples/training/multiscreen/newsreader/res/layout/headline_item.xml +++ b/samples/training/multiscreen/newsreader/res/layout/headline_item.xml @@ -14,11 +14,11 @@ limitations under the License. --> -<TextView - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textSize="16sp" - android:textColor="#01511a" - android:padding="10dp"> -</TextView> +<!-- BEGIN_INCLUDE(all) --> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textSize="16sp" + android:textColor="#01511a" + android:padding="10dp" /> +<!-- END_INCLUDE(all) --> diff --git a/samples/training/multiscreen/newsreader/res/layout/onepane.xml b/samples/training/multiscreen/newsreader/res/layout/onepane.xml index 83eeb86a6..4198d2e78 100644 --- a/samples/training/multiscreen/newsreader/res/layout/onepane.xml +++ b/samples/training/multiscreen/newsreader/res/layout/onepane.xml @@ -14,14 +14,15 @@ limitations under the License. --> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <fragment android:id="@+id/headlines" android:layout_height="fill_parent" - android:name="com.example.android.newsreader.HeadlinesFragment" - android:layout_width="match_parent" /> +<!-- BEGIN_INCLUDE(all) --> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <fragment android:id="@+id/headlines" + android:layout_height="fill_parent" + android:name="com.example.android.newsreader.HeadlinesFragment" + android:layout_width="match_parent" /> </LinearLayout> +<!-- END_INCLUDE(all) --> diff --git a/samples/training/multiscreen/newsreader/res/layout/onepane_with_bar.xml b/samples/training/multiscreen/newsreader/res/layout/onepane_with_bar.xml index 0ff3a2465..4eb40163a 100644 --- a/samples/training/multiscreen/newsreader/res/layout/onepane_with_bar.xml +++ b/samples/training/multiscreen/newsreader/res/layout/onepane_with_bar.xml @@ -14,19 +14,37 @@ limitations under the License. --> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent"> - <LinearLayout android:layout_width="match_parent" android:id="@+id/linearLayout1" android:gravity="center" android:layout_height="50dp"> - <ImageView android:id="@+id/imageView1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/logo" android:paddingRight="30dp" android:layout_gravity="left" android:layout_weight="0"></ImageView> - <View android:layout_height="wrap_content" android:id="@+id/view1" android:layout_width="wrap_content" android:layout_weight="1"></View> - <Button android:id="@+id/categorybutton" android:text="one" android:background="@drawable/button_bg" android:layout_height="match_parent" android:layout_weight="0" android:layout_width="120dp" style="@style/CategoryButtonStyle"/> +<!-- BEGIN_INCLUDE(all) --> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <LinearLayout android:layout_width="match_parent" + android:id="@+id/linearLayout1" + android:gravity="center" + android:layout_height="50dp"> + <ImageView android:id="@+id/imageView1" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:src="@drawable/logo" + android:paddingRight="30dp" + android:layout_gravity="left" + android:layout_weight="0" /> + <View android:layout_height="wrap_content" + android:id="@+id/view1" + android:layout_width="wrap_content" + android:layout_weight="1" /> + <Button android:id="@+id/categorybutton" + android:background="@drawable/button_bg" + android:layout_height="match_parent" + android:layout_weight="0" + android:layout_width="120dp" + style="@style/CategoryButtonStyle"/> </LinearLayout> - <fragment android:id="@+id/headlines" android:layout_height="fill_parent" + <fragment android:id="@+id/headlines" + android:layout_height="fill_parent" android:name="com.example.android.newsreader.HeadlinesFragment" android:layout_width="match_parent" /> - </LinearLayout> +<!-- END_INCLUDE(all) --> diff --git a/samples/training/multiscreen/newsreader/res/layout/twopanes.xml b/samples/training/multiscreen/newsreader/res/layout/twopanes.xml index 96c958acf..624776c15 100644 --- a/samples/training/multiscreen/newsreader/res/layout/twopanes.xml +++ b/samples/training/multiscreen/newsreader/res/layout/twopanes.xml @@ -14,14 +14,19 @@ limitations under the License. --> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" android:orientation="horizontal"> - <fragment android:id="@+id/headlines" android:layout_height="fill_parent" +<!-- BEGIN_INCLUDE(all) --> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="horizontal"> + <fragment android:id="@+id/headlines" + android:layout_height="fill_parent" android:name="com.example.android.newsreader.HeadlinesFragment" - android:layout_width="400dp" android:layout_marginRight="10dp"/> - <fragment android:id="@+id/article" android:layout_height="fill_parent" + android:layout_width="400dp" + android:layout_marginRight="10dp"/> + <fragment android:id="@+id/article" + android:layout_height="fill_parent" android:name="com.example.android.newsreader.ArticleFragment" android:layout_width="fill_parent" /> </LinearLayout> +<!-- END_INCLUDE(all) --> diff --git a/samples/training/multiscreen/newsreader/res/layout/twopanes_narrow.xml b/samples/training/multiscreen/newsreader/res/layout/twopanes_narrow.xml index 98d951639..b44407176 100644 --- a/samples/training/multiscreen/newsreader/res/layout/twopanes_narrow.xml +++ b/samples/training/multiscreen/newsreader/res/layout/twopanes_narrow.xml @@ -14,14 +14,19 @@ limitations under the License. --> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent" android:orientation="horizontal"> - <fragment android:id="@+id/headlines" android:layout_height="fill_parent" +<!-- BEGIN_INCLUDE(all) --> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="horizontal"> + <fragment android:id="@+id/headlines" + android:layout_height="fill_parent" android:name="com.example.android.newsreader.HeadlinesFragment" - android:layout_width="200dp" android:layout_marginRight="10dp"/> - <fragment android:id="@+id/article" android:layout_height="fill_parent" + android:layout_width="200dp" + android:layout_marginRight="10dp"/> + <fragment android:id="@+id/article" + android:layout_height="fill_parent" android:name="com.example.android.newsreader.ArticleFragment" android:layout_width="fill_parent" /> </LinearLayout> +<!-- END_INCLUDE(all) --> diff --git a/samples/training/multiscreen/newsreader/res/values-sw600dp-land/main.xml b/samples/training/multiscreen/newsreader/res/values-sw600dp-land/layouts.xml index 85e596673..9a4dc8c23 100644 --- a/samples/training/multiscreen/newsreader/res/values-sw600dp-land/main.xml +++ b/samples/training/multiscreen/newsreader/res/values-sw600dp-land/layouts.xml @@ -14,7 +14,9 @@ limitations under the License. --> +<!-- BEGIN_INCLUDE(all) --> <resources> <item name="main_layout" type="layout">@layout/twopanes</item> - <string name="has_two_panes">true</string> + <bool name="has_two_panes">true</bool> </resources> +<!-- END_INCLUDE(all) --> diff --git a/samples/training/multiscreen/newsreader/res/values-sw600dp-port/main.xml b/samples/training/multiscreen/newsreader/res/values-sw600dp-port/layouts.xml index 4d032dd39..0db5cbb37 100644 --- a/samples/training/multiscreen/newsreader/res/values-sw600dp-port/main.xml +++ b/samples/training/multiscreen/newsreader/res/values-sw600dp-port/layouts.xml @@ -14,7 +14,9 @@ limitations under the License. --> +<!-- BEGIN_INCLUDE(all) --> <resources> <item name="main_layout" type="layout">@layout/onepane</item> - <string name="has_two_panes">false</string> + <bool name="has_two_panes">false</bool> </resources> +<!-- END_INCLUDE(all) --> diff --git a/samples/training/multiscreen/newsreader/res/values-v11/main.xml b/samples/training/multiscreen/newsreader/res/values-v11/layouts.xml index cb82bb820..0db5cbb37 100644 --- a/samples/training/multiscreen/newsreader/res/values-v11/main.xml +++ b/samples/training/multiscreen/newsreader/res/values-v11/layouts.xml @@ -14,6 +14,9 @@ limitations under the License. --> +<!-- BEGIN_INCLUDE(all) --> <resources> <item name="main_layout" type="layout">@layout/onepane</item> + <bool name="has_two_panes">false</bool> </resources> +<!-- END_INCLUDE(all) --> diff --git a/samples/training/multiscreen/newsreader/res/values-xlarge-land/main.xml b/samples/training/multiscreen/newsreader/res/values-xlarge-land/layouts.xml index 85e596673..9a4dc8c23 100644 --- a/samples/training/multiscreen/newsreader/res/values-xlarge-land/main.xml +++ b/samples/training/multiscreen/newsreader/res/values-xlarge-land/layouts.xml @@ -14,7 +14,9 @@ limitations under the License. --> +<!-- BEGIN_INCLUDE(all) --> <resources> <item name="main_layout" type="layout">@layout/twopanes</item> - <string name="has_two_panes">true</string> + <bool name="has_two_panes">true</bool> </resources> +<!-- END_INCLUDE(all) --> diff --git a/samples/training/multiscreen/newsreader/res/values-xlarge-port/main.xml b/samples/training/multiscreen/newsreader/res/values-xlarge-port/layouts.xml index 90e6a4a46..39c4645db 100644 --- a/samples/training/multiscreen/newsreader/res/values-xlarge-port/main.xml +++ b/samples/training/multiscreen/newsreader/res/values-xlarge-port/layouts.xml @@ -14,7 +14,9 @@ limitations under the License. --> +<!-- BEGIN_INCLUDE(all) --> <resources> <item name="main_layout" type="layout">@layout/twopanes_narrow</item> - <string name="has_two_panes">true</string> + <bool name="has_two_panes">true</bool> </resources> +<!-- END_INCLUDE(all) --> diff --git a/samples/training/multiscreen/newsreader/res/values/main.xml b/samples/training/multiscreen/newsreader/res/values/layouts.xml index c59876243..3f2cf5895 100644 --- a/samples/training/multiscreen/newsreader/res/values/main.xml +++ b/samples/training/multiscreen/newsreader/res/values/layouts.xml @@ -14,7 +14,9 @@ limitations under the License. --> +<!-- BEGIN_INCLUDE(all) --> <resources> <item name="main_layout" type="layout">@layout/onepane_with_bar</item> - <string name="has_two_panes">false</string> + <bool name="has_two_panes">false</bool> </resources> +<!-- END_INCLUDE(all) --> diff --git a/samples/training/multiscreen/newsreader/src/com/example/android/newsreader/ArticleActivity.java b/samples/training/multiscreen/newsreader/src/com/example/android/newsreader/ArticleActivity.java index 2aff79236..9e63c3f00 100644 --- a/samples/training/multiscreen/newsreader/src/com/example/android/newsreader/ArticleActivity.java +++ b/samples/training/multiscreen/newsreader/src/com/example/android/newsreader/ArticleActivity.java @@ -47,11 +47,8 @@ public class ArticleActivity extends FragmentActivity { mCatIndex = getIntent().getExtras().getInt("catIndex", 0); mArtIndex = getIntent().getExtras().getInt("artIndex", 0); - // If we are in two-pane layout mode and the device is in landscape orientation, we are - // no longer necessary - if (getResources().getString(R.string.has_two_panes).equals("true") && - getResources().getConfiguration().orientation == - Configuration.ORIENTATION_LANDSCAPE) { + // If we are in two-pane layout mode, this activity is no longer necessary + if (getResources().getBoolean(R.bool.has_two_panes)) { finish(); return; } |
