diff --git a/.classpath b/.classpath deleted file mode 100644 index 26bdfa6..0000000 --- a/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..648a292 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Eclipse project files +.classpath +.project + +# Proguard folder generated by Eclipse +proguard/ + +# Intellij project files +*.iml +*.ipr +*.iws +.idea/ diff --git a/.project b/.project deleted file mode 100644 index b5c2b7b..0000000 --- a/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - VerticalTextView - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 48ab4c6..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/bin/AndroidManifest.xml b/bin/AndroidManifest.xml deleted file mode 100644 index c2d874b..0000000 --- a/bin/AndroidManifest.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/bin/VerticalTextView.apk b/bin/VerticalTextView.apk deleted file mode 100644 index 89e60eb..0000000 Binary files a/bin/VerticalTextView.apk and /dev/null differ diff --git a/bin/classes.dex b/bin/classes.dex deleted file mode 100644 index 80213e5..0000000 Binary files a/bin/classes.dex and /dev/null differ diff --git a/bin/classes/com/yoog/widget/BuildConfig.class b/bin/classes/com/yoog/widget/BuildConfig.class deleted file mode 100644 index ce08b59..0000000 Binary files a/bin/classes/com/yoog/widget/BuildConfig.class and /dev/null differ diff --git a/bin/classes/com/yoog/widget/MainActivity.class b/bin/classes/com/yoog/widget/MainActivity.class deleted file mode 100644 index da1d426..0000000 Binary files a/bin/classes/com/yoog/widget/MainActivity.class and /dev/null differ diff --git a/bin/classes/com/yoog/widget/R$attr.class b/bin/classes/com/yoog/widget/R$attr.class deleted file mode 100644 index 1053d28..0000000 Binary files a/bin/classes/com/yoog/widget/R$attr.class and /dev/null differ diff --git a/bin/classes/com/yoog/widget/R$dimen.class b/bin/classes/com/yoog/widget/R$dimen.class deleted file mode 100644 index 23e8e21..0000000 Binary files a/bin/classes/com/yoog/widget/R$dimen.class and /dev/null differ diff --git a/bin/classes/com/yoog/widget/R$drawable.class b/bin/classes/com/yoog/widget/R$drawable.class deleted file mode 100644 index 47057b0..0000000 Binary files a/bin/classes/com/yoog/widget/R$drawable.class and /dev/null differ diff --git a/bin/classes/com/yoog/widget/R$id.class b/bin/classes/com/yoog/widget/R$id.class deleted file mode 100644 index 1287d75..0000000 Binary files a/bin/classes/com/yoog/widget/R$id.class and /dev/null differ diff --git a/bin/classes/com/yoog/widget/R$layout.class b/bin/classes/com/yoog/widget/R$layout.class deleted file mode 100644 index 518f844..0000000 Binary files a/bin/classes/com/yoog/widget/R$layout.class and /dev/null differ diff --git a/bin/classes/com/yoog/widget/R$menu.class b/bin/classes/com/yoog/widget/R$menu.class deleted file mode 100644 index 01493f3..0000000 Binary files a/bin/classes/com/yoog/widget/R$menu.class and /dev/null differ diff --git a/bin/classes/com/yoog/widget/R$string.class b/bin/classes/com/yoog/widget/R$string.class deleted file mode 100644 index 97aa610..0000000 Binary files a/bin/classes/com/yoog/widget/R$string.class and /dev/null differ diff --git a/bin/classes/com/yoog/widget/R$style.class b/bin/classes/com/yoog/widget/R$style.class deleted file mode 100644 index bc379ae..0000000 Binary files a/bin/classes/com/yoog/widget/R$style.class and /dev/null differ diff --git a/bin/classes/com/yoog/widget/R$styleable.class b/bin/classes/com/yoog/widget/R$styleable.class deleted file mode 100644 index 7ee04b8..0000000 Binary files a/bin/classes/com/yoog/widget/R$styleable.class and /dev/null differ diff --git a/bin/classes/com/yoog/widget/R.class b/bin/classes/com/yoog/widget/R.class deleted file mode 100644 index b5bd242..0000000 Binary files a/bin/classes/com/yoog/widget/R.class and /dev/null differ diff --git a/bin/classes/com/yoog/widget/VerticalTextView.class b/bin/classes/com/yoog/widget/VerticalTextView.class deleted file mode 100644 index 86ab8b9..0000000 Binary files a/bin/classes/com/yoog/widget/VerticalTextView.class and /dev/null differ diff --git a/bin/dexedLibs/android-support-v4-01c64fc6c039b0149072e749b7d77338.jar b/bin/dexedLibs/android-support-v4-01c64fc6c039b0149072e749b7d77338.jar deleted file mode 100644 index b582827..0000000 Binary files a/bin/dexedLibs/android-support-v4-01c64fc6c039b0149072e749b7d77338.jar and /dev/null differ diff --git a/bin/jarlist.cache b/bin/jarlist.cache deleted file mode 100644 index 0565465..0000000 --- a/bin/jarlist.cache +++ /dev/null @@ -1,3 +0,0 @@ -# cache for current jar dependency. DO NOT EDIT. -# format is -# Encoding is UTF-8 diff --git a/bin/res/crunch/drawable-hdpi/ic_launcher.png b/bin/res/crunch/drawable-hdpi/ic_launcher.png deleted file mode 100644 index efa7c5f..0000000 Binary files a/bin/res/crunch/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/bin/res/crunch/drawable-mdpi/ic_launcher.png b/bin/res/crunch/drawable-mdpi/ic_launcher.png deleted file mode 100644 index ec27f2e..0000000 Binary files a/bin/res/crunch/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/bin/res/crunch/drawable-xhdpi/ic_launcher.png b/bin/res/crunch/drawable-xhdpi/ic_launcher.png deleted file mode 100644 index 92fc57d..0000000 Binary files a/bin/res/crunch/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/bin/res/crunch/drawable-xxhdpi/ic_launcher.png b/bin/res/crunch/drawable-xxhdpi/ic_launcher.png deleted file mode 100644 index b6f8f4e..0000000 Binary files a/bin/res/crunch/drawable-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/bin/resources.ap_ b/bin/resources.ap_ deleted file mode 100644 index 4c3cadc..0000000 Binary files a/bin/resources.ap_ and /dev/null differ diff --git a/gen/com/yoog/widget/BuildConfig.java b/gen/com/yoog/widget/BuildConfig.java deleted file mode 100644 index f90c66d..0000000 --- a/gen/com/yoog/widget/BuildConfig.java +++ /dev/null @@ -1,6 +0,0 @@ -/** Automatically generated file. DO NOT MODIFY */ -package com.yoog.widget; - -public final class BuildConfig { - public final static boolean DEBUG = true; -} \ No newline at end of file diff --git a/gen/com/yoog/widget/R.java b/gen/com/yoog/widget/R.java deleted file mode 100644 index 98a4450..0000000 --- a/gen/com/yoog/widget/R.java +++ /dev/null @@ -1,119 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package com.yoog.widget; - -public final class R { - public static final class attr { - /**

