• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Navigation voice changer app for Android


Commit MetaInfo

Revision1340326a2fb9177d5987738fcd2e987c6bd6f54d (tree)
Time2013-08-02 04:53:09
AuthorHMML <hmml3939@gmai...>
CommiterHMML

Log Message

Show alert screen on first startup.

Change Summary

Incremental Difference

--- a/res/layout/activity_download.xml
+++ b/res/layout/activity_download.xml
@@ -37,22 +37,29 @@
3737 android:orientation="vertical"
3838 android:visibility="gone" >
3939
40- <ProgressBar
41- android:id="@+id/progressBar"
42- style="?android:attr/progressBarStyle"
40+ <LinearLayout
4341 android:layout_width="wrap_content"
4442 android:layout_height="wrap_content"
45- android:layout_centerVertical="true"
46- android:padding="16dp" />
43+ android:layout_centerInParent="true" >
44+
45+ <ProgressBar
46+ android:id="@+id/progressBar"
47+ style="?android:attr/progressBarStyle"
48+ android:layout_width="wrap_content"
49+ android:layout_height="wrap_content"
50+ android:layout_gravity="center_vertical"
51+ android:padding="16dp" />
52+
53+ <TextView
54+ android:layout_width="match_parent"
55+ android:layout_height="wrap_content"
56+ android:layout_gravity="center_vertical"
57+ android:text="@string/download_progress"
58+ android:textColor="@android:color/white"
59+ android:textSize="24sp" />
60+
61+ </LinearLayout>
4762
48- <TextView
49- android:layout_width="match_parent"
50- android:layout_height="wrap_content"
51- android:layout_centerVertical="true"
52- android:layout_toRightOf="@id/progressBar"
53- android:text="@string/download_progress"
54- android:textColor="@android:color/white"
55- android:textSize="24sp" />
5663 </RelativeLayout>
5764
5865 </RelativeLayout>
\ No newline at end of file
--- a/res/values-ja/strings.xml
+++ b/res/values-ja/strings.xml
@@ -4,8 +4,8 @@
44 <string name="app_name">ナビボイスチェンジャー</string>
55 <string name="action_settings">設定</string>
66 <string name="hello_world">Hello world!</string>
7- <string name="menu_install">音声データのインストール</string>
8- <string name="menu_download">音声データのダウンロード</string>
7+ <string name="menu_install">音声のインストール</string>
8+ <string name="menu_download">音声のダウンロード</string>
99 <string name="menu_maint">メンテナンス</string>
1010 <string name="title_activity_install_list">音声データのインストール</string>
1111 <string name="err_broken_archive">音声データが壊れています。ダウンロードしなおしてください。</string>
@@ -35,5 +35,10 @@
3535 <string name="err_no_sd">外部ストレージが見つかりません。SDカードをチェックするか、ストレージの設定を確認してください。</string>
3636 <string name="err_no_sd_title">メディアエラー</string>
3737 <string name="c_menu_download">ダウンロード</string>
38+ <string name="accept">わかった</string>
39+ <string name="decline">断る!</string>
40+ <string name="tos_title">おことわり</string>
41+ <string name="tos">ダウンロードありがとうございます。すみませんが使うにあたり、以下に注意してください。\n\nこのアプリはマップと Android OS の現状の挙動に固定的に依存しています。それらは非公開のものであるため、将来の変更時にこのアプリは動作しなくなります。その場合の対応は全く保証できません。</string>
42+
3843
3944 </resources>
\ No newline at end of file
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -37,5 +37,9 @@
3737 <string name="err_no_sd">No external storage is detected. You need to check your SD card or storage setting.</string>
3838 <string name="err_no_sd_title">Medium Error</string>
3939 <string name="c_menu_download">Download</string>
40+ <string name="accept">Accept</string>
41+ <string name="decline">Decline</string>
42+ <string name="tos_title">Notice</string>
43+ <string name="tos">Thank you for downloading! Please keep mind following terms;\n\nThis app is depends on CURRENT behavior of Maps and Android OS statically. These are closed and un-documented, then this app WILL STOP WORKING on future changes. In that case, I can NOT promise to contienu to support.</string>
4044
4145 </resources>
--- a/src/jp/nekoteki/android/navivoicechanger/Config.java
+++ b/src/jp/nekoteki/android/navivoicechanger/Config.java
@@ -45,7 +45,7 @@ public class Config {
4545 }
4646 }
4747
48- public static Properties getProp(Context context) {
48+ private static Properties getProp(Context context) {
4949 Properties prop = new Properties();
5050 File conf = getConfFile(context);
5151 if (conf == null) return prop;
@@ -59,7 +59,7 @@ public class Config {
5959 return prop;
6060 }
6161
62- public static File getConfFile(Context context) {
62+ private static File getConfFile(Context context) {
6363 File dir = context.getExternalFilesDir(null);
6464 if (dir == null) return null;
6565 if (!dir.exists()) dir.mkdirs();
--- a/src/jp/nekoteki/android/navivoicechanger/MainMenuActivity.java
+++ b/src/jp/nekoteki/android/navivoicechanger/MainMenuActivity.java
@@ -1,8 +1,14 @@
11 package jp.nekoteki.android.navivoicechanger;
22
3+import java.io.IOException;
4+import java.util.zip.ZipException;
5+
36 import android.os.Bundle;
47 import android.app.Activity;
8+import android.app.AlertDialog;
9+import android.content.DialogInterface;
510 import android.content.Intent;
11+import android.util.Log;
612 import android.view.Menu;
713 import android.view.View;
814
@@ -35,6 +41,27 @@ public class MainMenuActivity extends Activity {
3541
3642 }
3743 });
44+
45+ String tos_agree = Config.get(getApplicationContext(), "tos_agree");
46+ if (tos_agree == null || !tos_agree.equals("1")) {
47+ AlertDialog.Builder dialog = new AlertDialog.Builder(this);
48+ dialog.setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() {
49+ @Override
50+ public void onClick(DialogInterface dialog, int which) {
51+ StaticUtils.terminateSelf(getApplicationContext());
52+ }
53+ });
54+ dialog.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
55+ @Override
56+ public void onClick(DialogInterface arg0, int arg1) {
57+ Config.set(getApplicationContext(), "tos_agree", "1");
58+ }
59+ });
60+ dialog.setCancelable(false);
61+ dialog.setTitle(R.string.tos_title);
62+ dialog.setMessage(R.string.tos);
63+ dialog.show();
64+ }
3865 }
3966
4067 @Override
--- a/src/jp/nekoteki/android/navivoicechanger/MaintActivity.java
+++ b/src/jp/nekoteki/android/navivoicechanger/MaintActivity.java
@@ -28,6 +28,7 @@ public class MaintActivity extends Activity {
2828 progress.setMessage("Purging files...");
2929 progress.show();
3030 VoiceData.purgeVoiceDataFromNavi(v.getContext());
31+ StaticUtils.killMapsProcess(v.getContext());
3132 progress.dismiss();
3233 Toast.makeText(v.getContext(), R.string.msg_installed_removed, Toast.LENGTH_SHORT).show();
3334 }
--- a/src/jp/nekoteki/android/navivoicechanger/RemoteVoiceData.java
+++ b/src/jp/nekoteki/android/navivoicechanger/RemoteVoiceData.java
@@ -15,16 +15,16 @@ import android.net.http.AndroidHttpClient;
1515 import android.util.Log;
1616
1717 public class RemoteVoiceData {
18- protected int id;
19- protected String ini_url;
20- protected String archive_url;
21- protected String preview_url;
22- protected float rating;
23- protected String title;
24- protected String unit;
25- protected String author;
26- protected String description;
27- protected VoiceData voice_data;
18+ private int id;
19+ private String ini_url;
20+ private String archive_url;
21+ private String preview_url;
22+ private float rating;
23+ private String title;
24+ private String unit;
25+ private String author;
26+ private String description;
27+ private VoiceData voice_data;
2828
2929 public VoiceData getVoiceData() {
3030 return voice_data;
--- /dev/null
+++ b/src/jp/nekoteki/android/navivoicechanger/StaticUtils.java
@@ -0,0 +1,26 @@
1+package jp.nekoteki.android.navivoicechanger;
2+
3+import android.app.Activity;
4+import android.app.ActivityManager;
5+import android.app.ActivityManager.RunningAppProcessInfo;
6+import android.content.Context;
7+import android.os.Process;
8+import android.util.Log;
9+
10+public class StaticUtils {
11+ public static void killMapsProcess(Context context) {
12+ Log.i("Utils", "Trying to kill Maps...");
13+ ActivityManager am = ((ActivityManager) context.getSystemService(Activity.ACTIVITY_SERVICE));
14+ am.killBackgroundProcesses("com.google.android.apps.maps");
15+ for (RunningAppProcessInfo pi: am.getRunningAppProcesses()) {
16+ if (pi.processName != "com.google.android.apps.maps")
17+ continue;
18+ Log.d("Utils", "Killing pid="+Integer.toString(pi.pid));
19+ android.os.Process.killProcess(pi.pid);
20+ }
21+ }
22+
23+ public static void terminateSelf(Context context) {
24+ Process.killProcess(Process.myPid());
25+ }
26+}
--- a/src/jp/nekoteki/android/navivoicechanger/VoiceData.java
+++ b/src/jp/nekoteki/android/navivoicechanger/VoiceData.java
@@ -57,17 +57,17 @@ public class VoiceData {
5757 public final static String ARCHIVE_FILENAME = "voice_instructions.zip";
5858 public static final String PREVIEW_FILESNAME = "preview.ogg";
5959
60- protected int id;
61- protected String title;
62- protected float rating;
63- protected String description;
64- protected String archive_md5;
65- protected String unit;
66- protected String lang;
67- protected String path;
68- protected int version;
69- protected String author;
70- protected Context context;
60+ private int id;
61+ private String title;
62+ private float rating;
63+ private String description;
64+ private String archive_md5;
65+ private String unit;
66+ private String lang;
67+ private String path;
68+ private int version;
69+ private String author;
70+ private Context context;
7171
7272 static List<VoiceData> scanVoiceData(Context context) {
7373 Log.d(VoiceData.class.getClass().getName(), "Start voice data dir scan.");
@@ -445,15 +445,7 @@ public class VoiceData {
445445 // ignore
446446 }
447447
448- ActivityManager am = ((ActivityManager) this.getContext().getSystemService(Activity.ACTIVITY_SERVICE));
449- am.killBackgroundProcesses("com.google.android.apps.maps");
450- for (RunningAppProcessInfo pi: am.getRunningAppProcesses()) {
451- if (pi.processName != "com.google.android.apps.maps")
452- continue;
453- android.os.Process.killProcess(pi.pid);
454- }
455-
456-
448+ StaticUtils.killMapsProcess(this.getContext());
457449 Log.i("VoiceData", "Install finished!");
458450 }
459451