diff options
| author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:16 -0800 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:16 -0800 |
| commit | d4aee0c0caa00aa02d4c50ed28151591ac0456b5 (patch) | |
| tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /apps/FontLab | |
| parent | d2f2b1d7b77d06bce8cf9340171cf6c25cd720c4 (diff) | |
| download | android_development-d4aee0c0caa00aa02d4c50ed28151591ac0456b5.tar.gz android_development-d4aee0c0caa00aa02d4c50ed28151591ac0456b5.tar.bz2 android_development-d4aee0c0caa00aa02d4c50ed28151591ac0456b5.zip | |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'apps/FontLab')
| -rw-r--r-- | apps/FontLab/Android.mk | 10 | ||||
| -rw-r--r-- | apps/FontLab/AndroidManifest.xml | 13 | ||||
| -rw-r--r-- | apps/FontLab/MODULE_LICENSE_APACHE2 | 0 | ||||
| -rw-r--r-- | apps/FontLab/NOTICE | 190 | ||||
| -rw-r--r-- | apps/FontLab/res/layout/font_lab.xml | 30 | ||||
| -rw-r--r-- | apps/FontLab/src/com/android/fontlab/BackgroundPicker.java | 77 | ||||
| -rw-r--r-- | apps/FontLab/src/com/android/fontlab/FontLab.java | 361 | ||||
| -rw-r--r-- | apps/FontLab/src/com/android/fontlab/FontPicker.java | 74 |
8 files changed, 0 insertions, 755 deletions
diff --git a/apps/FontLab/Android.mk b/apps/FontLab/Android.mk deleted file mode 100644 index 3cad52a4c..000000000 --- a/apps/FontLab/Android.mk +++ /dev/null @@ -1,10 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -LOCAL_SRC_FILES := $(call all-subdir-java-files) - -LOCAL_PACKAGE_NAME := FontLab - -include $(BUILD_PACKAGE) diff --git a/apps/FontLab/AndroidManifest.xml b/apps/FontLab/AndroidManifest.xml deleted file mode 100644 index ea961d539..000000000 --- a/apps/FontLab/AndroidManifest.xml +++ /dev/null @@ -1,13 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.fontlab"> - <application android:label="Font lab"> - <activity android:name="FontLab"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.DEFAULT" /> - <category android:name="android.intent.category.TEST" /> - </intent-filter> - </activity> - <activity android:name="BackgroundPicker"/> - <activity android:name="FontPicker"/> - </application> -</manifest> diff --git a/apps/FontLab/MODULE_LICENSE_APACHE2 b/apps/FontLab/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29bb..000000000 --- a/apps/FontLab/MODULE_LICENSE_APACHE2 +++ /dev/null diff --git a/apps/FontLab/NOTICE b/apps/FontLab/NOTICE deleted file mode 100644 index c5b1efa7a..000000000 --- a/apps/FontLab/NOTICE +++ /dev/null @@ -1,190 +0,0 @@ - - Copyright (c) 2005-2008, 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. - - 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. - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - diff --git a/apps/FontLab/res/layout/font_lab.xml b/apps/FontLab/res/layout/font_lab.xml deleted file mode 100644 index 1a79add49..000000000 --- a/apps/FontLab/res/layout/font_lab.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2007 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:id="@+id/content" - android:layout_width="fill_parent" android:layout_height="fill_parent" - android:orientation="vertical" - android:paddingLeft="4dip" android:paddingRight="4dip" - android:paddingTop="4dip" android:paddingBottom="4dip"> - - <TextView android:id="@+id/column1" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" - android:layout_marginBottom="8dip" /> - <TextView android:id="@+id/column2" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" /> - -</LinearLayout> - - diff --git a/apps/FontLab/src/com/android/fontlab/BackgroundPicker.java b/apps/FontLab/src/com/android/fontlab/BackgroundPicker.java deleted file mode 100644 index e23ac82d8..000000000 --- a/apps/FontLab/src/com/android/fontlab/BackgroundPicker.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2007 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.fontlab; - -import java.util.ArrayList; -import java.util.List; - -import android.app.ListActivity; -import android.content.Intent; -import android.os.Bundle; -import android.view.View; -import android.widget.ListView; -import android.widget.SimpleAdapter; - - -public abstract class BackgroundPicker extends ListActivity -{ - - public void onCreate(Bundle icicle) - { - super.onCreate(icicle); - - setListAdapter(new SimpleAdapter(this, - getData(), - android.R.layout.simple_list_item_1, - new String[] {"title"}, - new int[] {android.R.id.text1})); - } - - protected List getData() - { - List myData = new ArrayList<Bundle>(); - addItem(myData, "Solid White", 0, 0xFFFFFFFF, 0xFF000000); - addItem(myData, "Solid Light Gray", 0, 0xFFBFBFBF, 0xFF000000); - addItem(myData, "Solid Dark Gray", 0, 0xFF404040, 0xFFFFFFFF); - addItem(myData, "Solid Black", 0, 0xFF000000, 0xFFFFFFFF); - addItem(myData, "Solid Blue", 0, 0xFF1a387a, 0xFFFFFFFF); - addItem(myData, "Textured White", 0, 0, 0xFF000000); - // addItem(myData, "Textured Blue", android.R.drawable.screen_background_blue, 0, 0xFFFFFFFF); - - return myData; - } - - protected void addItem(List<Bundle> data, String name, int textureRes, int bgColor, int textColor) - { - Bundle temp = new Bundle(); - temp.putString("title", name); - if (textureRes != 0) { - temp.putInt("texture", textureRes); - } - temp.putInt("bgcolor", bgColor); - temp.putInt("text", textColor); - data.add(temp); - } - - protected void onListItemClick(ListView l, View v, int position, long id) - { - Bundle map = (Bundle) l.getItemAtPosition(position); - setResult(RESULT_OK, (new Intent()).putExtras(map)); - finish(); - } - -} diff --git a/apps/FontLab/src/com/android/fontlab/FontLab.java b/apps/FontLab/src/com/android/fontlab/FontLab.java deleted file mode 100644 index 27f2d4c42..000000000 --- a/apps/FontLab/src/com/android/fontlab/FontLab.java +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright (C) 2007 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.fontlab; - -import java.util.Map; - -import android.app.Activity; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Typeface; -import android.graphics.drawable.PaintDrawable; -import android.os.Bundle; -import android.view.KeyEvent; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.TextView; - -class FontLab extends Activity -{ - private static final int MIN_SIZE = 1; - private static final int MAX_SIZE = 60; - - private static final float SCALE_X_RANGE = 20; - private static final int MAX_SCALE_X = 20; - private static final int MIN_SCALE_X = -19; // -20 would make zero-scale - - private static final String[] sText = { - "Applications Contacts Maps Google Browser Text messages Address book" - + " Development Earth Quake Settings Voicemail Zoolander. Four score" - + " and seven years ago our fathers brought forth on this continent, a" - + " new nation, conceived in Liberty, and dedicated to the proposition" - + " that all men are created equal. Now we are engaged in a great civil" - + " war, testing whether that nation, or any nation so conceived and so" - + " dedicated, can long endure. We are met on a great battle-field of" - + " that war. We have come to dedicate a portion of that field, as a" - + " final resting place for those who here gave their lives that that" - + " nation might live. It is altogether fitting and proper that we" - + " should do this. But, in a larger sense, we can not dedicate - we" - + " can not consecrate - we can not hallow - this ground. The brave" - + " men, living and dead, who struggled here, have consecrated it, far" - + " above our poor power to add or detract. The world will little note," - + " nor long remember what we say here, but it can never forget what" - + " they did here. It is for us the living, rather, to be dedicated" - + " here to the unfinished work which they who fought here have thus" - + " far so nobly advanced. It is rather for us to be here dedicated to" - + " the great task remaining before us - that from these honored dead" - + " we take increased devotion to that cause for which they gave the" - + " last full measure of devotion - that we here highly resolve that" - + " these dead shall not have died in vain - that this nation, under" - + " God, shall have a new birth of freedom - and that government of the" - + " people, by the people, for the people, shall not perish from the" - + " earth." - , - "A Spanish doctor on Tuesday stood by his opinion that Fidel Castro is recovering from stomach surgery despite a newspaper report stating the Cuban leader is in a serious condition after a number of failed operations." - + " When Senator Wayne Allard, Republican of Colorado, announced Monday that he would not seek re-election, the uphill battle for his party to reclaim the Senate in 2008 became an even steeper climb." - + " Naomi Campbell was today sentenced to five days' community service and ordered to attend an anger management course after she admitted throwing a mobile phone at her maid." - , - "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*()-_=+[]\\{}|;':\",./<>?" - , - "HaH HbH HcH HdH HeH HfH HgH HhH HiH HjH HkH HlH HmH HnH HoH HpH HqH HrH HsH HtH HuH HvH HwH HxH HyH HzH" - + "HAH HBH HCH HDH HEH HFH HGH HHH HIH HJH HKH HLH HMH HNH HOH HPH HQH HRH HSH HTH HUH HVH HWH HXH HYH HZH" - }; - - private void updateText() { - mTextIndex %= sText.length; - String s = sText[mTextIndex]; - mColumn1.setText(s); - mColumn2.setText(s); - } - - public FontLab() {} - - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - setContentView(R.layout.font_lab); - - mColumn1 = (TextView)findViewById(R.id.column1); - mColumn2 = (TextView)findViewById(R.id.column2); - mContentView = findViewById(R.id.content); - - - mColumn1.setTextSize(mFontSize); - mColumn2.setTextSize(mFontSize); - - mColumn1.setTextColor(Color.BLACK); - mColumn1.setBackgroundDrawable(new PaintDrawable(Color.WHITE)); - mColumn2.setTextColor(Color.WHITE); - mColumn2.setBackgroundDrawable(new PaintDrawable(Color.BLACK)); - - refreshFont(); - updateTitle(); - updateText(); - - setDefaultKeyMode(Activity.DEFAULT_KEYS_SHORTCUT); - } - - private void updateTitle() { - Typeface tf = mColumn1.getTypeface(); - String title = " ps=" + mFontSize + " scaleX=" - + (1 + mTextScaleXDelta/SCALE_X_RANGE) - + " gamma=" + (mGamma/20.f) - + " " + sTypefaceName[mFontIndex] - + " " + sStyleName[tf.getStyle()] - ; - setTitle(title); - } - - /** Called when it is time to initialize the activity state. */ - protected void onRestoreInstanceState(Bundle state) { - super.onRestoreInstanceState(state); - } - - protected void onResume() { - super.onResume(); - } - - private static final String sStyleName[] = { - "Regular", "Bold", "Italic", "Bold Italic" - }; - private static final String sTypefaceName[] = { - "Droid Sans", - "Droid Serif", - "Droid Mono" - }; - private static final Typeface sTypeface[] = { - Typeface.SANS_SERIF, - Typeface.SERIF, - Typeface.MONOSPACE - }; - private static final int FONT_INDEX_SANS = 0; // index into sTypeface - private static final int FONT_INDEX_SERIF = 1; // index into sTypeface - private static final int FONT_INDEX_MONO = 2; // index into sTypeface - - private static boolean canSupportStyle(Typeface tf, int styleBits) { - tf = Typeface.create(tf, styleBits); - return (tf.getStyle() & styleBits) == styleBits; - } - - private void refreshFont() { - Typeface tf = Typeface.create(sTypeface[mFontIndex], mFontStyle); - mColumn1.setTypeface(tf); - mColumn2.setTypeface(tf); - updateTitle(); - } - - private MenuItem.OnMenuItemClickListener mFontClickListener = new MenuItem.OnMenuItemClickListener() { - public boolean onMenuItemClick(MenuItem item) { - mFontIndex = item.getItemId(); - refreshFont(); - return true; - } - }; - - private void addFontMenu(Menu menu, int index) { - MenuItem item = menu.add(0, index, 0, sTypefaceName[index]); - item.setCheckable(true); - item.setOnMenuItemClickListener(mFontClickListener); - item.setChecked(index == mFontIndex); - } - - private MenuItem.OnMenuItemClickListener mStyleClickListener = new MenuItem.OnMenuItemClickListener() { - public boolean onMenuItemClick(MenuItem item) { - mFontStyle = mFontStyle ^ item.getItemId(); - refreshFont(); - return true; - } - }; - - private void addStyleMenu(Menu menu, int style, char shortCut) { - MenuItem item = menu.add(0, style, 0, (style == Typeface.BOLD) ? "Bold" : "Italic"); - item.setCheckable(true); - item.setOnMenuItemClickListener(mStyleClickListener); - item.setChecked((mFontStyle & style) != 0); - - item.setVisible(canSupportStyle(sTypeface[mFontIndex], style)); - if (shortCut != 0) { - item.setAlphabeticShortcut(shortCut); - } - } - - private MenuItem.OnMenuItemClickListener mFlagClickListener = new MenuItem.OnMenuItemClickListener() { - public boolean onMenuItemClick(MenuItem item) { - int mask = item.getItemId(); - mColumn1.setPaintFlags(mColumn1.getPaintFlags() ^ mask); - mColumn2.setPaintFlags(mColumn2.getPaintFlags() ^ mask); - return true; - } - }; - - private - void addFlagMenu(Menu menu, int paintFlag, String label, char shortCut) { - MenuItem item = menu.add(0, paintFlag, 0, label); - item.setCheckable(true); - item.setOnMenuItemClickListener(mFlagClickListener); - item.setChecked((mColumn1.getPaintFlags() & paintFlag) != 0); - if (shortCut != 0) { - item.setAlphabeticShortcut(shortCut); - } - } - - private static void addListenerMenu(MenuItem item, - MenuItem.OnMenuItemClickListener listener, - char keyChar) { - item.setOnMenuItemClickListener(listener); - if (keyChar != '\0') { - item.setAlphabeticShortcut(keyChar); - } - } - - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - return true; - } - - @Override public boolean onPrepareOptionsMenu(Menu menu) { - super.onPrepareOptionsMenu(menu); - menu.clear(); - - addFontMenu(menu, FONT_INDEX_SANS); - addFontMenu(menu, FONT_INDEX_SERIF); - addFontMenu(menu, FONT_INDEX_MONO); - addStyleMenu(menu, Typeface.BOLD, 'b'); - addStyleMenu(menu, Typeface.ITALIC, 'i'); - addFlagMenu(menu, Paint.DEV_KERN_TEXT_FLAG, "DevKern", 'k'); - menu.add(0, 0, 0, "Text").setOnMenuItemClickListener(mTextCallback).setAlphabeticShortcut('t'); - - return true; - } - - protected void onActivityResult(int requestCode, int resultCode, - String data, Map extras) { - if (resultCode == RESULT_OK) { - switch (requestCode) { - case BACKGROUND_PICKED: - { - int color = ((Integer)extras.get("text")).intValue(); - mColumn1.setTextColor(color); - mColumn2.setTextColor(color); - - int colorTranslucent = (color & 0x00FFFFFF) + 0x77000000; - - setTitleColor(color); - - Integer texture = (Integer)extras.get("texture"); - if (texture != null) { - mContentView.setBackgroundResource(texture.intValue()); - } else { - color = ((Integer)extras.get("bgcolor")).intValue(); - mContentView.setBackgroundColor(color); - } - } - break; - } - } - } - - @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - int size = mFontSize; - int scaleX = mTextScaleXDelta; - - switch (keyCode) { - case KeyEvent.KEYCODE_DPAD_DOWN: - size -= 1; - break; - case KeyEvent.KEYCODE_DPAD_UP: - size += 1; - break; - case KeyEvent.KEYCODE_DPAD_RIGHT: - scaleX += 1; - break; - case KeyEvent.KEYCODE_DPAD_LEFT: - scaleX -= 1; - break; - /* - case KeyEvent.KEYCODE_U: - changeGamma(1); - return true; - case KeyEvent.KEYCODE_D: - changeGamma(-1); - return true; - */ - default: - return super.onKeyDown(keyCode, event); - } - - size = Math.min(MAX_SIZE, Math.max(MIN_SIZE, size)); - if (size != mFontSize) { - mFontSize = size; - mColumn1.setTextSize(mFontSize); - mColumn2.setTextSize(mFontSize); - updateTitle(); - return true; - } - - scaleX = Math.min(MAX_SCALE_X, Math.max(MIN_SCALE_X, scaleX)); - if (scaleX != mTextScaleXDelta) { - mTextScaleXDelta = scaleX; - mColumn1.setTextScaleX(1 + scaleX / SCALE_X_RANGE); - mColumn2.setTextScaleX(1 + scaleX / SCALE_X_RANGE); - updateTitle(); - return true; - } - - return super.onKeyDown(keyCode, event); - } - - private int mGamma = 28; // current default is 1.4 (* 20) - private void changeGamma(int delta) { - int gamma = Math.min(100, Math.max(1, mGamma + delta)); - if (gamma != mGamma) { - mGamma = gamma; - updateTitle(); -// Paint.setTextGamma(mGamma / 20.f); - mContentView.invalidate(); - android.util.Log.d("skia", "setTextGamma " + mGamma); - } - } - - private void setFont(TextView t, TextView f, Map extras) { - int style = ((Integer)extras.get("style")).intValue(); - String font = (String)extras.get("font"); - t.setTypeface(Typeface.create(font, style)); - - f.setText((String)extras.get("title")); - } - - MenuItem.OnMenuItemClickListener mTextCallback = new MenuItem.OnMenuItemClickListener() { - public boolean onMenuItemClick(MenuItem item) { - mTextIndex += 1; - updateText(); - return true; - } - }; - - private static final int BACKGROUND_PICKED = 1; - - private TextView mColumn1; - private TextView mColumn2; - private View mContentView; - private int mFontIndex = FONT_INDEX_SANS; - private int mFontStyle = Typeface.NORMAL; - private int mFontSize = 18; - private int mTextIndex; - private int mTextScaleXDelta; -} - diff --git a/apps/FontLab/src/com/android/fontlab/FontPicker.java b/apps/FontLab/src/com/android/fontlab/FontPicker.java deleted file mode 100644 index 7f4fdb672..000000000 --- a/apps/FontLab/src/com/android/fontlab/FontPicker.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2007 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.fontlab; - -import java.util.ArrayList; -import java.util.List; - -import android.app.ListActivity; -import android.content.Intent; -import android.graphics.Typeface; -import android.os.Bundle; -import android.view.View; -import android.widget.ListView; -import android.widget.SimpleAdapter; - - -public abstract class FontPicker extends ListActivity -{ - - public void onCreate(Bundle icicle) - { - super.onCreate(icicle); - - setListAdapter(new SimpleAdapter(this, - getData(), - android.R.layout.simple_list_item_1, - new String[] {"title"}, - new int[] {android.R.id.text1})); - } - - protected List getData() - { - List myData = new ArrayList<Bundle>(7); - addItem(myData, "Sans", "sans-serif", Typeface.NORMAL); - addItem(myData, "Sans Bold", "sans-serif", Typeface.BOLD); - addItem(myData, "Serif", "serif", Typeface.NORMAL); - addItem(myData, "Serif Bold", "serif", Typeface.BOLD); - addItem(myData, "Serif Italic", "serif", Typeface.ITALIC); - addItem(myData, "Serif Bold Italic", "serif", Typeface.BOLD_ITALIC); - addItem(myData, "Mono", "monospace", Typeface.NORMAL); - return myData; - } - - protected void addItem(List<Bundle> data, String name, String fontName, int style) - { - Bundle temp = new Bundle(); - temp.putString("title", name); - temp.putString("font", fontName); - temp.putInt("style", style); - data.add(temp); - } - - protected void onListItemClick(ListView l, View v, int position, long id) - { - Bundle map = (Bundle) l.getItemAtPosition(position); - setResult(RESULT_OK, (new Intent()).putExtras(map)); - finish(); - } - -} |
