├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── README_cn.md ├── buildtool ├── README.md └── typescript │ ├── bin │ ├── tsc │ └── tsserver │ └── lib │ ├── lib.d.ts │ ├── lib.es6.d.ts │ ├── tsc.js │ ├── tsserver.js │ └── typescriptServices.js ├── dist ├── android-ui.d.ts ├── android-ui.es5.js ├── android-ui.es5.js.map └── android-ui.js ├── package.json └── src ├── android ├── R │ ├── anim.ts │ ├── attr.ts │ ├── color.ts │ ├── drawable.ts │ ├── id.ts │ ├── image.ts │ ├── image_base64.ts │ ├── interpolator.ts │ ├── layout.ts │ └── string.ts ├── app │ ├── ActionBar.ts │ ├── ActionBarActivity.ts │ ├── Activity.ts │ ├── ActivityThread.ts │ ├── AlertController.ts │ ├── AlertDialog.ts │ ├── Application.ts │ └── Dialog.ts ├── content │ ├── Context.ts │ ├── DialogInterface.ts │ ├── Intent.ts │ └── res │ │ ├── ColorStateList.ts │ │ ├── Resources.ts │ │ └── TypedArray.ts ├── database │ ├── DataSetObservable.ts │ ├── DataSetObserver.ts │ └── Observable.ts ├── graphics │ ├── Canvas.ts │ ├── Color.ts │ ├── Matrix.ts │ ├── Paint.ts │ ├── Path.ts │ ├── PixelFormat.ts │ ├── Point.ts │ ├── Rect.ts │ ├── RectF.ts │ └── drawable │ │ ├── Animatable.ts │ │ ├── AnimationDrawable.ts │ │ ├── ClipDrawable.ts │ │ ├── ClipRoundRectDrawable.ts │ │ ├── ColorDrawable.ts │ │ ├── Drawable.ts │ │ ├── DrawableContainer.ts │ │ ├── InsetDrawable.ts │ │ ├── LayerDrawable.ts │ │ ├── RotateDrawable.ts │ │ ├── RoundRectDrawable.ts │ │ ├── ScaleDrawable.ts │ │ ├── ScrollBarDrawable.ts │ │ ├── ShadowDrawable.ts │ │ └── StateListDrawable.ts ├── os │ ├── Bundle.ts │ ├── Handler.ts │ ├── Message.ts │ ├── MessageQueue.ts │ ├── SystemClock.ts │ └── Trace.ts ├── support │ └── v4 │ │ ├── view │ │ ├── PagerAdapter.ts │ │ └── ViewPager.ts │ │ └── widget │ │ ├── DrawerLayout.ts │ │ └── ViewDragHelper.ts ├── text │ ├── BoringLayout.ts │ ├── DynamicLayout.ts │ ├── InputType.ts │ ├── Layout.ts │ ├── MeasuredText.ts │ ├── PackedIntVector.ts │ ├── PackedObjectVector.ts │ ├── SpanSet.ts │ ├── SpanWatcher.ts │ ├── Spannable.ts │ ├── Spanned.ts │ ├── StaticLayout.ts │ ├── TextDirectionHeuristic.ts │ ├── TextDirectionHeuristics.ts │ ├── TextLine.ts │ ├── TextPaint.ts │ ├── TextUtils.ts │ ├── TextWatcher.ts │ ├── method │ │ ├── AllCapsTransformationMethod.ts │ │ ├── MovementMethod.ts │ │ ├── PasswordTransformationMethod.ts │ │ ├── ReplacementTransformationMethod.ts │ │ ├── SingleLineTransformationMethod.ts │ │ ├── TransformationMethod.ts │ │ └── TransformationMethod2.ts │ └── style │ │ ├── CharacterStyle.ts │ │ ├── LeadingMarginSpan.ts │ │ ├── LineBackgroundSpan.ts │ │ ├── LineHeightSpan.ts │ │ ├── MetricAffectingSpan.ts │ │ ├── ParagraphStyle.ts │ │ ├── ReplacementSpan.ts │ │ ├── TabStopSpan.ts │ │ ├── UpdateAppearance.ts │ │ ├── UpdateLayout.ts │ │ └── WrapTogetherSpan.ts ├── util │ ├── ArrayMap.ts │ ├── CopyOnWriteArray.ts │ ├── DisplayMetrics.ts │ ├── LayoutDirection.ts │ ├── Log.ts │ ├── LongSparseArray.ts │ ├── MathUtils.ts │ ├── Pools.ts │ ├── SparseArray.ts │ ├── SparseBooleanArray.ts │ ├── SparseMap.ts │ ├── StateSet.ts │ └── TypedValue.ts ├── view │ ├── FocusFinder.ts │ ├── GestureDetector.ts │ ├── Gravity.ts │ ├── HapticFeedbackConstants.ts │ ├── KeyEvent.ts │ ├── LayoutInflater.ts │ ├── Menu.ts │ ├── MenuItem.ts │ ├── MotionEvent.ts │ ├── ScaleGestureDetector.ts │ ├── SoundEffectConstants.ts │ ├── Surface.ts │ ├── TouchDelegate.ts │ ├── VelocityTracker.ts │ ├── View.ts │ ├── ViewConfiguration.ts │ ├── ViewGroup.ts │ ├── ViewOverlay.ts │ ├── ViewParent.ts │ ├── ViewRootImpl.ts │ ├── ViewTreeObserver.ts │ ├── Window.ts │ ├── WindowManager.ts │ ├── animation │ │ ├── AccelerateDecelerateInterpolator.ts │ │ ├── AccelerateInterpolator.ts │ │ ├── AlphaAnimation.ts │ │ ├── Animation.ts │ │ ├── AnimationSet.ts │ │ ├── AnimationUtils.ts │ │ ├── AnticipateInterpolator.ts │ │ ├── AnticipateOvershootInterpolator.ts │ │ ├── BounceInterpolator.ts │ │ ├── CycleInterpolator.ts │ │ ├── DecelerateInterpolator.ts │ │ ├── Interpolator.ts │ │ ├── LinearInterpolator.ts │ │ ├── OvershootInterpolator.ts │ │ ├── RotateAnimation.ts │ │ ├── ScaleAnimation.ts │ │ ├── Transformation.ts │ │ └── TranslateAnimation.ts │ └── menu │ │ └── MenuPopupHelper.ts ├── webkit │ ├── WebView.ts │ └── WebViewClient.ts └── widget │ ├── AbsListView.ts │ ├── AbsSeekBar.ts │ ├── AbsSpinner.ts │ ├── Adapter.ts │ ├── AdapterView.ts │ ├── ArrayAdapter.ts │ ├── BaseAdapter.ts │ ├── BaseExpandableListAdapter.ts │ ├── Button.ts │ ├── CheckBox.ts │ ├── Checkable.ts │ ├── CheckedTextView.ts │ ├── CompoundButton.ts │ ├── EditText.ts │ ├── ExpandableListAdapter.ts │ ├── ExpandableListConnector.ts │ ├── ExpandableListPosition.ts │ ├── ExpandableListView.ts │ ├── FrameLayout.ts │ ├── GridView.ts │ ├── HeaderViewListAdapter.ts │ ├── HeterogeneousExpandableList.ts │ ├── HorizontalScrollView.ts │ ├── ImageButton.ts │ ├── ImageView.ts │ ├── LinearLayout.ts │ ├── ListAdapter.ts │ ├── ListPopupWindow.ts │ ├── ListView.ts │ ├── NumberPicker.ts │ ├── OverScroller.ts │ ├── PopupWindow.ts │ ├── ProgressBar.ts │ ├── RadioButton.ts │ ├── RadioGroup.ts │ ├── RatingBar.ts │ ├── RelativeLayout.ts │ ├── ScrollView.ts │ ├── Scroller.ts │ ├── SeekBar.ts │ ├── Spinner.ts │ ├── SpinnerAdapter.ts │ ├── TextView.ts │ ├── Toast.ts │ └── WrapperListAdapter.ts ├── androidui ├── AndroidUI.ts ├── AndroidUIElement.ts ├── attr │ ├── AttrBinder.ts │ ├── AttrValueParser.ts │ ├── StateAttr.ts │ └── StateAttrList.ts ├── image │ ├── ChangeImageSizeDrawable.ts │ ├── NetDrawable.ts │ ├── NetImage.ts │ ├── NinePatchDrawable.ts │ └── RegionImageDrawable.ts ├── native │ ├── NativeApi.ts │ ├── NativeCanvas.ts │ ├── NativeEditText.ts │ ├── NativeHtmlView.ts │ ├── NativeImage.ts │ ├── NativeSurface.ts │ └── NativeWebView.ts ├── util │ ├── ArrayCreator.ts │ ├── ClassFinder.ts │ ├── Long.ts │ ├── NumberChecker.ts │ ├── PageStack.ts │ ├── PerformanceAdjuster.ts │ └── Platform.ts └── widget │ ├── HtmlBaseView.ts │ ├── HtmlDataAdapter.ts │ ├── HtmlDataListAdapter.ts │ ├── HtmlDataPagerAdapter.ts │ ├── HtmlDataPickerAdapter.ts │ ├── HtmlImageView.ts │ ├── HtmlView.ts │ ├── OverScrollLocker.ts │ └── PullRefreshLoadLayout.ts ├── build_sdk_res.js ├── insert_sdk_version_dist.js ├── java ├── lang │ ├── Comparable.ts │ ├── Float.ts │ ├── Integer.ts │ ├── Long.ts │ ├── Object.ts │ ├── Runnable.ts │ ├── StringBuilder.ts │ ├── System.ts │ ├── ref │ │ └── WeakReference.ts │ └── util │ │ └── concurrent │ │ └── CopyOnWriteArrayList.ts └── util │ ├── ArrayDeque.ts │ ├── ArrayList.ts │ ├── Arrays.ts │ ├── Collections.ts │ ├── Comparator.ts │ └── List.ts ├── lib ├── com │ └── jakewharton │ │ └── salvage │ │ └── RecyclingPagerAdapter.ts └── uk │ └── co │ └── senab │ └── photoview │ ├── GestureDetector.ts │ ├── IPhotoView.ts │ ├── PhotoView.ts │ └── PhotoViewAttacher.ts ├── pack_enter.ts ├── res ├── image │ ├── actionbar_ic_back_white@3x.png │ ├── btn_check_off_disabled_focused_holo_light@3x.png │ ├── btn_check_off_disabled_holo_light@3x.png │ ├── btn_check_off_focused_holo_light@3x.png │ ├── btn_check_off_holo_light@3x.png │ ├── btn_check_off_pressed_holo_light@3x.png │ ├── btn_check_on_disabled_focused_holo_light@3x.png │ ├── btn_check_on_disabled_holo_light@3x.png │ ├── btn_check_on_focused_holo_light@3x.png │ ├── btn_check_on_holo_light@3x.png │ ├── btn_check_on_pressed_holo_light@3x.png │ ├── btn_default_disabled_focused_holo_light@3x.9.png │ ├── btn_default_disabled_holo_light@3x.9.png │ ├── btn_default_focused_holo_light@3x.9.png │ ├── btn_default_normal_holo_light@3x.9.png │ ├── btn_default_pressed_holo_light@3x.9.png │ ├── btn_radio_off_disabled_focused_holo_light@3x.png │ ├── btn_radio_off_disabled_holo_light@3x.png │ ├── btn_radio_off_focused_holo_light@3x.png │ ├── btn_radio_off_holo_light@3x.png │ ├── btn_radio_off_pressed_holo_light@3x.png │ ├── btn_radio_on_disabled_focused_holo_light@3x.png │ ├── btn_radio_on_disabled_holo_light@3x.png │ ├── btn_radio_on_focused_holo_light@3x.png │ ├── btn_radio_on_holo_light@3x.png │ ├── btn_radio_on_pressed_holo_light@3x.png │ ├── btn_rating_star_off_normal_holo_light@3x.png │ ├── btn_rating_star_off_pressed_holo_light@3x.png │ ├── btn_rating_star_on_normal_holo_light@3x.png │ ├── btn_rating_star_on_pressed_holo_light@3x.png │ ├── dropdown_background_dark@2x.9.png │ ├── editbox_background_focus_yellow@2x.9.png │ ├── editbox_background_normal@2x.9.png │ ├── ic_menu_moreoverflow_normal_holo_dark@3x.png │ ├── menu_panel_holo_dark@2x.9.png │ ├── menu_panel_holo_light@2x.9.png │ ├── popup_bottom_bright@2x.9.png │ ├── popup_center_bright@2x.9.png │ ├── popup_full_bright@2x.9.png │ ├── popup_top_bright@2x.9.png │ ├── progressbar_indeterminate_holo1@3x.png │ ├── progressbar_indeterminate_holo2@3x.png │ ├── progressbar_indeterminate_holo3@3x.png │ ├── progressbar_indeterminate_holo4@3x.png │ ├── progressbar_indeterminate_holo5@3x.png │ ├── progressbar_indeterminate_holo6@3x.png │ ├── progressbar_indeterminate_holo7@3x.png │ ├── progressbar_indeterminate_holo8@3x.png │ ├── rate_star_big_half_holo_light@3x.png │ ├── rate_star_big_off_holo_light@3x.png │ ├── rate_star_big_on_holo_light@3x.png │ ├── scrubber_control_disabled_holo@3x.png │ ├── scrubber_control_focused_holo@3x.png │ ├── scrubber_control_normal_holo@3x.png │ ├── scrubber_control_pressed_holo@3x.png │ ├── spinner_76_inner_holo@3x.png │ └── spinner_76_outer_holo@3x.png └── layout │ ├── _id_defined.xml │ ├── action_bar.xml │ ├── alert_dialog.xml │ ├── alert_dialog_progress.xml │ ├── popup_menu_item_layout.xml │ ├── select_dialog.xml │ ├── select_dialog_item.xml │ ├── select_dialog_multichoice.xml │ ├── select_dialog_singlechoice.xml │ ├── simple_spinner_dropdown_item.xml │ ├── simple_spinner_item.xml │ └── transient_notification.xml └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | test/ 2 | node_modules/ 3 | .idea 4 | .DS_Store 5 | .outjs -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | test/ 2 | node_modules/ 3 | .idea 4 | .DS_Store 5 | .outjs 6 | 7 | src/ 8 | buildtool/ 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Vladimir Kharlampidi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AndroidUIX 2 | [中文文档](https://github.com/linfaxin/AndroidUIX/blob/master/README_cn.md) 3 | 4 | Make a high-performance web app with Android UI. 5 | 6 | Site: http://linfaxin.github.io/AndroidUIX/ 7 | 8 | 9 | ### Feature 10 | 11 | 1. Native app experience & performance. 12 | 2. Render with web canvas, high-performance web app. 13 | 3. Same api as Android, you can find its question & usage on the internet. 14 | 15 | 16 | ### Getting Started 17 | 18 | Look wiki: [Getting Started](https://github.com/linfaxin/AndroidUIX/wiki/1.-Getting-Started) 19 | 20 | 21 | ### 60fps 22 | 23 | the sample app's fps: 24 | 25 | 1. IOS: 50-60fps 26 | 2. Android Chrome: 50fps 27 | 3. Android WebView(with [Runtime](https://github.com/linfaxin/AndroidUIRuntimeAndroid)): 50fps 28 | 29 | You can test [Showcase](http://androiduix.com/showcase/index.html) on your device. 30 | 31 | 32 | ### Showcase 33 | 34 | * [Showcase](http://linfaxin.github.io/AndroidUIX/showcase/index.html) 35 | 36 | 37 | 38 | ### LICENSE 39 | 40 | MIT. 41 | -------------------------------------------------------------------------------- /README_cn.md: -------------------------------------------------------------------------------- 1 | # AndroidUIX 2 | 3 | 移植Android的UI组件到Web端, 以Android的方式来制作高性能优体验的WebApp 4 | 5 | 网站: http://linfaxin.github.io/AndroidUIX 6 | 7 | 8 | ### 特点 9 | 10 | 1. 完整Native端组件体验 11 | 2. 使用Web Canvas绘制界面 12 | 3. 与Android SDK相同的API,相关用法和问题都可以在网络轻易找到。 13 | 14 | ### 开始 15 | 16 | [快速起步](https://github.com/linfaxin/AndroidUIX/wiki/%E4%B8%AD%E6%96%87_1.-%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B) 17 | 18 | ### 60fps 19 | 20 | Sample页在移动端的fps: 21 | 22 | 1. IOS: 50-60fps 23 | 2. Android Chrome: 50fps 24 | 3. Android WebView(App嵌入[Runtime](https://github.com/linfaxin/AndroidUIRuntimeAndroid)运行时): 50fps 25 | 26 | 你也可以在自己的手机浏览器上测试 [Showcase](http://androiduix.com/showcase/index.html)。 27 | 28 | ### Showcase 29 | 30 | * [Showcase](http://linfaxin.github.io/AndroidUIX/showcase/index.html) 31 | 32 | 33 | ### LICENSE 34 | 35 | MIT. 36 | -------------------------------------------------------------------------------- /buildtool/README.md: -------------------------------------------------------------------------------- 1 | ### AndroidUIX Modified Note 2 | 3 | The packed typescript's 'checkClassPropertyAccess' was closed, so you can access private/protected property out a class. 4 | -------------------------------------------------------------------------------- /buildtool/typescript/bin/tsc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('../lib/tsc.js') 3 | -------------------------------------------------------------------------------- /buildtool/typescript/bin/tsserver: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('../lib/tsserver.js') 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "androiduix", 3 | "version": "0.7.0", 4 | "description": "Framework to make high-performance SPA/WebApp. Render with web canvas.", 5 | "keywords": [ 6 | "webapp", 7 | "app", 8 | "canvas", 9 | "spa" 10 | ], 11 | "author": "LinFaXin", 12 | "maintainers": [ 13 | "LinFaXin (http://linfaxin.com)" 14 | ], 15 | "license": "MIT", 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/linfaxin/AndroidUIX" 19 | }, 20 | "bugs": { 21 | "url": "https://github.com/linfaxin/AndroidUIX/issues" 22 | }, 23 | "devDependencies": { 24 | "jsdom": "^7.2.2", 25 | "babel-cli": "^6.18.0", 26 | "babel-preset-es2015": "^6.18.0" 27 | }, 28 | "scripts": { 29 | "build" : "npm install --registry=https://registry.npm.taobao.org && npm run buildRes && npm run buildTS2ES6 && npm run buildES62ES5", 30 | "buildRes" : "cd src && node build_sdk_res.js", 31 | "buildTS2ES6" : "cd src && \"../buildtool/typescript/bin/tsc\" -p ./", 32 | "buildES62ES5" : "cd src && node insert_sdk_version_dist.js && babel ../dist/android-ui.js -o ../dist/android-ui.es5.js -s --presets=es2015" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/android/R/color.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/11/15. 3 | */ 4 | /// 5 | /// 6 | /// 7 | /// 8 | /// 9 | /// 10 | /// 11 | /// 12 | module android.R{ 13 | import Resources = android.content.res.Resources; 14 | import ColorStateList = android.content.res.ColorStateList; 15 | import Color = android.graphics.Color; 16 | import Drawable = android.graphics.drawable.Drawable; 17 | import InsetDrawable = android.graphics.drawable.InsetDrawable; 18 | import ColorDrawable = android.graphics.drawable.ColorDrawable; 19 | import StateListDrawable = android.graphics.drawable.StateListDrawable; 20 | import Gravity = android.view.Gravity; 21 | 22 | export class color { 23 | static get textView_textColor():ColorStateList { 24 | let _defaultStates = [[-android.view.View.VIEW_STATE_ENABLED], []]; 25 | let _defaultColors = [0xffc0c0c0, 0xff333333]; 26 | class DefaultStyleTextColor extends ColorStateList{ 27 | constructor() { 28 | super(_defaultStates, _defaultColors); 29 | } 30 | } 31 | return new DefaultStyleTextColor(); 32 | } 33 | 34 | static get primary_text_light_disable_only():ColorStateList { 35 | let _defaultStates = [[-android.view.View.VIEW_STATE_ENABLED], []]; 36 | let _defaultColors = [0x80000000, 0xff000000]; 37 | class DefaultStyleTextColor extends ColorStateList{ 38 | constructor() { 39 | super(_defaultStates, _defaultColors); 40 | } 41 | } 42 | return new DefaultStyleTextColor(); 43 | } 44 | 45 | static get primary_text_dark_disable_only():ColorStateList { 46 | let _defaultStates = [[-android.view.View.VIEW_STATE_ENABLED], []]; 47 | let _defaultColors = [0x80000000, 0xffffffff]; 48 | class DefaultStyleTextColor extends ColorStateList{ 49 | constructor() { 50 | super(_defaultStates, _defaultColors); 51 | } 52 | } 53 | return new DefaultStyleTextColor(); 54 | } 55 | 56 | static white = Color.WHITE; 57 | static black = Color.BLACK; 58 | static transparent = Color.TRANSPARENT; 59 | } 60 | } -------------------------------------------------------------------------------- /src/android/R/id.ts: -------------------------------------------------------------------------------- 1 | module android.R { 2 | export const id = { 3 | "content": "content", 4 | "background": "background", 5 | "secondaryProgress": "secondaryProgress", 6 | "progress": "progress", 7 | "contentPanel": "contentPanel", 8 | "topPanel": "topPanel", 9 | "buttonPanel": "buttonPanel", 10 | "customPanel": "customPanel", 11 | "custom": "custom", 12 | "titleDivider": "titleDivider", 13 | "titleDividerTop": "titleDividerTop", 14 | "title_template": "title_template", 15 | "icon": "icon", 16 | "alertTitle": "alertTitle", 17 | "scrollView": "scrollView", 18 | "message": "message", 19 | "button1": "button1", 20 | "button2": "button2", 21 | "button3": "button3", 22 | "leftSpacer": "leftSpacer", 23 | "rightSpacer": "rightSpacer", 24 | "text1": "text1", 25 | "action_bar_center_layout": "action_bar_center_layout", 26 | "action_bar_title": "action_bar_title", 27 | "action_bar_sub_title": "action_bar_sub_title", 28 | "action_bar_left": "action_bar_left", 29 | "action_bar_right": "action_bar_right", 30 | "parentPanel": "parentPanel", 31 | "progress_percent": "progress_percent", 32 | "progress_number": "progress_number", 33 | "title": "title", 34 | "shortcut": "shortcut", 35 | "select_dialog_listview": "select_dialog_listview" 36 | }; 37 | } -------------------------------------------------------------------------------- /src/android/R/interpolator.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 16/1/10. 3 | */ 4 | /// 5 | /// 6 | /// 7 | /// 8 | /// 9 | /// 10 | /// 11 | /// 12 | /// 13 | /// 14 | 15 | module android.R{ 16 | import Interpolator = android.view.animation.Interpolator; 17 | import AccelerateDecelerateInterpolator = android.view.animation.AccelerateDecelerateInterpolator; 18 | import AccelerateInterpolator = android.view.animation.AccelerateInterpolator; 19 | import AnticipateInterpolator = android.view.animation.AnticipateInterpolator; 20 | import AnticipateOvershootInterpolator = android.view.animation.AnticipateOvershootInterpolator; 21 | import BounceInterpolator = android.view.animation.BounceInterpolator; 22 | import CycleInterpolator = android.view.animation.CycleInterpolator; 23 | import DecelerateInterpolator = android.view.animation.DecelerateInterpolator; 24 | import LinearInterpolator = android.view.animation.LinearInterpolator; 25 | import OvershootInterpolator = android.view.animation.OvershootInterpolator; 26 | 27 | export class interpolator { 28 | static accelerate_cubic = new AccelerateInterpolator(1.5); 29 | static accelerate_decelerate = new AccelerateDecelerateInterpolator(); 30 | static accelerate_quad = new AccelerateInterpolator(); 31 | static accelerate_quint = new AccelerateInterpolator(2.5); 32 | static anticipate_overshoot = new AnticipateOvershootInterpolator(); 33 | static anticipate = new AnticipateInterpolator(); 34 | static bounce = new BounceInterpolator(); 35 | static cycle = new CycleInterpolator(1); 36 | static decelerate_cubic = new DecelerateInterpolator(1.5); 37 | static decelerate_quad = new DecelerateInterpolator(); 38 | static decelerate_quint = new DecelerateInterpolator(2.5); 39 | static linear = new LinearInterpolator(); 40 | static overshoot = new OvershootInterpolator(); 41 | } 42 | } -------------------------------------------------------------------------------- /src/android/R/string.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/11/21. 3 | */ 4 | module android.R{ 5 | export class string_{ 6 | static ok = 'OK'; 7 | static cancel = 'Cancel'; 8 | static close = 'Close'; 9 | static back = 'Back'; 10 | static crash_catch_alert = 'Some error happen, will refresh page:'; 11 | 12 | static prll_header_state_normal = 'Pull to refresh'; 13 | static prll_header_state_ready = 'Release to refresh'; 14 | static prll_header_state_loading = 'Loading'; 15 | static prll_header_state_fail = 'Refresh fail'; 16 | static prll_footer_state_normal = 'Load more'; 17 | static prll_footer_state_loading = 'Loading'; 18 | static prll_footer_state_ready = 'Pull to load more'; 19 | static prll_footer_state_fail = 'Click to reload'; 20 | static prll_footer_state_no_more = 'Load Finish'; 21 | 22 | private static zh(){ 23 | this.ok = '确定'; 24 | this.cancel = '取消'; 25 | this.close = '关闭'; 26 | this.back = '返回'; 27 | this.crash_catch_alert = '程序发生错误, 即将重载网页:'; 28 | 29 | this.prll_header_state_normal = '下拉以刷新'; 30 | this.prll_header_state_ready = '松开马上刷新'; 31 | this.prll_header_state_loading = '正在刷新...'; 32 | this.prll_header_state_fail = '刷新失败'; 33 | this.prll_footer_state_normal = '点击加载更多'; 34 | this.prll_footer_state_loading = '正在加载...'; 35 | this.prll_footer_state_ready = '松开加载更多'; 36 | this.prll_footer_state_no_more = '加载完毕'; 37 | this.prll_footer_state_fail = '加载失败,点击重试'; 38 | } 39 | } 40 | 41 | //merge language special to main 42 | const lang = navigator.language.split('-')[0].toLowerCase(); 43 | if(typeof string_[lang] === 'function') string_[lang].call(string_); 44 | } -------------------------------------------------------------------------------- /src/android/app/ActionBarActivity.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 16/1/21. 3 | * androidui NOTE: ActionBarActivity is not same style as android's 4 | */ 5 | /// 6 | /// 7 | 8 | 9 | module android.app { 10 | import View = android.view.View; 11 | import ViewGroup = android.view.ViewGroup; 12 | import MarginLayoutParams = android.view.ViewGroup.MarginLayoutParams; 13 | 14 | export class ActionBarActivity extends Activity { 15 | private mActionBar:ActionBar; 16 | 17 | protected onCreate(savedInstanceState?:android.os.Bundle):void { 18 | super.onCreate(savedInstanceState); 19 | this.initActionBar(); 20 | } 21 | 22 | private initActionBar(){ 23 | this.setActionBar(new ActionBar(this)); 24 | this.initDefaultBackFinish(); 25 | } 26 | 27 | private initDefaultBackFinish(){ 28 | if(this.androidUI.mActivityThread.mLaunchedActivities.size === 0) return;//xxx not do check here 29 | const activity = this; 30 | this.mActionBar.setActionLeft(android.R.string_.back, android.R.image.actionbar_ic_back_white, { 31 | onClick(view:View){ 32 | activity.finish(); 33 | } 34 | }); 35 | } 36 | 37 | setActionBar(actionBar:ActionBar){ 38 | const activity = this; 39 | let w = this.getWindow(); 40 | let decorView:ViewGroup = w.mDecor; 41 | this.mActionBar = actionBar; 42 | decorView.addView(actionBar, -1, -2); 43 | const onMeasure = decorView.onMeasure; 44 | decorView.onMeasure = (widthMeasureSpec:number, heightMeasureSpec:number)=>{ 45 | onMeasure.call(decorView, widthMeasureSpec, heightMeasureSpec); 46 | if(activity.mActionBar === actionBar){ 47 | let params = w.mContentParent.getLayoutParams(); 48 | if(params.topMargin != actionBar.getMeasuredHeight()){ 49 | params.topMargin = actionBar.getMeasuredHeight(); 50 | onMeasure.call(decorView, widthMeasureSpec, heightMeasureSpec); 51 | } 52 | } 53 | }; 54 | } 55 | 56 | 57 | protected invalidateOptionsMenuPopupHelper(menu:android.view.Menu):android.view.menu.MenuPopupHelper { 58 | let menuPopuoHelper = new android.view.menu.MenuPopupHelper(this, menu, this.getActionBar().mActionRight); 59 | if(menu.hasVisibleItems()){ 60 | this.getActionBar().setActionRight('', android.R.image.ic_menu_moreoverflow_normal_holo_dark, { 61 | onClick: function (view) { 62 | menuPopuoHelper.show(); 63 | } 64 | }); 65 | } 66 | return menuPopuoHelper; 67 | } 68 | 69 | getActionBar():ActionBar { 70 | return this.mActionBar; 71 | } 72 | 73 | protected onTitleChanged(title:string, color:number):void { 74 | super.onTitleChanged(title, color); 75 | this.mActionBar.setTitle(title); 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /src/android/content/Context.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 16/1/4. 3 | * lite impl of Android's Content 4 | */ 5 | /// 6 | /// 7 | /// 8 | /// 9 | /// 10 | /// 11 | 12 | 13 | module android.content { 14 | import Intent = android.content.Intent; 15 | import Bundle = android.os.Bundle; 16 | import LayoutInflater = android.view.LayoutInflater; 17 | 18 | export abstract class Context { 19 | androidUI: androidui.AndroidUI; 20 | private mLayoutInflater:LayoutInflater; 21 | private mResources:android.content.res.Resources; 22 | 23 | constructor(androidUI:androidui.AndroidUI) { 24 | this.androidUI = androidUI; 25 | this.mLayoutInflater = new LayoutInflater(this); 26 | this.mResources = new android.content.res.Resources(this); 27 | } 28 | 29 | abstract getWindowManager():android.view.WindowManager; 30 | 31 | getApplicationContext():android.app.Application{ 32 | return this.androidUI.mApplication; 33 | } 34 | 35 | /** Return a Resources instance for your application's package. */ 36 | getResources():android.content.res.Resources{ 37 | return this.mResources; 38 | } 39 | 40 | getLayoutInflater():LayoutInflater{ 41 | return this.mLayoutInflater; 42 | } 43 | 44 | /** 45 | * Retrieve styled attribute information. 46 | */ 47 | public obtainStyledAttributes(attrs:HTMLElement, defStyleAttr?:Map):res.TypedArray { 48 | return res.TypedArray.obtain(this.mResources, attrs, defStyleAttr); 49 | } 50 | 51 | } 52 | } -------------------------------------------------------------------------------- /src/android/database/DataSetObservable.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | 21 | module android.database{ 22 | import ArrayList = java.util.ArrayList; 23 | import Observable = android.database.Observable; 24 | import DataSetObserver = android.database.DataSetObserver; 25 | 26 | /** 27 | * A specialization of {@link Observable} for {@link DataSetObserver} 28 | * that provides methods for sending notifications to a list of 29 | * {@link DataSetObserver} objects. 30 | */ 31 | export class DataSetObservable extends Observable{ 32 | /** 33 | * Invokes {@link DataSetObserver#onChanged} on each observer. 34 | * Called when the contents of the data set have changed. The recipient 35 | * will obtain the new contents the next time it queries the data set. 36 | */ 37 | notifyChanged():void { 38 | // to avoid such problems, just march thru the list in the reverse order. 39 | for (let i = this.mObservers.size() - 1; i >= 0; i--) { 40 | this.mObservers.get(i).onChanged(); 41 | } 42 | } 43 | /** 44 | * Invokes {@link DataSetObserver#onInvalidated} on each observer. 45 | * Called when the data set is no longer valid and cannot be queried again, 46 | * such as when the data set has been closed. 47 | */ 48 | notifyInvalidated():void { 49 | for (let i = this.mObservers.size() - 1; i >= 0; i--) { 50 | this.mObservers.get(i).onInvalidated(); 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /src/android/database/DataSetObserver.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module android.database{ 18 | export class DataSetObserver { 19 | /** 20 | * This method is called when the entire data set has changed, 21 | * most likely through a call to {@link Cursor#requery()} on a {@link Cursor}. 22 | */ 23 | onChanged():void { 24 | // Do nothing 25 | } 26 | 27 | /** 28 | * This method is called when the entire data becomes invalid, 29 | * most likely through a call to {@link Cursor#deactivate()} or {@link Cursor#close()} on a 30 | * {@link Cursor}. 31 | */ 32 | onInvalidated():void { 33 | // Do nothing 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/android/database/Observable.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.database{ 20 | import ArrayList = java.util.ArrayList; 21 | 22 | /** 23 | * Provides methods for registering or unregistering arbitrary observers in an {@link ArrayList}. 24 | * 25 | * This abstract class is intended to be subclassed and specialized to maintain 26 | * a registry of observers of specific types and dispatch notifications to them. 27 | * 28 | * @param T The observer type. 29 | */ 30 | export abstract class Observable{ 31 | /** 32 | * The list of observers. An observer can be in the list at most 33 | * once and will never be null. 34 | */ 35 | protected mObservers = new ArrayList() 36 | 37 | /** 38 | * Adds an observer to the list. The observer cannot be null and it must not already 39 | * be registered. 40 | * @param observer the observer to register 41 | * @throws IllegalArgumentException the observer is null 42 | * @throws IllegalStateException the observer is already registered 43 | */ 44 | registerObserver(observer:T):void { 45 | if (observer == null) { 46 | throw new Error("The observer is null."); 47 | } 48 | if (this.mObservers.contains(observer)) { 49 | throw new Error("Observer " + observer + " is already registered."); 50 | } 51 | this.mObservers.add(observer); 52 | } 53 | 54 | /** 55 | * Removes a previously registered observer. The observer must not be null and it 56 | * must already have been registered. 57 | * @param observer the observer to unregister 58 | * @throws IllegalArgumentException the observer is null 59 | * @throws IllegalStateException the observer is not yet registered 60 | */ 61 | unregisterObserver(observer:T) { 62 | if (observer == null) { 63 | throw new Error("The observer is null."); 64 | } 65 | let index = this.mObservers.indexOf(observer); 66 | if (index == -1) { 67 | throw new Error("Observer " + observer + " was not registered."); 68 | } 69 | this.mObservers.remove(index); 70 | } 71 | 72 | /** 73 | * Remove all registered observers. 74 | */ 75 | unregisterAll():void { 76 | this.mObservers.clear(); 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /src/android/graphics/Path.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/12/6. 3 | * empty class: not support draw/clip path now. 4 | */ 5 | module android.graphics{ 6 | export class Path{ 7 | 8 | reset(){ 9 | 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/android/graphics/PixelFormat.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module android.graphics { 18 | export class PixelFormat { 19 | static UNKNOWN = 0; 20 | static TRANSLUCENT = -3; 21 | static TRANSPARENT = -2; 22 | static OPAQUE = -1; 23 | static RGBA_8888 = 1; 24 | static RGBX_8888 = 2; 25 | static RGB_888 = 3; 26 | static RGB_565 = 4; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/android/graphics/Point.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module android.graphics { 18 | /** 19 | * Point holds two integer coordinates 20 | */ 21 | export class Point { 22 | x:number = 0; 23 | y:number = 0; 24 | 25 | constructor(); 26 | constructor(x:number, y:number); 27 | constructor(src:Point); 28 | constructor(...args) { 29 | if (args.length === 1) { 30 | let src:Point = args[0]; 31 | this.x = src.x; 32 | this.y = src.y; 33 | } else { 34 | let [x=0, y=0] = args; 35 | this.x = x; 36 | this.y = y; 37 | } 38 | } 39 | 40 | /** 41 | * Set the point's x and y coordinates 42 | */ 43 | set(x:number, y:number) { 44 | this.x = x; 45 | this.y = y; 46 | } 47 | 48 | /** 49 | * Negate the point's coordinates 50 | */ 51 | negate() { 52 | this.x = -this.x; 53 | this.y = -this.y; 54 | } 55 | 56 | /** 57 | * Offset the point's coordinates by dx, dy 58 | */ 59 | offset(dx:number, dy:number) { 60 | this.x += dx; 61 | this.y += dy; 62 | } 63 | 64 | /** 65 | * Returns true if the point's coordinates equal (x,y) 66 | */ 67 | equals(x:number, y:number):boolean ; 68 | equals(o:any):boolean; 69 | equals(...args):boolean { 70 | if (args.length === 2) { 71 | let [x=0,y=0] = args; 72 | return this.x == x && this.y == y 73 | } else { 74 | let o = args[0]; 75 | if (this === o) return true; 76 | if (!o || !(o instanceof Point)) return false; 77 | let point = o; 78 | if (this.x != point.x) return false; 79 | if (this.y != point.y) return false; 80 | return true; 81 | } 82 | } 83 | 84 | toString():String { 85 | return "Point(" + this.x + ", " + this.y + ")"; 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /src/android/graphics/RectF.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/12/6. 3 | * NOTE: only extends Rect, Rect no integer vale limit now. 4 | */ 5 | /// 6 | 7 | module android.graphics{ 8 | export class RectF extends Rect{ 9 | } 10 | } -------------------------------------------------------------------------------- /src/android/graphics/drawable/Animatable.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | module android.graphics.drawable { 19 | /** 20 | * Interface that drawables suporting animations should implement. 21 | */ 22 | export interface Animatable { 23 | 24 | /** 25 | * Starts the drawable's animation. 26 | */ 27 | start():void ; 28 | 29 | /** 30 | * Stops the drawable's animation. 31 | */ 32 | stop():void ; 33 | 34 | /** 35 | * Indicates whether the animation is running. 36 | * 37 | * @return True if the animation is running, false otherwise. 38 | */ 39 | isRunning():boolean ; 40 | } 41 | export module Animatable{ 42 | export function isImpl(obj){ 43 | return obj && obj['start'] && obj['stop'] && obj['isRunning']; 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/android/os/Bundle.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | module android.os{ 19 | /** 20 | * A mapping from String values to various Parcelable types. 21 | * NOTE: lite impl of Android Bundle 22 | */ 23 | export class Bundle{ 24 | constructor(copy?:Bundle){ 25 | if(copy) Object.assign(this, copy); 26 | } 27 | 28 | get(key:string, defaultValue:any){ 29 | if(this.containsKey(key)){ 30 | return this[key]; 31 | } 32 | return defaultValue; 33 | } 34 | 35 | put(key:string, value:any){ 36 | this[key] = value; 37 | } 38 | 39 | containsKey(key:string){ 40 | return key in this; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/android/os/SystemClock.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/10/5. 3 | * AndroidUI's impl. 4 | */ 5 | module android.os{ 6 | export class SystemClock{ 7 | static uptimeMillis() : number{ 8 | return new Date().getTime(); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/android/text/SpanWatcher.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.text { 20 | import Spannable = android.text.Spannable; 21 | /** 22 | * When an object of this type is attached to a Spannable, its methods 23 | * will be called to notify it that other markup objects have been 24 | * added, changed, or removed. 25 | */ 26 | export interface SpanWatcher { 27 | 28 | /** 29 | * This method is called to notify you that the specified object 30 | * has been attached to the specified range of the text. 31 | */ 32 | onSpanAdded(text:Spannable, what:any, start:number, end:number):void ; 33 | 34 | /** 35 | * This method is called to notify you that the specified object 36 | * has been detached from the specified range of the text. 37 | */ 38 | onSpanRemoved(text:Spannable, what:any, start:number, end:number):void ; 39 | 40 | /** 41 | * This method is called to notify you that the specified object 42 | * has been relocated from the range ostart…oend 43 | * to the new range nstart…nend of the text. 44 | */ 45 | onSpanChanged(text:Spannable, what:any, ostart:number, oend:number, nstart:number, nend:number):void ; 46 | } 47 | } -------------------------------------------------------------------------------- /src/android/text/Spannable.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | 20 | module android.text { 21 | import Spanned = android.text.Spanned; 22 | import TextWatcher = android.text.TextWatcher; 23 | /** 24 | * This is the interface for text to which markup objects can be 25 | * attached and detached. Not all Spannable classes have mutable text; 26 | * see {@link Editable} for that. 27 | */ 28 | export interface Spannable extends Spanned { 29 | 30 | /** 31 | * Attach the specified markup object to the range start…end 32 | * of the text, or move the object to that range if it was already 33 | * attached elsewhere. See {@link Spanned} for an explanation of 34 | * what the flags mean. The object can be one that has meaning only 35 | * within your application, or it can be one that the text system will 36 | * use to affect text display or behavior. Some noteworthy ones are 37 | * the subclasses of {@link android.text.style.CharacterStyle} and 38 | * {@link android.text.style.ParagraphStyle}, and 39 | * {@link android.text.TextWatcher} and 40 | * {@link android.text.SpanWatcher}. 41 | */ 42 | setSpan(what:any, start:number, end:number, flags:number):void ; 43 | 44 | /** 45 | * Remove the specified object from the range of text to which it 46 | * was attached, if any. It is OK to remove an object that was never 47 | * attached in the first place. 48 | */ 49 | removeSpan(what:any):void ; 50 | 51 | 52 | } 53 | 54 | export module Spannable{ 55 | export function isImpl(obj):boolean { 56 | return obj && obj['setSpan'] && obj['removeSpan']; 57 | } 58 | /** 59 | * Factory used by TextView to create new Spannables. You can subclass 60 | * it to provide something other than SpannableString. 61 | */ 62 | export class Factory { 63 | 64 | private static sInstance:Spannable.Factory = new Factory(); 65 | 66 | /** 67 | * Returns the standard Spannable Factory. 68 | */ 69 | static getInstance():Spannable.Factory { 70 | return Factory.sInstance; 71 | } 72 | 73 | /** 74 | * Returns a new SpannableString from the specified CharSequence. 75 | * You can override this to provide a different kind of Spannable. 76 | */ 77 | newSpannable(source:String):Spannable { 78 | return source;//FIXME when SpannableString impl 79 | //return new SpannableString(source); 80 | } 81 | } 82 | } 83 | 84 | } -------------------------------------------------------------------------------- /src/android/text/TextDirectionHeuristic.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | module android.text { 19 | /** 20 | * Interface for objects that use a heuristic for guessing at the paragraph direction by examining text. 21 | */ 22 | export interface TextDirectionHeuristic { 23 | 24 | /** 25 | * Guess if a {@code CharSequence} is in the RTL direction or not. 26 | * 27 | * @param cs the CharSequence. 28 | * @param start start index, inclusive. 29 | * @param count the length to check, must not be negative and not greater than 30 | * {@code CharSequence.length() - start}. 31 | * @return true if all chars in the range are to be considered in a RTL direction, 32 | * false otherwise. 33 | */ 34 | isRtl(cs:string, start:number, count:number):boolean ; 35 | } 36 | } -------------------------------------------------------------------------------- /src/android/text/TextPaint.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | /// 19 | 20 | module android.text{ 21 | 22 | /** 23 | * TextPaint is an extension of Paint that leaves room for some extra 24 | * data used during text measuring and drawing. 25 | */ 26 | export class TextPaint extends android.graphics.Paint{ 27 | baselineShift = 0; 28 | // Special value 0 means no background paint 29 | bgColor = 0; 30 | linkColor:number = 0; 31 | 32 | /** 33 | * Special value 0 means no custom underline 34 | * @hide 35 | */ 36 | underlineColor = 0; 37 | /** 38 | * Defined as a multiplier of the default underline thickness. Use 1.0f for default thickness. 39 | * @hide 40 | */ 41 | underlineThickness:number = 0; 42 | 43 | 44 | /** 45 | * Copy the fields from tp into this TextPaint, including the 46 | * fields inherited from Paint. 47 | */ 48 | set(tp:TextPaint):void { 49 | super.set(tp); 50 | this.bgColor = tp.bgColor; 51 | this.baselineShift = tp.baselineShift; 52 | this.linkColor = tp.linkColor; 53 | //this.drawableState = tp.drawableState; 54 | //this.density = tp.density; 55 | this.underlineColor = tp.underlineColor; 56 | this.underlineThickness = tp.underlineThickness; 57 | } 58 | 59 | /** 60 | * Defines a custom underline for this Paint. 61 | * @param color underline solid color 62 | * @param thickness underline thickness 63 | * @hide 64 | */ 65 | setUnderlineText(color:number, thickness:number):void { 66 | this.underlineColor = color; 67 | this.underlineThickness = thickness; 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /src/android/text/TextWatcher.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | module android.text { 19 | /** 20 | * When an object of a type is attached to an Editable, its methods will 21 | * be called when the text is changed. 22 | */ 23 | export interface TextWatcher { 24 | 25 | /** 26 | * This method is called to notify you that, within s, 27 | * the count characters beginning at start 28 | * are about to be replaced by new text with length after. 29 | * It is an error to attempt to make changes to s from 30 | * this callback. 31 | */ 32 | beforeTextChanged(s:String, start:number, count:number, after:number):void ; 33 | 34 | /** 35 | * This method is called to notify you that, within s, 36 | * the count characters beginning at start 37 | * have just replaced old text that had length before. 38 | * It is an error to attempt to make changes to s from 39 | * this callback. 40 | */ 41 | onTextChanged(s:String, start:number, before:number, count:number):void ; 42 | 43 | /** 44 | * This method is called to notify you that, somewhere within 45 | * s, the text has been changed. 46 | * It is legitimate to make further changes to s from 47 | * this callback, but be careful not to get yourself into an infinite 48 | * loop, because any changes you make will cause this method to be 49 | * called again recursively. 50 | * (You are not told where the change took place because other 51 | * afterTextChanged() methods may already have made other changes 52 | * and invalidated the offsets. But if you need to know here, 53 | * you can use {@link Spannable#setSpan} in {@link #onTextChanged} 54 | * to mark your place and then look up from here where the span 55 | * ended up. 56 | */ 57 | afterTextChanged(s:String):void ;//Editable 58 | } 59 | } -------------------------------------------------------------------------------- /src/android/text/method/AllCapsTransformationMethod.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | /// 21 | /// 22 | 23 | module android.text.method { 24 | import Rect = android.graphics.Rect; 25 | import Log = android.util.Log; 26 | import View = android.view.View; 27 | import TransformationMethod = android.text.method.TransformationMethod; 28 | import TransformationMethod2 = android.text.method.TransformationMethod2; 29 | /** 30 | * Transforms source text into an ALL CAPS string, locale-aware. 31 | * 32 | * @hide 33 | */ 34 | export class AllCapsTransformationMethod implements TransformationMethod2 { 35 | 36 | private static TAG:string = "AllCapsTransformationMethod"; 37 | 38 | private mEnabled:boolean; 39 | 40 | 41 | constructor(context?:any) { 42 | } 43 | 44 | getTransformation(source:String, view:View):String { 45 | if (this.mEnabled) { 46 | return source != null ? source.toLocaleUpperCase() : null; 47 | } 48 | Log.w(AllCapsTransformationMethod.TAG, "Caller did not enable length changes; not transforming text"); 49 | return source; 50 | } 51 | 52 | onFocusChanged(view:View, sourceText:String, focused:boolean, direction:number, previouslyFocusedRect:Rect):void { 53 | } 54 | 55 | setLengthChangesAllowed(allowLengthChanges:boolean):void { 56 | this.mEnabled = allowLengthChanges; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /src/android/text/method/MovementMethod.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | /// 21 | 22 | module android.text.method { 23 | import TextView = android.widget.TextView; 24 | import KeyEvent = android.view.KeyEvent; 25 | import MotionEvent = android.view.MotionEvent; 26 | import Spannable = android.text.Spannable; 27 | /** 28 | * Provides cursor positioning, scrolling and text selection functionality in a {@link TextView}. 29 | *

30 | * The {@link TextView} delegates handling of key events, trackball motions and touches to 31 | * the movement method for purposes of content navigation. The framework automatically 32 | * selects an appropriate movement method based on the content of the {@link TextView}. 33 | *

34 | * This interface is intended for use by the framework; it should not be implemented 35 | * directly by applications. 36 | *

37 | */ 38 | export interface MovementMethod { 39 | 40 | initialize(widget:TextView, text:Spannable):void ; 41 | 42 | onKeyDown(widget:TextView, text:Spannable, keyCode:number, event:KeyEvent):boolean ; 43 | 44 | onKeyUp(widget:TextView, text:Spannable, keyCode:number, event:KeyEvent):boolean ; 45 | 46 | /** 47 | * If the key listener wants to other kinds of key events, return true, 48 | * otherwise return false and the caller (i.e. the widget host) 49 | * will handle the key. 50 | */ 51 | onKeyOther(view:TextView, text:Spannable, event:KeyEvent):boolean ; 52 | 53 | onTakeFocus(widget:TextView, text:Spannable, direction:number):void ; 54 | 55 | onTrackballEvent(widget:TextView, text:Spannable, event:MotionEvent):boolean ; 56 | 57 | onTouchEvent(widget:TextView, text:Spannable, event:MotionEvent):boolean ; 58 | 59 | onGenericMotionEvent(widget:TextView, text:Spannable, event:MotionEvent):boolean ; 60 | 61 | /** 62 | * Returns true if this movement method allows arbitrary selection 63 | * of any text; false if it has no selection (like a movement method 64 | * that only scrolls) or a constrained selection (for example 65 | * limited to links. The "Select All" menu item is disabled 66 | * if arbitrary selection is not allowed. 67 | */ 68 | canSelectArbitrarily():boolean ; 69 | } 70 | } -------------------------------------------------------------------------------- /src/android/text/method/PasswordTransformationMethod.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.text.method { 20 | export class PasswordTransformationMethod extends SingleLineTransformationMethod { 21 | private static instance:PasswordTransformationMethod; 22 | 23 | getTransformation(source:String, v:android.view.View):String { 24 | let transform = super.getTransformation(source, v); 25 | if(transform) transform = new Array(transform.length+1).join('•'); 26 | return transform; 27 | } 28 | 29 | static getInstance():PasswordTransformationMethod { 30 | if (PasswordTransformationMethod.instance != null) return PasswordTransformationMethod.instance; 31 | PasswordTransformationMethod.instance = new PasswordTransformationMethod(); 32 | return PasswordTransformationMethod.instance; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/android/text/method/SingleLineTransformationMethod.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | /// 21 | /// 22 | /// 23 | /// 24 | 25 | module android.text.method { 26 | import Rect = android.graphics.Rect; 27 | import Spannable = android.text.Spannable; 28 | import Spanned = android.text.Spanned; 29 | import TextUtils = android.text.TextUtils; 30 | import View = android.view.View; 31 | import ReplacementTransformationMethod = android.text.method.ReplacementTransformationMethod; 32 | import TransformationMethod = android.text.method.TransformationMethod; 33 | /** 34 | * This transformation method causes any newline characters (\n) to be 35 | * displayed as spaces instead of causing line breaks, and causes 36 | * carriage return characters (\r) to have no appearance. 37 | */ 38 | export class SingleLineTransformationMethod extends ReplacementTransformationMethod { 39 | 40 | private static ORIGINAL:string[] = [ '\n', '\r' ]; 41 | 42 | private static REPLACEMENT:string[] = [ ' ', '' ]; 43 | 44 | /** 45 | * The characters to be replaced are \n and \r. 46 | */ 47 | protected getOriginal():string[] { 48 | return SingleLineTransformationMethod.ORIGINAL; 49 | } 50 | 51 | /** 52 | * The character \n is replaced with is space; 53 | * the character \r is replaced with is FEFF (zero width space). 54 | */ 55 | protected getReplacement():string[] { 56 | return SingleLineTransformationMethod.REPLACEMENT; 57 | } 58 | 59 | static getInstance():SingleLineTransformationMethod { 60 | if (SingleLineTransformationMethod.sInstance != null) 61 | return SingleLineTransformationMethod.sInstance; 62 | SingleLineTransformationMethod.sInstance = new SingleLineTransformationMethod(); 63 | return SingleLineTransformationMethod.sInstance; 64 | } 65 | 66 | private static sInstance:SingleLineTransformationMethod; 67 | } 68 | } -------------------------------------------------------------------------------- /src/android/text/method/TransformationMethod.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | 20 | module android.text.method { 21 | import Rect = android.graphics.Rect; 22 | import View = android.view.View; 23 | /** 24 | * TextView uses TransformationMethods to do things like replacing the 25 | * characters of passwords with dots, or keeping the newline characters 26 | * from causing line breaks in single-line text fields. 27 | */ 28 | export interface TransformationMethod { 29 | 30 | /** 31 | * Returns a CharSequence that is a transformation of the source text -- 32 | * for example, replacing each character with a dot in a password field. 33 | * Beware that the returned text must be exactly the same length as 34 | * the source text, and that if the source text is Editable, the returned 35 | * text must mirror it dynamically instead of doing a one-time copy. 36 | */ 37 | getTransformation(source:String, view:View):String ; 38 | 39 | /** 40 | * This method is called when the TextView that uses this 41 | * TransformationMethod gains or loses focus. 42 | */ 43 | onFocusChanged(view:View, sourceText:String, focused:boolean, direction:number, previouslyFocusedRect:Rect):void ; 44 | } 45 | export module TransformationMethod{ 46 | export function isImpl(obj):boolean { 47 | return obj && obj['getTransformation'] && obj['onFocusChanged']; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/android/text/method/TransformationMethod2.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.text.method { 20 | import TransformationMethod = android.text.method.TransformationMethod; 21 | /** 22 | * TransformationMethod2 extends the TransformationMethod interface 23 | * and adds the ability to relax restrictions of TransformationMethod. 24 | * 25 | * @hide 26 | */ 27 | export interface TransformationMethod2 extends TransformationMethod { 28 | 29 | /** 30 | * Relax the contract of TransformationMethod to allow length changes, 31 | * or revert to the length-restricted behavior. 32 | * 33 | * @param allowLengthChanges true to allow the transformation to change the length 34 | * of the input string. 35 | */ 36 | setLengthChangesAllowed(allowLengthChanges:boolean):void ; 37 | } 38 | export module TransformationMethod2 { 39 | export function isImpl(obj):boolean { 40 | return TransformationMethod.isImpl(obj) && obj['setLengthChangesAllowed']; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/android/text/style/LineBackgroundSpan.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | 21 | module android.text.style { 22 | import Paint = android.graphics.Paint; 23 | import Canvas = android.graphics.Canvas; 24 | import ParagraphStyle = android.text.style.ParagraphStyle; 25 | export interface LineBackgroundSpan extends ParagraphStyle { 26 | 27 | drawBackground(c:Canvas, p:Paint, left:number, right:number, top:number, baseline:number, bottom:number, 28 | text:String, start:number, end:number, lnum:number):void ; 29 | } 30 | 31 | export module LineBackgroundSpan{ 32 | export var type = Symbol(); 33 | } 34 | } -------------------------------------------------------------------------------- /src/android/text/style/LineHeightSpan.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | /// 21 | /// 22 | /// 23 | 24 | module android.text.style { 25 | import Paint = android.graphics.Paint; 26 | import Canvas = android.graphics.Canvas; 27 | import Layout = android.text.Layout; 28 | import TextPaint = android.text.TextPaint; 29 | import ParagraphStyle = android.text.style.ParagraphStyle; 30 | import WrapTogetherSpan = android.text.style.WrapTogetherSpan; 31 | 32 | export interface LineHeightSpan extends ParagraphStyle, WrapTogetherSpan { 33 | chooseHeight(text:String, start:number, end:number, spanstartv:number, v:number, fm:Paint.FontMetricsInt):void ; 34 | } 35 | 36 | export module LineHeightSpan { 37 | export var type = Symbol(); 38 | export interface WithDensity extends LineHeightSpan { 39 | chooseHeight(text:String, start:number, end:number, spanstartv:number, v:number, fm:Paint.FontMetricsInt, paint?:TextPaint):void ; 40 | } 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /src/android/text/style/MetricAffectingSpan.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | /// 21 | 22 | module android.text.style { 23 | import Paint = android.graphics.Paint; 24 | import TextPaint = android.text.TextPaint; 25 | import CharacterStyle = android.text.style.CharacterStyle; 26 | import UpdateLayout = android.text.style.UpdateLayout; 27 | /** 28 | * The classes that affect character-level text formatting in a way that 29 | * changes the width or height of characters extend this class. 30 | */ 31 | export abstract class MetricAffectingSpan extends CharacterStyle implements UpdateLayout { 32 | static type = Symbol(); 33 | mType = MetricAffectingSpan.type; 34 | 35 | abstract updateMeasureState(p:TextPaint):void; 36 | 37 | /** 38 | * Returns "this" for most MetricAffectingSpans, but for 39 | * MetricAffectingSpans that were generated by {@link #wrap}, 40 | * returns the underlying MetricAffectingSpan. 41 | */ 42 | getUnderlying():MetricAffectingSpan { 43 | return this; 44 | } 45 | 46 | 47 | } 48 | 49 | export module MetricAffectingSpan { 50 | /* package */ 51 | export class Passthrough_MetricAffectingSpan extends MetricAffectingSpan { 52 | 53 | private mStyle:MetricAffectingSpan; 54 | 55 | /** 56 | * Creates a new Passthrough of the specfied MetricAffectingSpan. 57 | */ 58 | constructor(cs:MetricAffectingSpan) { 59 | super(); 60 | this.mStyle = cs; 61 | } 62 | 63 | /** 64 | * Passes updateDrawState through to the underlying MetricAffectingSpan. 65 | */ 66 | updateDrawState(tp:TextPaint):void { 67 | this.mStyle.updateDrawState(tp); 68 | } 69 | 70 | /** 71 | * Passes updateMeasureState through to the underlying MetricAffectingSpan. 72 | */ 73 | updateMeasureState(tp:TextPaint):void { 74 | this.mStyle.updateMeasureState(tp); 75 | } 76 | 77 | /** 78 | * Returns the MetricAffectingSpan underlying this one, or the one 79 | * underlying it if it too is a Passthrough. 80 | */ 81 | getUnderlying():MetricAffectingSpan { 82 | return this.mStyle.getUnderlying(); 83 | } 84 | } 85 | } 86 | 87 | } -------------------------------------------------------------------------------- /src/android/text/style/ParagraphStyle.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | module android.text.style { 19 | /** 20 | * The classes that affect paragraph-level text formatting implement 21 | * this interface. 22 | */ 23 | export interface ParagraphStyle { 24 | } 25 | export module ParagraphStyle{ 26 | export var type = Symbol(); 27 | } 28 | } -------------------------------------------------------------------------------- /src/android/text/style/ReplacementSpan.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | /// 21 | 22 | module android.text.style { 23 | import Paint = android.graphics.Paint; 24 | import Canvas = android.graphics.Canvas; 25 | import TextPaint = android.text.TextPaint; 26 | import MetricAffectingSpan = android.text.style.MetricAffectingSpan; 27 | 28 | export abstract class ReplacementSpan extends MetricAffectingSpan { 29 | static type = Symbol(); 30 | mType = ReplacementSpan.type; 31 | 32 | abstract getSize(paint:Paint, text:String, start:number, end:number, fm:Paint.FontMetricsInt):number ; 33 | 34 | abstract draw(canvas:Canvas, text:String, start:number, end:number, x:number, top:number, y:number, bottom:number, paint:Paint):void ; 35 | 36 | /** 37 | * This method does nothing, since ReplacementSpans are measured 38 | * explicitly instead of affecting Paint properties. 39 | */ 40 | updateMeasureState(p:TextPaint):void { 41 | } 42 | 43 | /** 44 | * This method does nothing, since ReplacementSpans are drawn 45 | * explicitly instead of affecting Paint properties. 46 | */ 47 | updateDrawState(ds:TextPaint):void { 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/android/text/style/TabStopSpan.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.text.style { 20 | import ParagraphStyle = android.text.style.ParagraphStyle; 21 | /** 22 | * Represents a single tab stop on a line. 23 | */ 24 | export interface TabStopSpan extends ParagraphStyle { 25 | 26 | /** 27 | * Returns the offset of the tab stop from the leading margin of the 28 | * line. 29 | * @return the offset 30 | */ 31 | getTabStop():number ; 32 | 33 | 34 | } 35 | 36 | export module TabStopSpan { 37 | export var type = Symbol(); 38 | export function isImpl(obj):boolean{ 39 | return obj && obj['getTabStop']; 40 | } 41 | 42 | /** 43 | * The default implementation of TabStopSpan. 44 | */ 45 | export class Standard implements TabStopSpan { 46 | 47 | /** 48 | * Constructor. 49 | * 50 | * @param where the offset of the tab stop from the leading margin of 51 | * the line 52 | */ 53 | constructor(where:number) { 54 | this.mTab = where; 55 | } 56 | 57 | getTabStop():number { 58 | return this.mTab; 59 | } 60 | 61 | private mTab:number = 0; 62 | } 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /src/android/text/style/UpdateAppearance.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.text.style { 20 | import UpdateLayout = android.text.style.UpdateLayout; 21 | /** 22 | * The classes that affect character-level text in a way that modifies their 23 | * appearance when one is added or removed must implement this interface. Note 24 | * that if the class also impacts size or other metrics, it should instead 25 | * implement {@link UpdateLayout}. 26 | */ 27 | export interface UpdateAppearance { 28 | } 29 | } -------------------------------------------------------------------------------- /src/android/text/style/UpdateLayout.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.text.style { 20 | import UpdateAppearance = android.text.style.UpdateAppearance; 21 | /** 22 | * The classes that affect character-level text formatting in a way that 23 | * triggers a text layout update when one is added or removed must implement 24 | * this interface. This interface also includes {@link UpdateAppearance} 25 | * since such a change implicitly also impacts the appearance. 26 | */ 27 | export interface UpdateLayout extends UpdateAppearance { 28 | } 29 | } -------------------------------------------------------------------------------- /src/android/text/style/WrapTogetherSpan.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.text.style { 20 | import ParagraphStyle = android.text.style.ParagraphStyle; 21 | export interface WrapTogetherSpan extends ParagraphStyle { 22 | } 23 | } -------------------------------------------------------------------------------- /src/android/util/ArrayMap.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/12/12. 3 | * AndroidUI's impl. 4 | */ 5 | module android.util{ 6 | export class ArrayMap{ 7 | private map = new Map(); 8 | 9 | constructor(capacity?:number){ 10 | } 11 | clear() { 12 | this.map.clear(); 13 | } 14 | erase() { 15 | this.map.clear(); 16 | } 17 | 18 | 19 | ensureCapacity(minimumCapacity:number):void { 20 | //do nothing 21 | } 22 | 23 | containsKey(key:K):boolean { 24 | return this.map.has(key); 25 | } 26 | 27 | 28 | indexOfValue(value:V):number { 29 | return [...this.map.values()].indexOf(value); 30 | } 31 | 32 | containsValue(value:V):boolean { 33 | return this.indexOfValue(value) >= 0; 34 | } 35 | get(key:K):V { 36 | return this.map.get(key); 37 | } 38 | 39 | keyAt(index:number):K { 40 | return [...this.map.keys()][index]; 41 | } 42 | 43 | valueAt(index:number):V { 44 | return [...this.map.values()][index]; 45 | } 46 | 47 | setValueAt(index:number, value:V):V { 48 | let key = this.keyAt(index); 49 | if(key==null) throw Error('index error'); 50 | let oldV = this.get(key); 51 | this.map.set(key, value); 52 | return oldV; 53 | } 54 | 55 | isEmpty():boolean { 56 | return this.map.size <= 0; 57 | } 58 | 59 | put(key:K, value:V):V { 60 | let oldV = this.get(key); 61 | this.map.set(key, value); 62 | return oldV; 63 | } 64 | 65 | append(key:K, value:V):void { 66 | this.map.set(key, value); 67 | } 68 | 69 | remove(key:K):V { 70 | let oldV = this.get(key); 71 | this.map.delete(key); 72 | return oldV; 73 | } 74 | 75 | removeAt(index:number):V { 76 | let key = this.keyAt(index); 77 | if(key==null) throw Error('index error'); 78 | let oldV = this.get(key); 79 | this.map.delete(key); 80 | return oldV; 81 | } 82 | 83 | keySet():Set { 84 | return new Set(this.map.keys()); 85 | } 86 | size() { 87 | return this.map.size; 88 | } 89 | 90 | 91 | } 92 | } -------------------------------------------------------------------------------- /src/android/util/CopyOnWriteArray.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/10/6. 3 | * AndroidUI's impl. 4 | */ 5 | module android.util { 6 | 7 | class Access{ 8 | mData:Array; 9 | mSize:number; 10 | 11 | get(index:number):T { 12 | return this.mData[index]; 13 | } 14 | 15 | size():number { 16 | return this.mSize; 17 | } 18 | 19 | } 20 | export class CopyOnWriteArray { 21 | private mData:Array = []; 22 | private mDataCopy:Array; 23 | private mAccess = new Access(); 24 | 25 | private mStart:boolean; 26 | 27 | private getArray():Array { 28 | if (this.mStart) { 29 | if (this.mDataCopy == null) this.mDataCopy = [...this.mData]; 30 | return this.mDataCopy; 31 | } 32 | return this.mData; 33 | } 34 | 35 | start():Array { 36 | if (this.mStart) throw new Error("Iteration already started"); 37 | this.mStart = true; 38 | this.mDataCopy = null; 39 | this.mAccess.mData = this.mData; 40 | this.mAccess.mSize = this.mData.length; 41 | 42 | return this.mAccess.mData; 43 | } 44 | end() { 45 | if (!this.mStart) throw new Error("Iteration not started"); 46 | this.mStart = false; 47 | if (this.mDataCopy != null) { 48 | this.mData = this.mDataCopy; 49 | this.mAccess.mData = []; 50 | this.mAccess.mSize = 0; 51 | } 52 | this.mDataCopy = null; 53 | } 54 | 55 | //[Symbol.iterator](){ 56 | // return this.start()[Symbol.iterator](); 57 | //} 58 | 59 | size():number { 60 | return this.getArray().length; 61 | } 62 | add(...items: T[]) { 63 | this.getArray().push(...items); 64 | } 65 | addAll(array:CopyOnWriteArray) { 66 | this.getArray().push(...array.mData); 67 | } 68 | remove(item:T ) { 69 | this.getArray().splice(this.getArray().indexOf(item), 1); 70 | } 71 | 72 | } 73 | } -------------------------------------------------------------------------------- /src/android/util/DisplayMetrics.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/10/5. 3 | * AndroidUI's impl. 4 | */ 5 | module android.util{ 6 | export class DisplayMetrics{ 7 | static DENSITY_LOW = 120; 8 | static DENSITY_MEDIUM = 160; 9 | static DENSITY_HIGH = 240; 10 | static DENSITY_XHIGH = 320; 11 | static DENSITY_XXHIGH = 480; 12 | static DENSITY_XXXHIGH = 640; 13 | static DENSITY_DEFAULT = DisplayMetrics.DENSITY_MEDIUM; 14 | 15 | widthPixels:number; 16 | heightPixels:number; 17 | density:number; 18 | densityDpi:number; 19 | scaledDensity:number; 20 | xdpi:number; 21 | ydpi:number; 22 | } 23 | } -------------------------------------------------------------------------------- /src/android/util/LayoutDirection.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | module android.util { 19 | /** 20 | * A class for defining layout directions. A layout direction can be left-to-right (LTR) 21 | * or right-to-left (RTL). It can also be inherited (from a parent) or deduced from the default 22 | * language script of a locale. 23 | */ 24 | export class LayoutDirection { 25 | 26 | /** 27 | * Horizontal layout direction is from Left to Right. 28 | */ 29 | static LTR:number = 0; 30 | 31 | /** 32 | * Horizontal layout direction is from Right to Left. 33 | */ 34 | static RTL:number = 1; 35 | 36 | /** 37 | * Horizontal layout direction is inherited. 38 | */ 39 | static INHERIT:number = 2; 40 | 41 | /** 42 | * Horizontal layout direction is deduced from the default language script for the locale. 43 | */ 44 | static LOCALE:number = 3; 45 | } 46 | } -------------------------------------------------------------------------------- /src/android/util/LongSparseArray.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/10/3. 3 | * AndroidUI's impl 4 | */ 5 | /// 6 | 7 | module android.util { 8 | export class LongSparseArray extends SparseArray{ 9 | } 10 | } -------------------------------------------------------------------------------- /src/android/util/SparseArray.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/10/3. 3 | * AndroidUI's impl. 4 | */ 5 | /// 6 | 7 | module android.util { 8 | 9 | export class SparseArray extends SparseMap { 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /src/android/util/SparseBooleanArray.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/10/3. 3 | * AndroidUI's impl. 4 | */ 5 | /// 6 | 7 | module android.util { 8 | export class SparseBooleanArray extends SparseArray{ 9 | } 10 | } -------------------------------------------------------------------------------- /src/android/util/SparseMap.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/10/3. 3 | * AndroidUI's impl. 4 | */ 5 | module android.util { 6 | 7 | //AndroidUI only. 8 | export class SparseMap { 9 | map:Map; 10 | 11 | constructor(initialCapacity?:number) { 12 | this.map = new Map(); 13 | } 14 | 15 | clone():SparseMap { 16 | let clone = new SparseMap(); 17 | clone.map = new Map(this.map); 18 | return clone; 19 | } 20 | 21 | get(key:K, valueIfKeyNotFound:T=null) { 22 | let value = this.map.get(key); 23 | if(value===undefined) return valueIfKeyNotFound; 24 | return value; 25 | } 26 | 27 | delete(key:K) { 28 | this.map.delete(key); 29 | } 30 | 31 | remove(key:K) { 32 | this.delete(key); 33 | } 34 | 35 | removeAt(index:number) { 36 | this.removeAtRange(index); 37 | } 38 | 39 | removeAtRange(index:number, size = 1) { 40 | let keys = [...this.map.keys()]; 41 | let end = Math.min(this.map.size, index + size); 42 | for (let i = index; i < end; i++) { 43 | this.map.delete(keys[i]); 44 | } 45 | } 46 | 47 | put(key:K, value:T) { 48 | this.map.set(key, value); 49 | } 50 | 51 | size():number { 52 | return this.map.size; 53 | } 54 | 55 | keyAt(index:number):K { 56 | return [...this.map.keys()][index]; 57 | } 58 | 59 | valueAt(index:number):T { 60 | return [...this.map.values()][index]; 61 | } 62 | 63 | setValueAt(index:number, value:T) { 64 | let key = this.keyAt(index); 65 | this.map.set(key, value); 66 | } 67 | 68 | indexOfKey(key:K):number { 69 | return [...this.map.keys()].indexOf(key); 70 | } 71 | 72 | indexOfValue(value:T):number { 73 | return [...this.map.values()].indexOf(value); 74 | } 75 | 76 | clear() { 77 | this.map.clear(); 78 | } 79 | 80 | append(key, value) { 81 | this.put(key, value); 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /src/android/view/HapticFeedbackConstants.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.view { 20 | import View = android.view.View; 21 | /** 22 | * Constants to be used to perform haptic feedback effects via 23 | * {@link View#performHapticFeedback(int)} 24 | */ 25 | export class HapticFeedbackConstants { 26 | 27 | /** 28 | * The user has performed a long press on an object that is resulting 29 | * in an action being performed. 30 | */ 31 | static LONG_PRESS:number = 0; 32 | 33 | /** 34 | * The user has pressed on a virtual on-screen key. 35 | */ 36 | static VIRTUAL_KEY:number = 1; 37 | 38 | /** 39 | * The user has pressed a soft keyboard key. 40 | */ 41 | static KEYBOARD_TAP:number = 3; 42 | 43 | /** 44 | * This is a private constant. Feel free to renumber as desired. 45 | * @hide 46 | */ 47 | static SAFE_MODE_DISABLED:number = 10000; 48 | 49 | /** 50 | * This is a private constant. Feel free to renumber as desired. 51 | * @hide 52 | */ 53 | static SAFE_MODE_ENABLED:number = 10001; 54 | 55 | /** 56 | * Flag for {@link View#performHapticFeedback(int, int) 57 | * View.performHapticFeedback(int, int)}: Ignore the setting in the 58 | * view for whether to perform haptic feedback, do it always. 59 | */ 60 | static FLAG_IGNORE_VIEW_SETTING:number = 0x0001; 61 | 62 | /** 63 | * Flag for {@link View#performHapticFeedback(int, int) 64 | * View.performHapticFeedback(int, int)}: Ignore the global setting 65 | * for whether to perform haptic feedback, do it always. 66 | */ 67 | static FLAG_IGNORE_GLOBAL_SETTING:number = 0x0002; 68 | } 69 | } -------------------------------------------------------------------------------- /src/android/view/SoundEffectConstants.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /// 17 | 18 | 19 | module android.view { 20 | /** 21 | * Constants to be used to play sound effects via {@link View#playSoundEffect(int)} 22 | */ 23 | export class SoundEffectConstants { 24 | 25 | static CLICK:number = 0; 26 | 27 | static NAVIGATION_LEFT:number = 1; 28 | 29 | static NAVIGATION_UP:number = 2; 30 | 31 | static NAVIGATION_RIGHT:number = 3; 32 | 33 | static NAVIGATION_DOWN:number = 4; 34 | 35 | /** 36 | * Get the sonification constant for the focus directions. 37 | * @param direction One of {@link View#FOCUS_UP}, {@link View#FOCUS_DOWN}, 38 | * {@link View#FOCUS_LEFT}, {@link View#FOCUS_RIGHT}, {@link View#FOCUS_FORWARD} 39 | * or {@link View#FOCUS_BACKWARD} 40 | 41 | * @return The appropriate sonification constant. 42 | */ 43 | static getContantForFocusDirection(direction:number):number { 44 | switch(direction) { 45 | case View.FOCUS_RIGHT: 46 | return SoundEffectConstants.NAVIGATION_RIGHT; 47 | case View.FOCUS_FORWARD: 48 | case View.FOCUS_DOWN: 49 | return SoundEffectConstants.NAVIGATION_DOWN; 50 | case View.FOCUS_LEFT: 51 | return SoundEffectConstants.NAVIGATION_LEFT; 52 | case View.FOCUS_BACKWARD: 53 | case View.FOCUS_UP: 54 | return SoundEffectConstants.NAVIGATION_UP; 55 | } 56 | throw Error(`new IllegalArgumentException("direction must be one of " + "{FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_FORWARD, FOCUS_BACKWARD}.")`); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /src/android/view/animation/AccelerateDecelerateInterpolator.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.view.animation{ 20 | /** 21 | * An interpolator where the rate of change starts and ends slowly but 22 | * accelerates through the middle. 23 | * 24 | */ 25 | export class AccelerateDecelerateInterpolator implements Interpolator{ 26 | getInterpolation(input:number):number { 27 | return (Math.cos((input + 1) * Math.PI) / 2) + 0.5; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/android/view/animation/AccelerateInterpolator.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.view.animation { 20 | /** 21 | * An interpolator where the rate of change starts out slowly and 22 | * and then accelerates. 23 | * 24 | */ 25 | export class AccelerateInterpolator implements Interpolator { 26 | private mFactor:number; 27 | private mDoubleFactor:number; 28 | 29 | /** 30 | * Constructor 31 | * 32 | * @param factor Degree to which the animation should be eased. Seting 33 | * factor to 1.0f produces a y=x^2 parabola. Increasing factor above 34 | * 1.0f exaggerates the ease-in effect (i.e., it starts even 35 | * slower and ends evens faster) 36 | */ 37 | constructor(factor = 1) { 38 | this.mFactor = factor; 39 | this.mDoubleFactor = factor * 2; 40 | } 41 | 42 | getInterpolation(input:number):number { 43 | 44 | if (this.mFactor == 1.0) { 45 | return input * input; 46 | } else { 47 | return Math.pow(input, this.mDoubleFactor); 48 | } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/android/view/animation/AlphaAnimation.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | 20 | module android.view.animation { 21 | import Animation = android.view.animation.Animation; 22 | import Transformation = android.view.animation.Transformation; 23 | /** 24 | * An animation that controls the alpha level of an object. 25 | * Useful for fading things in and out. This animation ends up 26 | * changing the alpha property of a {@link Transformation} 27 | * 28 | */ 29 | export class AlphaAnimation extends Animation { 30 | 31 | private mFromAlpha:number = 0; 32 | 33 | private mToAlpha:number = 0; 34 | 35 | ///** 36 | // * Constructor used when an AlphaAnimation is loaded from a resource. 37 | // * 38 | // * @param context Application context to use 39 | // * @param attrs Attribute set from which to read values 40 | // */ 41 | //constructor( context:Context, attrs:AttributeSet) { 42 | // super(context, attrs); 43 | // let a:TypedArray = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.AlphaAnimation); 44 | // this.mFromAlpha = a.getFloat(com.android.internal.R.styleable.AlphaAnimation_fromAlpha, 1.0); 45 | // this.mToAlpha = a.getFloat(com.android.internal.R.styleable.AlphaAnimation_toAlpha, 1.0); 46 | // a.recycle(); 47 | //} 48 | 49 | /** 50 | * Constructor to use when building an AlphaAnimation from code 51 | * 52 | * @param fromAlpha Starting alpha value for the animation, where 1.0 means 53 | * fully opaque and 0.0 means fully transparent. 54 | * @param toAlpha Ending alpha value for the animation. 55 | */ 56 | constructor(fromAlpha:number, toAlpha:number) { 57 | super(); 58 | this.mFromAlpha = fromAlpha; 59 | this.mToAlpha = toAlpha; 60 | } 61 | 62 | /** 63 | * Changes the alpha property of the supplied {@link Transformation} 64 | */ 65 | protected applyTransformation(interpolatedTime:number, t:Transformation):void { 66 | const alpha:number = this.mFromAlpha; 67 | t.setAlpha(alpha + ((this.mToAlpha - alpha) * interpolatedTime)); 68 | } 69 | 70 | willChangeTransformationMatrix():boolean { 71 | return false; 72 | } 73 | 74 | willChangeBounds():boolean { 75 | return false; 76 | } 77 | 78 | /** 79 | * @hide 80 | */ 81 | hasAlpha():boolean { 82 | return true; 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /src/android/view/animation/AnimationUtils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.view.animation { 20 | import SystemClock = android.os.SystemClock; 21 | /** 22 | * Defines common utilities for working with animations. 23 | * 24 | */ 25 | export class AnimationUtils { 26 | /** 27 | * Returns the current animation time in milliseconds. This time should be used when invoking 28 | * {@link Animation#setStartTime(long)}. Refer to {@link android.os.SystemClock} for more 29 | * information about the different available clocks. The clock used by this method is 30 | * not the "wall" clock (it is not {@link System#currentTimeMillis}). 31 | * 32 | * @return the current animation time in milliseconds 33 | * 34 | * @see android.os.SystemClock 35 | */ 36 | static currentAnimationTimeMillis():number { 37 | return SystemClock.uptimeMillis(); 38 | } 39 | 40 | /** 41 | * Loads an {@link Animation} object from a resource 42 | * 43 | * @param context Application context used to access resources 44 | * @param id The resource id of the animation to load 45 | * @return The animation object reference by the specified id 46 | * @throws NotFoundException when the animation cannot be loaded 47 | */ 48 | public static loadAnimation(context:android.content.Context, id:string):Animation { 49 | return context.getResources().getAnimation(id); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/android/view/animation/AnticipateInterpolator.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.view.animation{ 20 | /** 21 | * An interpolator where the change starts backward then flings forward. 22 | */ 23 | export class AnticipateInterpolator implements Interpolator{ 24 | private mTension:number; 25 | /** 26 | * @param tension Amount of anticipation. When tension equals 0.0f, there is 27 | * no anticipation and the interpolator becomes a simple 28 | * acceleration interpolator. 29 | */ 30 | constructor(tension=2) { 31 | this.mTension = tension; 32 | } 33 | 34 | getInterpolation(t:number):number { 35 | // a(t) = t * t * ((tension + 1) * t - tension) 36 | return t * t * ((this.mTension + 1) * t - this.mTension); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/android/view/animation/AnticipateOvershootInterpolator.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.view.animation{ 20 | /** 21 | * An interpolator where the change starts backward then flings forward and overshoots 22 | * the target value and finally goes back to the final value. 23 | */ 24 | export class AnticipateOvershootInterpolator implements Interpolator{ 25 | private mTension:number; 26 | /** 27 | * @param tension Amount of anticipation/overshoot. When tension equals 0.0f, 28 | * there is no anticipation/overshoot and the interpolator becomes 29 | * a simple acceleration/deceleration interpolator. 30 | * @param extraTension Amount by which to multiply the tension. For instance, 31 | * to get the same overshoot as an OvershootInterpolator with 32 | * a tension of 2.0f, you would use an extraTension of 1.5f. 33 | */ 34 | constructor(tension=2, extraTension=1.5) { 35 | this.mTension = tension * extraTension; 36 | } 37 | 38 | private static a(t:number, s:number):number{ 39 | return t * t * ((s + 1) * t - s); 40 | } 41 | private static o(t:number, s:number):number{ 42 | return t * t * ((s + 1) * t + s); 43 | } 44 | 45 | 46 | getInterpolation(t:number):number { 47 | // a(t, s) = t * t * ((s + 1) * t - s) 48 | // o(t, s) = t * t * ((s + 1) * t + s) 49 | // f(t) = 0.5 * a(t * 2, tension * extraTension), when t < 0.5 50 | // f(t) = 0.5 * (o(t * 2 - 2, tension * extraTension) + 2), when t <= 1.0 51 | if (t < 0.5) return 0.5 * AnticipateOvershootInterpolator.a(t * 2.0, this.mTension); 52 | else return 0.5 * (AnticipateOvershootInterpolator.o(t * 2.0 - 2.0, this.mTension) + 2.0); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/android/view/animation/BounceInterpolator.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /// 17 | 18 | module android.view.animation { 19 | /** 20 | * An interpolator where the change bounces at the end. 21 | */ 22 | export class BounceInterpolator implements Interpolator { 23 | private static bounce(t:number):number { 24 | return t * t * 8.0; 25 | } 26 | 27 | getInterpolation(t:number):number { 28 | // _b(t) = t * t * 8 29 | // bs(t) = _b(t) for t < 0.3535 30 | // bs(t) = _b(t - 0.54719) + 0.7 for t < 0.7408 31 | // bs(t) = _b(t - 0.8526) + 0.9 for t < 0.9644 32 | // bs(t) = _b(t - 1.0435) + 0.95 for t <= 1.0 33 | // b(t) = bs(t * 1.1226) 34 | t *= 1.1226; 35 | if (t < 0.3535) return BounceInterpolator.bounce(t); 36 | else if (t < 0.7408) return BounceInterpolator.bounce(t - 0.54719) + 0.7; 37 | else if (t < 0.9644) return BounceInterpolator.bounce(t - 0.8526) + 0.9; 38 | else return BounceInterpolator.bounce(t - 1.0435) + 0.95; 39 | } 40 | 41 | } 42 | } -------------------------------------------------------------------------------- /src/android/view/animation/CycleInterpolator.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /// 17 | 18 | module android.view.animation{ 19 | /** 20 | * Repeats the animation for a specified number of cycles. The 21 | * rate of change follows a sinusoidal pattern. 22 | * 23 | */ 24 | export class CycleInterpolator implements Interpolator{ 25 | private mCycles:number; 26 | constructor(mCycles:number) { 27 | this.mCycles = mCycles; 28 | } 29 | 30 | getInterpolation(input:number):number { 31 | return (Math.sin(2 * this.mCycles * Math.PI * input)); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/android/view/animation/DecelerateInterpolator.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.view.animation { 20 | /** 21 | * An interpolator where the rate of change starts out quickly and 22 | * and then decelerates. 23 | * 24 | */ 25 | export class DecelerateInterpolator implements Interpolator { 26 | private mFactor:number; 27 | 28 | /** 29 | * Constructor 30 | * 31 | * @param factor Degree to which the animation should be eased. Setting factor to 1.0f produces 32 | * an upside-down y=x^2 parabola. Increasing factor above 1.0f makes exaggerates the 33 | * ease-out effect (i.e., it starts even faster and ends evens slower) 34 | */ 35 | constructor(factor = 1) { 36 | this.mFactor = factor; 37 | } 38 | 39 | getInterpolation(input:number):number { 40 | let result; 41 | if (this.mFactor == 1.0) { 42 | result = (1.0 - (1.0 - input) * (1.0 - input)); 43 | } else { 44 | result = (1.0 - Math.pow((1.0 - input), 2 * this.mFactor)); 45 | } 46 | return result; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/android/view/animation/Interpolator.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module android.view.animation{ 18 | /** 19 | * An interpolator defines the rate of change of an animation. This allows 20 | * the basic animation effects (alpha, scale, translate, rotate) to be 21 | * accelerated, decelerated, repeated, etc. 22 | */ 23 | export interface Interpolator{ 24 | /** 25 | * Maps a value representing the elapsed fraction of an animation to a value that represents 26 | * the interpolated fraction. This interpolated value is then multiplied by the change in 27 | * value of an animation to derive the animated value at the current elapsed animation time. 28 | * 29 | * @param input A value between 0 and 1.0 indicating our current point 30 | * in the animation where 0 represents the start and 1.0 represents 31 | * the end 32 | * @return The interpolation value. This value can be more than 1.0 for 33 | * interpolators which overshoot their targets, or less than 0 for 34 | * interpolators that undershoot their targets. 35 | */ 36 | getInterpolation(input:number):number; 37 | } 38 | } -------------------------------------------------------------------------------- /src/android/view/animation/LinearInterpolator.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.view.animation{ 20 | /** 21 | * An interpolator where the rate of change is constant 22 | * 23 | */ 24 | export class LinearInterpolator implements Interpolator{ 25 | getInterpolation(input:number):number { 26 | return input; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/android/view/animation/OvershootInterpolator.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.view.animation { 20 | /** 21 | * An interpolator where the change flings forward and overshoots the last value 22 | * then comes back. 23 | */ 24 | export class OvershootInterpolator implements Interpolator { 25 | private mTension:number; 26 | 27 | /** 28 | * @param tension Amount of overshoot. When tension equals 0.0f, there is 29 | * no overshoot and the interpolator becomes a simple 30 | * deceleration interpolator. 31 | */ 32 | constructor(tension = 2) { 33 | this.mTension = tension; 34 | } 35 | 36 | getInterpolation(t:number):number { 37 | // _o(t) = t * t * ((tension + 1) * t + tension) 38 | // o(t) = _o(t - 1) + 1 39 | t -= 1.0; 40 | return t * t * ((this.mTension + 1) * t + this.mTension) + 1.0; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/android/webkit/WebViewClient.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | module android.webkit { 4 | export class WebViewClient { 5 | onPageFinished(view:WebView, url:string):void { 6 | 7 | } 8 | 9 | /** 10 | * Notify the host application of a change in the document title. 11 | * @param view The WebView that initiated the callback. 12 | * @param title A String containing the new title of the document. 13 | */ 14 | onReceivedTitle(view:WebView, title:string):void { 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/android/widget/CheckBox.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | /// 21 | 22 | module android.widget { 23 | import Button = android.widget.Button; 24 | import CompoundButton = android.widget.CompoundButton; 25 | import TextView = android.widget.TextView; 26 | /** 27 | *

28 | * A checkbox is a specific type of two-states button that can be either 29 | * checked or unchecked. A example usage of a checkbox inside your activity 30 | * would be the following: 31 | *

32 | * 33 | *
34 |      * public class MyActivity extends Activity {
35 |  *     protected void onCreate(Bundle icicle) {
36 |  *         super.onCreate(icicle);
37 |  *
38 |  *         setContentView(R.layout.content_layout_id);
39 |  *
40 |  *         final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbox_id);
41 |  *         if (checkBox.isChecked()) {
42 |  *             checkBox.setChecked(false);
43 |  *         }
44 |  *     }
45 |  * }
46 |      * 
47 | * 48 | *

See the Checkboxes 49 | * guide.

50 | * 51 | *

XML attributes

52 | *

53 | * See {@link android.R.styleable#CompoundButton CompoundButton Attributes}, 54 | * {@link android.R.styleable#Button Button Attributes}, 55 | * {@link android.R.styleable#TextView TextView Attributes}, 56 | * {@link android.R.styleable#View View Attributes} 57 | *

58 | */ 59 | export class CheckBox extends CompoundButton { 60 | 61 | constructor(context:android.content.Context, bindElement?:HTMLElement, defStyle = android.R.attr.checkboxStyle) { 62 | super(context, bindElement, defStyle); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /src/android/widget/Checkable.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | module android.widget { 19 | /** 20 | * Defines an extension for views that make them checkable. 21 | * 22 | */ 23 | export interface Checkable { 24 | 25 | /** 26 | * Change the checked state of the view 27 | * 28 | * @param checked The new checked state 29 | */ 30 | setChecked(checked:boolean):void ; 31 | 32 | /** 33 | * @return The current checked state of the view 34 | */ 35 | isChecked():boolean ; 36 | 37 | /** 38 | * Change the checked state of the view to the inverse of its current state 39 | * 40 | */ 41 | toggle():void ; 42 | } 43 | } -------------------------------------------------------------------------------- /src/android/widget/ImageButton.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | 21 | module android.widget{ 22 | 23 | /** 24 | *

25 | * Displays a button with an image (instead of text) that can be pressed 26 | * or clicked by the user. By default, an ImageButton looks like a regular 27 | * {@link android.widget.Button}, with the standard button background 28 | * that changes color during different button states. The image on the surface 29 | * of the button is defined either by the {@code android:src} attribute in the 30 | * {@code } XML element or by the 31 | * {@link #setImageResource(int)} method.

32 | * 33 | *

To remove the standard button background image, define your own 34 | * background image or set the background color to be transparent.

35 | *

To indicate the different button states (focused, selected, etc.), you can 36 | * define a different image for each state. E.g., a blue image by default, an 37 | * orange one for when focused, and a yellow one for when pressed. An easy way to 38 | * do this is with an XML drawable "selector." For example:

39 | *
40 |      * <?xml version="1.0" encoding="utf-8"?>
41 |      * <selector xmlns:android="http://schemas.android.com/apk/res/android">
42 |      *     <item android:state_pressed="true"
43 |      *           android:drawable="@drawable/button_pressed" /> <!-- pressed -->
44 |      *     <item android:state_focused="true"
45 |      *           android:drawable="@drawable/button_focused" /> <!-- focused -->
46 |      *     <item android:drawable="@drawable/button_normal" /> <!-- default -->
47 |      * </selector>
48 | * 49 | *

Save the XML file in your project {@code res/drawable/} folder and then 50 | * reference it as a drawable for the source of your ImageButton (in the 51 | * {@code android:src} attribute). Android will automatically change the image 52 | * based on the state of the button and the corresponding images 53 | * defined in the XML.

54 | * 55 | *

The order of the {@code } elements is important because they are 56 | * evaluated in order. This is why the "normal" button image comes last, because 57 | * it will only be applied after {@code android:state_pressed} and {@code 58 | * android:state_focused} have both evaluated false.

59 | * 60 | *

See the Buttons 61 | * guide.

62 | * 63 | *

XML attributes

64 | *

65 | * See {@link android.R.styleable#ImageView Button Attributes}, 66 | * {@link android.R.styleable#View View Attributes} 67 | *

68 | */ 69 | export class ImageButton extends ImageView { 70 | constructor(context:android.content.Context, bindElement?:HTMLElement, defStyle = android.R.attr.imageButtonStyle){ 71 | super(context, bindElement, defStyle); 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /src/android/widget/ListAdapter.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | 19 | module android.widget { 20 | import Adapter = android.widget.Adapter; 21 | /** 22 | * Extended {@link Adapter} that is the bridge between a {@link ListView} 23 | * and the data that backs the list. Frequently that data comes from a Cursor, 24 | * but that is not 25 | * required. The ListView can display any data provided that it is wrapped in a 26 | * ListAdapter. 27 | */ 28 | export interface ListAdapter extends Adapter { 29 | 30 | /** 31 | * Indicates whether all the items in this adapter are enabled. If the 32 | * value returned by this method changes over time, there is no guarantee 33 | * it will take effect. If true, it means all items are selectable and 34 | * clickable (there is no separator.) 35 | * 36 | * @return True if all items are enabled, false otherwise. 37 | * 38 | * @see #isEnabled(int) 39 | */ 40 | areAllItemsEnabled():boolean ; 41 | 42 | /** 43 | * Returns true if the item at the specified position is not a separator. 44 | * (A separator is a non-selectable, non-clickable item). 45 | * 46 | * The result is unspecified if position is invalid. An {@link ArrayIndexOutOfBoundsException} 47 | * should be thrown in that case for fast failure. 48 | * 49 | * @param position Index of the item 50 | * 51 | * @return True if the item is not a separator 52 | * 53 | * @see #areAllItemsEnabled() 54 | */ 55 | isEnabled(position:number):boolean ; 56 | } 57 | export module ListAdapter{ 58 | export function isImpl(obj){ 59 | return obj && obj['areAllItemsEnabled'] && obj['isEnabled']; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /src/android/widget/RadioButton.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | /// 21 | 22 | module android.widget { 23 | import Button = android.widget.Button; 24 | import CheckBox = android.widget.CheckBox; 25 | import CompoundButton = android.widget.CompoundButton; 26 | import TextView = android.widget.TextView; 27 | /** 28 | *

29 | * A radio button is a two-states button that can be either checked or 30 | * unchecked. When the radio button is unchecked, the user can press or click it 31 | * to check it. However, contrary to a {@link android.widget.CheckBox}, a radio 32 | * button cannot be unchecked by the user once checked. 33 | *

34 | * 35 | *

36 | * Radio buttons are normally used together in a 37 | * {@link android.widget.RadioGroup}. When several radio buttons live inside 38 | * a radio group, checking one radio button unchecks all the others.

39 | *

40 | * 41 | *

See the Radio Buttons 42 | * guide.

43 | * 44 | *

XML attributes

45 | *

46 | * See {@link android.R.styleable#CompoundButton CompoundButton Attributes}, 47 | * {@link android.R.styleable#Button Button Attributes}, 48 | * {@link android.R.styleable#TextView TextView Attributes}, 49 | * {@link android.R.styleable#View View Attributes} 50 | *

51 | */ 52 | export class RadioButton extends CompoundButton { 53 | 54 | constructor(context:android.content.Context, bindElement?:HTMLElement, defStyle = android.R.attr.radiobuttonStyle) { 55 | super(context, bindElement, defStyle); 56 | } 57 | 58 | /** 59 | * {@inheritDoc} 60 | *

61 | * If the radio button is already checked, this method will not toggle the radio button. 62 | */ 63 | toggle():void { 64 | // checked (as opposed to check boxes widgets) 65 | if (!this.isChecked()) { 66 | super.toggle(); 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /src/android/widget/Scroller.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 16/1/15. 3 | * AndroidUI's impl 4 | */ 5 | /// 6 | 7 | module android.widget { 8 | export class Scroller extends OverScroller{ 9 | } 10 | } -------------------------------------------------------------------------------- /src/android/widget/SpinnerAdapter.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | 21 | module android.widget { 22 | import View = android.view.View; 23 | import ViewGroup = android.view.ViewGroup; 24 | import Adapter = android.widget.Adapter; 25 | /** 26 | * Extended {@link Adapter} that is the bridge between a 27 | * {@link android.widget.Spinner} and its data. A spinner adapter allows to 28 | * define two different views: one that shows the data in the spinner itself and 29 | * one that shows the data in the drop down list when the spinner is pressed.

30 | */ 31 | export interface SpinnerAdapter extends Adapter { 32 | 33 | /** 34 | *

Get a {@link android.view.View} that displays in the drop down popup 35 | * the data at the specified position in the data set.

36 | * 37 | * @param position index of the item whose view we want. 38 | * @param convertView the old view to reuse, if possible. Note: You should 39 | * check that this view is non-null and of an appropriate type before 40 | * using. If it is not possible to convert this view to display the 41 | * correct data, this method can create a new view. 42 | * @param parent the parent that this view will eventually be attached to 43 | * @return a {@link android.view.View} corresponding to the data at the 44 | * specified position. 45 | */ 46 | getDropDownView(position:number, convertView:View, parent:ViewGroup):View ; 47 | } 48 | } -------------------------------------------------------------------------------- /src/android/widget/WrapperListAdapter.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | /// 20 | 21 | module android.widget { 22 | import Adapter = android.widget.Adapter; 23 | import ListAdapter = android.widget.ListAdapter; 24 | import ListView = android.widget.ListView; 25 | /** 26 | * List adapter that wraps another list adapter. The wrapped adapter can be retrieved 27 | * by calling {@link #getWrappedAdapter()}. 28 | * 29 | * @see ListView 30 | */ 31 | export interface WrapperListAdapter extends ListAdapter { 32 | 33 | /** 34 | * Returns the adapter wrapped by this list adapter. 35 | * 36 | * @return The {@link android.widget.ListAdapter} wrapped by this adapter. 37 | */ 38 | getWrappedAdapter():ListAdapter ; 39 | } 40 | } -------------------------------------------------------------------------------- /src/androidui/AndroidUIElement.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 16/1/4. 3 | */ 4 | 5 | /// 6 | 7 | module androidui{ 8 | 9 | if (typeof HTMLDivElement !== 'function'){ 10 | const _HTMLDivElement = function(){}; 11 | _HTMLDivElement.prototype = (HTMLDivElement).prototype; 12 | HTMLDivElement = _HTMLDivElement; 13 | } 14 | 15 | /** 16 | * Root Element of a android ui. 17 | */ 18 | export class AndroidUIElement extends HTMLDivElement { 19 | AndroidUI:AndroidUI; 20 | 21 | createdCallback():void{ 22 | $domReady(()=>initElement(this)); 23 | } 24 | 25 | attachedCallback():void { 26 | } 27 | 28 | detachedCallback():void { 29 | } 30 | 31 | attributeChangedCallback(attributeName:string, oldVal:string, newVal:string):void { 32 | if(attributeName==='debug' && newVal!=null && newVal!='false' && newVal!='0'){ 33 | this.AndroidUI.setDebugEnable(); 34 | } 35 | } 36 | } 37 | 38 | function runFunction(func:string){ 39 | if(typeof window[func] === "function"){ 40 | window[func](); 41 | }else{ 42 | try { 43 | eval(func); 44 | } catch (e) { 45 | console.warn(e); 46 | } 47 | } 48 | } 49 | 50 | function $domReady(func:()=>void){ 51 | if(/^loaded|^complete|^interactive/.test(document.readyState)){//already loaded 52 | //delay call onCreate, insure browser load lib complete 53 | setTimeout(func, 0); 54 | }else{ 55 | document.addEventListener('DOMContentLoaded', func); 56 | } 57 | } 58 | 59 | function initElement(ele:AndroidUIElement){ 60 | ele.AndroidUI = new AndroidUI(ele); 61 | let debugAttr = ele.getAttribute('debug'); 62 | if(debugAttr!=null && debugAttr!='0' && debugAttr!='false') ele.AndroidUI.setDebugEnable(); 63 | 64 | //life callback 65 | let onClose = ele.getAttribute('onclose'); 66 | if(onClose){ 67 | ele.AndroidUI.setUIClient({ 68 | shouldShowAppClosed(androidUI:AndroidUI):void { 69 | if(!onClose) return; 70 | runFunction(onClose); 71 | } 72 | }); 73 | } 74 | let onLoad = ele.getAttribute('onload'); 75 | if(onLoad){ 76 | runFunction(onLoad); 77 | } 78 | } 79 | 80 | if(typeof document['registerElement'] === "function"){ 81 | (document).registerElement("android-ui", AndroidUIElement); 82 | }else{ 83 | $domReady(()=>{ 84 | let eles = document.getElementsByTagName('android-ui'); 85 | for(let ele of Array.from(eles)){ 86 | initElement(ele); 87 | } 88 | }); 89 | } 90 | 91 | 92 | 93 | //init common style 94 | let styleElement = document.createElement('style'); 95 | styleElement.innerHTML += ` 96 | android-ui { 97 | position : relative; 98 | overflow : hidden; 99 | display : block; 100 | outline: none; 101 | } 102 | android-ui * { 103 | overflow : hidden; 104 | border : none; 105 | outline: none; 106 | pointer-events: auto; 107 | } 108 | android-ui resources { 109 | display: none; 110 | } 111 | android-ui Button { 112 | border: none; 113 | background: none; 114 | } 115 | android-ui windowsgroup { 116 | pointer-events: none; 117 | } 118 | android-ui > canvas { 119 | position: absolute; 120 | left: 0; 121 | top: 0; 122 | } 123 | `; 124 | document.head.appendChild(styleElement); 125 | } -------------------------------------------------------------------------------- /src/androidui/attr/StateAttr.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/11/3. 3 | */ 4 | /// 5 | /// 6 | /// 7 | 8 | module androidui.attr{ 9 | 10 | export class StateAttr { 11 | private stateSpec:number[]; 12 | private attributes = new Map(); 13 | 14 | constructor(state:number[]) { 15 | this.stateSpec = state.concat().sort(); 16 | } 17 | 18 | clone():StateAttr { 19 | let stateAttr = new StateAttr(this.stateSpec); 20 | stateAttr.attributes = new Map(this.attributes); 21 | return stateAttr; 22 | } 23 | 24 | setAttr(name:string, value:string){ 25 | this.attributes.set(name, value); 26 | } 27 | 28 | hasAttr(name:string){ 29 | return this.attributes.has(name); 30 | } 31 | 32 | getAttrMap():Map{ 33 | return this.attributes; 34 | } 35 | 36 | putAll(stateAttr:StateAttr){ 37 | for(let [key, value] of stateAttr.attributes.entries()){ 38 | this.attributes.set(key, value); 39 | } 40 | } 41 | 42 | isDefaultState():boolean { 43 | return this.stateSpec.length === 0; 44 | } 45 | 46 | isStateEquals(state:number[]):boolean{ 47 | if(!state) return false; 48 | return java.util.Arrays.equals(this.stateSpec, state.concat().sort()); 49 | } 50 | 51 | isStateMatch(state:number[]):boolean{ 52 | return android.util.StateSet.stateSetMatches(this.stateSpec, state); 53 | } 54 | 55 | 56 | /** 57 | * this:{'k1':'v1', 'k3':'v3-1'} 58 | * another:{'k2':'v2', 'k3':'v3-2'} 59 | * @returns {Map} new map: {'k1':'v1', 'k2':null, 'k3':'v3-1'} 60 | */ 61 | createDiffKeyAsNullValueAttrMap(another:StateAttr):Map{ 62 | if(!another) return this.attributes; 63 | let removed = new Map(another.attributes); 64 | for(let key of this.attributes.keys()) removed.delete(key); 65 | 66 | let merge = new Map(this.attributes); 67 | for(let key of removed.keys()) merge.set(key, null); 68 | 69 | return merge; 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /src/androidui/image/RegionImageDrawable.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/12/24. 3 | */ 4 | /// 5 | /// 6 | /// 7 | /// 8 | /// 9 | 10 | 11 | module androidui.image{ 12 | import Paint = android.graphics.Paint; 13 | import Rect = android.graphics.Rect; 14 | import Drawable = android.graphics.drawable.Drawable; 15 | import Canvas = android.graphics.Canvas; 16 | import Resources = android.content.res.Resources; 17 | 18 | export class RegionImageDrawable extends Drawable { 19 | private mState:State; 20 | 21 | constructor(image:NetImage, bound, paint = new Paint()){ 22 | super(); 23 | this.mState = new State(image, bound, paint); 24 | image.addLoadListener(()=>{ 25 | this.invalidateSelf(); 26 | }); 27 | } 28 | 29 | draw(canvas:Canvas):void { 30 | canvas.drawImage(this.mState.mImage, this.mState.mBound, this.getBounds(), this.mState.mPaint); 31 | } 32 | 33 | setAlpha(alpha:number):void { 34 | this.mState.mPaint.setAlpha(alpha); 35 | } 36 | 37 | getAlpha():number { 38 | return this.mState.mPaint.getAlpha(); 39 | } 40 | 41 | getIntrinsicWidth():number { 42 | return Math.floor(this.mState.mBound.width() * Resources.getDisplayMetrics().density / this.mState.mImage.getImageRatio()); 43 | } 44 | 45 | getIntrinsicHeight():number { 46 | return Math.floor(this.mState.mBound.height() * Resources.getDisplayMetrics().density / this.mState.mImage.getImageRatio()); 47 | } 48 | 49 | getImage():NetImage { 50 | return this.mState.mImage; 51 | } 52 | 53 | getConstantState():Drawable.ConstantState { 54 | return this.mState; 55 | } 56 | 57 | } 58 | 59 | class State implements Drawable.ConstantState{ 60 | mImage:NetImage; 61 | mBound:Rect; 62 | mPaint:Paint; 63 | constructor(image:NetImage, bound:Rect, paint:Paint) { 64 | this.mImage = image; 65 | this.mBound = bound; 66 | this.mPaint = paint; 67 | } 68 | newDrawable():Drawable { 69 | return new RegionImageDrawable(this.mImage, this.mBound, this.mPaint); 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /src/androidui/native/NativeEditText.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | module androidui.native { 5 | 6 | import Rect = android.graphics.Rect; 7 | export class NativeEditText extends android.widget.EditText { 8 | private mRectTmp = new Rect(); 9 | // protected setForceDisableDrawText(disable:boolean){ 10 | // //always show text on canvas. 11 | // } 12 | private computeTextArea():void { 13 | this.getGlobalVisibleRect(this.mRectTmp); 14 | 15 | if (this.mLayout == null) { 16 | this.assumeLayout(); 17 | } 18 | this.mRectTmp.left += this.getTotalPaddingLeft(); 19 | this.mRectTmp.top += this.getTotalPaddingTop(); 20 | this.mRectTmp.right -= (this.getTotalPaddingRight()); 21 | this.mRectTmp.bottom -= (this.getTotalPaddingBottom()); 22 | } 23 | 24 | protected onInputElementFocusChanged(focused:boolean):any { 25 | if(focused){ 26 | this.computeTextArea(); 27 | NativeApi.drawHTML.showDrawHTMLBound(this.hashCode(), this.mRectTmp.left, this.mRectTmp.top, this.mRectTmp.right, this.mRectTmp.bottom); 28 | }else{ 29 | NativeApi.drawHTML.hideDrawHTMLBound(this.hashCode()); 30 | } 31 | return super.onInputElementFocusChanged(focused); 32 | } 33 | 34 | protected tryShowInputElement():any { 35 | this.computeTextArea(); 36 | NativeApi.drawHTML.showDrawHTMLBound(this.hashCode(), this.mRectTmp.left, this.mRectTmp.top, this.mRectTmp.right, this.mRectTmp.bottom); 37 | return super.tryShowInputElement(); 38 | } 39 | 40 | protected tryDismissInputElement():any { 41 | NativeApi.drawHTML.hideDrawHTMLBound(this.hashCode()); 42 | return super.tryDismissInputElement(); 43 | } 44 | 45 | protected _syncBoundAndScrollToElement():void { 46 | super._syncBoundAndScrollToElement(); 47 | if(this.isInputElementShowed() && this.isFocused() && this.getText().length>0) { 48 | this.computeTextArea(); 49 | NativeApi.drawHTML.showDrawHTMLBound(this.hashCode(), this.mRectTmp.left, this.mRectTmp.top, this.mRectTmp.right, this.mRectTmp.bottom); 50 | } 51 | } 52 | 53 | protected onDetachedFromWindow():void { 54 | super.onDetachedFromWindow(); 55 | NativeApi.drawHTML.hideDrawHTMLBound(this.hashCode()); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /src/androidui/native/NativeHtmlView.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | module androidui.native{ 5 | import HtmlView = androidui.widget.HtmlView; 6 | import Rect = android.graphics.Rect; 7 | 8 | export class NativeHtmlView extends HtmlView { 9 | private mRectDrawHTMLBoundTmp = new Rect(); 10 | 11 | protected _syncBoundAndScrollToElement():void { 12 | super._syncBoundAndScrollToElement(); 13 | this.getGlobalVisibleRect(this.mRectDrawHTMLBoundTmp); 14 | NativeApi.drawHTML.showDrawHTMLBound(this.hashCode(), this.mRectDrawHTMLBoundTmp.left, this.mRectDrawHTMLBoundTmp.top, this.mRectDrawHTMLBoundTmp.right, this.mRectDrawHTMLBoundTmp.bottom); 15 | } 16 | 17 | protected onDetachedFromWindow():void { 18 | super.onDetachedFromWindow(); 19 | NativeApi.drawHTML.hideDrawHTMLBound(this.hashCode()); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/androidui/native/NativeImage.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/12/14. 3 | */ 4 | /// 5 | /// 6 | /// 7 | 8 | module androidui.native { 9 | import NetImage = androidui.image.NetImage; 10 | import Rect = android.graphics.Rect; 11 | 12 | let sNextId = 0; 13 | const NativeImageInstances = new Map(); 14 | 15 | export class NativeImage extends NetImage{ 16 | imageId:number; 17 | leftBorder:number[]; 18 | topBorder:number[]; 19 | rightBorder:number[]; 20 | bottomBorder:number[]; 21 | private getPixelsCallbacks:Array<(data:number[])=>void>; 22 | 23 | protected createImage(){ 24 | this.imageId = sNextId++; 25 | NativeImageInstances.set(this.imageId, this); 26 | NativeApi.image.createImage(this.imageId); 27 | } 28 | 29 | protected loadImage(){ 30 | NativeApi.image.loadImage(this.imageId, this.src); 31 | } 32 | 33 | recycle(){ 34 | NativeApi.image.recycleImage(this.imageId); 35 | NativeImageInstances.delete(this.imageId); 36 | } 37 | 38 | getPixels(bound:Rect, callBack:(data:number[])=>void):void { 39 | if(!callBack) return; 40 | if(!bound) bound = new Rect(0, 0, this.width, this.height); 41 | if(bound.isEmpty()) { 42 | callBack([]); 43 | return; 44 | } 45 | if(!this.getPixelsCallbacks) this.getPixelsCallbacks = []; 46 | this.getPixelsCallbacks.push(callBack); 47 | let callBackIndex = this.getPixelsCallbacks.length-1; 48 | NativeApi.image.getPixels(this.imageId, callBackIndex, bound.left, bound.top, bound.right, bound.bottom); 49 | } 50 | 51 | 52 | getBorderPixels(callBack:(leftBorder:number[], topBorder:number[], rightBorder:number[], bottomBorder:number[])=>void):void { 53 | if(!callBack) return; 54 | if(this.leftBorder && this.topBorder && this.rightBorder && this.bottomBorder){ 55 | callBack(this.leftBorder, this.topBorder, this.rightBorder, this.bottomBorder); 56 | }else{ 57 | super.getBorderPixels(callBack); 58 | } 59 | } 60 | 61 | //call from native 62 | private static notifyLoadFinish(imageId:number, width:number, height:number, 63 | leftBorder:number[], topBorder:number[], rightBorder:number[], bottomBorder:number[]){ 64 | let image:NativeImage = NativeImageInstances.get(imageId); 65 | image.mImageWidth = width; 66 | image.mImageHeight = height; 67 | image.leftBorder = leftBorder; 68 | image.topBorder = topBorder; 69 | image.rightBorder = rightBorder; 70 | image.bottomBorder = bottomBorder; 71 | image.fireOnLoad(); 72 | } 73 | //call from native 74 | private static notifyLoadError(imageId:number){ 75 | let image:NativeImage = NativeImageInstances.get(imageId); 76 | image.mImageWidth = image.mImageHeight = 0; 77 | image.fireOnError(); 78 | } 79 | 80 | //call from native 81 | private static notifyGetPixels(imageId:number, callBackIndex:number, data:number[]){ 82 | let image:NativeImage = NativeImageInstances.get(imageId); 83 | let callBack = image.getPixelsCallbacks[callBackIndex]; 84 | image.getPixelsCallbacks[callBackIndex] = null; 85 | callBack(data); 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /src/androidui/native/NativeSurface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/12/14. 3 | */ 4 | /// 5 | /// 6 | /// 7 | /// 8 | 9 | 10 | module androidui.native { 11 | import Surface = android.view.Surface; 12 | 13 | 14 | let sNextSurfaceID = 0; 15 | const SurfaceInstances = new Map(); 16 | 17 | export class NativeSurface extends Surface{ 18 | private surfaceId; 19 | private lockedCanvas:NativeSurfaceLockCanvas; 20 | 21 | protected initImpl() { 22 | this.initCanvasBound(); 23 | this.surfaceId = ++sNextSurfaceID; 24 | SurfaceInstances.set(this.surfaceId, this); 25 | let bound = this.mCanvasBound; 26 | NativeApi.surface.createSurface(this.surfaceId, bound.left, bound.top, bound.right, bound.bottom); 27 | } 28 | 29 | notifyBoundChange() { 30 | this.initCanvasBound(); 31 | let bound = this.mCanvasBound; 32 | NativeApi.surface.onSurfaceBoundChange(this.surfaceId, bound.left, bound.top, bound.right, bound.bottom); 33 | } 34 | 35 | protected lockCanvasImpl(left:number, top:number, width:number, height:number):android.graphics.Canvas { 36 | if(!this.lockedCanvas){ 37 | this.lockedCanvas = new NativeSurfaceLockCanvas(width, height); 38 | } 39 | NativeApi.surface.lockCanvas(this.surfaceId, this.lockedCanvas.canvasId, left, top, left+width, top+height); 40 | return this.lockedCanvas; 41 | } 42 | 43 | unlockCanvasAndPost(canvas:android.graphics.Canvas):void { 44 | if(canvas instanceof NativeCanvas){ 45 | NativeApi.surface.unlockCanvasAndPost(this.surfaceId, canvas.canvasId); 46 | }else{ 47 | throw Error('canvas is not NativeCanvas'); 48 | } 49 | } 50 | 51 | showFps(fps:number):void { 52 | NativeApi.surface.showFps(fps); 53 | } 54 | 55 | //call from native 56 | private static notifySurfaceReady(surfaceId:number){ 57 | let surface:NativeSurface = SurfaceInstances.get(surfaceId); 58 | surface.viewRoot.scheduleTraversals(); 59 | } 60 | 61 | private static notifySurfaceSupportDirtyDraw(surfaceId:number, dirtyDrawSupport:boolean){ 62 | let surface:NativeSurface = SurfaceInstances.get(surfaceId); 63 | surface.mSupportDirtyDraw = dirtyDrawSupport; 64 | surface.viewRoot.scheduleTraversals(); 65 | } 66 | } 67 | 68 | class NativeSurfaceLockCanvas extends NativeCanvas{ 69 | 70 | protected createCanvasImpl():void { 71 | //no need create canvas, will create when lock canvas 72 | } 73 | } 74 | 75 | } -------------------------------------------------------------------------------- /src/androidui/util/ArrayCreator.ts: -------------------------------------------------------------------------------- 1 | module androidui.util{ 2 | export class ArrayCreator { 3 | 4 | /** 5 | * In Java, number array will default fill 0. 6 | * @param size 7 | * @returns {number[]} 8 | */ 9 | static newNumberArray(size:number):Array { 10 | let array = new Array(size); 11 | if(size>0) ArrayCreator.fillArray(array, 0); 12 | return array; 13 | } 14 | 15 | /** 16 | * In Java, boolean array will default fill false. 17 | * @param size 18 | * @returns {boolean[]} 19 | */ 20 | static newBooleanArray(size:number):Array { 21 | let array = new Array(size); 22 | ArrayCreator.fillArray(array, false); 23 | return array; 24 | } 25 | 26 | /** 27 | * fill value to array 28 | * @param array 29 | * @param value 30 | */ 31 | static fillArray(array:Array, value:any){ 32 | for (var i = 0, length = array.length; i < length; i++) { 33 | array[i] = value; 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/androidui/util/ClassFinder.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/11/6. 3 | */ 4 | module androidui.util{ 5 | export class ClassFinder { 6 | /** 7 | * @param classFullName com.xxx.xxx.MyView 8 | * @param findInRoot root obj to find 9 | */ 10 | static findClass(classFullName:string, findInRoot:any=window) { 11 | let nameParts = classFullName.split('.'); 12 | 13 | let finding:any = findInRoot; 14 | for(let part of nameParts){ 15 | //try ignore case first 16 | let quickFind = finding[part.toLowerCase()]; 17 | if(quickFind){ 18 | finding = quickFind; 19 | continue; 20 | } 21 | 22 | //search 23 | let found = false; 24 | for(let key in finding){ 25 | if(key.toUpperCase()===part.toUpperCase()){ 26 | finding = finding[key]; 27 | found = true; 28 | break; 29 | } 30 | } 31 | if(!found) return null; 32 | } 33 | 34 | if(finding === findInRoot){ 35 | return null; 36 | } 37 | return finding; 38 | } 39 | 40 | static _findViewClassCache = {}; 41 | static findViewClass(className:string) { 42 | let rootViewClass = ClassFinder._findViewClassCache[className]; 43 | if(!rootViewClass) rootViewClass = ClassFinder.findClass(className, android.view); 44 | if(!rootViewClass) rootViewClass = ClassFinder.findClass(className, android['widget']); 45 | if(!rootViewClass) rootViewClass = ClassFinder.findClass(className, androidui['widget']); 46 | if(!rootViewClass) rootViewClass = ClassFinder.findClass(className); 47 | if(!rootViewClass){ 48 | if(document.createElement(className) instanceof HTMLUnknownElement){ 49 | console.warn('inflate: not find class ' + className); 50 | } 51 | return null; 52 | } 53 | ClassFinder._findViewClassCache[className] = rootViewClass; 54 | return rootViewClass; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /src/androidui/util/NumberChecker.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/11/24. 3 | */ 4 | module androidui.util{ 5 | export class NumberChecker{ 6 | static warnNotNumber(...n:number[]):boolean { 7 | try { 8 | this.assetNotNumber(...n); 9 | } catch (e) { 10 | console.error(e); 11 | return true; 12 | } 13 | return false; 14 | } 15 | static assetNotNumber(...ns:number[]) { 16 | if(!this.checkIsNumber()){ 17 | throw Error('assetNotNumber : ' + ns); 18 | } 19 | } 20 | static checkIsNumber(...ns:number[]):boolean { 21 | if(ns==null) return false; 22 | for(let n of ns){ 23 | if(n==null || Number.isNaN(n)) return false; 24 | } 25 | return true; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/androidui/util/Platform.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 16/2/4. 3 | */ 4 | module androidui.util { 5 | export class Platform { 6 | static isIOS = navigator.userAgent.match(/(iPhone|iPad|iPod|ios)/i) ? true : false; 7 | static isAndroid = navigator.userAgent.match('Android') ? true : false; 8 | static isWeChat = navigator.userAgent.match(/MicroMessenger/i) ? true : false; 9 | } 10 | } -------------------------------------------------------------------------------- /src/androidui/widget/HtmlBaseView.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/10/26. 3 | */ 4 | /// 5 | /// 6 | /// 7 | /// 8 | /// 9 | 10 | module androidui.widget { 11 | import View = android.view.View; 12 | import Gravity = android.view.Gravity; 13 | import Resources = android.content.res.Resources; 14 | import Color = android.graphics.Color; 15 | import ColorStateList = android.content.res.ColorStateList; 16 | import MeasureSpec = View.MeasureSpec; 17 | import TypedValue = android.util.TypedValue; 18 | 19 | export class HtmlBaseView extends View { 20 | private mHtmlTouchAble = false; 21 | 22 | constructor(context:android.content.Context, bindElement?:HTMLElement, defStyle?:Map) { 23 | super(context, bindElement, defStyle); 24 | } 25 | 26 | onTouchEvent(event:android.view.MotionEvent):boolean { 27 | if(this.mHtmlTouchAble){ 28 | event[android.view.ViewRootImpl.ContinueEventToDom] = true; 29 | } 30 | return super.onTouchEvent(event) || this.mHtmlTouchAble; 31 | } 32 | 33 | setHtmlTouchAble(enable:boolean):void { 34 | this.mHtmlTouchAble = enable; 35 | } 36 | 37 | isHtmlTouchAble():boolean { 38 | return this.mHtmlTouchAble; 39 | } 40 | 41 | protected dependOnDebugLayout():boolean { 42 | return true; 43 | } 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/androidui/widget/HtmlDataAdapter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/11/16. 3 | */ 4 | /// 5 | /// 6 | /// 7 | 8 | module androidui.widget{ 9 | import View = android.view.View; 10 | import ViewGroup = android.view.ViewGroup; 11 | import Context = android.content.Context; 12 | 13 | /** 14 | * adapter can defined in html 15 | */ 16 | export interface HtmlDataAdapter { 17 | onInflateAdapter(bindElement:HTMLElement, context?:Context, parent?:ViewGroup):void; 18 | } 19 | } -------------------------------------------------------------------------------- /src/androidui/widget/HtmlDataPickerAdapter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/11/16. 3 | */ 4 | 5 | /// 6 | /// 7 | /// 8 | 9 | module androidui.widget{ 10 | 11 | import ViewGroup = android.view.ViewGroup; 12 | import View = android.view.View; 13 | import NumberPicker = android.widget.NumberPicker; 14 | import Context = android.content.Context; 15 | 16 | 17 | export class HtmlDataPickerAdapter implements HtmlDataAdapter{ 18 | bindElementData:HTMLElement; 19 | 20 | onInflateAdapter(bindElement:HTMLElement, context?:Context, parent?:android.view.ViewGroup):void { 21 | this.bindElementData = bindElement; 22 | if(parent instanceof NumberPicker){ 23 | if(!window['MutationObserver']) return; 24 | const callBack = (arr: MutationRecord[], observer: MutationObserver)=>{ 25 | const values = []; 26 | for(let child of Array.from(this.bindElementData.children)){ 27 | values.push((child).innerText); 28 | } 29 | parent.setDisplayedValues(values); 30 | }; 31 | callBack.call(this); 32 | 33 | let observer:MutationObserver = new MutationObserver(callBack); 34 | observer.observe(this.bindElementData, {childList:true}); 35 | } 36 | } 37 | 38 | 39 | } 40 | } -------------------------------------------------------------------------------- /src/androidui/widget/HtmlView.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/10/26. 3 | */ 4 | /// 5 | /// 6 | /// 7 | /// 8 | /// 9 | /// 10 | /// 11 | /// 12 | /// 13 | 14 | module androidui.widget { 15 | import View = android.view.View; 16 | import Gravity = android.view.Gravity; 17 | import Resources = android.content.res.Resources; 18 | import Color = android.graphics.Color; 19 | import ColorStateList = android.content.res.ColorStateList; 20 | import MeasureSpec = View.MeasureSpec; 21 | import TypedValue = android.util.TypedValue; 22 | 23 | export class HtmlView extends HtmlBaseView { 24 | 25 | constructor(context:android.content.Context, bindElement?:HTMLElement, defStyle?:Map) { 26 | super(context, bindElement, defStyle); 27 | } 28 | 29 | protected onMeasure(widthMeasureSpec:any, heightMeasureSpec:any):void { 30 | let widthMode = MeasureSpec.getMode(widthMeasureSpec); 31 | let heightMode = MeasureSpec.getMode(heightMeasureSpec); 32 | let widthSize = MeasureSpec.getSize(widthMeasureSpec); 33 | let heightSize = MeasureSpec.getSize(heightMeasureSpec); 34 | 35 | let width:number, height:number; 36 | const density = this.getResources().getDisplayMetrics().density; 37 | 38 | if (widthMode == MeasureSpec.EXACTLY) { 39 | // Parent has told us how big to be. So be it. 40 | width = widthSize; 41 | 42 | } else { 43 | let sWidth = this.bindElement.style.width, sLeft = this.bindElement.style.left; 44 | this.bindElement.style.width = ''; 45 | this.bindElement.style.left = ''; 46 | width = this.bindElement.offsetWidth * density + 2;//more space (some case may wrap word) 47 | 48 | this.bindElement.style.width = sWidth; 49 | this.bindElement.style.left = sLeft; 50 | 51 | // Check against our minimum width 52 | width = Math.max(width, this.getSuggestedMinimumWidth()); 53 | 54 | if (widthMode == MeasureSpec.AT_MOST) { 55 | width = Math.min(widthSize, width); 56 | } 57 | } 58 | 59 | 60 | if (heightMode == MeasureSpec.EXACTLY) { 61 | // Parent has told us how big to be. So be it. 62 | height = heightSize; 63 | 64 | } else { 65 | let sWidth = this.bindElement.style.width; 66 | this.bindElement.style.width = width / density + "px"; 67 | this.bindElement.style.height = ''; 68 | height = this.bindElement.offsetHeight * density; 69 | 70 | this.bindElement.style.width = sWidth; 71 | 72 | // Check against our minimum height 73 | height = Math.max(height, this.getSuggestedMinimumHeight()); 74 | 75 | if (heightMode == MeasureSpec.AT_MOST) { 76 | height = Math.min(height, heightSize); 77 | } 78 | } 79 | 80 | this.setMeasuredDimension(width, height); 81 | } 82 | 83 | setHtml(html:string) { 84 | this.bindElement.innerHTML = html; 85 | this.requestLayout(); 86 | } 87 | 88 | getHtml():string { 89 | return this.bindElement.innerHTML; 90 | } 91 | 92 | } 93 | 94 | } -------------------------------------------------------------------------------- /src/insert_sdk_version_dist.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var packageJson = require('../package'); 3 | 4 | var versionInfo = `/** 5 | * AndroidUIX v${packageJson.version} 6 | * ${packageJson.repository.url} 7 | */`; 8 | 9 | var jsPath = '../dist/android-ui.js'; 10 | fs.writeFileSync(jsPath, versionInfo + '\n' + fs.readFileSync(jsPath)); -------------------------------------------------------------------------------- /src/java/lang/Comparable.ts: -------------------------------------------------------------------------------- 1 | 2 | module java.lang { 3 | 4 | export interface Comparable { 5 | 6 | /** 7 | * @param o the object to be compared. 8 | * @return a negative integer, zero, or a positive integer as this object 9 | * is less than, equal to, or greater than the specified object. 10 | * 11 | * @throws NullPointerException if the specified object is null 12 | * @throws ClassCastException if the specified object's type prevents it 13 | * from being compared to this object. 14 | */ 15 | compareTo(o:T):number; 16 | } 17 | 18 | export module Comparable{ 19 | export function isImpl(obj){ 20 | return obj && obj['compareTo']; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/java/lang/Float.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/11/13. 3 | */ 4 | module java.lang{ 5 | export class Float{ 6 | static MIN_VALUE = Number.MIN_VALUE; 7 | static MAX_VALUE = Number.MAX_VALUE; 8 | 9 | static parseFloat(value:string):number { 10 | return Number.parseFloat(value); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/java/lang/Integer.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/11/13. 3 | */ 4 | module java.lang{ 5 | export class Integer{ 6 | static MIN_VALUE = -0x80000000; 7 | static MAX_VALUE = 0x7fffffff; 8 | 9 | static parseInt(value:string):number { 10 | return Number.parseInt(value); 11 | } 12 | 13 | static toHexString(n:number):string { 14 | if(!n) return n+''; 15 | return n.toString(16); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/java/lang/Long.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/11/13. 3 | */ 4 | /// 5 | 6 | module java.lang{ 7 | export class Long{ 8 | static MIN_VALUE = goog.math.Long.MIN_VALUE.toNumber(); 9 | static MAX_VALUE = goog.math.Long.MAX_VALUE.toNumber(); 10 | } 11 | } -------------------------------------------------------------------------------- /src/java/lang/Object.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/11/26. 3 | */ 4 | module java.lang{ 5 | 6 | let hashCodeGenerator = 0; 7 | export class JavaObject { 8 | static get class():Class { 9 | return Class.getClass(this); 10 | } 11 | 12 | private hash = hashCodeGenerator++; 13 | hashCode():number{ 14 | return this.hash; 15 | } 16 | 17 | getClass():Class { 18 | return Class.getClass(this.constructor); 19 | } 20 | 21 | equals(o):boolean { 22 | return this === o; 23 | } 24 | 25 | } 26 | 27 | export class Class{ 28 | private static classCache = new Map(); 29 | private static getClass(clazz:Function) { 30 | let c = Class.classCache.get(clazz); 31 | if (!c) { 32 | c = new Class(clazz); 33 | Class.classCache.set(clazz, c); 34 | } 35 | return c; 36 | } 37 | 38 | clazz:Function; 39 | constructor(clazz:Function) { 40 | this.clazz = clazz; 41 | } 42 | 43 | getName():string { 44 | return this.clazz.name; 45 | } 46 | getSimpleName():string { 47 | return this.clazz.name; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/java/lang/Runnable.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/10/5. 3 | */ 4 | module java.lang{ 5 | export interface Runnable{ 6 | run(); 7 | } 8 | export module Runnable { 9 | export function of(func:()=>any): Runnable { 10 | return { 11 | run: func 12 | } 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/java/lang/StringBuilder.ts: -------------------------------------------------------------------------------- 1 | module java.lang{ 2 | export class StringBuilder{ 3 | array : Array; 4 | 5 | constructor(); 6 | constructor(capacity : number); 7 | constructor(str : string); 8 | constructor(arg?) { 9 | this.array = []; 10 | if(!Number.isInteger(arg) && arg){//number means capacity, miss 11 | this.append(arg); 12 | } 13 | } 14 | length() : number { 15 | return this.array.length; 16 | } 17 | append(a:any) : StringBuilder{ 18 | let str:string = a + ''; 19 | this.array.push(...str.split('')); 20 | return this; 21 | } 22 | 23 | /** 24 | * @throws StringIndexOutOfBoundsException {@inheritDoc} 25 | */ 26 | deleteCharAt(index:number):StringBuilder { 27 | this.array.splice(index, 1); 28 | return this; 29 | } 30 | 31 | replace(start:number, end:number, str:string):StringBuilder { 32 | this.array.splice(start, end-start, ...str.split('')); 33 | return this; 34 | } 35 | 36 | setLength(length : number){ 37 | let arrayLength = this.array.length; 38 | if(length===arrayLength) return; 39 | if(length=srcLength) return; 26 | let destIndex = i+destPos; 27 | if(destIndex>=destLength) return; 28 | dest[destIndex] = src[srcIndex]; 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/java/lang/ref/WeakReference.ts: -------------------------------------------------------------------------------- 1 | module java.lang.ref { 2 | //TODO may not weak 3 | export class WeakReference { 4 | weakMap:WeakMap; 5 | 6 | constructor(referent:T) { 7 | this.weakMap = new WeakMap(); 8 | this.weakMap.set(this, referent); 9 | } 10 | 11 | get():T { 12 | return this.weakMap.get(this); 13 | } 14 | 15 | set(value:T) { 16 | this.weakMap.set(this, value); 17 | } 18 | 19 | clear() { 20 | this.weakMap.delete(this); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/java/lang/util/concurrent/CopyOnWriteArrayList.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/10/6. 3 | */ 4 | module java.lang.util.concurrent { 5 | 6 | export class CopyOnWriteArrayList { 7 | private mData:Array = []; 8 | private isDataNew = true; 9 | 10 | iterator(){ 11 | this.isDataNew = false; 12 | return this.mData; 13 | } 14 | 15 | [Symbol.iterator](){ 16 | this.isDataNew = false; 17 | return this.mData[Symbol.iterator](); 18 | } 19 | 20 | private checkNewData(){ 21 | if(!this.isDataNew){ 22 | this.isDataNew = true; 23 | this.mData = [...this.mData]; 24 | } 25 | } 26 | 27 | size():number { 28 | return this.mData.length; 29 | } 30 | add(...items: T[]) { 31 | this.checkNewData(); 32 | this.mData.push(...items); 33 | } 34 | addAll(array:CopyOnWriteArrayList) { 35 | this.checkNewData(); 36 | this.mData.push(...array.mData); 37 | } 38 | remove(item:T ) { 39 | this.checkNewData(); 40 | this.mData.splice(this.mData.indexOf(item), 1); 41 | } 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /src/java/util/ArrayDeque.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/12/12. 3 | */ 4 | /// 5 | 6 | module java.util{ 7 | 8 | export class ArrayDeque extends ArrayList { 9 | 10 | public addFirst(e:E):void { 11 | this.add(0, e); 12 | } 13 | public addLast(e:E):void { 14 | this.add(e); 15 | } 16 | 17 | public offerFirst(e:E):boolean { 18 | this.addFirst(e); 19 | return true; 20 | } 21 | public offerLast(e:E):boolean { 22 | this.addLast(e); 23 | return true; 24 | } 25 | removeFirst():E { 26 | let x = this.pollFirst(); 27 | if(x==null) throw Error('NoSuchElementException'); 28 | return x; 29 | } 30 | 31 | removeLast():E { 32 | let x = this.pollLast(); 33 | if(x==null) throw Error('NoSuchElementException'); 34 | return x; 35 | } 36 | 37 | pollFirst():E { 38 | return this.array.shift(); 39 | } 40 | pollLast():E { 41 | return this.array.splice(this.array.length-1)[0]; 42 | } 43 | getFirst():E { 44 | let x = this.peekFirst(); 45 | if(x==null) throw Error('NoSuchElementException'); 46 | return x; 47 | } 48 | getLast():E { 49 | let x = this.peekLast(); 50 | if(x==null) throw Error('NoSuchElementException'); 51 | return x; 52 | } 53 | peekFirst():E { 54 | return this.array[0]; 55 | } 56 | peekLast():E { 57 | return this.array[this.array.length-1]; 58 | } 59 | 60 | removeFirstOccurrence(o:any):boolean { 61 | if (o == null) return false; 62 | for(let i = 0, count=this.size(); i=0; i--){ 73 | if(this.array[i]==o){ 74 | this.delete(i); 75 | return true; 76 | } 77 | } 78 | return false; 79 | } 80 | 81 | offer(e:E):boolean { 82 | return this.offerLast(e); 83 | } 84 | remove():E { 85 | return this.removeFirst(); 86 | } 87 | poll():E { 88 | return this.pollFirst(); 89 | } 90 | element():E { 91 | return this.getFirst(); 92 | } 93 | peek():E { 94 | return this.peekFirst(); 95 | } 96 | push(e:E) { 97 | this.addFirst(e); 98 | } 99 | pop():E { 100 | return this.removeFirst(); 101 | } 102 | 103 | private delete(i:number):boolean { 104 | if(i >= this.array.length) return false; 105 | this.array.splice(i, 1); 106 | return true; 107 | } 108 | 109 | 110 | 111 | 112 | } 113 | } -------------------------------------------------------------------------------- /src/java/util/Collections.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/11/28. 3 | */ 4 | /// 5 | /// 6 | /// 7 | /// 8 | 9 | 10 | 11 | module java.util{ 12 | import Comparable = java.lang.Comparable; 13 | 14 | export class Collections{ 15 | 16 | private static EMPTY_LIST = new ArrayList(); 17 | static emptyList():List { 18 | return Collections.EMPTY_LIST; 19 | } 20 | 21 | static sort(list:List, c?:Comparator){ 22 | if(c) { 23 | list.sort((t1, t2):number=> { 24 | return c.compare(t1, t2); 25 | }); 26 | }else { 27 | list.sort((t1, t2):number=> { 28 | if(Comparable.isImpl(t1) && Comparable.isImpl(t2)){ 29 | return (>t1).compareTo(t2); 30 | } 31 | return 0; 32 | }); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/java/util/Comparator.ts: -------------------------------------------------------------------------------- 1 | module java.util { 2 | export interface Comparator { 3 | 4 | /** 5 | * Compares its two arguments for order. Returns a negative integer, 6 | * zero, or a positive integer as the first argument is less than, equal 7 | * to, or greater than the second.

8 | * 9 | * @param o1 the first object to be compared. 10 | * @param o2 the second object to be compared. 11 | * @return a negative integer, zero, or a positive integer as the 12 | * first argument is less than, equal to, or greater than the 13 | * second. 14 | * @throws NullPointerException if an argument is null and this 15 | * comparator does not permit null arguments 16 | * @throws ClassCastException if the arguments' types prevent them from 17 | * being compared by this comparator. 18 | */ 19 | compare(o1:T, o2:T):number; 20 | } 21 | } -------------------------------------------------------------------------------- /src/java/util/List.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by linfaxin on 15/10/28. 3 | */ 4 | module java.util{ 5 | export interface List{ 6 | size():number; 7 | isEmpty():boolean; 8 | contains(o:T); 9 | indexOf(o:T); 10 | lastIndexOf(o:T); 11 | clone():List; 12 | toArray(a:Array):Array; 13 | getArray():Array; 14 | get(index:number):T; 15 | set(index:number, element:T):T; 16 | 17 | add(t:T); 18 | add(index:number, t:T); 19 | 20 | remove(o:number|T); 21 | clear(); 22 | addAll(list:List); 23 | addAll(index:number, list:List); 24 | removeAll(list:List):boolean; 25 | 26 | subList(fromIndex:number, toIndex:number):List; 27 | 28 | sort(compareFn?: (a: T, b: T) => number); 29 | } 30 | } -------------------------------------------------------------------------------- /src/pack_enter.ts: -------------------------------------------------------------------------------- 1 | 2 | //use the deepest sub class as enter 3 | /// 4 | /// 5 | 6 | /// 7 | /// 8 | /// 9 | /// 10 | /// 11 | /// 12 | /// 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// 18 | /// 19 | /// 20 | /// 21 | /// 22 | /// 23 | /// 24 | /// 25 | /// 26 | /// 27 | /// 28 | /// 29 | /// 30 | /// 31 | 32 | /// 33 | 34 | /// 35 | 36 | 37 | /// 38 | /// 39 | /// 40 | /// 41 | /// 42 | 43 | /// 44 | /// 45 | 46 | 47 | /// 48 | /// 49 | /// 50 | 51 | /// 52 | /// 53 | 54 | 55 | 56 | /// 57 | /// 58 | /// 59 | /// 60 | /// 61 | /// 62 | /// 63 | /// 64 | /// 65 | /// 66 | 67 | /// 68 | /// 69 | 70 | window[`android`] = android; 71 | window[`java`] = java; 72 | window[`AndroidUI`] = androidui.AndroidUI; 73 | (function() { 74 | var event = document.createEvent("CustomEvent"); 75 | event.initCustomEvent("AndroidUILoadFinish", true, true, null); 76 | document.dispatchEvent(event); 77 | })(); 78 | -------------------------------------------------------------------------------- /src/res/image/actionbar_ic_back_white@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/actionbar_ic_back_white@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_check_off_disabled_focused_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_check_off_disabled_focused_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_check_off_disabled_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_check_off_disabled_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_check_off_focused_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_check_off_focused_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_check_off_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_check_off_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_check_off_pressed_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_check_off_pressed_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_check_on_disabled_focused_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_check_on_disabled_focused_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_check_on_disabled_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_check_on_disabled_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_check_on_focused_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_check_on_focused_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_check_on_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_check_on_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_check_on_pressed_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_check_on_pressed_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_default_disabled_focused_holo_light@3x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_default_disabled_focused_holo_light@3x.9.png -------------------------------------------------------------------------------- /src/res/image/btn_default_disabled_holo_light@3x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_default_disabled_holo_light@3x.9.png -------------------------------------------------------------------------------- /src/res/image/btn_default_focused_holo_light@3x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_default_focused_holo_light@3x.9.png -------------------------------------------------------------------------------- /src/res/image/btn_default_normal_holo_light@3x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_default_normal_holo_light@3x.9.png -------------------------------------------------------------------------------- /src/res/image/btn_default_pressed_holo_light@3x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_default_pressed_holo_light@3x.9.png -------------------------------------------------------------------------------- /src/res/image/btn_radio_off_disabled_focused_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_radio_off_disabled_focused_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_radio_off_disabled_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_radio_off_disabled_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_radio_off_focused_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_radio_off_focused_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_radio_off_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_radio_off_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_radio_off_pressed_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_radio_off_pressed_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_radio_on_disabled_focused_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_radio_on_disabled_focused_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_radio_on_disabled_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_radio_on_disabled_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_radio_on_focused_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_radio_on_focused_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_radio_on_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_radio_on_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_radio_on_pressed_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_radio_on_pressed_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_rating_star_off_normal_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_rating_star_off_normal_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_rating_star_off_pressed_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_rating_star_off_pressed_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_rating_star_on_normal_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_rating_star_on_normal_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/btn_rating_star_on_pressed_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/btn_rating_star_on_pressed_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/dropdown_background_dark@2x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/dropdown_background_dark@2x.9.png -------------------------------------------------------------------------------- /src/res/image/editbox_background_focus_yellow@2x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/editbox_background_focus_yellow@2x.9.png -------------------------------------------------------------------------------- /src/res/image/editbox_background_normal@2x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/editbox_background_normal@2x.9.png -------------------------------------------------------------------------------- /src/res/image/ic_menu_moreoverflow_normal_holo_dark@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/ic_menu_moreoverflow_normal_holo_dark@3x.png -------------------------------------------------------------------------------- /src/res/image/menu_panel_holo_dark@2x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/menu_panel_holo_dark@2x.9.png -------------------------------------------------------------------------------- /src/res/image/menu_panel_holo_light@2x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/menu_panel_holo_light@2x.9.png -------------------------------------------------------------------------------- /src/res/image/popup_bottom_bright@2x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/popup_bottom_bright@2x.9.png -------------------------------------------------------------------------------- /src/res/image/popup_center_bright@2x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/popup_center_bright@2x.9.png -------------------------------------------------------------------------------- /src/res/image/popup_full_bright@2x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/popup_full_bright@2x.9.png -------------------------------------------------------------------------------- /src/res/image/popup_top_bright@2x.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/popup_top_bright@2x.9.png -------------------------------------------------------------------------------- /src/res/image/progressbar_indeterminate_holo1@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/progressbar_indeterminate_holo1@3x.png -------------------------------------------------------------------------------- /src/res/image/progressbar_indeterminate_holo2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/progressbar_indeterminate_holo2@3x.png -------------------------------------------------------------------------------- /src/res/image/progressbar_indeterminate_holo3@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/progressbar_indeterminate_holo3@3x.png -------------------------------------------------------------------------------- /src/res/image/progressbar_indeterminate_holo4@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/progressbar_indeterminate_holo4@3x.png -------------------------------------------------------------------------------- /src/res/image/progressbar_indeterminate_holo5@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/progressbar_indeterminate_holo5@3x.png -------------------------------------------------------------------------------- /src/res/image/progressbar_indeterminate_holo6@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/progressbar_indeterminate_holo6@3x.png -------------------------------------------------------------------------------- /src/res/image/progressbar_indeterminate_holo7@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/progressbar_indeterminate_holo7@3x.png -------------------------------------------------------------------------------- /src/res/image/progressbar_indeterminate_holo8@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/progressbar_indeterminate_holo8@3x.png -------------------------------------------------------------------------------- /src/res/image/rate_star_big_half_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/rate_star_big_half_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/rate_star_big_off_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/rate_star_big_off_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/rate_star_big_on_holo_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/rate_star_big_on_holo_light@3x.png -------------------------------------------------------------------------------- /src/res/image/scrubber_control_disabled_holo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/scrubber_control_disabled_holo@3x.png -------------------------------------------------------------------------------- /src/res/image/scrubber_control_focused_holo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/scrubber_control_focused_holo@3x.png -------------------------------------------------------------------------------- /src/res/image/scrubber_control_normal_holo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/scrubber_control_normal_holo@3x.png -------------------------------------------------------------------------------- /src/res/image/scrubber_control_pressed_holo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/scrubber_control_pressed_holo@3x.png -------------------------------------------------------------------------------- /src/res/image/spinner_76_inner_holo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/spinner_76_inner_holo@3x.png -------------------------------------------------------------------------------- /src/res/image/spinner_76_outer_holo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linfaxin/AndroidUIX/686261f3f5537684c9d20d0c6a7d9b659d408cc2/src/res/image/spinner_76_outer_holo@3x.png -------------------------------------------------------------------------------- /src/res/layout/_id_defined.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/res/layout/action_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 19 | 29 | 30 |