mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-27 18:02:22 +03:00
Added font size preference.
This commit is contained in:
parent
5d1a3e617e
commit
6f23054f60
8 changed files with 63 additions and 0 deletions
|
@ -5,6 +5,7 @@ import android.app.Fragment;
|
|||
import android.app.FragmentManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.content.pm.ShortcutManager;
|
||||
import android.graphics.drawable.Icon;
|
||||
|
@ -319,6 +320,24 @@ public abstract class BaseNoteFragment extends Fragment implements CategoryDialo
|
|||
}
|
||||
}
|
||||
|
||||
protected float getFontSizeFromPreferences(SharedPreferences sp) {
|
||||
final String prefValueTiny = getString(R.string.pref_value_font_size_tiny);
|
||||
final String prefValueSmall = getString(R.string.pref_value_font_size_small);
|
||||
final String prefValueMedium = getString(R.string.pref_value_font_size_medium);
|
||||
final String prefValueLarge = getString(R.string.pref_value_font_size_large);
|
||||
String fontSize = sp.getString(getString(R.string.pref_key_font_size), prefValueMedium);
|
||||
|
||||
if (fontSize.equals(prefValueTiny)) {
|
||||
return getResources().getDimension(R.dimen.note_font_size_tiny);
|
||||
} else if (fontSize.equals(prefValueSmall)) {
|
||||
return getResources().getDimension(R.dimen.note_font_size_small);
|
||||
} else if (fontSize.equals(prefValueMedium)) {
|
||||
return getResources().getDimension(R.dimen.note_font_size_medium);
|
||||
} else {
|
||||
return getResources().getDimension(R.dimen.note_font_size_large);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String getContent();
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.preference.PreferenceManager;
|
|||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
|
@ -155,6 +156,7 @@ public class NoteEditFragment extends BaseNoteFragment {
|
|||
|
||||
editContent.setCustomSelectionActionModeCallback(new StyleCallback(this.editContent));
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||
editContent.setTextSize(TypedValue.COMPLEX_UNIT_PX, getFontSizeFromPreferences(sp));
|
||||
if (sp.getBoolean(getString(R.string.pref_key_font), false)) {
|
||||
editContent.setTypeface(Typeface.MONOSPACE);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.os.Bundle;
|
|||
import android.preference.PreferenceManager;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
|
@ -100,6 +101,7 @@ public class NotePreviewFragment extends BaseNoteFragment {
|
|||
noteContent.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||
noteContent.setTextSize(TypedValue.COMPLEX_UNIT_PX, getFontSizeFromPreferences(sp));
|
||||
if (sp.getBoolean(getString(R.string.pref_key_font), false)) {
|
||||
noteContent.setTypeface(Typeface.MONOSPACE);
|
||||
}
|
||||
|
|
5
app/src/main/res/drawable/ic_format_size_black_24dp.xml
Normal file
5
app/src/main/res/drawable/ic_format_size_black_24dp.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:tint="#666666" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M9,4v3h5v12h3L17,7h5L22,4L9,4zM3,12h3v7h3v-7h3L12,9L3,9v3z"/>
|
||||
</vector>
|
|
@ -5,4 +5,10 @@
|
|||
<item>@string/pref_value_mode_preview</item>
|
||||
<item>@string/pref_value_mode_last</item>
|
||||
</string-array>
|
||||
<string-array name="fontSize_values">
|
||||
<item>@string/pref_value_font_size_tiny</item>
|
||||
<item>@string/pref_value_font_size_small</item>
|
||||
<item>@string/pref_value_font_size_medium</item>
|
||||
<item>@string/pref_value_font_size_large</item>
|
||||
</string-array>
|
||||
</resources>
|
|
@ -12,6 +12,12 @@
|
|||
<dimen name="primary_font_size">16sp</dimen>
|
||||
<dimen name="secondary_font_size">14sp</dimen>
|
||||
|
||||
<!-- Font Sizes -->
|
||||
<dimen name="note_font_size_tiny">14sp</dimen>
|
||||
<dimen name="note_font_size_small">16sp</dimen>
|
||||
<dimen name="note_font_size_medium">18sp</dimen>
|
||||
<dimen name="note_font_size_large">22sp</dimen>
|
||||
|
||||
<!-- Widgets -->
|
||||
<dimen name="widget_margin">8dp</dimen>
|
||||
<dimen name="widget_single_note_padding">10dp</dimen>
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
<string name="settings_note_mode">Display mode for notes</string>
|
||||
<string name="settings_theme_title">Dark theme</string>
|
||||
<string name="settings_font_title">Monospace font</string>
|
||||
<string name="settings_font_size">Font size</string>
|
||||
<string name="settings_wifi_only">Sync only on Wi-Fi</string>
|
||||
<string name="settings_cert_category">Manage certificates</string>
|
||||
<string name="settings_cert_trust_system">Trust system certificates</string>
|
||||
|
@ -142,12 +143,17 @@
|
|||
<string name="pref_key_note_mode" translatable="false">noteMode</string>
|
||||
<string name="pref_key_theme" translatable="false">darkTheme</string>
|
||||
<string name="pref_key_font" translatable="false">font</string>
|
||||
<string name="pref_key_font_size" translatable="false">fontSize</string>
|
||||
<string name="pref_key_wifi_only" translatable="false">wifiOnly</string>
|
||||
<string name="pref_key_last_note_mode" translatable="false">lastNoteMode</string>
|
||||
<string name="pref_value_mode_edit" translatable="false">edit</string>
|
||||
<string name="pref_value_mode_preview" translatable="false">preview</string>
|
||||
<string name="pref_value_mode_last" translatable="false">last</string>
|
||||
<string name="pref_value_mode_note" translatable="false">note</string>
|
||||
<string name="pref_value_font_size_tiny" translatable="false">tiny</string>
|
||||
<string name="pref_value_font_size_small" translatable="false">small</string>
|
||||
<string name="pref_value_font_size_medium" translatable="false">medium</string>
|
||||
<string name="pref_value_font_size_large" translatable="false">large</string>
|
||||
<string name="pref_value_theme_light">Light</string>
|
||||
<string name="pref_value_theme_dark">Dark</string>
|
||||
<string name="pref_value_font_normal">Normal</string>
|
||||
|
@ -167,6 +173,14 @@
|
|||
<item>Remember my last selection</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Array: font size -->
|
||||
<string-array name="fontSize_entries">
|
||||
<item>Tiny</item>
|
||||
<item>Small</item>
|
||||
<item>Medium</item>
|
||||
<item>Large</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Plurals -->
|
||||
<plurals name="ab_selected">
|
||||
<item quantity="one">%d selected</item>
|
||||
|
|
|
@ -30,6 +30,15 @@
|
|||
android:key="@string/pref_key_font"
|
||||
android:title="@string/settings_font_title" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@string/pref_value_font_size_medium"
|
||||
android:entries="@array/fontSize_entries"
|
||||
android:entryValues="@array/fontSize_values"
|
||||
android:icon="@drawable/ic_format_size_black_24dp"
|
||||
android:key="@string/pref_key_font_size"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_font_size" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="@string/pref_value_wifi_and_mobile"
|
||||
android:icon="@drawable/ic_sync_black_24dp"
|
||||
|
|
Loading…
Reference in a new issue