Revision | 5f02698dbf16aa11983da58dec22baaeea94f29a (tree) |
---|---|
Time | 2014-05-28 04:52:52 |
Author | Masahiko, SAWAI <say@user...> |
Commiter | Masahiko, SAWAI |
Added init preferences function
@@ -69,6 +69,13 @@ | ||
69 | 69 | android:theme="@android:style/Theme.Dialog" |
70 | 70 | /> |
71 | 71 | |
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 | + | |
72 | 79 | <!-- Debug Function Activity --> |
73 | 80 | <activity android:name=".debug.DebugActivity" /> |
74 | 81 |
@@ -13,8 +13,8 @@ | ||
13 | 13 | android:layout_weight="1" |
14 | 14 | android:padding="4dip" |
15 | 15 | android:gravity="center" |
16 | - android:textColor="?android:textColorPrimary" | |
17 | 16 | android:text="@string/delete_csv_file_no_file_message" |
17 | + android:textColor="?android:textColorPrimary" | |
18 | 18 | android:textSize="18sp" |
19 | 19 | /> |
20 | 20 |
@@ -41,5 +41,4 @@ | ||
41 | 41 | android:text="@android:string/ok" |
42 | 42 | /> |
43 | 43 | </LinearLayout> |
44 | -</LinearLayout> | |
45 | - | |
44 | +</LinearLayout> | |
\ No newline at end of file |
@@ -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 |
@@ -4,7 +4,6 @@ | ||
4 | 4 | <!-- common--> |
5 | 5 | <string name="no_data">データがありません</string> |
6 | 6 | <string name="quit">終了</string> |
7 | - <string name="etc">その他</string> | |
8 | 7 | <string name="send">送信</string> |
9 | 8 | |
10 | 9 | <string name="export_csv_file">CSV ファイルに出力</string> |
@@ -38,4 +38,12 @@ | ||
38 | 38 | <string name="csv_dropbox_uploader_title">Dropbox アップローダ</string> |
39 | 39 | <string name="csv_dropbox_uploader_summary">CSV ファイルを Dropbox へアップロードする設定をします。</string> |
40 | 40 | |
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 | + | |
41 | 49 | </resources> |
@@ -4,7 +4,6 @@ | ||
4 | 4 | <!-- common--> |
5 | 5 | <string name="no_data">No Data</string> |
6 | 6 | <string name="quit">Quit</string> |
7 | - <string name="etc">Etc</string> | |
8 | 7 | <string name="send">Send</string> |
9 | 8 | |
10 | 9 | <string name="export_csv_file">Export CSV File</string> |
@@ -36,4 +36,12 @@ | ||
36 | 36 | <string name="csv_dropbox_uploader_title">Dropbox Uploader</string> |
37 | 37 | <string name="csv_dropbox_uploader_summary">Set up to upload CSV file to Dropbox.</string> |
38 | 38 | |
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 | + | |
39 | 47 | </resources> |
@@ -102,8 +102,19 @@ | ||
102 | 102 | </PreferenceCategory> |
103 | 103 | |
104 | 104 | <PreferenceCategory |
105 | - android:title="@string/etc" | |
105 | + android:title="@string/etc_category_title" | |
106 | 106 | > |
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 | + | |
107 | 118 | <PreferenceScreen |
108 | 119 | android:key="about_app_screen" |
109 | 120 | android:title="@string/about_app_title" |
@@ -44,6 +44,7 @@ import android.widget.Toast; | ||
44 | 44 | import java.io.File; |
45 | 45 | import java.util.List; |
46 | 46 | import org.routine_work.simple_battery_logger.db.DBConstants; |
47 | +import org.routine_work.simple_battery_logger.service.AllCsvFileMediaScanService; | |
47 | 48 | import org.routine_work.simple_battery_logger.service.ServiceUtils; |
48 | 49 | import org.routine_work.simple_battery_logger.util.PreferenceUtils; |
49 | 50 | import org.routine_work.util.SystemResourceUtils; |
@@ -179,6 +180,11 @@ public class BatteryLoggerPreferenceActivity extends PreferenceActivity | ||
179 | 180 | else if (csvExportDirectoryKey.equals(key)) |
180 | 181 | { |
181 | 182 | 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); | |
182 | 188 | } |
183 | 189 | |
184 | 190 | updateSummary(key); |
@@ -188,11 +194,17 @@ public class BatteryLoggerPreferenceActivity extends PreferenceActivity | ||
188 | 194 | |
189 | 195 | private void updateAllSummary() |
190 | 196 | { |
197 | + Log.v(LOG_TAG, "Hello"); | |
198 | + | |
191 | 199 | updateSummary(null); |
200 | + | |
201 | + Log.v(LOG_TAG, "Bye"); | |
192 | 202 | } |
193 | 203 | |
194 | 204 | private void updateSummary(String key) |
195 | 205 | { |
206 | + Log.v(LOG_TAG, "Hello"); | |
207 | + | |
196 | 208 | if (key == null || key.equals(dataKeepingPeriodKey)) |
197 | 209 | { |
198 | 210 | ListPreference dataKeepingPeriodPreference = (ListPreference) getPreferenceScreen().findPreference(dataKeepingPeriodKey); |
@@ -224,6 +236,8 @@ public class BatteryLoggerPreferenceActivity extends PreferenceActivity | ||
224 | 236 | } |
225 | 237 | csvSortOrderListPreference.setSummary(summary); |
226 | 238 | } |
239 | + | |
240 | + Log.v(LOG_TAG, "Bye"); | |
227 | 241 | } |
228 | 242 | |
229 | 243 | private void updateDropboxUploaderPreference() |
@@ -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 | +} |
@@ -59,7 +59,7 @@ public class AllCsvFileMediaScanService extends IntentService | ||
59 | 59 | Log.i(LOG_TAG, "AllCsvFileMediaScanService : Start at " + new Date()); |
60 | 60 | |
61 | 61 | Context context = this.getApplicationContext(); |
62 | - if (PreferenceUtils.isCsvAutoExportEnabled(context) == false) | |
62 | + if (PreferenceUtils.isCsvMediaScanCompleted(context) == false) | |
63 | 63 | { |
64 | 64 | String csvExportDirectoryName = PreferenceUtils.getCsvExportDirectoryName(context); |
65 | 65 | File externalStorageDirectory = Environment.getExternalStorageDirectory(); |
@@ -209,4 +209,16 @@ public class PreferenceUtils | ||
209 | 209 | editor.putBoolean(key, value); |
210 | 210 | editor.commit(); |
211 | 211 | } |
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 | + } | |
212 | 224 | } |