forked from pocorall/scaloid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.scala
More file actions
3305 lines (2301 loc) · 96.5 KB
/
common.scala
File metadata and controls
3305 lines (2301 loc) · 96.5 KB
1
2
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
*
*
*
* Less painful Android development with Scala
*
*
* http://scaloid.org
*
*
*
*
*
*
* Copyright 2012 Sung-Ho Lee
*
* Sung-Ho Lee licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package org.scaloid
import android.app._
import admin.DevicePolicyManager
import android.view._
import android.net.{ConnectivityManager, Uri}
import android.os._
import android.media.{AudioManager, RingtoneManager}
import collection.mutable.ArrayBuffer
import android.util.Log
import android.text.{InputFilter, Editable, TextWatcher, ClipboardManager}
import android.view.accessibility.AccessibilityManager
import android.accounts.AccountManager
import android.view.inputmethod.InputMethodManager
import android.location.LocationManager
import android.hardware.SensorManager
import android.telephony.TelephonyManager
import android.net.wifi.WifiManager
import android.content._
import android.widget._
import android.inputmethodservice._
import android.preference._
import android.preference.Preference._
import android.view.WindowManager.LayoutParams._
import android.view.View._
import android.graphics.drawable.Drawable
import java.lang.CharSequence
import scala.Int
import android.view.ContextMenu.ContextMenuInfo
import android.text.method._
import android.gesture._
import android.appwidget._
import annotation.target.{beanGetter, getter}
import android.view.ViewGroup.LayoutParams
import android.widget.TextView.OnEditorActionListener
import android.graphics.Typeface
import reflect.ClassTag
case class LoggerTag(_tag: String) {
private val MAX_TAG_LEN = 22
val tag = if (_tag.length < MAX_TAG_LEN) _tag else ":" + _tag.substring(_tag.length - (MAX_TAG_LEN - 1), _tag.length)
}
package object common {
@getter
@beanGetter
class noEquivalentGetterExists extends annotation.StaticAnnotation
implicit def resourceIdToTextResource(id: Int)(implicit context: Context): CharSequence = context.getText(id)
/**
* Launches a new activity for a give uri. For example, opens a web browser for http protocols.
*/
def openUri(uri: Uri)(implicit context: Context) {
context.startActivity(new Intent(Intent.ACTION_VIEW, uri))
}
def play(uri: Uri = notificationSound)(implicit context: Context) {
val r = RingtoneManager.getRingtone(context, uri)
if (r != null) {
r.play()
}
}
implicit def func2ViewOnClickListener[F](f: View => F): View.OnClickListener =
new View.OnClickListener() {
def onClick(view: View) {
f(view)
}
}
implicit def lazy2ViewOnClickListener[F](f: => F): View.OnClickListener =
new View.OnClickListener() {
def onClick(view: View) {
f
}
}
def defaultValue[U]: U = {
class Default[W] {
var default: W = _
}
new Default[U].default
}
trait ConstantsSupport {
// android:inputType constants for TextView
import android.text.InputType._
val NONE = 0
val TEXT = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_NORMAL
val TEXT_CAP_CHARACTERS = TYPE_TEXT_FLAG_CAP_CHARACTERS
val TEXT_CAP_WORDS = TYPE_TEXT_FLAG_CAP_WORDS
val TEXT_CAP_SENTENCES = TYPE_TEXT_FLAG_CAP_SENTENCES
val TEXT_AUTO_CORRECT = TYPE_TEXT_FLAG_AUTO_CORRECT
val TEXT_AUTO_COMPLETE = TYPE_TEXT_FLAG_AUTO_COMPLETE
val TEXT_MULTI_LINE = TYPE_TEXT_FLAG_MULTI_LINE
val TEXT_IME_MULTI_LINE = TYPE_TEXT_FLAG_IME_MULTI_LINE
val TEXT_NO_SUGGESTIONS = TYPE_TEXT_FLAG_NO_SUGGESTIONS
val TEXT_URI = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_URI
val TEXT_EMAIL_ADDRESS = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS
val TEXT_EMAIL_SUBJECT = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_SUBJECT
val TEXT_SHORT_MESSAGE = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_SHORT_MESSAGE
val TEXT_LONG_MESSAGE = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_LONG_MESSAGE
val TEXT_PERSION_NAME = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PERSON_NAME
val TEXT_POSTAL_ADDRESS = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_POSTAL_ADDRESS
val TEXT_PASSWORD = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD
// TODO: write more (http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType)
}
class RichView[V <: View](val base: V) extends TraitView[V]
@inline implicit def view2RichView[V <: View](view: V) = new RichView[V](view)
trait TraitView[V <: View] extends ConstantsSupport {
@inline def onClick(f: => Unit): V = {
base.setOnClickListener(new OnClickListener {
def onClick(p1: View): Unit = {
f
}
})
base
}
@inline def onClick(f: (View) => Unit): V = {
base.setOnClickListener(new OnClickListener {
def onClick(p1: View): Unit = {
f(p1)
}
})
base
}
@inline def onCreateContextMenu(f: => Unit): V = {
base.setOnCreateContextMenuListener(new OnCreateContextMenuListener {
def onCreateContextMenu(p1: ContextMenu, p2: View, p3: ContextMenuInfo): Unit = {
f
}
})
base
}
@inline def onCreateContextMenu(f: (ContextMenu, View, ContextMenuInfo) => Unit): V = {
base.setOnCreateContextMenuListener(new OnCreateContextMenuListener {
def onCreateContextMenu(p1: ContextMenu, p2: View, p3: ContextMenuInfo): Unit = {
f(p1, p2, p3)
}
})
base
}
@inline def onFocusChange(f: => Unit): V = {
base.setOnFocusChangeListener(new OnFocusChangeListener {
def onFocusChange(p1: View, p2: Boolean): Unit = {
f
}
})
base
}
@inline def onFocusChange(f: (View, Boolean) => Unit): V = {
base.setOnFocusChangeListener(new OnFocusChangeListener {
def onFocusChange(p1: View, p2: Boolean): Unit = {
f(p1, p2)
}
})
base
}
@inline def onKey(f: => Boolean): V = {
base.setOnKeyListener(new OnKeyListener {
def onKey(p1: View, p2: Int, p3: KeyEvent): Boolean = {
f
}
})
base
}
@inline def onKey(f: (View, Int, KeyEvent) => Boolean): V = {
base.setOnKeyListener(new OnKeyListener {
def onKey(p1: View, p2: Int, p3: KeyEvent): Boolean = {
f(p1, p2, p3)
}
})
base
}
@inline def onLongClick(f: => Boolean): V = {
base.setOnLongClickListener(new OnLongClickListener {
def onLongClick(p1: View): Boolean = {
f
}
})
base
}
@inline def onLongClick(f: (View) => Boolean): V = {
base.setOnLongClickListener(new OnLongClickListener {
def onLongClick(p1: View): Boolean = {
f(p1)
}
})
base
}
@inline def onTouch(f: => Boolean): V = {
base.setOnTouchListener(new OnTouchListener {
def onTouch(p1: View, p2: MotionEvent): Boolean = {
f
}
})
base
}
@inline def onTouch(f: (View, MotionEvent) => Boolean): V = {
base.setOnTouchListener(new OnTouchListener {
def onTouch(p1: View, p2: MotionEvent): Boolean = {
f(p1, p2)
}
})
base
}
@inline def animation_=(p: android.view.animation.Animation) = {
base.setAnimation(p)
base
}
@inline def animation(p: android.view.animation.Animation) = animation_=(p)
@inline def animation = base.getAnimation
@inline def applicationWindowToken = base.getApplicationWindowToken
@inline def background = base.getBackground
@inline def backgroundColor_=(p: Int) = {
base.setBackgroundColor(p)
base
}
@inline def backgroundColor(p: Int) = backgroundColor_=(p)
@noEquivalentGetterExists
@inline def backgroundColor: Int = defaultValue[Int]
@inline def backgroundDrawable_=(p: android.graphics.drawable.Drawable) = {
base.setBackgroundDrawable(p)
base
}
@inline def backgroundDrawable(p: android.graphics.drawable.Drawable) = backgroundDrawable_=(p)
@noEquivalentGetterExists
@inline def backgroundDrawable: android.graphics.drawable.Drawable = defaultValue[android.graphics.drawable.Drawable]
@inline def backgroundResource_=(p: Int) = {
base.setBackgroundResource(p)
base
}
@inline def backgroundResource(p: Int) = backgroundResource_=(p)
@noEquivalentGetterExists
@inline def backgroundResource: Int = defaultValue[Int]
@inline def baseline = base.getBaseline
@inline def bottom = base.getBottom
@inline def clickable_=(p: Boolean) = {
base.setClickable(p)
base
}
@inline def clickable(p: Boolean) = clickable_=(p)
@inline def clickable = base.isClickable
@inline def contentDescription_=(p: java.lang.CharSequence) = {
base.setContentDescription(p)
base
}
@inline def contentDescription(p: java.lang.CharSequence) = contentDescription_=(p)
@inline def contentDescription = base.getContentDescription
//@inline def context = base.getContext
@inline def drawableState = base.getDrawableState
@inline def drawingCache = base.getDrawingCache
@inline def drawingCacheBackgroundColor_=(p: Int) = {
base.setDrawingCacheBackgroundColor(p)
base
}
@inline def drawingCacheBackgroundColor(p: Int) = drawingCacheBackgroundColor_=(p)
@inline def drawingCacheBackgroundColor = base.getDrawingCacheBackgroundColor
@inline def enableDrawingCache = {base.setDrawingCacheEnabled(true); base}
@inline def disableDrawingCache = {base.setDrawingCacheEnabled(false); base}
@inline def drawingCacheEnabled_=(p: Boolean) = {
base.setDrawingCacheEnabled(p)
base
}
@inline def drawingCacheEnabled(p: Boolean) = drawingCacheEnabled_=(p)
@inline def drawingCacheEnabled = base.isDrawingCacheEnabled
@inline def drawingCacheQuality_=(p: Int) = {
base.setDrawingCacheQuality(p)
base
}
@inline def drawingCacheQuality(p: Int) = drawingCacheQuality_=(p)
@inline def drawingCacheQuality = base.getDrawingCacheQuality
@inline def drawingTime = base.getDrawingTime
@inline def enableDuplicateParentState = {base.setDuplicateParentStateEnabled(true); base}
@inline def disableDuplicateParentState = {base.setDuplicateParentStateEnabled(false); base}
@inline def duplicateParentStateEnabled_=(p: Boolean) = {
base.setDuplicateParentStateEnabled(p)
base
}
@inline def duplicateParentStateEnabled(p: Boolean) = duplicateParentStateEnabled_=(p)
@inline def duplicateParentStateEnabled = base.isDuplicateParentStateEnabled
@inline def enabled_=(p: Boolean) = {
base.setEnabled(p)
base
}
@inline def enabled(p: Boolean) = enabled_=(p)
@inline def enabled = base.isEnabled
@inline def fadingEdgeLength_=(p: Int) = {
base.setFadingEdgeLength(p)
base
}
@inline def fadingEdgeLength(p: Int) = fadingEdgeLength_=(p)
@noEquivalentGetterExists
@inline def fadingEdgeLength: Int = defaultValue[Int]
@inline def focusable_=(p: Boolean) = {
base.setFocusable(p)
base
}
@inline def focusable(p: Boolean) = focusable_=(p)
@inline def focusable = base.isFocusable
@inline def focusableInTouchMode_=(p: Boolean) = {
base.setFocusableInTouchMode(p)
base
}
@inline def focusableInTouchMode(p: Boolean) = focusableInTouchMode_=(p)
@inline def focusableInTouchMode = base.isFocusableInTouchMode
@inline def focused = base.isFocused
@inline def handler = base.getHandler
@inline def enableHapticFeedback = {base.setHapticFeedbackEnabled(true); base}
@inline def disableHapticFeedback = {base.setHapticFeedbackEnabled(false); base}
@inline def hapticFeedbackEnabled_=(p: Boolean) = {
base.setHapticFeedbackEnabled(p)
base
}
@inline def hapticFeedbackEnabled(p: Boolean) = hapticFeedbackEnabled_=(p)
@inline def hapticFeedbackEnabled = base.isHapticFeedbackEnabled
@inline def height = base.getHeight
@inline def enableHorizontalFadingEdge = {base.setHorizontalFadingEdgeEnabled(true); base}
@inline def disableHorizontalFadingEdge = {base.setHorizontalFadingEdgeEnabled(false); base}
@inline def horizontalFadingEdgeEnabled_=(p: Boolean) = {
base.setHorizontalFadingEdgeEnabled(p)
base
}
@inline def horizontalFadingEdgeEnabled(p: Boolean) = horizontalFadingEdgeEnabled_=(p)
@inline def horizontalFadingEdgeEnabled = base.isHorizontalFadingEdgeEnabled
@inline def horizontalFadingEdgeLength = base.getHorizontalFadingEdgeLength
@inline def enableHorizontalScrollBar = {base.setHorizontalScrollBarEnabled(true); base}
@inline def disableHorizontalScrollBar = {base.setHorizontalScrollBarEnabled(false); base}
@inline def horizontalScrollBarEnabled_=(p: Boolean) = {
base.setHorizontalScrollBarEnabled(p)
base
}
@inline def horizontalScrollBarEnabled(p: Boolean) = horizontalScrollBarEnabled_=(p)
@inline def horizontalScrollBarEnabled = base.isHorizontalScrollBarEnabled
@inline def id_=(p: Int) = {
base.setId(p)
base
}
@inline def id(p: Int) = id_=(p)
@inline def id = base.getId
@inline def inEditMode = base.isInEditMode
@inline def inTouchMode = base.isInTouchMode
@inline def keepScreenOn_=(p: Boolean) = {
base.setKeepScreenOn(p)
base
}
@inline def keepScreenOn(p: Boolean) = keepScreenOn_=(p)
@inline def keepScreenOn = base.getKeepScreenOn
@inline def keyDispatcherState = base.getKeyDispatcherState
@inline def layoutParams_=(p: android.view.ViewGroup.LayoutParams) = {
base.setLayoutParams(p)
base
}
@inline def layoutParams(p: android.view.ViewGroup.LayoutParams) = layoutParams_=(p)
@inline def layoutParams = base.getLayoutParams
@inline def layoutRequested = base.isLayoutRequested
@inline def left = base.getLeft
@inline def longClickable_=(p: Boolean) = {
base.setLongClickable(p)
base
}
@inline def longClickable(p: Boolean) = longClickable_=(p)
@inline def longClickable = base.isLongClickable
@inline def measuredHeight = base.getMeasuredHeight
@inline def measuredWidth = base.getMeasuredWidth
@inline def minimumHeight_=(p: Int) = {
base.setMinimumHeight(p)
base
}
@inline def minimumHeight(p: Int) = minimumHeight_=(p)
@noEquivalentGetterExists
@inline def minimumHeight: Int = defaultValue[Int]
@inline def minimumWidth_=(p: Int) = {
base.setMinimumWidth(p)
base
}
@inline def minimumWidth(p: Int) = minimumWidth_=(p)
@noEquivalentGetterExists
@inline def minimumWidth: Int = defaultValue[Int]
@inline def nextFocusDownId_=(p: Int) = {
base.setNextFocusDownId(p)
base
}
@inline def nextFocusDownId(p: Int) = nextFocusDownId_=(p)
@inline def nextFocusDownId = base.getNextFocusDownId
@inline def nextFocusLeftId_=(p: Int) = {
base.setNextFocusLeftId(p)
base
}
@inline def nextFocusLeftId(p: Int) = nextFocusLeftId_=(p)
@inline def nextFocusLeftId = base.getNextFocusLeftId
@inline def nextFocusRightId_=(p: Int) = {
base.setNextFocusRightId(p)
base
}
@inline def nextFocusRightId(p: Int) = nextFocusRightId_=(p)
@inline def nextFocusRightId = base.getNextFocusRightId
@inline def nextFocusUpId_=(p: Int) = {
base.setNextFocusUpId(p)
base
}
@inline def nextFocusUpId(p: Int) = nextFocusUpId_=(p)
@inline def nextFocusUpId = base.getNextFocusUpId
@inline def onClickListener_=(p: android.view.View.OnClickListener) = {
base.setOnClickListener(p)
base
}
@inline def onClickListener(p: android.view.View.OnClickListener) = onClickListener_=(p)
@noEquivalentGetterExists
@inline def onClickListener: android.view.View.OnClickListener = defaultValue[android.view.View.OnClickListener]
@inline def onCreateContextMenuListener_=(p: android.view.View.OnCreateContextMenuListener) = {
base.setOnCreateContextMenuListener(p)
base
}
@inline def onCreateContextMenuListener(p: android.view.View.OnCreateContextMenuListener) = onCreateContextMenuListener_=(p)
@noEquivalentGetterExists
@inline def onCreateContextMenuListener: android.view.View.OnCreateContextMenuListener = defaultValue[android.view.View.OnCreateContextMenuListener]
@inline def onFocusChangeListener_=(p: android.view.View.OnFocusChangeListener) = {
base.setOnFocusChangeListener(p)
base
}
@inline def onFocusChangeListener(p: android.view.View.OnFocusChangeListener) = onFocusChangeListener_=(p)
@inline def onFocusChangeListener = base.getOnFocusChangeListener
@inline def onKeyListener_=(p: android.view.View.OnKeyListener) = {
base.setOnKeyListener(p)
base
}
@inline def onKeyListener(p: android.view.View.OnKeyListener) = onKeyListener_=(p)
@noEquivalentGetterExists
@inline def onKeyListener: android.view.View.OnKeyListener = defaultValue[android.view.View.OnKeyListener]
@inline def onLongClickListener_=(p: android.view.View.OnLongClickListener) = {
base.setOnLongClickListener(p)
base
}
@inline def onLongClickListener(p: android.view.View.OnLongClickListener) = onLongClickListener_=(p)
@noEquivalentGetterExists
@inline def onLongClickListener: android.view.View.OnLongClickListener = defaultValue[android.view.View.OnLongClickListener]
@inline def onTouchListener_=(p: android.view.View.OnTouchListener) = {
base.setOnTouchListener(p)
base
}
@inline def onTouchListener(p: android.view.View.OnTouchListener) = onTouchListener_=(p)
@noEquivalentGetterExists
@inline def onTouchListener: android.view.View.OnTouchListener = defaultValue[android.view.View.OnTouchListener]
@inline def opaque = base.isOpaque
@inline def paddingBottom = base.getPaddingBottom
@inline def paddingLeft = base.getPaddingLeft
@inline def paddingRight = base.getPaddingRight
@inline def paddingTop = base.getPaddingTop
@inline def parent = base.getParent
@inline def pressed_=(p: Boolean) = {
base.setPressed(p)
base
}
@inline def pressed(p: Boolean) = pressed_=(p)
@inline def pressed = base.isPressed
@inline def resources = base.getResources
@inline def right = base.getRight
@inline def rootView = base.getRootView
@inline def enableSave = {base.setSaveEnabled(true); base}
@inline def disableSave = {base.setSaveEnabled(false); base}
@inline def saveEnabled_=(p: Boolean) = {
base.setSaveEnabled(p)
base
}
@inline def saveEnabled(p: Boolean) = saveEnabled_=(p)
@inline def saveEnabled = base.isSaveEnabled
@inline def scrollBarStyle_=(p: Int) = {
base.setScrollBarStyle(p)
base
}
@inline def scrollBarStyle(p: Int) = scrollBarStyle_=(p)
@inline def scrollBarStyle = base.getScrollBarStyle
@inline def scrollContainer_=(p: Boolean) = {
base.setScrollContainer(p)
base
}
@inline def scrollContainer(p: Boolean) = scrollContainer_=(p)
@noEquivalentGetterExists
@inline def scrollContainer: Boolean = defaultValue[Boolean]
@inline def scrollX = base.getScrollX
@inline def scrollY = base.getScrollY
@inline def enableScrollbarFading = {base.setScrollbarFadingEnabled(true); base}
@inline def disableScrollbarFading = {base.setScrollbarFadingEnabled(false); base}
@inline def scrollbarFadingEnabled_=(p: Boolean) = {
base.setScrollbarFadingEnabled(p)
base
}
@inline def scrollbarFadingEnabled(p: Boolean) = scrollbarFadingEnabled_=(p)
@inline def scrollbarFadingEnabled = base.isScrollbarFadingEnabled
@inline def selected_=(p: Boolean) = {
base.setSelected(p)
base
}
@inline def selected(p: Boolean) = selected_=(p)
@inline def selected = base.isSelected
@inline def shown = base.isShown
@inline def solidColor = base.getSolidColor
@inline def enableSoundEffects = {base.setSoundEffectsEnabled(true); base}
@inline def disableSoundEffects = {base.setSoundEffectsEnabled(false); base}
@inline def soundEffectsEnabled_=(p: Boolean) = {
base.setSoundEffectsEnabled(p)
base
}
@inline def soundEffectsEnabled(p: Boolean) = soundEffectsEnabled_=(p)
@inline def soundEffectsEnabled = base.isSoundEffectsEnabled
@inline def top = base.getTop
@inline def touchDelegate_=(p: android.view.TouchDelegate) = {
base.setTouchDelegate(p)
base
}
@inline def touchDelegate(p: android.view.TouchDelegate) = touchDelegate_=(p)
@inline def touchDelegate = base.getTouchDelegate
@inline def touchables = base.getTouchables
@inline def enableVerticalFadingEdge = {base.setVerticalFadingEdgeEnabled(true); base}
@inline def disableVerticalFadingEdge = {base.setVerticalFadingEdgeEnabled(false); base}
@inline def verticalFadingEdgeEnabled_=(p: Boolean) = {
base.setVerticalFadingEdgeEnabled(p)
base
}
@inline def verticalFadingEdgeEnabled(p: Boolean) = verticalFadingEdgeEnabled_=(p)
@inline def verticalFadingEdgeEnabled = base.isVerticalFadingEdgeEnabled
@inline def verticalFadingEdgeLength = base.getVerticalFadingEdgeLength
@inline def enableVerticalScrollBar = {base.setVerticalScrollBarEnabled(true); base}
@inline def disableVerticalScrollBar = {base.setVerticalScrollBarEnabled(false); base}
@inline def verticalScrollBarEnabled_=(p: Boolean) = {
base.setVerticalScrollBarEnabled(p)
base
}
@inline def verticalScrollBarEnabled(p: Boolean) = verticalScrollBarEnabled_=(p)
@inline def verticalScrollBarEnabled = base.isVerticalScrollBarEnabled
@inline def verticalScrollbarWidth = base.getVerticalScrollbarWidth
@inline def viewTreeObserver = base.getViewTreeObserver
@inline def visibility_=(p: Int) = {
base.setVisibility(p)
base
}
@inline def visibility(p: Int) = visibility_=(p)
@inline def visibility = base.getVisibility
@inline def width = base.getWidth
@inline def windowToken = base.getWindowToken
@inline def windowVisibility = base.getWindowVisibility
@inline def padding_=(p: Int) = {
base.setPadding(p, p, p, p)
base
}
@inline def padding(p: Int) = padding_=(p)
@noEquivalentGetterExists
@inline def padding: Int = 0
val MATCH_PARENT = ViewGroup.LayoutParams.MATCH_PARENT
val WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT
@deprecated("Use MATCH_PARENT instead","Android API Level 8")
val FILL_PARENT = ViewGroup.LayoutParams.MATCH_PARENT
def layout[LP <: ViewGroupLayoutParams[_]](implicit defaultLayoutParam: (V) => LP): LP = {
defaultLayoutParam(base)
}
def matchLayout[LP <: ViewGroupLayoutParams[_]](implicit defaultLayoutParam: (V) => LP): LP = {
val lp = defaultLayoutParam(base)
lp.height = MATCH_PARENT
lp.width = MATCH_PARENT
lp
}
def wrapLayout[LP <: ViewGroupLayoutParams[_]](implicit defaultLayoutParam: (V) => LP): LP = {
val lp = defaultLayoutParam(base)
lp.height = WRAP_CONTENT
lp.width = WRAP_CONTENT
lp
}
def base: V
}
class RichEditText[V <: EditText](val base: V) extends TraitEditText[V]
@inline implicit def editText2RichEditText[V <: EditText](editText: V) = new RichEditText[V](editText)
trait TraitEditText[V <: EditText] extends TraitTextView[V] {
}
class SEditText(implicit context: Context) extends EditText(context) with TraitEditText[SEditText] {
def base = this
}
object SEditText {
def apply()(implicit context: Context): SEditText = new SEditText
def apply(txt: CharSequence)(implicit context: Context): SEditText = new SEditText() text txt
}
class RichActivity[V <: Activity](val base: V) extends TraitActivity[V]
@inline implicit def activity2RichActivity[V <: Activity](activity: V) = new RichActivity[V](activity)
trait TraitActivity[V <: Activity] extends RunOnUiThread {
@inline def contentView_=(p: View) = {
base.setContentView(p)
base
}
@inline def contentView(p: View) = contentView_=(p)
@noEquivalentGetterExists
@inline def contentView: View = null
def base: Activity
def find[V <: View](id: Int): V = base.findViewById(id).asInstanceOf[V]
}
trait SActivity extends Activity with SContext with TraitActivity[SActivity] {
def base = this
}
class RichTextView[V <: TextView](val base: V) extends TraitTextView[V]
@inline implicit def textView2RichTextView[V <: TextView](textView: V) = new RichTextView[V](textView)
trait TraitTextView[V <: TextView] extends TraitView[V] {
@inline def beforeTextChanged(f: => Unit): V = {
base.addTextChangedListener(new TextWatcher {
def beforeTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int): Unit = {
f
}
def onTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int): Unit = {
}
def afterTextChanged(p1: Editable): Unit = {
}
})
base
}
@inline def onTextChanged(f: => Unit): V = {
base.addTextChangedListener(new TextWatcher {
def beforeTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int): Unit = {
}
def onTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int): Unit = {
f
}
def afterTextChanged(p1: Editable): Unit = {
}
})
base
}
@inline def afterTextChanged(f: => Unit): V = {
base.addTextChangedListener(new TextWatcher {
def beforeTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int): Unit = {
}
def onTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int): Unit = {
}
def afterTextChanged(p1: Editable): Unit = {
f
}
})
base
}
@inline def beforeTextChanged(f: (CharSequence, Int, Int, Int) => Unit): V = {
base.addTextChangedListener(new TextWatcher {
def beforeTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int): Unit = {
f(p1, p2, p3, p4)
}
def onTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int): Unit = {
}
def afterTextChanged(p1: Editable): Unit = {
}
})
base
}
@inline def onTextChanged(f: (CharSequence, Int, Int, Int) => Unit): V = {
base.addTextChangedListener(new TextWatcher {
def beforeTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int): Unit = {
}
def onTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int): Unit = {
f(p1, p2, p3, p4)
}
def afterTextChanged(p1: Editable): Unit = {
}
})
base
}
@inline def afterTextChanged(f: (Editable) => Unit): V = {
base.addTextChangedListener(new TextWatcher {
def beforeTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int): Unit = {
}
def onTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int): Unit = {
}
def afterTextChanged(p1: Editable): Unit = {
f(p1)
}
})
base
}
@inline def onEditorAction(f: => Boolean): V = {
base.setOnEditorActionListener(new OnEditorActionListener {
def onEditorAction(p1: TextView, p2: Int, p3: KeyEvent): Boolean = {
f
}
})
base
}
@inline def onEditorAction(f: (TextView, Int, KeyEvent) => Boolean): V = {
base.setOnEditorActionListener(new OnEditorActionListener {
def onEditorAction(p1: TextView, p2: Int, p3: KeyEvent): Boolean = {
f(p1, p2, p3)
}
})
base
}
@inline def autoLinkMask_=(p: Int) = {
base.setAutoLinkMask(p)
base
}
@inline def autoLinkMask(p: Int) = autoLinkMask_=(p)
@inline def autoLinkMask = base.getAutoLinkMask
@inline def compoundDrawablePadding_=(p: Int) = {
base.setCompoundDrawablePadding(p)
base
}
@inline def compoundDrawablePadding(p: Int) = compoundDrawablePadding_=(p)
@inline def compoundDrawablePadding = base.getCompoundDrawablePadding
@inline def compoundDrawables = base.getCompoundDrawables
@inline def compoundPaddingBottom = base.getCompoundPaddingBottom
@inline def compoundPaddingLeft = base.getCompoundPaddingLeft
@inline def compoundPaddingRight = base.getCompoundPaddingRight
@inline def compoundPaddingTop = base.getCompoundPaddingTop
@inline def currentHintTextColor = base.getCurrentHintTextColor
@inline def currentTextColor = base.getCurrentTextColor
@inline def cursorVisible_=(p: Boolean) = {
base.setCursorVisible(p)
base
}
@inline def cursorVisible(p: Boolean) = cursorVisible_=(p)
@noEquivalentGetterExists
@inline def cursorVisible: Boolean = defaultValue[Boolean]
@inline def editableFactory_=(p: android.text.Editable.Factory) = {
base.setEditableFactory(p)
base
}
@inline def editableFactory(p: android.text.Editable.Factory) = editableFactory_=(p)
@noEquivalentGetterExists