summaryrefslogtreecommitdiffstats
path: root/picolanginstaller
diff options
context:
space:
mode:
authorCharles Chen <clchen@google.com>2009-06-22 17:31:44 -0700
committerCharles Chen <clchen@google.com>2009-06-22 18:33:45 -0700
commit3fc71a14d6c0ca80a5fbc579de14a9a7b422e5c3 (patch)
tree81c9c820dfe19d796c86f01d2c2e08baf9d6e458 /picolanginstaller
parent1284d937084a20b457c280259fff59391129509a (diff)
downloadexternal_svox-3fc71a14d6c0ca80a5fbc579de14a9a7b422e5c3.zip
external_svox-3fc71a14d6c0ca80a5fbc579de14a9a7b422e5c3.tar.gz
external_svox-3fc71a14d6c0ca80a5fbc579de14a9a7b422e5c3.tar.bz2
Adding PicoLangInstaller.
Diffstat (limited to 'picolanginstaller')
-rw-r--r--picolanginstaller/Android.mk8
-rwxr-xr-xpicolanginstaller/AndroidManifest.xml16
-rwxr-xr-xpicolanginstaller/res/drawable/icon.pngbin0 -> 1140 bytes
-rwxr-xr-xpicolanginstaller/res/layout/installing.xml29
-rwxr-xr-xpicolanginstaller/res/layout/retry.xml15
-rwxr-xr-xpicolanginstaller/res/layout/uninstall.xml15
-rwxr-xr-xpicolanginstaller/res/raw/svoxlangpack.zipbin0 -> 4348562 bytes
-rwxr-xr-xpicolanginstaller/res/values/strings.xml9
-rwxr-xr-xpicolanginstaller/src/com/svox/langpack/installer/InstallerActivity.java142
9 files changed, 234 insertions, 0 deletions
diff --git a/picolanginstaller/Android.mk b/picolanginstaller/Android.mk
new file mode 100644
index 0000000..a1c529f
--- /dev/null
+++ b/picolanginstaller/Android.mk
@@ -0,0 +1,8 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := PicoLangInstaller
+
+include $(BUILD_PACKAGE)
diff --git a/picolanginstaller/AndroidManifest.xml b/picolanginstaller/AndroidManifest.xml
new file mode 100755
index 0000000..cc11466
--- /dev/null
+++ b/picolanginstaller/AndroidManifest.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.svox.langpack.installer"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <uses-sdk android:minSdkVersion="donut" />
+ <application android:icon="@drawable/icon" android:label="@string/app_name">
+ <activity android:name=".InstallerActivity"
+ 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>
+</manifest>
diff --git a/picolanginstaller/res/drawable/icon.png b/picolanginstaller/res/drawable/icon.png
new file mode 100755
index 0000000..cdb9e94
--- /dev/null
+++ b/picolanginstaller/res/drawable/icon.png
Binary files differ
diff --git a/picolanginstaller/res/layout/installing.xml b/picolanginstaller/res/layout/installing.xml
new file mode 100755
index 0000000..117c333
--- /dev/null
+++ b/picolanginstaller/res/layout/installing.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/root" android:layout_width="fill_parent"
+ android:background="#ff000000"
+ android:layout_height="fill_parent">
+
+ <LinearLayout android:id="@+id/progress_indicator"
+ android:orientation="vertical"
+ android:layout_centerInParent="true"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+
+ <TextView android:paddingTop="5dip"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/installing_message" android:textSize="18sp"
+ android:textColor="?android:attr/textColorPrimary" />
+
+ <ProgressBar android:id="@android:id/progress"
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_gravity="center"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+ </LinearLayout>
+
+</RelativeLayout>
diff --git a/picolanginstaller/res/layout/retry.xml b/picolanginstaller/res/layout/retry.xml
new file mode 100755
index 0000000..87eb202
--- /dev/null
+++ b/picolanginstaller/res/layout/retry.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <TextView android:paddingTop="5dip" android:layout_width="wrap_content"
+ android:layout_height="wrap_content" android:layout_gravity="center"
+ android:text="@string/retry_message" android:textSize="18sp"
+ android:textColor="?android:attr/textColorPrimary" />
+
+ <Button android:id="@+id/retryButton" android:layout_width="wrap_content"
+ android:layout_height="wrap_content" android:layout_gravity="center"
+ android:text="@string/retry" android:textSize="25sp" />
+
+</LinearLayout>
diff --git a/picolanginstaller/res/layout/uninstall.xml b/picolanginstaller/res/layout/uninstall.xml
new file mode 100755
index 0000000..fe108a5
--- /dev/null
+++ b/picolanginstaller/res/layout/uninstall.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <TextView android:paddingTop="5dip" android:layout_width="wrap_content"
+ android:layout_height="wrap_content" android:layout_gravity="center"
+ android:text="@string/uninstall_message" android:textSize="18sp"
+ android:textColor="?android:attr/textColorPrimary" />
+
+ <Button android:id="@+id/uninstallButton" android:layout_width="wrap_content"
+ android:layout_height="wrap_content" android:layout_gravity="center"
+ android:text="@string/uninstall" android:textSize="25sp" />
+
+</LinearLayout>
diff --git a/picolanginstaller/res/raw/svoxlangpack.zip b/picolanginstaller/res/raw/svoxlangpack.zip
new file mode 100755
index 0000000..46f00e2
--- /dev/null
+++ b/picolanginstaller/res/raw/svoxlangpack.zip
Binary files differ
diff --git a/picolanginstaller/res/values/strings.xml b/picolanginstaller/res/values/strings.xml
new file mode 100755
index 0000000..fac323d
--- /dev/null
+++ b/picolanginstaller/res/values/strings.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Pico TTS Language Pack Installer</string>
+ <string name="installing_message">Installing voice data on SD card.</string>
+ <string name="uninstall_message">The voice data has been installed successfully on your SD card. You can now uninstall this installer to save space in your phone memory; the voice data from this installer will safely remain on your SD card.</string>
+ <string name="uninstall">Uninstall</string>
+ <string name="retry_message">The voice data could not be installed on your SD card. Please make sure your SD card is inserted in your device and that there is at least 6 MB of free space on that card. If your card is already in your device, please try removing the card and reinserting it.</string>
+ <string name="retry">Retry</string>
+</resources>
diff --git a/picolanginstaller/src/com/svox/langpack/installer/InstallerActivity.java b/picolanginstaller/src/com/svox/langpack/installer/InstallerActivity.java
new file mode 100755
index 0000000..1635365
--- /dev/null
+++ b/picolanginstaller/src/com/svox/langpack/installer/InstallerActivity.java
@@ -0,0 +1,142 @@
+package com.svox.langpack.installer;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.AssetFileDescriptor;
+import android.content.res.Resources;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+
+public class InstallerActivity extends Activity {
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ runInstaller();
+ }
+
+ private void runInstaller(){
+ try {
+ Resources res = getResources();
+ AssetFileDescriptor langPackFd = res
+ .openRawResourceFd(R.raw.svoxlangpack);
+ InputStream stream = langPackFd.createInputStream();
+
+ (new Thread(new unzipper(stream))).start();
+ } catch (IOException e) {
+ Log.e("PicoLangInstaller", "Unable to open langpack resource.");
+ e.printStackTrace();
+ }
+ setContentView(R.layout.installing);
+ }
+
+ private void uninstall() {
+ Intent intent = new Intent(Intent.ACTION_DELETE);
+ String packageName = getPackageName();
+ Uri data = Uri.fromParts("package", packageName, null);
+ intent.setData(data);
+ startActivity(intent);
+ }
+
+ private boolean unzipLangPack(InputStream stream) {
+ File baseDir = new File("/sdcard/svox");
+ baseDir.mkdir();
+ FileOutputStream out;
+ byte buf[] = new byte[16384];
+ try {
+ ZipInputStream zis = new ZipInputStream(stream);
+ ZipEntry entry = zis.getNextEntry();
+ while (entry != null) {
+ if (entry.isDirectory()) {
+ File newDir = new File("/sdcard/" + entry.getName());
+ newDir.mkdir();
+ } else {
+ String name = entry.getName();
+ File outputFile = new File("/sdcard/" + name);
+ String outputPath = outputFile.getCanonicalPath();
+ name = outputPath
+ .substring(outputPath.lastIndexOf("/") + 1);
+ outputPath = outputPath.substring(0, outputPath
+ .lastIndexOf("/"));
+ File outputDir = new File(outputPath);
+ outputDir.mkdirs();
+ outputFile = new File(outputPath, name);
+ outputFile.createNewFile();
+ out = new FileOutputStream(outputFile);
+
+ int numread = 0;
+ do {
+ numread = zis.read(buf);
+ if (numread <= 0) {
+ break;
+ } else {
+ out.write(buf, 0, numread);
+ }
+ } while (true);
+ out.close();
+ }
+ entry = zis.getNextEntry();
+ }
+ return true;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public class unzipper implements Runnable {
+ public InputStream stream;
+
+ public unzipper(InputStream is) {
+ stream = is;
+ }
+
+ public void run() {
+ Log.e("lang pack installer", "Start");
+ boolean succeeded = unzipLangPack(stream);
+ Log.e("lang pack installer", "Done!");
+ if (succeeded) {
+ runOnUiThread(new uninstallDisplayer());
+ } else {
+ runOnUiThread(new retryDisplayer());
+ }
+ }
+ }
+
+ public class uninstallDisplayer implements Runnable {
+ public void run() {
+ setContentView(R.layout.uninstall);
+ Button uninstallButton = (Button) findViewById(R.id.uninstallButton);
+ uninstallButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View arg0) {
+ uninstall();
+ }
+ });
+ }
+ }
+
+ public class retryDisplayer implements Runnable {
+ public void run() {
+ setContentView(R.layout.retry);
+ Button retryButton = (Button) findViewById(R.id.retryButton);
+ retryButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View arg0) {
+ runInstaller();
+ }
+ });
+ }
+ }
+
+}