Add new Android voice translator sample app

This adds a simple voice translator Android app that uses
the JNI bindings to the PGF C runtime.

Caveats:

- Since the C runtime doesn't compile for Android right now,
  I've bundled an old copy, along with its Java bindings.
  That should be removed once the C runtime compiels for Android
  again.

- Adding an automated build would be nice.

- Replacing the grammar requires editing a Java file, that should 
  really be more dynamic.
This commit is contained in:
bringert
2013-10-04 16:26:46 +00:00
parent 0d9d926131
commit 6adc9f7be4
45 changed files with 1236 additions and 147 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 547 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<solid android:color="#75CD75" />
</shape>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<solid android:color="#7575CD" />
</shape>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
>
<RelativeLayout
android:id="@+id/top_bg"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:padding="8dp"
android:background="#C0C0C0"
>
<ImageView
android:id="@+id/start_stop"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignTop="@+id/source_language"
android:layout_alignBottom="@+id/target_language"
android:layout_alignParentRight="true"
android:padding="8dp"
android:src="@drawable/ic_mic"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/microphone"
/>
<ImageView
android:id="@+id/switch_languages"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignTop="@+id/source_language"
android:layout_alignBottom="@+id/target_language"
android:layout_toLeftOf="@id/start_stop"
android:padding="8dp"
android:src="@drawable/ic_action_switch"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/switch_languages"
/>
<org.grammaticalframework.ui.android.LanguageSelector
android:id="@+id/source_language"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/switch_languages"
android:padding="0dp"
/>
<org.grammaticalframework.ui.android.LanguageSelector
android:id="@+id/target_language"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="@id/source_language"
android:layout_toLeftOf="@id/switch_languages"
android:padding="0dp"
/>
</RelativeLayout>
<org.grammaticalframework.ui.android.ConversationView
android:id="@+id/conversation"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_below="@id/top_bg"
>
<LinearLayout
android:id="@+id/conversation_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:padding="16dp"
>
</LinearLayout>
</org.grammaticalframework.ui.android.ConversationView>
</RelativeLayout>

View File

@@ -0,0 +1,11 @@
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginRight="32dp"
android:layout_gravity="left"
android:padding="8dp"
android:textSize="20sp"
android:background="@drawable/first_person_utterance_bg"
/>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="8dp"
android:textSize="20sp"
/>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="32dp"
android:layout_gravity="right"
android:padding="8dp"
android:textSize="20sp"
android:background="@drawable/second_person_utterance_bg"
/>

View File

@@ -0,0 +1,8 @@
<resources>
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw600dp devices (e.g. 7" tablets) here.
-->
</resources>

View File

@@ -0,0 +1,9 @@
<resources>
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
-->
<dimen name="activity_horizontal_margin">128dp</dimen>
</resources>

View File

@@ -0,0 +1,11 @@
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>

View File

@@ -0,0 +1,12 @@
<resources>
<!--
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.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>

View File

@@ -0,0 +1,7 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>

View File

@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">GFTranslator</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="app_name">GF Translator</string>
<string name="microphone">Microphone</string>
<string name="switch_languages">Switch languages</string>
</resources>

View File

@@ -0,0 +1,20 @@
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>