summaryrefslogtreecommitdiffstats
path: root/pico/src/com
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2009-08-07 13:21:15 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2009-08-07 13:29:59 -0700
commit94ebc238b39b38825ab2d6f0b81640a90b712394 (patch)
tree6d436d50362f7944b8f1c1c39906668a1195fdd8 /pico/src/com
parenta8d076f716bca609b7e740cd888177fbc589a521 (diff)
downloadexternal_svox-94ebc238b39b38825ab2d6f0b81640a90b712394.zip
external_svox-94ebc238b39b38825ab2d6f0b81640a90b712394.tar.gz
external_svox-94ebc238b39b38825ab2d6f0b81640a90b712394.tar.bz2
Fix bug 2022435.
When the user clicks "install" for the TTS language pack installer and the download completes, the addition of the corresponding package is picked up by VoiceDataInstallerReceiver. It then causes the installer to run by firing off the RUN_TTS_DATA_INSTALLER event. This is less confusing for the user because the installation of the language files is now automatic once the download is initiated. Before, the user had to "open" the installer after the download completed.
Diffstat (limited to 'pico/src/com')
-rwxr-xr-xpico/src/com/svox/pico/VoiceDataInstallerReceiver.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/pico/src/com/svox/pico/VoiceDataInstallerReceiver.java b/pico/src/com/svox/pico/VoiceDataInstallerReceiver.java
new file mode 100755
index 0000000..71c5782
--- /dev/null
+++ b/pico/src/com/svox/pico/VoiceDataInstallerReceiver.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+package com.svox.pico;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+import android.util.Log;
+
+/*
+ * Is notified when the language pack installer is added to the system, and runs the installer.
+ */
+public class VoiceDataInstallerReceiver extends BroadcastReceiver {
+
+ private final static String TAG = "RunVoiceDataInstaller";
+
+ private final static String INSTALLER_PACKAGE = "com.svox.langpack.installer";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())
+ && INSTALLER_PACKAGE.equals(getPackageName(intent))) {
+ Log.v(TAG, INSTALLER_PACKAGE + " package was added, running installer...");
+ // the language pack installer has been added to the system
+ // now run the installer
+ Intent runIntent = new Intent("com.svox.langpack.installer.RUN_TTS_DATA_INSTALLER");
+ runIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(runIntent);
+ }
+ }
+
+ /**
+ * Returns the name of the package that was added from the intent.
+ * @param intent the {@link Intent}
+ */
+ private static String getPackageName(Intent intent) {
+ return intent.getData().getSchemeSpecificPart();
+ }
+}