Repository: connectbot/connectbot
Issue: StringIndexOutOfBoundsException when generating public keys under Traditional Chinese locale

Steps to reprduce:

1. Use Traditional Chinese locale. On my phone it's displayed as 中文(繁體)
2. "Manage Pubkeys" (管理公鑰) => "+"
3. Type a random name and hit "Generate" (產生)

Then the generation dialog crashes: (I add two ```Log.e()``` to see what's wrong)
```
02-28 02:29:35.812  27000    27000                  DEBUG  E  觸摸此方框來收集隨機數：0％完成
02-28 02:29:35.813  27000    27000                  DEBUG  E  -1
02-28 02:29:35.818  27000    27000         AndroidRuntime  D  Shutting down VM
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  FATAL EXCEPTION: main
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  Process: org.connectbot.debug, PID: 27000
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  java.lang.StringIndexOutOfBoundsException: length=16; regionStart=0; regionLength=-1
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at java.lang.String.startEndAndLength(String.java:298)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at java.lang.String.substring(String.java:1087)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at org.connectbot.util.EntropyView.onDraw(EntropyView.java:101)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.View.draw(View.java:16200)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.View.updateDisplayListIfDirty(View.java:15197)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.View.draw(View.java:15970)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewGroup.drawChild(ViewGroup.java:3610)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.View.updateDisplayListIfDirty(View.java:15192)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.View.draw(View.java:15970)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewGroup.drawChild(ViewGroup.java:3610)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.View.updateDisplayListIfDirty(View.java:15192)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.View.draw(View.java:15970)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewGroup.drawChild(ViewGroup.java:3610)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.View.updateDisplayListIfDirty(View.java:15192)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.View.draw(View.java:15970)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewGroup.drawChild(ViewGroup.java:3610)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.View.draw(View.java:16203)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at com.android.internal.policy.PhoneWindow$DecorView.draw(PhoneWindow.java:2690)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.View.updateDisplayListIfDirty(View.java:15197)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:287)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:322)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewRootImpl.draw(ViewRootImpl.java:2620)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2439)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2072)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1112)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6035)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.Choreographer.doCallbacks(Choreographer.java:670)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.Choreographer.doFrame(Choreographer.java:606)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.os.Handler.handleCallback(Handler.java:739)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.os.Handler.dispatchMessage(Handler.java:95)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.os.Looper.loop(Looper.java:148)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at android.app.ActivityThread.main(ActivityThread.java:5451)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at java.lang.reflect.Method.invoke(Native Method)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
02-28 02:29:35.819  27000    27000         AndroidRuntime  E  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
```

Everything works fine with English locale.

Tested with the latest git master (0a380c1795e088b2915446d2d270eb64b0902aff)

Changed files:
app/src/main/java/org/connectbot/util/EntropyView.java

diff --git a/app/src/main/java/org/connectbot/util/EntropyView.java b/app/src/main/java/org/connectbot/util/EntropyView.java
index e25cb0d3..c7411b02 100644
--- a/app/src/main/java/org/connectbot/util/EntropyView.java
+++ b/app/src/main/java/org/connectbot/util/EntropyView.java
@@ -94,6 +94,8 @@ public class EntropyView extends View {
 				mPaint.measureText(prompt) > (getWidth() * 0.8)) {
 			if (splitText == 0)
 				splitText = prompt.indexOf(' ', prompt.length() / 2);
+			if (splitText < 0)
+				splitText = prompt.length() / 2;
 
 			c.drawText(prompt.substring(0, splitText),
 					getWidth() / 2.0f,