diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-09-04 13:34:44 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-09-04 13:34:44 +0000 |
| commit | 7c000467c9996fe0b6e58022ad5524388f20f3e9 (patch) | |
| tree | 152895a2a08813eac8d6fb66e448b420afdfb8d9 /src/ui/android | |
| parent | 35a98594be9d6c946ffcc3821c8726556da9fc50 (diff) | |
updated files src/ui/android
Diffstat (limited to 'src/ui/android')
| -rw-r--r-- | src/ui/android/.classpath | 17 | ||||
| -rw-r--r-- | src/ui/android/.project | 66 | ||||
| -rw-r--r-- | src/ui/android/AndroidManifest.xml | 27 | ||||
| -rw-r--r-- | src/ui/android/default.properties | 13 | ||||
| -rw-r--r-- | src/ui/android/project.properties | 14 | ||||
| -rw-r--r-- | src/ui/android/res/layout/main.xml | 25 | ||||
| -rw-r--r-- | src/ui/android/res/values/strings.xml | 7 | ||||
| -rw-r--r-- | src/ui/android/src/org/grammaticalframework/ui/android/FridgeMagnets.java | 151 |
8 files changed, 80 insertions, 240 deletions
diff --git a/src/ui/android/.classpath b/src/ui/android/.classpath index 6e9239ff0..48f4f566f 100644 --- a/src/ui/android/.classpath +++ b/src/ui/android/.classpath @@ -1,7 +1,10 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="gen"/> + <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> + <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> + <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> + <classpathentry combineaccessrules="false" kind="src" path="/jpgf"/> + <classpathentry kind="output" path="bin/classes"/> +</classpath> diff --git a/src/ui/android/.project b/src/ui/android/.project index c24012a32..abf063e43 100644 --- a/src/ui/android/.project +++ b/src/ui/android/.project @@ -1,33 +1,33 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>GF-Android</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ApkBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>GFTranslator</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.android.ide.eclipse.adt.ApkBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>com.android.ide.eclipse.adt.AndroidNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/src/ui/android/AndroidManifest.xml b/src/ui/android/AndroidManifest.xml index 7188f74b3..6f48b1186 100644 --- a/src/ui/android/AndroidManifest.xml +++ b/src/ui/android/AndroidManifest.xml @@ -1,18 +1,27 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="org.grammaticalframework.ui.android" - android:versionCode="1" - android:versionName="1.0"> - <application android:icon="@drawable/icon" android:label="@string/app_name"> - <activity android:name=".FridgeMagnets" - android:label="@string/app_name"> + package="org.grammaticalframework.ui.android" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk + android:minSdkVersion="8" + android:targetSdkVersion="8" /> + + <application + android:allowBackup="true" + android:icon="@drawable/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme" > + <activity + android:name="org.grammaticalframework.ui.android.MainActivity" + android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> - </application> - <uses-sdk android:minSdkVersion="2" /> -</manifest>
\ No newline at end of file +</manifest> diff --git a/src/ui/android/default.properties b/src/ui/android/default.properties deleted file mode 100644 index 19c96655d..000000000 --- a/src/ui/android/default.properties +++ /dev/null @@ -1,13 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Indicates whether an apk should be generated for each density. -split.density=false -# Project target. -target=android-4 diff --git a/src/ui/android/project.properties b/src/ui/android/project.properties new file mode 100644 index 000000000..ce39f2d0a --- /dev/null +++ b/src/ui/android/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-18 diff --git a/src/ui/android/res/layout/main.xml b/src/ui/android/res/layout/main.xml deleted file mode 100644 index 67ce499fb..000000000 --- a/src/ui/android/res/layout/main.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/main_view" - android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:background="@drawable/brushed_metal" - > - <se.fnord.android.layout.PredicateLayout - android:id="@+id/magnets_sentence" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:padding="5dip"/> - - <View - android:layout_height="8dip" - android:layout_width="fill_parent" - android:background="#FF909090"/> - - <se.fnord.android.layout.PredicateLayout - android:id="@+id/magnets_bag" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:padding="5dip"/> -</LinearLayout> diff --git a/src/ui/android/res/values/strings.xml b/src/ui/android/res/values/strings.xml index 662c708c1..0d7b9a606 100644 --- a/src/ui/android/res/values/strings.xml +++ b/src/ui/android/res/values/strings.xml @@ -1,5 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <string name="hello">Hello World, FridgeMagnets!</string> - <string name="app_name">Fridge Magnets</string> + + <string name="app_name">GFTranslator</string> + <string name="action_settings">Settings</string> + <string name="hello_world">Hello world!</string> + </resources> diff --git a/src/ui/android/src/org/grammaticalframework/ui/android/FridgeMagnets.java b/src/ui/android/src/org/grammaticalframework/ui/android/FridgeMagnets.java deleted file mode 100644 index d1262e7bb..000000000 --- a/src/ui/android/src/org/grammaticalframework/ui/android/FridgeMagnets.java +++ /dev/null @@ -1,151 +0,0 @@ -package org.grammaticalframework.ui.android; - -import java.util.Arrays; - -import android.os.*; -import android.app.*; -import android.content.*; -import android.text.*; -import android.view.*; -import android.view.inputmethod.*; -import android.widget.*; -import android.graphics.*; -import se.fnord.android.layout.*; - -public class FridgeMagnets extends Activity { - /** Called when the activity is first created. */ - String[] words = {"hello","buy","I","you","have","please","where", - "how","go","Gothenburg","London","rakia","wine", - "whisky","man","woman","boy","girl","to"}; - - private Controller controller = new Controller(); - private EditText searchBox = null; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - Arrays.sort(words); - - refreshBagOfWords(null); - - View main = findViewById(R.id.main_view); - main.setFocusableInTouchMode(true); - main.setOnKeyListener(controller); - } - - private void applyMagnetStyles(TextView view) { - view.setTextColor(Color.BLACK); - view.setBackgroundColor(Color.WHITE); - view.setSingleLine(true); - view.setPadding(2, 2, 2, 2); - view.setClickable(true); - } - - private void refreshBagOfWords(String prefix) { - PredicateLayout l = (PredicateLayout) findViewById(R.id.magnets_bag); - - l.removeAllViews(); - - for (int i = 0; i < words.length; i++) { - if (prefix != null && !words[i].startsWith(prefix)) - continue; - - TextView t = new TextView(this); - t.setText(words[i]); - t.setOnTouchListener(controller); - applyMagnetStyles(t); - l.addView(t, new PredicateLayout.LayoutParams(3, 3)); - } - } - - private void addWord(String word) { - PredicateLayout l = (PredicateLayout) findViewById(R.id.magnets_sentence); - - TextView t = new TextView(this); - t.setText(word); - applyMagnetStyles(t); - l.addView(t, new PredicateLayout.LayoutParams(3, 3)); - } - - private void showSearchBox() { - if (searchBox != null) - return; - - PredicateLayout l = (PredicateLayout) findViewById(R.id.magnets_sentence); - - EditText edit = new EditText(this); - edit.setInputType(InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE); - edit.addTextChangedListener(controller); - edit.setOnKeyListener(controller); - applyMagnetStyles(edit); - - l.addView(edit, new PredicateLayout.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT, - 3, 3)); - edit.requestFocus(); - InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(edit, 0); - - searchBox = edit; - } - - private void hideSearchBox() { - if (searchBox == null) - return; - - InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(searchBox.getWindowToken(), 0); - - PredicateLayout l = (PredicateLayout) findViewById(R.id.magnets_sentence); - l.removeView(searchBox); - - refreshBagOfWords(null); - - searchBox = null; - } - - private class Controller implements View.OnKeyListener, View.OnTouchListener, TextWatcher { - - @Override - public boolean onKey(View view, int keyCode, KeyEvent event) { - if (event.getAction() == KeyEvent.ACTION_DOWN) { - if (searchBox == null && keyCode == KeyEvent.KEYCODE_SEARCH) { - showSearchBox(); - return true; - } else if (searchBox != null && keyCode == KeyEvent.KEYCODE_SEARCH) { - hideSearchBox(); - return true; - } - } - return false; - } - - @Override - public boolean onTouch(View view, MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_UP) { - hideSearchBox(); - addWord(((TextView) view).getText().toString()); - return true; - } - - return false; - } - - @Override - public void afterTextChanged(Editable arg0) { - } - - @Override - public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { - } - - @Override - public void onTextChanged(CharSequence text, int arg1, int arg2, int arg3) { - refreshBagOfWords(text.toString()); - } - } -}
\ No newline at end of file |
