Fix #8185319 Need to put Android BidiFormatter into the Support Library

- add demo into Support4Demos

Change-Id: I041144510c907dd1639ea56c45321486d86fe859
diff --git a/samples/Support4Demos/AndroidManifest.xml b/samples/Support4Demos/AndroidManifest.xml
index 603093f..0230348 100644
--- a/samples/Support4Demos/AndroidManifest.xml
+++ b/samples/Support4Demos/AndroidManifest.xml
@@ -276,6 +276,14 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".text.BidiFormatterSupport"
+                  android:label="@string/bidiformatter_support_title">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.example.android.supportv4.SUPPORT4_SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
         <provider android:authorities="com.example.supportv4.content.sharingsupportprovider"
                   android:name=".content.SharingSupportProvider" />
 
diff --git a/samples/Support4Demos/res/layout/bidiformater_support.xml b/samples/Support4Demos/res/layout/bidiformater_support.xml
new file mode 100644
index 0000000..92f4ae0
--- /dev/null
+++ b/samples/Support4Demos/res/layout/bidiformater_support.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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:padding="16dp"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent">
+
+    <LinearLayout android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content">
+
+        <TextView android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/without_bidiformatter"
+                 />
+
+        <TextView android:id="@+id/textview_without_bidiformatter"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:textSize="24dip"
+                 />
+
+    </LinearLayout>
+
+    <LinearLayout android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content">
+
+        <TextView android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/with_bidiformatter"
+                />
+
+        <TextView android:id="@+id/textview_with_bidiformatter"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:textSize="24dip"
+                  />
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/samples/Support4Demos/res/values/strings.xml b/samples/Support4Demos/res/values/strings.xml
index 4882f76..3a58835 100644
--- a/samples/Support4Demos/res/values/strings.xml
+++ b/samples/Support4Demos/res/values/strings.xml
@@ -149,4 +149,9 @@
     <string name="sample_media_route_provider_service">Media Route Provider Service Support Library Sample</string>
     <string name="fixed_volume_route_name">Fixed Volume Remote Playback Route</string>
     <string name="variable_volume_route_name">Variable Volume Remote Playback Route</string>
+
+    <string name="without_bidiformatter">Without BidiFormatter:</string>
+    <string name="with_bidiformatter">With BidiFormatter:</string>
+    <string name="bidiformatter_support_title">BidiFormatter Demo</string>
+
 </resources>
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/text/BidiFormatterSupport.java b/samples/Support4Demos/src/com/example/android/supportv4/text/BidiFormatterSupport.java
new file mode 100644
index 0000000..07c874f
--- /dev/null
+++ b/samples/Support4Demos/src/com/example/android/supportv4/text/BidiFormatterSupport.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2013 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.example.android.supportv4.text;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+import android.support.v4.text.bidi.BidiFormatter;
+import android.widget.TextView;
+import com.example.android.supportv4.R;
+
+/**
+ * This example illustrates a common usage of the BidiFormatter in the Android support library.
+ */
+public class BidiFormatterSupport extends Activity {
+
+    private static String text = "%s הוא עסוק";
+    private static String phone = "+1 650 253 0000";
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.bidiformater_support);
+
+        String formattedText = String.format(text, phone);
+
+        TextView tv_sample = (TextView) findViewById(R.id.textview_without_bidiformatter);
+        tv_sample.setText(formattedText);
+
+        TextView tv_bidiformatter = (TextView) findViewById(R.id.textview_with_bidiformatter);
+        String wrappedPhone = BidiFormatter.getInstance(true /* rtlContext */).unicodeWrap(phone);
+        formattedText = String.format(text, wrappedPhone);
+        tv_bidiformatter.setText(formattedText);
+    }
+}