summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml2
-rw-r--r--res/layout/dialog_rename.xml41
-rw-r--r--res/layout/gesture_create.xml (renamed from res/layout/create_gesture.xml)36
-rw-r--r--res/layout/gestures_list.xml12
-rw-r--r--res/layout/ime.xml5
-rw-r--r--src/us/minak/IMEGestureOverlayView.java (renamed from src/us/minak/DrawingSpaceView.java)17
-rw-r--r--src/us/minak/IMEService.java8
-rw-r--r--src/us/minak/IMEView.java21
-rw-r--r--src/us/minak/OnCharacterEnteredListener.java5
-rw-r--r--src/us/minak/OnGestureRecognizedListener.java26
-rw-r--r--src/us/minak/SettingsActivity.java2
-rw-r--r--src/us/minak/SettingsCreateGestureActivity.java (renamed from src/us/minak/CreateGestureActivity.java)4
-rw-r--r--src/us/minak/SettingsUtil.java6
-rw-r--r--src/us/minak/StringReciever.java5
14 files changed, 57 insertions, 133 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2838bb2..fda3879 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -9,7 +9,7 @@
<application
android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
+ android:icon="@drawable/minak"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
diff --git a/res/layout/dialog_rename.xml b/res/layout/dialog_rename.xml
deleted file mode 100644
index 49df806..0000000
--- a/res/layout/dialog_rename.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="20dip"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/label"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:text="@string/gestures_rename_label"
- android:gravity="left"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <EditText
- android:id="@+id/name"
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:scrollHorizontally="true"
- android:autoText="false"
- android:capitalize="none"
- android:gravity="fill_horizontal"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
-</LinearLayout>
diff --git a/res/layout/create_gesture.xml b/res/layout/gesture_create.xml
index 89e64c6..2864bc7 100644
--- a/res/layout/create_gesture.xml
+++ b/res/layout/gesture_create.xml
@@ -22,12 +22,12 @@
android:orientation="vertical">
+ <!-- The "Name" bar at the top -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
-
android:orientation="horizontal">
-
+ <!-- The prompt -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -35,18 +35,19 @@
android:text="@string/prompt_gesture_name"
android:textAppearance="?android:attr/textAppearanceMedium" />
-
+ <!-- The input -->
<EditText
android:id="@+id/gesture_name"
android:layout_width="0dip"
android:layout_weight="1.0"
android:layout_height="wrap_content"
+ android:inputType="text"
android:maxLength="40"
android:singleLine="true" />
</LinearLayout>
-
+ <!-- The gesture input -->
<android.gesture.GestureOverlayView
android:id="@+id/gestures_overlay"
android:layout_width="match_parent"
@@ -54,34 +55,33 @@
android:layout_weight="1.0"
android:gestureStrokeType="multiple" />
-
+ <!-- The "add" and "cancel" buttons -->
<LinearLayout
style="@android:style/ButtonBar"
-
android:layout_width="match_parent"
android:layout_height="wrap_content"
-
android:orientation="horizontal">
<Button
android:id="@+id/done"
-
+ android:onClick="addGesture"
+ android:text="@string/button_done"
+
+ android:enabled="false"
+
android:layout_width="0dip"
android:layout_height="wrap_content"
- android:layout_weight="1"
-
- android:enabled="false"
+ android:layout_weight="1"
+ style="?android:attr/buttonBarButtonStyle" />
- android:onClick="addGesture"
- android:text="@string/button_done" />
-
<Button
+ android:onClick="cancelGesture"
+ android:text="@string/button_discard"
+
android:layout_width="0dip"
android:layout_height="wrap_content"
- android:layout_weight="1"
-
- android:onClick="cancelGesture"
- android:text="@string/button_discard" />
+ android:layout_weight="1"
+ style="?android:attr/buttonBarButtonStyle" />
</LinearLayout>
diff --git a/res/layout/gestures_list.xml b/res/layout/gestures_list.xml
index d0b5e3d..bdbe1f5 100644
--- a/res/layout/gestures_list.xml
+++ b/res/layout/gestures_list.xml
@@ -50,24 +50,22 @@
<Button
android:id="@+id/addButton"
android:onClick="addGesture"
+ android:text="@string/button_add"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
-
- android:enabled="false"
- android:text="@string/button_add" />
+ style="?android:attr/buttonBarButtonStyle" />
<Button
android:id="@+id/reloadButton"
android:onClick="reloadGestures"
+ android:text="@string/button_reload"
android:layout_width="0dip"
android:layout_height="wrap_content"
- android:layout_weight="1"
-
- android:enabled="false"
- android:text="@string/button_reload" />
+ android:layout_weight="1"
+ style="?android:attr/buttonBarButtonStyle" />
</LinearLayout>
diff --git a/res/layout/ime.xml b/res/layout/ime.xml
index c5e78ef..34bbd6d 100644
--- a/res/layout/ime.xml
+++ b/res/layout/ime.xml
@@ -3,7 +3,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <us.minak.DrawingSpaceView
+ <us.minak.IMEGestureOverlayView
android:id="@+id/drawing_space"
android:layout_width="wrap_content"
android:layout_height="200dp"
@@ -15,7 +15,6 @@
android:gestureStrokeAngleThreshold="0.0"
android:gestureStrokeLengthThreshold="0.0"
android:gestureStrokeSquarenessThreshold="0.0"
- android:gestureStrokeType="multiple">
- </us.minak.DrawingSpaceView>
+ android:gestureStrokeType="multiple" />
</us.minak.IMEView>
diff --git a/src/us/minak/DrawingSpaceView.java b/src/us/minak/IMEGestureOverlayView.java
index 7f9c3fa..fed2bf1 100644
--- a/src/us/minak/DrawingSpaceView.java
+++ b/src/us/minak/IMEGestureOverlayView.java
@@ -16,7 +16,6 @@ import java.util.List;
import android.content.Context;
import android.gesture.Gesture;
-import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
@@ -26,20 +25,20 @@ import android.util.AttributeSet;
/**
* Represent a space where drawing gestures are performed.
*/
-public class DrawingSpaceView extends GestureOverlayView implements OnGesturePerformedListener {
+public class IMEGestureOverlayView extends GestureOverlayView implements OnGesturePerformedListener {
private static final double SCORE_TRESHOLD = 3.0;
private final GestureLibrary mGestureLibrary;
- private OnGestureRecognizedListener mOnGestureRecognizedListener;
+ private StringReciever mOutput;
- public DrawingSpaceView(Context context, AttributeSet attrs) {
+ public IMEGestureOverlayView(Context context, AttributeSet attrs) {
super(context, attrs);
- mGestureLibrary = GestureLibraries.fromRawResource(context, R.raw.gestures);
+ mGestureLibrary = SettingsUtil.getGestureLibrary(context);
mGestureLibrary.load();
addOnGesturePerformedListener(this);
}
- public void setOnGestureRecognizedListener(OnGestureRecognizedListener onGestureRecognizedListener) {
- mOnGestureRecognizedListener = onGestureRecognizedListener;
+ public void setOutput(StringReciever output) {
+ mOutput = output;
}
@Override
@@ -49,9 +48,9 @@ public class DrawingSpaceView extends GestureOverlayView implements OnGesturePer
if (!predictions.isEmpty()) {
bestPrediction = predictions.get(0);
}
- if (mOnGestureRecognizedListener != null && bestPrediction != null) {
+ if (mOutput != null && bestPrediction != null) {
if (bestPrediction.score > SCORE_TRESHOLD) {
- mOnGestureRecognizedListener.gestureRecognized(bestPrediction.name);
+ mOutput.putString(bestPrediction.name);
} else {
clear(false);
}
diff --git a/src/us/minak/IMEService.java b/src/us/minak/IMEService.java
index 92aad05..fb260aa 100644
--- a/src/us/minak/IMEService.java
+++ b/src/us/minak/IMEService.java
@@ -5,7 +5,6 @@ import android.view.View;
import android.view.inputmethod.EditorInfo;
public class IMEService extends InputMethodService {
- private IMEView imeView;
/**
* Loads the configuration.
*/
@@ -18,14 +17,13 @@ public class IMEService extends InputMethodService {
public View onCreateInputView() {
final IMEView view = (IMEView) getLayoutInflater().inflate(R.layout.ime, null);
- view.setOnCharacterEnteredListener(new OnCharacterEnteredListener() {
+ view.setOutput(new StringReciever() {
@Override
- public void characterEntered(String character) {
+ public void putString(String character) {
getCurrentInputConnection().commitText(character, 1);
}
});
- this.imeView = view;
return view;
}
@@ -33,6 +31,6 @@ public class IMEService extends InputMethodService {
* Called to inform the input method that text input has started in an editor.
*/
public void onStartInput(EditorInfo info, boolean restarting) {
- // TODO: get characters from this.imeView, and pass them to getCurrentInputConnection().commitText(..., 1);
+ // TODO: I don't even know
}
}
diff --git a/src/us/minak/IMEView.java b/src/us/minak/IMEView.java
index d341ae5..03b3716 100644
--- a/src/us/minak/IMEView.java
+++ b/src/us/minak/IMEView.java
@@ -5,30 +5,27 @@ import android.util.AttributeSet;
import android.widget.RelativeLayout;
public class IMEView extends RelativeLayout{
- private final Context mContext;
- private OnCharacterEnteredListener mOnCharacterEnteredListener;
+ private StringReciever mOutput;
+
public IMEView(Context context, AttributeSet attrs) {
super(context, attrs);
- mContext = context;
}
@Override
protected void onFinishInflate() {
- DrawingSpaceView drawingSpaceView = (DrawingSpaceView) findViewById(R.id.drawing_space);
- drawingSpaceView.setOnGestureRecognizedListener(new OnGestureRecognizedListener() {
+ IMEGestureOverlayView drawingSpaceView = (IMEGestureOverlayView) findViewById(R.id.drawing_space);
+ drawingSpaceView.setOutput(new StringReciever() {
@Override
- public void gestureRecognized(String character) {
- enterCharacter(character);
- }
-
+ public void putString(String character) { enterCharacter(character); }
});
}
- public void setOnCharacterEnteredListener(OnCharacterEnteredListener onCharacterEnteredListener) {
- mOnCharacterEnteredListener = onCharacterEnteredListener;
+ public void setOutput(StringReciever output) {
+ mOutput = output;
}
private void enterCharacter(String character) {
- mOnCharacterEnteredListener.characterEntered(character);
+ if (mOutput != null)
+ mOutput.putString(character);
}
}
diff --git a/src/us/minak/OnCharacterEnteredListener.java b/src/us/minak/OnCharacterEnteredListener.java
deleted file mode 100644
index 82226b6..0000000
--- a/src/us/minak/OnCharacterEnteredListener.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package us.minak;
-
-public interface OnCharacterEnteredListener {
- void characterEntered(String character);
-} \ No newline at end of file
diff --git a/src/us/minak/OnGestureRecognizedListener.java b/src/us/minak/OnGestureRecognizedListener.java
deleted file mode 100644
index a30e8b8..0000000
--- a/src/us/minak/OnGestureRecognizedListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- ********************************************************************************
- * Copyright (c) 2012 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Inc. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- ********************************************************************************
- */
-
-package us.minak;
-
-/**
- * A simple interface for handling recognizing a gesture.
- */
-public interface OnGestureRecognizedListener {
- /**
- * Invoked when a gesture is recognized.
- *
- * @param character
- * The character represented by the gesture.
- */
- void gestureRecognized(String character);
-}
diff --git a/src/us/minak/SettingsActivity.java b/src/us/minak/SettingsActivity.java
index cf3f635..c052e6c 100644
--- a/src/us/minak/SettingsActivity.java
+++ b/src/us/minak/SettingsActivity.java
@@ -119,7 +119,7 @@ public class SettingsActivity extends ListActivity {
/** Called by onClick */
public void addGesture(View v) {
- Intent intent = new Intent(this, CreateGestureActivity.class);
+ Intent intent = new Intent(this, SettingsCreateGestureActivity.class);
startActivityForResult(intent, REQUEST_NEW_GESTURE);
}
diff --git a/src/us/minak/CreateGestureActivity.java b/src/us/minak/SettingsCreateGestureActivity.java
index c153ac3..64975e0 100644
--- a/src/us/minak/CreateGestureActivity.java
+++ b/src/us/minak/SettingsCreateGestureActivity.java
@@ -26,7 +26,7 @@ import android.gesture.GestureLibrary;
import android.widget.TextView;
import android.widget.Toast;
-public class CreateGestureActivity extends Activity {
+public class SettingsCreateGestureActivity extends Activity {
private static final float LENGTH_THRESHOLD = 120.0f;
private Gesture mGesture;
@@ -36,7 +36,7 @@ public class CreateGestureActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.create_gesture);
+ setContentView(R.layout.gesture_create);
mDoneButton = findViewById(R.id.done);
diff --git a/src/us/minak/SettingsUtil.java b/src/us/minak/SettingsUtil.java
index 8fe710f..c043e0b 100644
--- a/src/us/minak/SettingsUtil.java
+++ b/src/us/minak/SettingsUtil.java
@@ -1,6 +1,6 @@
package us.minak;
-import android.content.ContextWrapper;
+import android.content.Context;
import android.gesture.GestureLibrary;
import android.gesture.GestureLibraries;
@@ -13,7 +13,7 @@ public class SettingsUtil {
private static File sGestureFile = null;
private static GestureLibrary sGestureLibrary = null;
- public static File getGestureFile(ContextWrapper context) {
+ public static File getGestureFile(Context context) {
if (sGestureFile == null)
sGestureFile = new File(context.getExternalFilesDir(null), "gestures.ttf");
// If the gestures file doesn't exist, copy the default gestures to it
@@ -33,7 +33,7 @@ public class SettingsUtil {
}
return sGestureFile;
}
- public static GestureLibrary getGestureLibrary(ContextWrapper context) {
+ public static GestureLibrary getGestureLibrary(Context context) {
if (sGestureLibrary == null)
sGestureLibrary = GestureLibraries.fromFile(getGestureFile(context));
return sGestureLibrary;
diff --git a/src/us/minak/StringReciever.java b/src/us/minak/StringReciever.java
new file mode 100644
index 0000000..2b91da1
--- /dev/null
+++ b/src/us/minak/StringReciever.java
@@ -0,0 +1,5 @@
+package us.minak;
+
+public interface StringReciever {
+ void putString(String character);
+}