Must be one of the following constant values.

- ---- - - - - -
ConstantValueDescription
uptodown0
downtoup1
lefttoright2
righttoleft3
- */ - public static final int direction=0x7f010000; - } - public static final class dimen { - /** Default screen margins, per the Android Design guidelines. - - Customize dimensions originally defined in res/values/dimens.xml (such as - screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. - - */ - public static final int activity_horizontal_margin=0x7f050000; - public static final int activity_vertical_margin=0x7f050001; - } - public static final class drawable { - public static final int ic_launcher=0x7f020000; - } - public static final class id { - public static final int action_settings=0x7f040004; - public static final int downtoup=0x7f040001; - public static final int lefttoright=0x7f040002; - public static final int righttoleft=0x7f040003; - public static final int uptodown=0x7f040000; - } - public static final class layout { - public static final int activity_main=0x7f030000; - } - public static final class menu { - public static final int main=0x7f080000; - } - public static final class string { - public static final int action_settings=0x7f060001; - public static final int app_name=0x7f060000; - public static final int hello_world=0x7f060002; - } - public static final class style { - /** - Base application theme, dependent on API level. This theme is replaced - by AppBaseTheme from res/values-vXX/styles.xml on newer devices. - - - Theme customizations available in newer API levels can go in - res/values-vXX/styles.xml, while customizations related to - backward-compatibility can go here. - - - Base application theme for API 11+. This theme completely replaces - AppBaseTheme from res/values/styles.xml on API 11+ devices. - - API 11 theme customizations can go here. - - Base application theme for API 14+. This theme completely replaces - AppBaseTheme from BOTH res/values/styles.xml and - res/values-v11/styles.xml on API 14+ devices. - - API 14 theme customizations can go here. - */ - public static final int AppBaseTheme=0x7f070000; - /** Application theme. - All customizations that are NOT specific to a particular API-level can go here. - */ - public static final int AppTheme=0x7f070001; - } - public static final class styleable { - /** Attributes that can be used with a verticaltextview. -

Includes the following attributes:

- - - - - -
AttributeDescription
{@link #verticaltextview_direction com.yoog.widget:direction}
- @see #verticaltextview_direction - */ - public static final int[] verticaltextview = { - 0x7f010000 - }; - /** -

This symbol is the offset where the {@link com.yoog.widget.R.attr#direction} - attribute's value can be found in the {@link #verticaltextview} array. - - -

Must be one of the following constant values.

- ---- - - - - -
ConstantValueDescription
uptodown0
downtoup1
lefttoright2
righttoleft3
- @attr name com.yoog.widget:direction - */ - public static final int verticaltextview_direction = 0; - }; -} diff --git a/hs_err_pid9628.log b/hs_err_pid9628.log deleted file mode 100644 index 777195b..0000000 --- a/hs_err_pid9628.log +++ /dev/null @@ -1,109 +0,0 @@ -# -# A fatal error has been detected by the Java Runtime Environment: -# -# Internal Error (javaClasses.cpp:136), pid=9628, tid=5540 -# fatal error: Invalid layout of preloaded class -# -# JRE version: (7.0_45-b18) (build ) -# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.45-b08 mixed mode windows-amd64 compressed oops) -# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows -# -# If you would like to submit a bug report, please visit: -# http://bugreport.sun.com/bugreport/crash.jsp -# - ---------------- T H R E A D --------------- - -Current thread (0x000000000257d800): JavaThread "Unknown thread" [_thread_in_vm, id=5540, stack(0x00000000028d0000,0x00000000029d0000)] - -Stack: [0x00000000028d0000,0x00000000029d0000] - ---------------- P R O C E S S --------------- - -Java Threads: ( => current thread ) - -Other Threads: - -=>0x000000000257d800 (exited) JavaThread "Unknown thread" [_thread_in_vm, id=5540, stack(0x00000000028d0000,0x00000000029d0000)] - -VM state:not at safepoint (not fully initialized) - -VM Mutex/Monitor currently owned by a thread: None - -GC Heap History (0 events): -No events - -Deoptimization events (0 events): -No events - -Internal exceptions (0 events): -No events - -Events (10 events): -Event: 0.160 loading class 0x00000000025fc620 done -Event: 0.160 loading class 0x00000000025fc040 done -Event: 0.160 loading class 0x00000000025fc020 -Event: 0.160 loading class 0x0000000002604120 -Event: 0.160 loading class 0x0000000002604120 done -Event: 0.160 loading class 0x0000000002604150 -Event: 0.160 loading class 0x0000000002604150 done -Event: 0.160 loading class 0x0000000002604180 -Event: 0.160 loading class 0x0000000002604180 done -Event: 0.160 loading class 0x00000000025fc020 done - - -Dynamic libraries: -0x000000013f220000 - 0x000000013f253000 D:\Java\jre7\bin\javaw.exe -0x0000000077240000 - 0x00000000773eb000 C:\Windows\SYSTEM32\ntdll.dll -0x0000000077120000 - 0x000000007723f000 C:\Windows\system32\kernel32.dll -0x000007fefd170000 - 0x000007fefd1db000 C:\Windows\system32\KERNELBASE.dll -0x000007feff190000 - 0x000007feff26b000 C:\Windows\system32\ADVAPI32.dll -0x000007fefee20000 - 0x000007fefeebf000 C:\Windows\system32\msvcrt.dll -0x000007fefeec0000 - 0x000007fefeedf000 C:\Windows\SYSTEM32\sechost.dll -0x000007fefeee0000 - 0x000007feff00e000 C:\Windows\system32\RPCRT4.dll -0x0000000076ee0000 - 0x0000000076fda000 C:\Windows\system32\USER32.dll -0x000007feff010000 - 0x000007feff077000 C:\Windows\system32\GDI32.dll -0x000007fefe9d0000 - 0x000007fefe9de000 C:\Windows\system32\LPK.dll -0x000007fefea70000 - 0x000007fefeb3a000 C:\Windows\system32\USP10.dll -0x000007fefb770000 - 0x000007fefb964000 C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16385_none_fa645303170382f6\COMCTL32.dll -0x000007fefd700000 - 0x000007fefd771000 C:\Windows\system32\SHLWAPI.dll -0x000007fefec70000 - 0x000007fefec9e000 C:\Windows\system32\IMM32.DLL -0x000007fefd470000 - 0x000007fefd579000 C:\Windows\system32\MSCTF.dll -0x000007fefcf30000 - 0x000007fefcf70000 C:\Windows\system32\nvinitx.dll -0x000000006ead0000 - 0x000000006eba2000 D:\Java\jre7\bin\msvcr100.dll -0x000000005d380000 - 0x000000005db49000 D:\Java\jre7\bin\server\jvm.dll -0x000007fefb6d0000 - 0x000007fefb6d9000 C:\Windows\system32\WSOCK32.dll -0x000007fefe510000 - 0x000007fefe55d000 C:\Windows\system32\WS2_32.dll -0x000007fefe9e0000 - 0x000007fefe9e8000 C:\Windows\system32\NSI.dll -0x000007fefd070000 - 0x000007fefd0ab000 C:\Windows\system32\WINMM.dll -0x0000000077400000 - 0x0000000077407000 C:\Windows\system32\PSAPI.DLL -0x00000000743c0000 - 0x00000000743cf000 D:\Java\jre7\bin\verify.dll -0x0000000074390000 - 0x00000000743b8000 D:\Java\jre7\bin\java.dll -0x0000000071f30000 - 0x0000000071f45000 D:\Java\jre7\bin\zip.dll - -VM Arguments: -jvm_args: -Dfile.encoding=UTF-8 -Xbootclasspath:D:\GoogleEclipseBit64\sdk\platforms\android-19\android.jar -java_command: com.letv.lepai.common.utils.ZipUtils -Launcher Type: SUN_STANDARD - -Environment Variables: -PATH=C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\TortoiseSVN\bin;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;D:\GoogleEclipseBit64\sdk\platform-tools;D:\GoogleEclipseBit64\sdk\tools; -USERNAME=chenyueguo -OS=Windows_NT -PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 58 Stepping 9, GenuineIntel - - - ---------------- S Y S T E M --------------- - -OS: Windows 7 , 64 bit Build 7600 - -CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 58 stepping 9, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, erms, ht, tsc, tscinvbit, tscinv - -Memory: 4k page, physical 3786988k(942124k free), swap 7789168k(1870796k free) - -vm_info: Java HotSpot(TM) 64-Bit Server VM (24.45-b08) for windows-amd64 JRE (1.7.0_45-b18), built on Oct 8 2013 05:47:22 by "java_re" with unknown MS VC++:1600 - -time: Thu Oct 23 14:16:02 2014 -elapsed time: 0 seconds - diff --git a/src/com/yoog/widget/VerticalTextView.java b/src/com/yoog/widget/VerticalTextView.java index 4822422..0a3ef26 100644 --- a/src/com/yoog/widget/VerticalTextView.java +++ b/src/com/yoog/widget/VerticalTextView.java @@ -11,135 +11,143 @@ import android.widget.TextView; public class VerticalTextView extends TextView { - - public final static int ORIENTATION_UP_TO_DOWN = 0; - public final static int ORIENTATION_DOWN_TO_UP = 1; - public final static int ORIENTATION_LEFT_TO_RIGHT = 2; - public final static int ORIENTATION_RIGHT_TO_LEFT = 3; - - Rect text_bounds = new Rect(); - private int direction; - - public VerticalTextView(Context context) { - super(context); - } - - public VerticalTextView(Context context, AttributeSet attrs) { - super(context, attrs); - - TypedArray a = context.obtainStyledAttributes(attrs, - R.styleable.verticaltextview); - direction = a.getInt(R.styleable.verticaltextview_direction, 0); - a.recycle(); - - requestLayout(); - invalidate(); - - } - - public void setDirection(int direction) { - this.direction = direction; - - requestLayout(); - invalidate(); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - getPaint().getTextBounds(getText().toString(), 0, getText().length(), - text_bounds); - if (direction == ORIENTATION_LEFT_TO_RIGHT - || direction == ORIENTATION_RIGHT_TO_LEFT) { - setMeasuredDimension(measureHeight(widthMeasureSpec), - measureWidth(heightMeasureSpec)); - } else if (direction == ORIENTATION_UP_TO_DOWN - || direction == ORIENTATION_DOWN_TO_UP) { - setMeasuredDimension(measureWidth(widthMeasureSpec), - measureHeight(heightMeasureSpec)); - } - - } - - private int measureWidth(int measureSpec) { - int result = 0; - int specMode = MeasureSpec.getMode(measureSpec); - int specSize = MeasureSpec.getSize(measureSpec); - - if (specMode == MeasureSpec.EXACTLY) { - result = specSize; - } else { - result = text_bounds.height() + getPaddingTop() - + getPaddingBottom(); - // result = text_bounds.height(); - if (specMode == MeasureSpec.AT_MOST) { - result = Math.min(result, specSize); - } - } - return result; - } - - private int measureHeight(int measureSpec) { - int result = 0; - int specMode = MeasureSpec.getMode(measureSpec); - int specSize = MeasureSpec.getSize(measureSpec); - - if (specMode == MeasureSpec.EXACTLY) { - result = specSize; - } else { - result = text_bounds.width() + getPaddingLeft() + getPaddingRight(); - // result = text_bounds.width(); - if (specMode == MeasureSpec.AT_MOST) { - result = Math.min(result, specSize); - } - } - return result; - } - - @Override - protected void onDraw(Canvas canvas) { -// super.onDraw(canvas); - - canvas.save(); - - int startX = 0; - int startY = 0; - int stopX = 0; - int stopY = 0; - Path path = new Path(); - if (direction == ORIENTATION_UP_TO_DOWN) { - startX = (getWidth() - text_bounds.height() >> 1); - startY = (getHeight() - text_bounds.width() >> 1); - stopX = (getWidth() - text_bounds.height() >> 1); - stopY = (getHeight() + text_bounds.width() >> 1); - path.moveTo(startX, startY); - path.lineTo(stopX, stopY); - } else if (direction == ORIENTATION_DOWN_TO_UP) { - startX = (getWidth() + text_bounds.height() >> 1); - startY = (getHeight() + text_bounds.width() >> 1); - stopX = (getWidth() + text_bounds.height() >> 1); - stopY = (getHeight() - text_bounds.width() >> 1); - path.moveTo(startX, startY); - path.lineTo(stopX, stopY); - } else if (direction == ORIENTATION_LEFT_TO_RIGHT) { - startX = (getWidth() - text_bounds.width() >> 1); - startY = (getHeight() + text_bounds.height() >> 1); - stopX = (getWidth() + text_bounds.width() >> 1); - stopY = (getHeight() + text_bounds.height() >> 1); - path.moveTo(startX, startY); - path.lineTo(stopX, stopY); - } else if (direction == ORIENTATION_RIGHT_TO_LEFT) { - startX = (getWidth() + text_bounds.width() >> 1); - startY = (getHeight() - text_bounds.height() >> 1); - stopX = (getWidth() - text_bounds.width() >> 1); - stopY = (getHeight() - text_bounds.height() >> 1); - path.moveTo(startX, startY); - path.lineTo(stopX, stopY); - } - - this.getPaint().setColor(this.getCurrentTextColor()); -// canvas.drawLine(startX, startY, stopX, stopY, this.getPaint()); - canvas.drawTextOnPath(getText().toString(), path, 0, 0, this.getPaint()); - - canvas.restore(); - } + public final static int ORIENTATION_UP_TO_DOWN = 0; + public final static int ORIENTATION_DOWN_TO_UP = 1; + public final static int ORIENTATION_LEFT_TO_RIGHT = 2; + public final static int ORIENTATION_RIGHT_TO_LEFT = 3; + + private Rect text_bounds = new Rect(); + private int text_width = 0, text_height = 0; + private Path path = new Path(); + private int direction; + + public VerticalTextView(Context context) { + super(context); + } + + public VerticalTextView(Context context, AttributeSet attrs) { + super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.VerticalTextView); + direction = a.getInt(R.styleable.VerticalTextView_direction, 0); + a.recycle(); + + requestLayout(); + invalidate(); + } + + public void setDirection(int direction) { + this.direction = direction; + + requestLayout(); + invalidate(); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + getPaint().getTextBounds(getText().toString(), 0, getText().length(), text_bounds); + text_width = (int) getPaint().measureText(getText().toString()); + text_height = text_bounds.height() + Math.abs(text_width - text_bounds.width()); + if (direction == ORIENTATION_LEFT_TO_RIGHT || direction == ORIENTATION_RIGHT_TO_LEFT) { + setMeasuredDimension(measureHeight(widthMeasureSpec), measureWidth(heightMeasureSpec)); + } else if (direction == ORIENTATION_UP_TO_DOWN || direction == ORIENTATION_DOWN_TO_UP) { + setMeasuredDimension(measureWidth(widthMeasureSpec), measureHeight(heightMeasureSpec)); + } + } + + private int measureWidth(int measureSpec) { + int result; + int specMode = MeasureSpec.getMode(measureSpec); + int specSize = MeasureSpec.getSize(measureSpec); + + if (specMode == MeasureSpec.EXACTLY) { + result = specSize; + } else { + result = text_height + getPaddingTop() + getPaddingBottom(); + // result = text_bounds.height(); + if (specMode == MeasureSpec.AT_MOST) { + result = Math.min(result, specSize); + } + } + return result; + } + + private int measureHeight(int measureSpec) { + int result; + int specMode = MeasureSpec.getMode(measureSpec); + int specSize = MeasureSpec.getSize(measureSpec); + + if (specMode == MeasureSpec.EXACTLY) { + result = specSize; + } else { + result = text_width + getPaddingLeft() + getPaddingRight(); + // result = text_bounds.width(); + if (specMode == MeasureSpec.AT_MOST) { + result = Math.min(result, specSize); + } + } + return result; + } + + private int startX = 0, startY = 0; + private int stopX = 0, stopY = 0; + private int hOffset = 0, vOffset = 0; + + @Override + protected void onDraw(Canvas canvas) { + //super.onDraw(canvas); + + canvas.save(); + + switch (direction) { + case ORIENTATION_UP_TO_DOWN: + startX = (getWidth() - text_height >> 1); + startY = (getHeight() - text_width >> 1); + stopX = (getWidth() - text_height >> 1); + stopY = (getHeight() + text_width >> 1); + break; + case ORIENTATION_DOWN_TO_UP: + startX = (getWidth() + text_height >> 1); + startY = (getHeight() + text_width >> 1); + stopX = (getWidth() + text_height >> 1); + stopY = (getHeight() - text_width >> 1); + break; + case ORIENTATION_LEFT_TO_RIGHT: + startX = (getWidth() - text_width >> 1); + startY = (getHeight() + text_height >> 1); + stopX = (getWidth() + text_width >> 1); + stopY = (getHeight() + text_height >> 1); + break; + case ORIENTATION_RIGHT_TO_LEFT: + startX = (getWidth() + text_width >> 1); + startY = (getHeight() - text_height >> 1); + stopX = (getWidth() - text_width >> 1); + stopY = (getHeight() - text_height >> 1); + break; + } + if (text_height >= text_bounds.height()) {//adjust negative offset + hOffset = (text_bounds.height() - text_height) >> 1; + } + if (text_width >= text_bounds.width()) {//adjust negative offset + vOffset = (text_bounds.width() - text_width) >> 1; + } + path.moveTo(startX, startY); + path.lineTo(stopX, stopY); + + this.getPaint().setColor(this.getCurrentTextColor()); + //canvas.drawLine(startX, startY, stopX, stopY, this.getPaint()); + canvas.drawTextOnPath(getText().toString(), path, hOffset, vOffset, this.getPaint()); + + canvas.restore(); + } + + @Override + public void setText(CharSequence text, BufferType type) { + super.setText(text, type); + + //https://github.com/yoog568/VerticalTextView/issues/3 + requestLayout(); + // redraw view with new layout + invalidate(); + } }