Create a one-time, first-run about activity that
Ben Komalo [Mon, 1 Nov 2010 17:47:30 +0000 (10:47 -0700)]
introduces the concept of NFC and tags.

Change-Id: I4425ed36c87a71b38e88b0aa2280b22cfd81bcf4

AndroidManifest.xml
res/drawable-hdpi/panel_background.9.png [new file with mode: 0644]
res/drawable-hdpi/tag_scan_illustration.png [new file with mode: 0644]
res/drawable-mdpi/panel_background.9.png [new file with mode: 0644]
res/drawable-mdpi/tag_scan_illustration.png [new file with mode: 0644]
res/layout/intro_to_nfc.xml [new file with mode: 0644]
res/values/strings.xml
res/values/styles.xml
src/com/android/apps/tag/AboutActivity.java [new file with mode: 0644]
src/com/android/apps/tag/TagBrowserActivity.java

index dd3c84a..6386f18 100644 (file)
             </intent-filter>
         </activity>
 
+        <activity android:name="AboutActivity"
+            android:label=""
+            android:theme="@style/AboutTheme"
+            android:launchMode="singleTop"
+            android:screenOrientation="portrait"
+        />
+
         <service android:name="TagService" />
 
         <provider android:name=".provider.TagProvider"
diff --git a/res/drawable-hdpi/panel_background.9.png b/res/drawable-hdpi/panel_background.9.png
new file mode 100644 (file)
index 0000000..55d8e4b
Binary files /dev/null and b/res/drawable-hdpi/panel_background.9.png differ
diff --git a/res/drawable-hdpi/tag_scan_illustration.png b/res/drawable-hdpi/tag_scan_illustration.png
new file mode 100644 (file)
index 0000000..4315994
Binary files /dev/null and b/res/drawable-hdpi/tag_scan_illustration.png differ
diff --git a/res/drawable-mdpi/panel_background.9.png b/res/drawable-mdpi/panel_background.9.png
new file mode 100644 (file)
index 0000000..822b6c6
Binary files /dev/null and b/res/drawable-mdpi/panel_background.9.png differ
diff --git a/res/drawable-mdpi/tag_scan_illustration.png b/res/drawable-mdpi/tag_scan_illustration.png
new file mode 100644 (file)
index 0000000..2c48f52
Binary files /dev/null and b/res/drawable-mdpi/tag_scan_illustration.png differ
diff --git a/res/layout/intro_to_nfc.xml b/res/layout/intro_to_nfc.xml
new file mode 100644 (file)
index 0000000..be893a4
--- /dev/null
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Copyright (C) 2010 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+>
+
+    <TextView
+        android:text="@string/intro_title"
+        android:padding="4dip"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:gravity="center"
+    />
+
+    <!-- TODO: make the layout more flexible instead of a fixed size. -->
+    <ScrollView
+        android:layout_weight="1"
+        android:layout_width="280dip"
+        android:layout_height="355dip"
+    >
+        <FrameLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+        >
+            <LinearLayout
+                android:id="@+id/page_1"
+                style="@style/about_page"
+                android:orientation="vertical"
+            >
+                <TextView
+                    android:text="@string/intro_text_about"
+                    style="@style/about_text"
+                />
+
+                <ImageView
+                    android:src="@drawable/tag_scan_illustration"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center_horizontal"
+                />
+
+                <TextView
+                    android:text="@string/intro_text_usage"
+                    style="@style/about_text"
+                />
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/page_2"
+                style="@style/about_page"
+                android:orientation="vertical"
+            >
+                <TextView
+                    android:text="@string/intro_text_contents"
+                    style="@style/about_text"
+                    android:layout_marginBottom="16dip"
+                />
+
+                <TextView
+                    android:text="@string/intro_text_more"
+                    style="@style/about_text"
+                    android:layout_marginBottom="16dip"
+                />
+
+                <TextView
+                    android:text="@string/intro_text_more2"
+                    style="@style/about_text"
+                />
+            </LinearLayout>
+
+        </FrameLayout>
+    </ScrollView>
+
+    <LinearLayout
+        android:padding="4dip"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+    >
+
+        <Button
+            android:id="@+id/back"
+            android:text="@string/back"
+            android:layout_width="0dip"
+            android:layout_height="match_parent"
+            android:layout_weight="0.5"
+        />
+
+        <Button
+            android:id="@+id/next"
+            android:text="@string/next"
+            android:layout_width="0dip"
+            android:layout_height="match_parent"
+            android:layout_weight="0.5"
+        />
+    </LinearLayout>
+
+</LinearLayout>
index 8540df5..f9e763b 100644 (file)
     <!-- Description string for vCard messages -->
     <string name="vcard_title">Contact info for ^1</string>
 
