Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc tweaks #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
android:versionName="@string/app_version" >

<uses-sdk
android:minSdkVersion="8"
android:minSdkVersion="11"
android:targetSdkVersion="13" />

<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/MyTheme" >
Expand All @@ -33,8 +34,8 @@

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="text/plain" />
<data android:mimeType="text/x-tex" />
<data android:mimeType="text/*" />
<data android:mimeType="application/octet-stream" />
<data android:scheme="file" />
<data android:scheme="content" />
</intent-filter>
Expand All @@ -45,4 +46,4 @@
</activity>
</application>

</manifest>
</manifest>
86 changes: 0 additions & 86 deletions res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,92 +8,6 @@
<item>black</item>
<item>white</item>
</string-array>
<string-array name="entries_fontsizes">
<item>8</item>
<item>9</item>
<item>10</item>
<item>11</item>
<item>12</item>
<item>13</item>
<item>14</item>
<item>15</item>
<item>16</item>
<item>17</item>
<item>18</item>
<item>19</item>
<item>20</item>
<item>21</item>
<item>22</item>
<item>23</item>
<item>24</item>
<item>25</item>
<item>26</item>
<item>27</item>
<item>28</item>
<item>29</item>
<item>30</item>
<item>31</item>
<item>32</item>
<item>33</item>
<item>34</item>
<item>35</item>
<item>36</item>
<item>37</item>
<item>38</item>
<item>39</item>
<item>40</item>
<item>41</item>
<item>42</item>
<item>43</item>
<item>44</item>
<item>45</item>
<item>46</item>
<item>47</item>
<item>48</item>
</string-array>
<string-array name="entry_values_fontsizes">
<item>8</item>
<item>9</item>
<item>10</item>
<item>11</item>
<item>12</item>
<item>13</item>
<item>14</item>
<item>15</item>
<item>16</item>
<item>17</item>
<item>18</item>
<item>19</item>
<item>20</item>
<item>21</item>
<item>22</item>
<item>23</item>
<item>24</item>
<item>25</item>
<item>26</item>
<item>27</item>
<item>28</item>
<item>29</item>
<item>30</item>
<item>31</item>
<item>32</item>
<item>33</item>
<item>34</item>
<item>35</item>
<item>36</item>
<item>37</item>
<item>38</item>
<item>39</item>
<item>40</item>
<item>41</item>
<item>42</item>
<item>43</item>
<item>44</item>
<item>45</item>
<item>46</item>
<item>47</item>
<item>48</item>
</string-array>
<string-array name="entries_scrolllines">
<item>1 page</item>
<item>1/2 page</item>
Expand Down
2 changes: 1 addition & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Text Viewer</string>
<string name="app_version">0.1.8</string>
<string name="app_version">0.1.9b0</string>
<string name="main_inst">This is an example text.\nPlease use something like file-manager to open a text-like file.</string>
<string name="menu_title_main_preferences">Preferences</string>
<string name="menu_title_main_search">Search</string>
Expand Down
16 changes: 9 additions & 7 deletions res/xml/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
android:defaultValue="black"
android:entries="@array/entries_colorthemes"
android:entryValues="@array/entry_values_colorthemes" />
<ListPreference
android:key="fontsize"
android:title="@string/config_title_fontsize"
android:defaultValue="14"
android:entries="@array/entries_fontsizes"
android:entryValues="@array/entry_values_fontsizes" />
<com.gmail.altakey.dawne.NumberPickerPreference
android:key="fontsize"
android:title="@string/config_title_fontsize"
android:defaultValue="14"
android:max="48"
min="8" />
<CheckBoxPreference
android:key="usemonospacefonts"
android:title="@string/config_title_usemonospacefonts"
Expand All @@ -40,5 +40,7 @@
android:entryValues="@array/entry_values_charsetpreference" />
<Preference
android:title="@string/config_title_version"
android:summary="@string/app_version" />
android:summary="@string/app_version"
android:enabled="false"
/>
</PreferenceScreen>
8 changes: 4 additions & 4 deletions src/com/gmail/altakey/dawne/ConfigActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class ConfigActivity extends PreferenceActivity implements
SharedPreferences.OnSharedPreferenceChangeListener {
private ListPreference colortheme;
private ListPreference fontsize;
private NumberPickerPreference fontsize;
private ListPreference scrolllines;
private ListPreference charsetpreference;

Expand All @@ -36,8 +36,8 @@ protected void onCreate(Bundle savedInstanceState) {

this.colortheme = (ListPreference) getPreferenceScreen()
.findPreference(ConfigKey.COLORTHEME);
this.fontsize = (ListPreference) getPreferenceScreen().findPreference(
ConfigKey.FONTSIZE);
this.fontsize = (NumberPickerPreference) getPreferenceScreen()
.findPreference(ConfigKey.FONTSIZE);
this.scrolllines = (ListPreference) getPreferenceScreen()
.findPreference(ConfigKey.SCROLL_LINES);
this.charsetpreference = (ListPreference) getPreferenceScreen()
Expand Down Expand Up @@ -75,7 +75,7 @@ private void updateSummary(SharedPreferences sharedPreferences, String key) {
this.colortheme.setSummary(this.colortheme.getEntry());

if (key.equals(ConfigKey.FONTSIZE))
this.fontsize.setSummary(sharedPreferences.getString(key, "")
this.fontsize.setSummary(sharedPreferences.getString(key, "14")
+ " sp");

if (key.equals(ConfigKey.SCROLL_LINES))
Expand Down
78 changes: 78 additions & 0 deletions src/com/gmail/altakey/dawne/NumberPickerPreference.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* Copyright (C) 2013 Takahiro Yoshimura
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.gmail.altakey.dawne;

import android.preference.DialogPreference;
import android.widget.NumberPicker;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.content.res.TypedArray;

public class NumberPickerPreference extends DialogPreference {
private int mDefault, mMin, mMax;
private NumberPicker mPicker;
private static final String androidNS =
"http://schemas.android.com/apk/res/android";

public NumberPickerPreference(Context ctx, AttributeSet attr) {
super(ctx, attr);
handleAttributeSet(attr);
}
private void handleAttributeSet (AttributeSet attr) {
mMin = attr.getAttributeIntValue(null, "min", 2);
mMax = attr.getAttributeIntValue(androidNS, "max", 96);
}
@Override
protected View onCreateDialogView() {
mPicker = new NumberPicker(getContext());
mPicker.setMinValue(mMin);
mPicker.setMaxValue(mMax);
mPicker.setValue(Integer.parseInt(
getPersistedString(Integer.toString(mDefault))
));
return mPicker;
}
@Override
protected void onSetInitialValue(boolean restore, Object defaultValue) {
if (restore)
mDefault = Integer.parseInt(
getPersistedString(Integer.toString(mDefault))
);
else {
mDefault = (Integer)defaultValue;
if (shouldPersist())
persistString(Integer.toString(mDefault));
}
}
@Override
protected Object onGetDefaultValue(TypedArray a, int index) {
mDefault = a.getInt(index, 12);
return mDefault;
}
@Override
protected void onDialogClosed(boolean result) {
super.onDialogClosed(result);
if (result) {
int new_value = mPicker.getValue();
if (callChangeListener(new_value)) {
persistString(Integer.toString(new_value));
}
}
}
}