add fab button to article fragment

This commit is contained in:
Andrew Dolgov 2014-11-08 00:57:08 +04:00
parent e7ed44307c
commit a509415720
9 changed files with 77 additions and 9 deletions

View File

@ -33,4 +33,5 @@ dependencies {
compile 'com.android.support:support-v4:21.0.0' compile 'com.android.support:support-v4:21.0.0'
compile 'com.google.code.gson:gson:2.2.4' compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:appcompat-v7:21.0.0' compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.shamanland:fab:0.0.5'
} }

View File

@ -82,6 +82,7 @@
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="cardview-v7-21.0.0" level="project" /> <orderEntry type="library" exported="" name="cardview-v7-21.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.0" level="project" /> <orderEntry type="library" exported="" name="support-annotations-21.0.0" level="project" />
<orderEntry type="library" exported="" name="fab-0.0.5" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.0" level="project" /> <orderEntry type="library" exported="" name="support-v4-21.0.0" level="project" />
<orderEntry type="library" exported="" name="dashclock-api-r1.1" level="project" /> <orderEntry type="library" exported="" name="dashclock-api-r1.1" level="project" />
<orderEntry type="library" exported="" name="systembartint-1.0.3" level="project" /> <orderEntry type="library" exported="" name="systembartint-1.0.3" level="project" />

View File

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

View File

@ -23,6 +23,8 @@ import android.webkit.WebView;
import android.webkit.WebView.HitTestResult; import android.webkit.WebView.HitTestResult;
import android.widget.TextView; import android.widget.TextView;
import com.shamanland.fab.ShowHideOnScroll;
import org.fox.ttrss.types.Article; import org.fox.ttrss.types.Article;
import org.fox.ttrss.types.Attachment; import org.fox.ttrss.types.Attachment;
import org.fox.ttrss.util.TypefaceCache; import org.fox.ttrss.util.TypefaceCache;
@ -93,7 +95,31 @@ public class ArticleFragment extends Fragment {
View view = inflater.inflate(useTitleWebView ? R.layout.article_fragment_compat : R.layout.article_fragment, container, false); View view = inflater.inflate(useTitleWebView ? R.layout.article_fragment_compat : R.layout.article_fragment, container, false);
if (m_article != null) { if (m_article != null) {
View scrollView = view.findViewById(R.id.article_scrollview);
View fab = view.findViewById(R.id.article_fab);
if (scrollView != null && fab != null) {
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);
}
}
});
}
/* if (!useTitleWebView) { /* if (!useTitleWebView) {
View scroll = view.findViewById(R.id.article_scrollview); View scroll = view.findViewById(R.id.article_scrollview);

View File

@ -27,6 +27,8 @@ import android.webkit.WebView;
import android.webkit.WebView.HitTestResult; import android.webkit.WebView.HitTestResult;
import android.widget.TextView; import android.widget.TextView;
import com.shamanland.fab.ShowHideOnScroll;
import org.fox.ttrss.CommonActivity; import org.fox.ttrss.CommonActivity;
import org.fox.ttrss.R; import org.fox.ttrss.R;
import org.fox.ttrss.util.ImageCacheService; import org.fox.ttrss.util.ImageCacheService;
@ -133,8 +135,33 @@ public class OfflineArticleFragment extends Fragment {
m_cursor.moveToFirst(); m_cursor.moveToFirst();
if (m_cursor.isFirst()) { if (m_cursor.isFirst()) {
final String link = m_cursor.getString(m_cursor.getColumnIndex("link"));
if (!useTitleWebView) { if (!useTitleWebView) {
View scroll = view.findViewById(R.id.article_scrollview); View scrollView = view.findViewById(R.id.article_scrollview);
View fab = view.findViewById(R.id.article_fab);
if (scrollView != null && fab != null) {
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);
}
}
});
}
/* View scroll = view.findViewById(R.id.article_scrollview);
if (scroll != null) { if (scroll != null) {
final float scale = getResources().getDisplayMetrics().density; final float scale = getResources().getDisplayMetrics().density;
@ -152,7 +179,7 @@ public class OfflineArticleFragment extends Fragment {
} }
} } */
} }
int articleFontSize = Integer.parseInt(m_prefs.getString("article_font_size_sp", "16")); int articleFontSize = Integer.parseInt(m_prefs.getString("article_font_size_sp", "16"));
@ -160,8 +187,6 @@ public class OfflineArticleFragment extends Fragment {
TextView title = (TextView)view.findViewById(R.id.title); TextView title = (TextView)view.findViewById(R.id.title);
final String link = m_cursor.getString(m_cursor.getColumnIndex("link"));
if (title != null) { if (title != null) {
if (m_prefs.getBoolean("enable_condensed_fonts", false)) { if (m_prefs.getBoolean("enable_condensed_fonts", false)) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1,4 +1,4 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/article_fragment" android:id="@+id/article_fragment"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -101,5 +101,14 @@
</LinearLayout> </LinearLayout>
</org.fox.ttrss.util.NoChildFocusScrollView> </org.fox.ttrss.util.NoChildFocusScrollView>
<com.shamanland.fab.FloatingActionButton
android:id="@+id/article_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginRight="16dp"
android:layout_marginBottom="20dp"
android:src="@drawable/ic_action_web_site"
/>
</RelativeLayout> </FrameLayout>

View File

@ -30,6 +30,7 @@
<item name="parentBtnBackground">#dddddd</item> <item name="parentBtnBackground">#dddddd</item>
<item name="articleHeader">?colorPrimaryDark</item> <item name="articleHeader">?colorPrimaryDark</item>
<item name="articleHeaderTextColor">@android:color/white</item> <item name="articleHeaderTextColor">@android:color/white</item>
<item name="floatingActionButtonStyle">@style/FabTheme</item>
<item name="colorPrimary">#6482af</item> <item name="colorPrimary">#6482af</item>
<item name="colorPrimaryDark">#526A8E</item> <item name="colorPrimaryDark">#526A8E</item>
@ -79,6 +80,7 @@
<item name="headlineSelectedSecondaryTextColor">#a0a0a0</item> <item name="headlineSelectedSecondaryTextColor">#a0a0a0</item>
<item name="articleHeader">?colorPrimaryDark</item> <item name="articleHeader">?colorPrimaryDark</item>
<item name="articleHeaderTextColor">@android:color/white</item> <item name="articleHeaderTextColor">@android:color/white</item>
<item name="floatingActionButtonStyle">@style/FabTheme</item>
<item name="colorPrimary">#51698E</item> <item name="colorPrimary">#51698E</item>
<item name="colorPrimaryDark">#445877</item> <item name="colorPrimaryDark">#445877</item>
@ -87,4 +89,8 @@
<style name="DarkDialogTheme" parent="android:Theme"></style> <style name="DarkDialogTheme" parent="android:Theme"></style>
<style name="FabTheme" parent="FloatingActionButton">
<item name="floatingActionButtonColor">?colorPrimaryDark</item>
</style>
</resources> </resources>