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.
BIN
src/ui/android/res/drawable-hdpi/ic_action_switch.png
Normal file
|
After Width: | Height: | Size: 436 B |
BIN
src/ui/android/res/drawable-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
src/ui/android/res/drawable-hdpi/ic_mic.png
Normal file
|
After Width: | Height: | Size: 665 B |
BIN
src/ui/android/res/drawable-mdpi/ic_action_switch.png
Normal file
|
After Width: | Height: | Size: 327 B |
BIN
src/ui/android/res/drawable-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
src/ui/android/res/drawable-mdpi/ic_mic.png
Normal file
|
After Width: | Height: | Size: 437 B |
BIN
src/ui/android/res/drawable-xhdpi/ic_action_switch.png
Normal file
|
After Width: | Height: | Size: 547 B |
BIN
src/ui/android/res/drawable-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
src/ui/android/res/drawable-xhdpi/ic_mic.png
Normal file
|
After Width: | Height: | Size: 783 B |
BIN
src/ui/android/res/drawable-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 35 KiB |
@@ -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>
|
||||
|
Before Width: | Height: | Size: 2.5 KiB |
@@ -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>
|
||||
85
src/ui/android/res/layout/activity_main.xml
Normal 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>
|
||||
11
src/ui/android/res/layout/first_person_utterance.xml
Normal 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"
|
||||
/>
|
||||
8
src/ui/android/res/layout/languages_item.xml
Normal 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"
|
||||
/>
|
||||
12
src/ui/android/res/layout/second_person_utterance.xml
Normal 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"
|
||||
/>
|
||||
8
src/ui/android/res/values-sw600dp/dimens.xml
Normal 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>
|
||||
9
src/ui/android/res/values-sw720dp-land/dimens.xml
Normal 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>
|
||||
11
src/ui/android/res/values-v11/styles.xml
Normal 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>
|
||||
12
src/ui/android/res/values-v14/styles.xml
Normal 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>
|
||||
7
src/ui/android/res/values/dimens.xml
Normal 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>
|
||||
@@ -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>
|
||||
|
||||
20
src/ui/android/res/values/styles.xml
Normal 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>
|
||||