am f6151b66: Merge "Fix #8185319 Need to put Android BidiFormatter into the Support Library" into jb-mr2-dev

* commit 'f6151b661a719a1c825043d277aea6834c079d8f':
  Fix #8185319 Need to put Android BidiFormatter into the Support Library
This commit is contained in:
Fabrice Di Meglio
2013-03-14 19:53:14 +00:00
committed by Android Git Automerger
4 changed files with 121 additions and 0 deletions

View File

@@ -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" />

View File

@@ -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>

View File

@@ -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>

View File

@@ -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);
}
}