• 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

Commit MetaInfo

Revision5f02698dbf16aa11983da58dec22baaeea94f29a (tree)
Time2014-05-28 04:52:52
AuthorMasahiko, SAWAI <say@user...>
CommiterMasahiko, SAWAI

Log Message

Added init preferences function

Change Summary

Incremental Difference

--- a/simple-battery-logger/simple-battery-logger-app/AndroidManifest.xml
+++ b/simple-battery-logger/simple-battery-logger-app/AndroidManifest.xml
@@ -69,6 +69,13 @@
6969 android:theme="@android:style/Theme.Dialog"
7070 />
7171
72+ <!-- Initialize Preference Activity -->
73+ <activity
74+ android:name=".InitializePreferenceActivity"
75+ android:label="@string/delete_data"
76+ android:theme="@android:style/Theme.Dialog"
77+ />
78+
7279 <!-- Debug Function Activity -->
7380 <activity android:name=".debug.DebugActivity" />
7481
--- a/simple-battery-logger/simple-battery-logger-app/res/layout/delete_all_csv_file_activity.xml
+++ b/simple-battery-logger/simple-battery-logger-app/res/layout/delete_all_csv_file_activity.xml
@@ -13,8 +13,8 @@
1313 android:layout_weight="1"
1414 android:padding="4dip"
1515 android:gravity="center"
16- android:textColor="?android:textColorPrimary"
1716 android:text="@string/delete_csv_file_no_file_message"
17+ android:textColor="?android:textColorPrimary"
1818 android:textSize="18sp"
1919 />
2020
@@ -41,5 +41,4 @@
4141 android:text="@android:string/ok"
4242 />
4343 </LinearLayout>
44-</LinearLayout>
45-
44+</LinearLayout>
\ No newline at end of file
--- /dev/null
+++ b/simple-battery-logger/simple-battery-logger-app/res/layout/initialize_preference_activity.xml
@@ -0,0 +1,43 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<LinearLayout
3+ xmlns:android="http://schemas.android.com/apk/res/android"
4+ style="@style/body"
5+ android:orientation="vertical"
6+>
7+ <View style="@style/hline" />
8+
9+ <TextView
10+ android:layout_width="fill_parent"
11+ android:layout_height="wrap_content"
12+ android:layout_weight="1"
13+ android:padding="4dip"
14+ android:gravity="center"
15+ android:text="@string/initialize_preference_confirm_message"
16+ android:textColor="?android:textColorPrimary"
17+ android:textSize="18sp"
18+ />
19+
20+ <View style="@style/hline" />
21+
22+ <LinearLayout
23+ android:orientation="horizontal"
24+ android:layout_width="fill_parent"
25+ android:layout_height="wrap_content"
26+ android:layout_weight="0"
27+ >
28+ <Button
29+ android:id="@+id/cancel_button"
30+ android:layout_width="0dip"
31+ android:layout_height="wrap_content"
32+ android:layout_weight="1"
33+ android:text="@android:string/cancel"
34+ />
35+ <Button
36+ android:id="@+id/ok_button"
37+ android:layout_width="0dip"
38+ android:layout_height="wrap_content"
39+ android:layout_weight="1"
40+ android:text="@android:string/ok"
41+ />
42+ </LinearLayout>
43+</LinearLayout>
\ No newline at end of file
--- a/simple-battery-logger/simple-battery-logger-app/res/values-ja/strings.xml
+++ b/simple-battery-logger/simple-battery-logger-app/res/values-ja/strings.xml
@@ -4,7 +4,6 @@
44 <!-- common-->
55 <string name="no_data">データがありません</string>
66 <string name="quit">終了</string>
7- <string name="etc">その他</string>
87 <string name="send">送信</string>
98
109 <string name="export_csv_file">CSV ファイルに出力</string>
--- a/simple-battery-logger/simple-battery-logger-app/res/values-ja/strings_preferences.xml
+++ b/simple-battery-logger/simple-battery-logger-app/res/values-ja/strings_preferences.xml
@@ -38,4 +38,12 @@
3838 <string name="csv_dropbox_uploader_title">Dropbox アップローダ</string>
3939 <string name="csv_dropbox_uploader_summary">CSV ファイルを Dropbox へアップロードする設定をします。</string>
4040
41+ <!-- Etc Category -->
42+ <string name="etc_category_title">その他</string>
43+ <!-- Initialize Preferences -->
44+ <string name="initialize_preference">設定を初期化</string>
45+ <string name="initialize_preference_title">設定を初期化</string>
46+ <string name="initialize_preference_summary">すべての設定を初期化します。</string>
47+ <string name="initialize_preference_confirm_message">すべての設定は規定の値に初期化されます。</string>
48+
4149 </resources>
--- a/simple-battery-logger/simple-battery-logger-app/res/values/strings.xml
+++ b/simple-battery-logger/simple-battery-logger-app/res/values/strings.xml
@@ -4,7 +4,6 @@
44 <!-- common-->
55 <string name="no_data">No Data</string>
66 <string name="quit">Quit</string>
7- <string name="etc">Etc</string>
87 <string name="send">Send</string>
98
109 <string name="export_csv_file">Export CSV File</string>
--- a/simple-battery-logger/simple-battery-logger-app/res/values/strings_preferences.xml
+++ b/simple-battery-logger/simple-battery-logger-app/res/values/strings_preferences.xml
@@ -36,4 +36,12 @@
3636 <string name="csv_dropbox_uploader_title">Dropbox Uploader</string>
3737 <string name="csv_dropbox_uploader_summary">Set up to upload CSV file to Dropbox.</string>
3838
39+ <!-- Etc Category -->
40+ <string name="etc_category_title">Etc</string>
41+ <!-- Initialize Preferences -->
42+ <string name="initialize_preference">Initialize Preferences</string>
43+ <string name="initialize_preference_title">Initialize Preferences</string>
44+ <string name="initialize_preference_summary">All preference values are initialized.</string>
45+ <string name="initialize_preference_confirm_message">All the preference values will be initialized by default value. The current data are deleted.</string>
46+
3947 </resources>
--- a/simple-battery-logger/simple-battery-logger-app/res/xml/preferences.xml
+++ b/simple-battery-logger/simple-battery-logger-app/res/xml/preferences.xml
@@ -102,8 +102,19 @@
102102 </PreferenceCategory>
103103
104104 <PreferenceCategory
105- android:title="@string/etc"
105+ android:title="@string/etc_category_title"
106106 >
107+ <PreferenceScreen
108+ android:title="@string/initialize_preference_title"
109+ android:summary="@string/initialize_preference_summary"
110+ >
111+ <intent
112+ android:action="android.intent.action.MAIN"
113+ android:targetPackage="org.routine_work.simple_battery_logger"
114+ android:targetClass="org.routine_work.simple_battery_logger.InitializePreferenceActivity"
115+ />
116+ </PreferenceScreen>
117+
107118 <PreferenceScreen
108119 android:key="about_app_screen"
109120 android:title="@string/about_app_title"
--- a/simple-battery-logger/simple-battery-logger-app/src/org/routine_work/simple_battery_logger/BatteryLoggerPreferenceActivity.java
+++ b/simple-battery-logger/simple-battery-logger-app/src/org/routine_work/simple_battery_logger/BatteryLoggerPreferenceActivity.java
@@ -44,6 +44,7 @@ import android.widget.Toast;
4444 import java.io.File;
4545 import java.util.List;
4646 import org.routine_work.simple_battery_logger.db.DBConstants;
47+import org.routine_work.simple_battery_logger.service.AllCsvFileMediaScanService;
4748 import org.routine_work.simple_battery_logger.service.ServiceUtils;
4849 import org.routine_work.simple_battery_logger.util.PreferenceUtils;
4950 import org.routine_work.util.SystemResourceUtils;
@@ -179,6 +180,11 @@ public class BatteryLoggerPreferenceActivity extends PreferenceActivity
179180 else if (csvExportDirectoryKey.equals(key))
180181 {
181182 PreferenceUtils.exportCsvExportDirectoryName(this);
183+
184+ // Scan new export csv directory
185+ PreferenceUtils.putCsvMediaScanCompleted(this, false);
186+ Intent intent = new Intent(getApplicationContext(), AllCsvFileMediaScanService.class);
187+ startService(intent);
182188 }
183189
184190 updateSummary(key);
@@ -188,11 +194,17 @@ public class BatteryLoggerPreferenceActivity extends PreferenceActivity
188194
189195 private void updateAllSummary()
190196 {
197+ Log.v(LOG_TAG, "Hello");
198+
191199 updateSummary(null);
200+
201+ Log.v(LOG_TAG, "Bye");
192202 }
193203
194204 private void updateSummary(String key)
195205 {
206+ Log.v(LOG_TAG, "Hello");
207+
196208 if (key == null || key.equals(dataKeepingPeriodKey))
197209 {
198210 ListPreference dataKeepingPeriodPreference = (ListPreference) getPreferenceScreen().findPreference(dataKeepingPeriodKey);
@@ -224,6 +236,8 @@ public class BatteryLoggerPreferenceActivity extends PreferenceActivity
224236 }
225237 csvSortOrderListPreference.setSummary(summary);
226238 }
239+
240+ Log.v(LOG_TAG, "Bye");
227241 }
228242
229243 private void updateDropboxUploaderPreference()
--- /dev/null
+++ b/simple-battery-logger/simple-battery-logger-app/src/org/routine_work/simple_battery_logger/InitializePreferenceActivity.java
@@ -0,0 +1,70 @@
1+/*
2+ * The MIT License
3+ *
4+ * Copyright 2014 Masahiko, SAWAI <masahiko.sawai@gmail.com>.
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in
14+ * all copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+ * THE SOFTWARE.
23+ */
24+package org.routine_work.simple_battery_logger;
25+
26+import android.app.Activity;
27+import android.os.Bundle;
28+import android.view.View;
29+import android.view.View.OnClickListener;
30+import android.widget.Button;
31+import org.routine_work.simple_battery_logger.util.PreferenceUtils;
32+import org.routine_work.util.Log;
33+
34+public class InitializePreferenceActivity extends Activity implements OnClickListener
35+{
36+
37+ private static final String LOG_TAG = "simple-battery-logger";
38+
39+ @Override
40+ protected void onCreate(Bundle savedInstanceState)
41+ {
42+ super.onCreate(savedInstanceState);
43+ setContentView(R.layout.initialize_preference_activity);
44+
45+ Button okButton = (Button) findViewById(R.id.ok_button);
46+ okButton.setOnClickListener(this);
47+ Button cancelButton = (Button) findViewById(R.id.cancel_button);
48+ cancelButton.setOnClickListener(this);
49+ }
50+
51+ @Override
52+ public void onClick(View view)
53+ {
54+ int id = view.getId();
55+ switch (id)
56+ {
57+ case R.id.ok_button:
58+ Log.d(LOG_TAG, "ok_button is clicked");
59+ PreferenceUtils.reset(this);
60+ setResult(RESULT_OK);
61+ finish();
62+ break;
63+ case R.id.cancel_button:
64+ Log.d(LOG_TAG, "cancel_button is clicked");
65+ finish();
66+ setResult(RESULT_CANCELED);
67+ break;
68+ }
69+ }
70+}
--- a/simple-battery-logger/simple-battery-logger-app/src/org/routine_work/simple_battery_logger/service/AllCsvFileMediaScanService.java
+++ b/simple-battery-logger/simple-battery-logger-app/src/org/routine_work/simple_battery_logger/service/AllCsvFileMediaScanService.java
@@ -59,7 +59,7 @@ public class AllCsvFileMediaScanService extends IntentService
5959 Log.i(LOG_TAG, "AllCsvFileMediaScanService : Start at " + new Date());
6060
6161 Context context = this.getApplicationContext();
62- if (PreferenceUtils.isCsvAutoExportEnabled(context) == false)
62+ if (PreferenceUtils.isCsvMediaScanCompleted(context) == false)
6363 {
6464 String csvExportDirectoryName = PreferenceUtils.getCsvExportDirectoryName(context);
6565 File externalStorageDirectory = Environment.getExternalStorageDirectory();
--- a/simple-battery-logger/simple-battery-logger-app/src/org/routine_work/simple_battery_logger/util/PreferenceUtils.java
+++ b/simple-battery-logger/simple-battery-logger-app/src/org/routine_work/simple_battery_logger/util/PreferenceUtils.java
@@ -209,4 +209,16 @@ public class PreferenceUtils
209209 editor.putBoolean(key, value);
210210 editor.commit();
211211 }
212+
213+ public static void reset(Context context)
214+ {
215+ Log.v(LOG_TAG, "Hello");
216+
217+ SharedPreferences sharedPreferences = getPrivateSharedPreferences(context);
218+ SharedPreferences.Editor edit = sharedPreferences.edit();
219+ edit.clear();
220+ edit.commit();
221+
222+ Log.v(LOG_TAG, "Bye");
223+ }
212224 }