DistilledViewPrefs

Additional

Language
Java
Version
1.1 (Sep 30, 2015)
Created
Sep 27, 2015
Updated
Sep 30, 2015
Owner
QVDev
Contributor
QVDev
1
Activity
Badge
Generate
Download
Source code
APK file

Advertising

DistilledViewPrefs

Dialog for Android TextView to improve readability. Mostly used for applications where the main focus is to read. Spin-off from the blog https://medium.com/@qvdev/improving-readability-3baa2d943936

Please feel free to post feedback on any topic. Improvements, code related or suggestions. Fork it if you feel for it as well. :)

Screens

Implementation example

Add this to your gradle build file

repositories {
    maven { url "https://github.com/QVDev/DistilledViewPrefs/raw/master/releases/" }
}

dependencies {
    compile 'distilledview.utils.qvdev.com.distilled:distilledview-lib:1.1'
}

Register for preference changes. Take the default as the library does as well

//Let your class implement
implements SharedPreferences.OnSharedPreferenceChangeListener

//Register for listener and set text view defaults
private void initTextViewWithPreferedOptions() {                 

//Register
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);

//Get the text view
mDemoTextView = (TextView) findViewById(R.id.example_text_view);

//Restore
restorePreferedTextViewOptions();
}

private void restorePreferedTextViewOptions() {   
//Call the DistilledPagePrefsView to restore stored values
DistilledPagePrefsView.restorePreferedOptions(mDemoTextView);

}

And now let the preferences do the magic

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String preferenceName) {

DistilledPagePrefsView.applyToTextView(mDemoTextView, sharedPreferences, preferenceName);

}

And last but not least call the dialog where you want it via

public void showDistilledDialog() {
    DistilledPagePrefsView.showDialog(this);
}