diff --git a/CHANGELOG.md b/CHANGELOG.md index 4803e85..6474fc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - Added an option to use a webview in the article viewer (see #149) -- Fixes (#151 #152 #155 #157 #160) +- Fixes (#151 #152 #155 #157 #160 #174) - New year fixes !!! @@ -20,6 +20,8 @@ - Better handling for articles update. (See #169) +- Ability to change the article viewer content font size (see #153) + **1.5.5.x (didn't last long) AND 1.5.6.x** - Toolbar in reader activity. diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ArticleFragment.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ArticleFragment.kt index 435c9db..bb75f3a 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ArticleFragment.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ArticleFragment.kt @@ -25,6 +25,7 @@ import apps.amine.bou.readerforselfoss.utils.isEmptyOrNullOrNullString import apps.amine.bou.readerforselfoss.utils.openItemUrl import apps.amine.bou.readerforselfoss.utils.shareLink import apps.amine.bou.readerforselfoss.utils.sourceAndDateText +import apps.amine.bou.readerforselfoss.utils.toPx import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions import com.crashlytics.android.Crashlytics @@ -39,6 +40,7 @@ import java.net.URL class ArticleFragment : Fragment() { private lateinit var pageNumber: Number + private var fontSize: Int = 14 private lateinit var allItems: ArrayList private lateinit var mCustomTabActivityHelper: CustomTabActivityHelper private lateinit var url: String @@ -84,6 +86,8 @@ class ArticleFragment : Fragment() { mCustomTabActivityHelper.bindCustomTabsService(activity) val prefs = PreferenceManager.getDefaultSharedPreferences(activity) + fontSize = prefs.getString("reader_font_size", "14").toInt() + mFloatingToolbar.setClickListener( object : FloatingToolbar.ItemClickListener { @@ -321,7 +325,7 @@ class ArticleFragment : Fragment() { rootView.webcontent.loadDataWithBaseURL( baseUrl, - "$c", + "$c", "text/html; charset=utf-8", "utf-8", null diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/settings/SettingsActivity.java b/app/src/main/java/apps/amine/bou/readerforselfoss/settings/SettingsActivity.java index 087aeab..91b1102 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/settings/SettingsActivity.java +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/settings/SettingsActivity.java @@ -20,8 +20,10 @@ import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.preference.SwitchPreference; import android.support.v7.app.ActionBar; +import android.text.Editable; import android.text.InputFilter; import android.text.Spanned; +import android.text.TextWatcher; import android.view.MenuItem; import android.widget.Toast; @@ -131,6 +133,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity { protected boolean isValidFragment(String fragmentName) { return PreferenceFragment.class.getName().equals(fragmentName) || GeneralPreferenceFragment.class.getName().equals(fragmentName) + || ArticleViewerPreferenceFragment.class.getName().equals(fragmentName) || DebugPreferenceFragment.class.getName().equals(fragmentName) || LinksPreferenceFragment.class.getName().equals(fragmentName); } @@ -188,6 +191,56 @@ public class SettingsActivity extends AppCompatPreferenceActivity { } } + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public static class ArticleViewerPreferenceFragment extends PreferenceFragment { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.pref_viewer); + setHasOptionsMenu(true); + + final EditTextPreference fontSize = (EditTextPreference) findPreference("reader_font_size"); + fontSize.getEditText().addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {} + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {} + + @Override + public void afterTextChanged(Editable editable) { + try { + fontSize.getEditText().setTextSize(Integer.parseInt(editable.toString())); + } catch (NumberFormatException e) {} + } + }); + fontSize.getEditText().setFilters(new InputFilter[]{ + new InputFilter() { + + @Override + public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { + try { + int input = Integer.parseInt(dest.toString() + source.toString()); + if (input > 0) + return null; + } catch (NumberFormatException nfe) {} + return ""; + } + } + }); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if (id == android.R.id.home) { + getActivity().finish(); + return true; + } + return super.onOptionsItemSelected(item); + } + } + @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static class DebugPreferenceFragment extends PreferenceFragment { @Override diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/utils/SizeUtils.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/utils/SizeUtils.kt new file mode 100644 index 0000000..46518ba --- /dev/null +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/utils/SizeUtils.kt @@ -0,0 +1,9 @@ +package apps.amine.bou.readerforselfoss.utils + +import android.content.res.Resources + +val Int.toPx: Int + get() = (this * Resources.getSystem().displayMetrics.density).toInt() + +val Int.toDp: Int + get() = (this / Resources.getSystem().displayMetrics.density).toInt() diff --git a/app/src/main/res/drawable-hdpi/ic_chrome_reader_mode_black_24.png b/app/src/main/res/drawable-hdpi/ic_chrome_reader_mode_black_24.png new file mode 100644 index 0000000..3d3ccd5 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_chrome_reader_mode_black_24.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_chrome_reader_mode_black_24.png b/app/src/main/res/drawable-mdpi/ic_chrome_reader_mode_black_24.png new file mode 100644 index 0000000..6eb0b6b Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_chrome_reader_mode_black_24.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_chrome_reader_mode_black_24.png b/app/src/main/res/drawable-xhdpi/ic_chrome_reader_mode_black_24.png new file mode 100644 index 0000000..d4bc567 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_chrome_reader_mode_black_24.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_chrome_reader_mode_black_24.png b/app/src/main/res/drawable-xxhdpi/ic_chrome_reader_mode_black_24.png new file mode 100644 index 0000000..7c4fedd Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_chrome_reader_mode_black_24.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_chrome_reader_mode_black_24.png b/app/src/main/res/drawable-xxxhdpi/ic_chrome_reader_mode_black_24.png new file mode 100644 index 0000000..6ca3403 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_chrome_reader_mode_black_24.png differ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ba594ba..8b7cc0f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -164,4 +164,6 @@ Mark articles as read when swiping between articles. Add to favorites Remove from favorites + Article reader content font size + Article viewer diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index 244b2c1..f34aa1d 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -76,9 +76,5 @@ android:summaryOff="@string/pref_switch_actions_tap_off" android:summaryOn="@string/pref_switch_actions_tap_on" android:title="@string/pref_switch_actions_tap_title" /> - diff --git a/app/src/main/res/xml/pref_headers.xml b/app/src/main/res/xml/pref_headers.xml index 3bcc108..07b54ab 100644 --- a/app/src/main/res/xml/pref_headers.xml +++ b/app/src/main/res/xml/pref_headers.xml @@ -5,6 +5,12 @@ android:icon="@drawable/ic_settings_black_24dp" android:title="@string/pref_header_general"/> + +
+
+ + + +