add preference to disable fab

This commit is contained in:
Andrew Dolgov 2014-11-12 10:32:21 +04:00
parent fba3486928
commit 487d05e6c0
5 changed files with 47 additions and 32 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss"
android:versionCode="278"
android:versionName="1.70" >
android:versionCode="279"
android:versionName="1.71" >
<uses-sdk
android:minSdkVersion="9"

View File

@ -100,23 +100,27 @@ public class ArticleFragment extends Fragment {
View fab = view.findViewById(R.id.article_fab);
if (scrollView != null && fab != null) {
scrollView.setOnTouchListener(new ShowHideOnScroll(fab));
if (m_prefs.getBoolean("enable_article_fab", true)) {
scrollView.setOnTouchListener(new ShowHideOnScroll(fab));
fab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
try {
URL url = new URL(m_article.link.trim());
String uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(),
url.getPort(), url.getPath(), url.getQuery(), url.getRef()).toString();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
m_activity.toast(R.string.error_other_error);
fab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
try {
URL url = new URL(m_article.link.trim());
String uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(),
url.getPort(), url.getPath(), url.getQuery(), url.getRef()).toString();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
m_activity.toast(R.string.error_other_error);
}
}
}
});
});
} else {
fab.setVisibility(View.GONE);
}
}

View File

@ -142,23 +142,27 @@ public class OfflineArticleFragment extends Fragment {
View fab = view.findViewById(R.id.article_fab);
if (scrollView != null && fab != null) {
scrollView.setOnTouchListener(new ShowHideOnScroll(fab));
if (m_prefs.getBoolean("enable_article_fab", true)) {
scrollView.setOnTouchListener(new ShowHideOnScroll(fab));
fab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
try {
URL url = new URL(link.trim());
String uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(),
url.getPort(), url.getPath(), url.getQuery(), url.getRef()).toString();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
m_activity.toast(R.string.error_other_error);
fab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
try {
URL url = new URL(link.trim());
String uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(),
url.getPort(), url.getPath(), url.getQuery(), url.getRef()).toString();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
m_activity.toast(R.string.error_other_error);
}
}
}
});
});
} else {
fab.setVisibility(View.GONE);
}
}
/* View scroll = view.findViewById(R.id.article_scrollview);

View File

@ -250,5 +250,7 @@
<string name="headlines_sort_articles_title">Sort articles</string>
<string name="fresh_articles">Fresh articles</string>
<string name="feed_all_articles">All articles</string>
<string name="prefs_enable_fab">Enable FAB</string>
<string name="prefs_enable_fab_long">Show floating action button while reading</string>
</resources>

View File

@ -143,6 +143,11 @@
android:defaultValue="true"
android:key="confirm_headlines_catchup"
android:title="@string/prefs_confirm_headlines_catchup" />
<CheckBoxPreference
android:defaultValue="true"
android:key="enable_article_fab"
android:summary="@string/prefs_enable_fab_long"
android:title="@string/prefs_enable_fab" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/offline_mode" >
<ListPreference