+    <!-- Button label for going next in the introductory tutorial -->
+    <string name="next">Next</string>
+
+    <!-- Button label for going back in the introductory tutorial -->
+    <string name="back">Back</string>
+
+    <!-- Button label for going closing introductory tutorial -->
+    <string name="close">Close</string>
+
+    <!-- Title for the introductory dialog. -->
+    <string name="intro_title">About Tags</string>
+
+    <!-- Text blurb for describing the app in an introductory flow. [CHAR LIMIT=160] -->
+    <string name="intro_text_about">Tags is for organizing and sharing Near Field Communication (NFC) tags.</string>
+
+    <!-- Text blurb for describing usage of the app in an introductory flow. [CHAR LIMIT=120]-->
+    <string name="intro_text_usage">You scan a tag by turning on your phone and placing it right next to a tag.</string>
+
+    <!-- Text blurb for describing tag contents in an introductory flow. [CHAR LIMIT=240]-->
+    <string name="intro_text_contents">NFC tags can contain text, URLs, pictures, and other kinds of information.</string>
+
+    <!-- Text blurb for more information an introductory flow. [CHAR LIMIT=120]-->
+    <string name="intro_text_more">To scan or share tags, you must have NFC turned on (in Settings, under Wireless &amp;
+Networks).</string>
+
+    <!-- Text blurb for more information an introductory flow. [CHAR LIMIT=120]-->
+    <string name="intro_text_more2">For more information, press Menu and touch Help on any Tags screen.</string>
+
 </resources>
index 4e3a67b..c41d85c 100644 (file)
 <resources>
 
     <style name="record_title">
-        <item name="android:layout_marginBottom">4dip</item>
         <item name="android:layout_width">match_parent</item>
         <item name="android:layout_height">wrap_content</item>
         <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
     </style>
 
+    <style name="about_page">
+        <item name="android:background">?android:attr/colorBackground</item>
+        <item name="android:padding">16dip</item>
+        <item name="android:layout_width">match_parent</item>
+        <item name="android:layout_height">match_parent</item>
+    </style>
+
+    <style name="about_text">
+        <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
+        <item name="android:textColor">?android:attr/colorForeground</item>
+        <item name="android:layout_width">match_parent</item>
+        <item name="android:layout_height">wrap_content</item>
+    </style>
+
+    <style name="AboutTheme" parent="@android:style/Theme.Light">
+        <item name="android:windowNoTitle">true</item>
+        <item name="android:windowFrame">@null</item>
+        <item name="android:windowIsFloating">true</item>
+        <item name="android:windowContentOverlay">@null</item>
+        <item name="android:windowBackground">@drawable/panel_background</item>
+    </style>
+
 </resources>
diff --git a/src/com/android/apps/tag/AboutActivity.java b/src/com/android/apps/tag/AboutActivity.java
new file mode 100644 (file)
index 0000000..468b77f
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.apps.tag;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+
+/**
+ * Dialog with introductory text blurbs and pictures explaining NFC.
+ */
+public class AboutActivity extends Activity implements OnClickListener {
+
+    private int mPage;
+    private View[] mPageContainers;
+    private Button mBack;
+    private Button mNext;
+
+    @Override
+    protected void onCreate(Bundle savedInstance) {
+        super.onCreate(savedInstance);
+
+        LayoutInflater inflater = LayoutInflater.from(this);
+        setContentView(inflater.inflate(R.layout.intro_to_nfc, null));
+
+        mPageContainers = new View[2];
+        mPageContainers[0] = findViewById(R.id.page_1);
+        mPageContainers[1] = findViewById(R.id.page_2);
+
+        mBack = (Button) findViewById(R.id.back);
+        mNext = (Button) findViewById(R.id.next);
+
+        mBack.setOnClickListener(this);
+        mNext.setOnClickListener(this);
+
+        mPage = -1;
+        navigate(0);
+    }
+
+    private void navigate(int page) {
+        if (mPage == page) {
+            return;
+        }
+
+        if (page >= mPageContainers.length) {
+            finish();
+            return;
+        }
+
+        mPage = page;
+        for (int i = 0, len = mPageContainers.length; i < len; i++) {
+            View view = mPageContainers[i];
+            view.setVisibility((i == page) ? View.VISIBLE : View.GONE);
+        }
+
+        mBack.setEnabled((mPage == 0) ? false : true);
+
+        if (mPage < mPageContainers.length - 1) {
+            mNext.setText(getResources().getString(R.string.next));
+        } else {
+            mNext.setText(getResources().getString(R.string.close));
+        }
+    }
+
+    @Override
+    public void onClick(View view) {
+        if (view == mBack) {
+            navigate(mPage - 1);
+        } else if (view == mNext) {
+            navigate(mPage + 1);
+        }
+    }
+}
index 67053b2..6df1567 100644 (file)
@@ -38,6 +38,7 @@ import android.widget.TabHost;
 public class TagBrowserActivity extends TabActivity implements DialogInterface.OnClickListener {
 
     private static final int DIALOG_NFC_OFF = 1;
+    private static final String PREF_KEY_SHOW_INTRO = "showintro";
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -63,6 +64,13 @@ public class TagBrowserActivity extends TabActivity implements DialogInterface.O
                 .setIndicator(getText(R.string.tab_my_tag),
                         res.getDrawable(R.drawable.ic_tab_my_tag))
                 .setContent(new Intent().setClass(this, MyTagActivity.class)));
+
+        SharedPreferences preferences = getPreferences(Context.MODE_PRIVATE);
+        if (!preferences.getBoolean(PREF_KEY_SHOW_INTRO, false)) {
+            preferences.edit().putBoolean(PREF_KEY_SHOW_INTRO, true).apply();
+            Intent intent = new Intent(this, AboutActivity.class);
+            startActivity(intent);
+        }
     }
 
     @Override