• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

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

Simple Notepad Application for Android OS


Commit MetaInfo

Revisiond7e33e1711a68689f03ef1eadaa6d2800a6c4a06 (tree)
Zeit2017-03-19 11:26:24
AutorMasahiko, SAWAI <say@user...>
CommiterMasahiko, SAWAI

Log Message

Added font size settings

Ändern Zusammenfassung

Diff

--- a/doc/Changes.txt
+++ b/doc/Changes.txt
@@ -1,3 +1,8 @@
1+1.0.11
2+======
3+
4+* Added font size settings
5+
16 1.0.10
27 ======
38
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-hdpi/ic_next_dark.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-hdpi/ic_next_light.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-hdpi/ic_prev_dark.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-hdpi/ic_prev_light.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-ldpi/ic_next_dark.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-ldpi/ic_next_light.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-ldpi/ic_prev_dark.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-ldpi/ic_prev_light.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-mdpi/ic_next_dark.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-mdpi/ic_next_light.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-mdpi/ic_prev_dark.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-mdpi/ic_prev_light.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-xhdpi/ic_next_dark.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-xhdpi/ic_next_light.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-xhdpi/ic_prev_dark.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-xhdpi/ic_prev_light.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-xxhdpi/ic_next_dark.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-xxhdpi/ic_next_light.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-xxhdpi/ic_prev_dark.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-xxhdpi/ic_prev_light.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-xxxhdpi/ic_next_dark.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-xxxhdpi/ic_next_light.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-xxxhdpi/ic_prev_dark.png differ
Binary files /dev/null and b/notepad-app-level-11/src/main/res/drawable-xxxhdpi/ic_prev_light.png differ
--- /dev/null
+++ b/notepad-app-level-11/src/main/res/layout/find_word_actionview.xml
@@ -0,0 +1,12 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<EditText
3+ xmlns:android="http://schemas.android.com/apk/res/android"
4+ android:id="@+id/find_word_edittext"
5+ android:layout_width="@dimen/find_word_edittext_layout_width"
6+ android:layout_height="fill_parent"
7+ android:layout_weight="1"
8+ android:singleLine="true"
9+ android:inputType="text"
10+ android:hint="@string/find_word_hint"
11+ android:imeOptions="actionSearch"
12+/>
\ No newline at end of file
--- a/notepad-app/src/main/java/org/routine_work/notepad/NoteDetailActivity.java
+++ b/notepad-app/src/main/java/org/routine_work/notepad/NoteDetailActivity.java
@@ -38,6 +38,7 @@ import android.text.ClipboardManager;
3838 import android.text.InputType;
3939 import android.text.TextUtils;
4040 import android.text.util.Linkify;
41+import android.util.TypedValue;
4142 import android.view.*;
4243 import android.view.ContextMenu.ContextMenuInfo;
4344 import android.view.View.OnFocusChangeListener;
@@ -261,6 +262,15 @@ public class NoteDetailActivity extends Activity
261262 // bindNoteToViews();
262263 // originalNote.copyFrom(currentNote);
263264
265+ int fontSize = NotepadPreferenceUtils.getNoteDetailFontSize(this);
266+ int fontSizeDefault = NotepadPreferenceUtils.getNoteDetailFontSizeDefault(this);
267+ int titleFontSize = (fontSize > fontSizeDefault) ? fontSize : fontSizeDefault;
268+
269+ noteTitleEditText.setTextSize(TypedValue.COMPLEX_UNIT_SP, titleFontSize);
270+ noteContentEditText.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
271+ noteTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, titleFontSize);
272+ noteContentTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize);
273+
264274 Log.d(LOG_TAG, "------------------------------------------------------------");
265275 Log.d(LOG_TAG, "currentAction => " + currentAction);
266276 Log.d(LOG_TAG, "currentNoteUri => " + currentNoteUri);
--- a/notepad-app/src/main/java/org/routine_work/notepad/prefs/NotepadPreferenceActivity.java
+++ b/notepad-app/src/main/java/org/routine_work/notepad/prefs/NotepadPreferenceActivity.java
@@ -172,5 +172,23 @@ public class NotepadPreferenceActivity extends PreferenceActivity
172172 listPreference = (ListPreference) getPreferenceScreen().findPreference(prefKey);
173173 summary = listPreference.getEntry();
174174 listPreference.setSummary(summary);
175+
176+ // Note Detail : Font Size in Portrait
177+ prefKey = getString(R.string.note_detail_font_size_port_key);
178+ listPreference = (ListPreference) getPreferenceScreen().findPreference(prefKey);
179+ if (listPreference != null)
180+ {
181+ summary = listPreference.getEntry();
182+ listPreference.setSummary(summary);
183+ }
184+
185+ // Note Detail : Font Size in Landscape
186+ prefKey = getString(R.string.note_detail_font_size_land_key);
187+ listPreference = (ListPreference) getPreferenceScreen().findPreference(prefKey);
188+ if (listPreference != null)
189+ {
190+ summary = listPreference.getEntry();
191+ listPreference.setSummary(summary);
192+ }
175193 }
176194 }
--- a/notepad-app/src/main/java/org/routine_work/notepad/prefs/NotepadPreferenceUtils.java
+++ b/notepad-app/src/main/java/org/routine_work/notepad/prefs/NotepadPreferenceUtils.java
@@ -245,6 +245,81 @@ public class NotepadPreferenceUtils
245245 return noteContentAutoLink;
246246 }
247247
248+ public static int getNoteDetailFontSize(Context context)
249+ {
250+ int fontSize = 18;
251+ int keyId;
252+ int defaultValueId;
253+ Log.v(LOG_TAG, "Hello");
254+
255+ SharedPreferences sharedPreferences = getSharedPreferences(context);
256+ Resources resources = context.getResources();
257+ Configuration configuration = resources.getConfiguration();
258+ switch (configuration.orientation)
259+ {
260+ case Configuration.ORIENTATION_LANDSCAPE:
261+ keyId = R.string.note_detail_font_size_land_key;
262+ defaultValueId = R.string.note_detail_font_size_land_default_value;
263+ break;
264+ default:
265+ keyId = R.string.note_detail_font_size_port_key;
266+ defaultValueId = R.string.note_detail_font_size_port_default_value;
267+ break;
268+ }
269+
270+ String key = resources.getString(keyId);
271+ String defaultValue = resources.getString(defaultValueId);
272+ String value = sharedPreferences.getString(key, defaultValue);
273+ Log.d(LOG_TAG, "value => " + value);
274+ try
275+ {
276+ fontSize = Integer.parseInt(value);
277+ }
278+ catch (NumberFormatException e)
279+ {
280+ Log.e(LOG_TAG, "Integer.parseInt(" + value + ") is failed.");
281+ }
282+
283+ Log.d(LOG_TAG, "fontSize => " + fontSize);
284+ Log.v(LOG_TAG, "Bye");
285+ return fontSize;
286+ }
287+
288+ public static int getNoteDetailFontSizeDefault(Context context)
289+ {
290+ int noteDefailFontSizeDefault = 18;
291+ int defaultValueId;
292+ Log.v(LOG_TAG, "Hello");
293+
294+ Resources resources = context.getResources();
295+
296+ Configuration configuration = resources.getConfiguration();
297+ switch (configuration.orientation)
298+ {
299+ case Configuration.ORIENTATION_LANDSCAPE:
300+ defaultValueId = R.string.note_detail_font_size_land_default_value;
301+ break;
302+ default:
303+ defaultValueId = R.string.note_detail_font_size_port_default_value;
304+ break;
305+ }
306+
307+ String defaultValue = resources.getString(defaultValueId);
308+ Log.d(LOG_TAG, "defaultValue => " + defaultValue);
309+ try
310+ {
311+ noteDefailFontSizeDefault = Integer.parseInt(defaultValue);
312+ }
313+ catch (NumberFormatException e)
314+ {
315+ Log.e(LOG_TAG, "Integer.parseInt(" + defaultValue + ") is failed.");
316+ }
317+
318+ Log.d(LOG_TAG, "fontSize => " + noteDefailFontSizeDefault);
319+ Log.v(LOG_TAG, "Bye");
320+ return noteDefailFontSizeDefault;
321+ }
322+
248323 public static boolean getNoteTitleCapitalization(Context context)
249324 {
250325 boolean noteTitleCapitalization;
--- a/notepad-app/src/main/res/values-ja/strings_preferences.xml
+++ b/notepad-app/src/main/res/values-ja/strings_preferences.xml
@@ -39,6 +39,22 @@
3939 <string name="note_list_sort_order_entry_date_added_desc" >作成日時の降順</string>
4040 -->
4141
42+ <!-- Note Detail Category -->
43+ <string name="note_detail_category_title">ノートの表示と編集</string>
44+ <!-- Note Detail : Font Size -->
45+ <string name="note_detail_font_size">フォントサイズ</string>
46+ <string name="note_detail_font_size_title">フォントサイズ</string>
47+ <string name="note_detail_font_size_port">フォントサイズ(縦画面)</string>
48+ <string name="note_detail_font_size_land">フォントサイズ(横画面)</string>
49+ <string name="note_detail_font_size__port_title">フォントサイズ(縦画面)</string>
50+ <string name="note_detail_font_size__land_title">フォントサイズ(横画面)</string>
51+ <!-- Note Detail : Font Size Entries-->
52+ <string name="note_detail_font_size_tiny">極小</string>
53+ <string name="note_detail_font_size_small">小</string>
54+ <string name="note_detail_font_size_normal">中</string>
55+ <string name="note_detail_font_size_large">大</string>
56+ <string name="note_detail_font_size_huge">極大</string>
57+
4258 <!-- Auto Link Category -->
4359 <string name="note_autolink_category_title">自動リンク</string>
4460 <!-- Auto Link : Note Title -->
--- a/notepad-app/src/main/res/values/preference.xml
+++ b/notepad-app/src/main/res/values/preference.xml
@@ -65,6 +65,29 @@
6565 -->
6666 </string-array>
6767
68+ <!-- Note Detail Category -->
69+ <!-- Note Detail Font Size -->
70+ <string name="note_detail_font_size_port_key" >note_detail_font_size_port</string>
71+ <string name="note_detail_font_size_land_key" >note_detail_font_size_land</string>
72+ <string name="note_detail_font_size_port_default_value" >18</string>
73+ <string name="note_detail_font_size_land_default_value" >18</string>
74+
75+ <string-array name="note_detail_font_size_entries">
76+ <item>@string/note_detail_font_size_tiny</item>
77+ <item>@string/note_detail_font_size_small</item>
78+ <item>@string/note_detail_font_size_normal</item>
79+ <item>@string/note_detail_font_size_large</item>
80+ <item>@string/note_detail_font_size_huge</item>
81+ </string-array>
82+
83+ <string-array name="note_detail_font_size_values">
84+ <item>10</item>
85+ <item>14</item>
86+ <item>18</item>
87+ <item>22</item>
88+ <item>26</item>
89+ </string-array>
90+
6891 <!-- Auto Link Category -->
6992 <!-- Auto Link : Note Title -->
7093 <string name="note_title_autolink_key" >note_title_autolink</string>
--- a/notepad-app/src/main/res/values/strings_preference.xml
+++ b/notepad-app/src/main/res/values/strings_preference.xml
@@ -39,6 +39,20 @@
3939 <string name="note_list_sort_order_entry_date_added_desc" >created descending</string>
4040 -->
4141
42+ <!-- Note Detail Category -->
43+ <string name="note_detail_category_title">Note View and Edit</string>
44+ <!-- Note Detail : Font Size -->
45+ <string name="note_detail_font_size_port">Font size in portrait</string>
46+ <string name="note_detail_font_size_land">Font size in landscape</string>
47+ <string name="note_detail_font_size__port_title">Font size in portrait</string>
48+ <string name="note_detail_font_size__land_title">Font size in landscape</string>
49+ <!-- Note Detail : Font Size Entries-->
50+ <string name="note_detail_font_size_tiny">Tiny</string>
51+ <string name="note_detail_font_size_small">Small</string>
52+ <string name="note_detail_font_size_normal">Normal</string>
53+ <string name="note_detail_font_size_large">Large</string>
54+ <string name="note_detail_font_size_huge">Huge</string>
55+
4256 <!-- Auto Link Category -->
4357 <string name="note_autolink_category_title">Auto link</string>
4458 <!-- Auto Link : Note Title -->
--- a/notepad-app/src/main/res/xml/notepad_preference.xml
+++ b/notepad-app/src/main/res/xml/notepad_preference.xml
@@ -60,6 +60,25 @@
6060 />
6161 </PreferenceCategory>
6262
63+ <PreferenceCategory android:title="@string/note_detail_category_title" >
64+ <ListPreference
65+ android:key="@string/note_detail_font_size_port_key"
66+ android:defaultValue="@string/note_detail_font_size_port_default_value"
67+ android:title="@string/note_detail_font_size_port"
68+ android:dialogTitle="@string/note_detail_font_size__port_title"
69+ android:entries="@array/note_detail_font_size_entries"
70+ android:entryValues="@array/note_detail_font_size_values"
71+ />
72+ <ListPreference
73+ android:key="@string/note_detail_font_size_land_key"
74+ android:defaultValue="@string/note_detail_font_size_land_default_value"
75+ android:title="@string/note_detail_font_size_land"
76+ android:dialogTitle="@string/note_detail_font_size__land_title"
77+ android:entries="@array/note_detail_font_size_entries"
78+ android:entryValues="@array/note_detail_font_size_values"
79+ />
80+ </PreferenceCategory>
81+
6382 <PreferenceCategory android:title="@string/note_autolink_category_title" >
6483 <CheckBoxPreference
6584 android:key="@string/note_title_autolink_key"
--- /dev/null
+++ b/notepad-common/src/main/java/org/routine_work/notepad/utils/TextViewFindWordContext.java
@@ -0,0 +1,240 @@
1+package org.routine_work.notepad.utils;
2+
3+import android.text.Spannable;
4+import android.text.SpannableStringBuilder;
5+import android.text.Spanned;
6+import android.text.TextUtils;
7+import android.text.style.BackgroundColorSpan;
8+import android.text.style.ForegroundColorSpan;
9+import java.util.ArrayList;
10+import java.util.List;
11+import java.util.regex.Matcher;
12+import java.util.regex.Pattern;
13+import org.routine_work.utils.Log;
14+
15+public class TextViewFindWordContext
16+{
17+
18+ private static final String LOG_TAG = "simple-notepad";
19+
20+ class FoundWord
21+ {
22+
23+ int lineNumber;
24+ int startIndex;
25+ int endIndex;
26+ }
27+
28+ private int foundWordBackgroundColor = 0xFF8B008B;
29+ private int foundWordForegroundColor = 0xFFFFFFFF;
30+ private int selectedWordBackgroundColor = 0xFFAA00AA;
31+ private int selectedWordForegroundColor = 0xFFFFFFFF;
32+ private String contentText = "";
33+ private String targetWord = "";
34+ private String[] contentTextLines;
35+ private FoundWord[] foundWords = new FoundWord[0];
36+ private int selectedWordIndex = 0;
37+
38+ /**
39+ * @return the foundWordBackgroundColor
40+ */
41+ public int getFoundWordBackgroundColor()
42+ {
43+ return foundWordBackgroundColor;
44+ }
45+
46+ /**
47+ * @param foundWordBackgroundColor the foundWordBackgroundColor to set
48+ */
49+ public void setFoundWordBackgroundColor(int foundWordBackgroundColor)
50+ {
51+ this.foundWordBackgroundColor = foundWordBackgroundColor;
52+ }
53+
54+ /**
55+ * @return the selectedWordBackgroundColor
56+ */
57+ public int getSelectedWordBackgroundColor()
58+ {
59+ return selectedWordBackgroundColor;
60+ }
61+
62+ /**
63+ * @param selectedWordBackgroundColor the selectedWordBackgroundColor to set
64+ */
65+ public void setSelectedWordBackgroundColor(int selectedWordBackgroundColor)
66+ {
67+ this.selectedWordBackgroundColor = selectedWordBackgroundColor;
68+ }
69+
70+ /**
71+ * @return the foundWordForegroundColor
72+ */
73+ public int getFoundWordForegroundColor()
74+ {
75+ return foundWordForegroundColor;
76+ }
77+
78+ /**
79+ * @param foundWordForegroundColor the foundWordForegroundColor to set
80+ */
81+ public void setFoundWordForegroundColor(int foundWordForegroundColor)
82+ {
83+ this.foundWordForegroundColor = foundWordForegroundColor;
84+ }
85+
86+ /**
87+ * @return the selectedWordForegroundColor
88+ */
89+ public int getSelectedWordForegroundColor()
90+ {
91+ return selectedWordForegroundColor;
92+ }
93+
94+ /**
95+ * @param selectedWordForegroundColor the selectedWordForegroundColor to set
96+ */
97+ public void setSelectedWordForegroundColor(int selectedWordForegroundColor)
98+ {
99+ this.selectedWordForegroundColor = selectedWordForegroundColor;
100+ }
101+
102+ public void setTargetWord(CharSequence serachWord)
103+ {
104+ if (targetWord == null)
105+ {
106+ targetWord = "";
107+ }
108+ this.targetWord = serachWord.toString();
109+ this.selectedWordIndex = 0;
110+ updateContext();
111+ }
112+
113+ public String getTargetWord()
114+ {
115+ return this.targetWord;
116+ }
117+
118+ public void setContentText(CharSequence contentText)
119+ {
120+ if (contentText == null)
121+ {
122+ contentText = "";
123+ }
124+ this.contentText = contentText.toString();
125+ this.selectedWordIndex = 0;
126+ updateContext();
127+ }
128+
129+ public void prevWord()
130+ {
131+ if (foundWords.length > 0)
132+ {
133+ selectedWordIndex--;
134+ if (selectedWordIndex < 0)
135+ {
136+ selectedWordIndex = foundWords.length - 1;
137+ }
138+ }
139+ }
140+
141+ public void nextWord()
142+ {
143+ if (foundWords.length > 0)
144+ {
145+ selectedWordIndex++;
146+ if (selectedWordIndex >= foundWords.length)
147+ {
148+ selectedWordIndex = 0;
149+ }
150+ }
151+ }
152+
153+ public int getContentTextLineCount()
154+ {
155+ int lineCount = 0;
156+ if (contentTextLines != null)
157+ {
158+ lineCount = contentTextLines.length;
159+ }
160+ return lineCount;
161+ }
162+
163+ public int getFoundWordCount()
164+ {
165+ return foundWords.length;
166+ }
167+
168+ public int getSelectedWordLineNumber()
169+ {
170+ int lineNumber = -1;
171+ if (foundWords.length > 0)
172+ {
173+ lineNumber = foundWords[selectedWordIndex].lineNumber;
174+ }
175+ return lineNumber;
176+ }
177+
178+ private void updateContext()
179+ {
180+ contentTextLines = this.contentText.split("\n");
181+
182+ List<FoundWord> foundWordList = new ArrayList<FoundWord>();
183+ if (TextUtils.isEmpty(this.targetWord) == false)
184+ {
185+ for (int i = 0; i < contentTextLines.length; i++)
186+ {
187+ String line = contentTextLines[i];
188+ Pattern p = Pattern.compile(this.targetWord, Pattern.CASE_INSENSITIVE);
189+ Matcher m = p.matcher(line);
190+ while (m.find())
191+ {
192+ FoundWord foundWord = new FoundWord();
193+ foundWord.lineNumber = i;
194+ foundWord.startIndex = m.start();
195+ foundWord.endIndex = m.end();
196+ foundWordList.add(foundWord);
197+// Log.v(LOG_TAG, "foundWord => " + foundWord);
198+// Log.v(LOG_TAG, "foundWord.startIndex => " + foundWord.startIndex);
199+// Log.v(LOG_TAG, "foundWord.endIndex => " + foundWord.endIndex);
200+ }
201+ }
202+ }
203+ this.foundWords = foundWordList.toArray(new FoundWord[0]);
204+ }
205+
206+ public Spannable getSpannable()
207+ {
208+// Log.v(LOG_TAG, "selectedWordIndex => " + selectedWordIndex);
209+ SpannableStringBuilder builder = new SpannableStringBuilder();
210+ for (int i = 0; i < contentTextLines.length; i++)
211+ {
212+ int lineHeadIndex = builder.length();
213+ builder.append(this.contentTextLines[i]);
214+
215+ for (int j = 0; j < foundWords.length; j++)
216+ {
217+ FoundWord foundWord = foundWords[j];
218+ if (foundWord.lineNumber == i)
219+ {
220+ int startIndex = lineHeadIndex + foundWord.startIndex;
221+ int endIndex = lineHeadIndex + foundWord.endIndex;
222+ if (j == selectedWordIndex)
223+ {
224+ builder.setSpan(new BackgroundColorSpan(getSelectedWordBackgroundColor()), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
225+ builder.setSpan(new ForegroundColorSpan(getSelectedWordForegroundColor()), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
226+ }
227+ else
228+ {
229+ builder.setSpan(new BackgroundColorSpan(getFoundWordBackgroundColor()), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
230+ builder.setSpan(new ForegroundColorSpan(getFoundWordForegroundColor()), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
231+ }
232+ }
233+ }
234+
235+ builder.append("\n");
236+ }
237+
238+ return builder;
239+ }
240+}