Simple Notepad Application for Android OS
Révision | 266cf5d2003a2b36db4930ce1bc600770eadd87f (tree) |
---|---|
l'heure | 2013-06-26 17:14:50 |
Auteur | Masahiko, SAWAI <say@user...> |
Commiter | Masahiko, SAWAI |
notepad-app-level11 にテキスト受信機能の有効無効の設定を実装
@@ -52,16 +52,24 @@ | ||
52 | 52 | <string name="note_list_sort_order_entry_date_added_desc" >作成日時の降順</string> |
53 | 53 | --> |
54 | 54 | |
55 | - <!-- AutoLink Category --> | |
55 | + <!-- Auto Link Category --> | |
56 | 56 | <string name="note_autolink_category_title">自動リンク</string> |
57 | - <!-- AutoLink : Note Title --> | |
57 | + <!-- Auto Link : Note Title --> | |
58 | 58 | <string name="note_title_autolink_title">タイトル内の自動リンク</string> |
59 | - <string name="note_title_autolink_summary_on">ノートのタイトル内のURLやメールアドレスは自動的にリンクされます。</string> | |
60 | - <string name="note_title_autolink_summary_off">ノートのタイトル内のURLやメールアドレスはリンクされません。</string> | |
61 | - <!-- AutoLink : Note Content --> | |
59 | + <string name="note_title_autolink_summary_on">ノートのタイトル内のURLやメールアドレスを自動的にリンクにします。</string> | |
60 | + <string name="note_title_autolink_summary_off">ノートのタイトル内のURLやメールアドレスをリンクにしません。</string> | |
61 | + <!-- Auto Link : Note Content --> | |
62 | 62 | <string name="note_content_autolink_title">本文内の自動リンク</string> |
63 | - <string name="note_content_autolink_summary_on">ノートの本文内のURLやメールアドレスは自動的にリンクされます。</string> | |
64 | - <string name="note_content_autolink_summary_off">ノートの本文内のURLやメールアドレスはリンクされません。</string> | |
63 | + <string name="note_content_autolink_summary_on">ノートの本文内のURLやメールアドレスを自動的にリンクにします。</string> | |
64 | + <string name="note_content_autolink_summary_off">ノートの本文内のURLやメールアドレスをリンクにしません。</string> | |
65 | + | |
66 | + <!-- Share Data Category --> | |
67 | + <string name="share_data_category_title">データ共有</string> | |
68 | + <!-- Receive Text --> | |
69 | + <string name="receive_text_category_title">テキストの受け取り</string> | |
70 | + <string name="receive_text_title">テキストの受け取り</string> | |
71 | + <string name="receive_text_summary_on">テキストデータを受け取って新規ノートとして追加できます。</string> | |
72 | + <string name="receive_text_summary_off">テキストデータの受け取り機能は無効です。</string> | |
65 | 73 | |
66 | 74 | <!-- Backup and Restore Category --> |
67 | 75 | <string name="backup_and_restore">バックアップと復元</string> |
@@ -85,10 +85,17 @@ | ||
85 | 85 | --> |
86 | 86 | </string-array> |
87 | 87 | |
88 | - <!-- note viewer auto link --> | |
88 | + <!-- Auto Link Category --> | |
89 | + <!-- Auto Link : Note Title --> | |
89 | 90 | <string name="note_title_autolink_key" >note_title_autolink</string> |
90 | 91 | <bool name="note_title_autolink_default_value" >false</bool> |
92 | + <!-- Auto Link : Note Content --> | |
91 | 93 | <string name="note_content_autolink_key" >note_content_autolink</string> |
92 | 94 | <bool name="note_content_autolink_default_value" >true</bool> |
93 | 95 | |
96 | + <!-- Share Data Category --> | |
97 | + <!-- Share Data : Receive Text --> | |
98 | + <string name="receive_text_key" >receive_text</string> | |
99 | + <bool name="receive_text_default_value" >true</bool> | |
100 | + | |
94 | 101 | </resources> |
@@ -52,19 +52,26 @@ | ||
52 | 52 | <string name="note_list_sort_order_entry_date_added_desc" >created descending</string> |
53 | 53 | --> |
54 | 54 | |
55 | - <!-- AutoLink Category --> | |
55 | + <!-- Auto Link Category --> | |
56 | 56 | <string name="note_autolink_category_title">Auto Link</string> |
57 | - <!-- AutoLink : Note Title --> | |
57 | + <!-- Auto Link : Note Title --> | |
58 | 58 | <string name="note_title_autolink_title">Auto Link in Title</string> |
59 | 59 | <string name="note_title_autolink_summary_on">The URL and the E-mail in the title are linked automatically.</string> |
60 | 60 | <string name="note_title_autolink_summary_off">The URL and the E-mail in the title are not linked.</string> |
61 | - <!-- AutoLink : Note Content --> | |
61 | + <!-- Auto Link : Note Content --> | |
62 | 62 | <string name="note_content_autolink_title">Auto Link in Text</string> |
63 | 63 | <string name="note_content_autolink_summary_on">The URL and the E-mail in the text are linked automatically.</string> |
64 | 64 | <string name="note_content_autolink_summary_off">The URL and the E-mail in the text are not linked.</string> |
65 | 65 | |
66 | + <!-- Share Data Category --> | |
67 | + <string name="share_data_category_title">Share Data</string> | |
68 | + <!-- Receive Text --> | |
69 | + <string name="receive_text_title">Receive Text</string> | |
70 | + <string name="receive_text_summary_on">The text intent receiving is enabled.</string> | |
71 | + <string name="receive_text_summary_off">The text intent receiving is disabled.</string> | |
72 | + | |
66 | 73 | <!-- Backup and Restore Category --> |
67 | - <string name="backup_and_restore">Backup & Restore</string> | |
74 | + <string name="backup_and_restore">Back up & Restore</string> | |
68 | 75 | <!-- Backup Data --> |
69 | 76 | <string name="backup_data">Backup Data</string> |
70 | 77 | <string name="backup_data_title">Backup Data</string> |
@@ -109,6 +109,16 @@ | ||
109 | 109 | /> |
110 | 110 | </PreferenceCategory> |
111 | 111 | |
112 | + <PreferenceCategory android:title="@string/share_data_category_title" > | |
113 | + <CheckBoxPreference | |
114 | + android:key="@string/receive_text_key" | |
115 | + android:defaultValue="@bool/receive_text_default_value" | |
116 | + android:title="@string/receive_text_title" | |
117 | + android:summaryOn="@string/receive_text_summary_on" | |
118 | + android:summaryOff="@string/receive_text_summary_off" | |
119 | + /> | |
120 | + </PreferenceCategory> | |
121 | + | |
112 | 122 | <PreferenceCategory android:title="@string/backup_and_restore" > |
113 | 123 | <PreferenceScreen |
114 | 124 | android:title="@string/backup_data_title" |
@@ -23,7 +23,9 @@ | ||
23 | 23 | */ |
24 | 24 | package org.routine_work.notepad.prefs; |
25 | 25 | |
26 | +import android.content.ComponentName; | |
26 | 27 | import android.content.SharedPreferences; |
28 | +import android.content.pm.PackageManager; | |
27 | 29 | import android.os.Bundle; |
28 | 30 | import android.preference.ListPreference; |
29 | 31 | import android.preference.PreferenceActivity; |
@@ -32,6 +34,7 @@ import android.view.MenuInflater; | ||
32 | 34 | import android.view.MenuItem; |
33 | 35 | import org.routine_work.notepad.NotepadActivity; |
34 | 36 | import org.routine_work.notepad.R; |
37 | +import org.routine_work.notepad.ReceiveTextActivity; | |
35 | 38 | import org.routine_work.utils.Log; |
36 | 39 | |
37 | 40 | /** |
@@ -106,7 +109,33 @@ public class NotepadPreferenceActivity extends PreferenceActivity | ||
106 | 109 | Log.v(LOG_TAG, "Hello"); |
107 | 110 | Log.i(LOG_TAG, "shared preference " + key + " is changed."); |
108 | 111 | |
109 | - updateSummary(); | |
112 | + String receiveTextKey = getString(R.string.receive_text_key); | |
113 | + if (key.equals(receiveTextKey)) | |
114 | + { | |
115 | + // update component enable/disable | |
116 | + boolean defaultValue = getResources().getBoolean(R.bool.receive_text_default_value); | |
117 | + boolean receiveTextEnabled = prefs.getBoolean(key, defaultValue); | |
118 | + int newState; | |
119 | + | |
120 | + if (receiveTextEnabled) | |
121 | + { | |
122 | + newState = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; | |
123 | + Log.d(LOG_TAG, "Enable ReceiveTextActivity component"); | |
124 | + } | |
125 | + else | |
126 | + { | |
127 | + newState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; | |
128 | + Log.d(LOG_TAG, "Disable ReceiveTextActivity component"); | |
129 | + } | |
130 | + | |
131 | + PackageManager packageManager = getPackageManager(); | |
132 | + ComponentName componentName = new ComponentName(this, ReceiveTextActivity.class); | |
133 | + packageManager.setComponentEnabledSetting(componentName, newState, PackageManager.DONT_KILL_APP); // dont stop | |
134 | + } | |
135 | + else | |
136 | + { | |
137 | + updateSummary(); | |
138 | + } | |
110 | 139 | |
111 | 140 | Log.v(LOG_TAG, "Bye"); |
112 | 141 | } |
@@ -120,12 +120,12 @@ public class NotepadPreferenceActivity extends PreferenceActivity | ||
120 | 120 | if (receiveTextEnabled) |
121 | 121 | { |
122 | 122 | newState = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; |
123 | - Log.d(LOG_TAG, "Update ReceiveTextActivity component : PackageManager.COMPONENT_ENABLED_STATE_ENABLED"); | |
123 | + Log.d(LOG_TAG, "Enable ReceiveTextActivity component"); | |
124 | 124 | } |
125 | 125 | else |
126 | 126 | { |
127 | 127 | newState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; |
128 | - Log.d(LOG_TAG, "Update ReceiveTextActivity component : PackageManager.COMPONENT_ENABLED_STATE_DISABLED"); | |
128 | + Log.d(LOG_TAG, "Disable ReceiveTextActivity component"); | |
129 | 129 | } |
130 | 130 | |
131 | 131 | PackageManager packageManager = getPackageManager(); |