implement compact headline mode

This commit is contained in:
Andrew Dolgov 2014-11-13 21:42:10 +03:00
parent 4f6ac1ef05
commit 89823f32f1
15 changed files with 553 additions and 36 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="282"
android:versionName="1.74" >
android:versionCode="283"
android:versionName="1.75" >
<uses-sdk
android:minSdkVersion="10"

View File

@ -302,6 +302,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
m_compactLayoutMode = savedInstanceState.getBoolean("compactLayoutMode");
}
if ("HL_COMPACT".equals(m_prefs.getString("headline_mode", "HL_DEFAULT")))
m_compactLayoutMode = true;
DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
m_maxImageSize = (int) (128 * metrics.density + 0.5);
@ -329,6 +332,11 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
ListView list = (ListView)view.findViewById(R.id.headlines_list);
if (!m_compactLayoutMode) {
list.setDividerHeight(0);
list.setDivider(null);
}
if (m_prefs.getBoolean("headlines_mark_read_scroll", false)) {
WindowManager wm = (WindowManager) m_activity.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
@ -654,20 +662,20 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
int headlineSmallFontSize = Math.max(10, Math.min(18, headlineFontSize - 2));
if (v == null) {
int layoutId = R.layout.headlines_row;
int layoutId = m_compactLayoutMode ? R.layout.headlines_row_compact : R.layout.headlines_row;
switch (getItemViewType(position)) {
switch (getItemViewType(position)) {
case VIEW_LOADMORE:
layoutId = R.layout.headlines_row_loadmore;
break;
case VIEW_UNREAD:
layoutId = R.layout.headlines_row_unread;
layoutId = m_compactLayoutMode ? R.layout.headlines_row_unread_compact : R.layout.headlines_row_unread;
break;
case VIEW_SELECTED:
layoutId = R.layout.headlines_row_selected;
layoutId = m_compactLayoutMode ? R.layout.headlines_row_selected_compact : R.layout.headlines_row_selected;
break;
case VIEW_SELECTED_UNREAD:
layoutId = R.layout.headlines_row_selected_unread;
layoutId = m_compactLayoutMode ? R.layout.headlines_row_selected_unread_compact : R.layout.headlines_row_selected_unread;
break;
}
@ -796,7 +804,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
}
if (!m_compactLayoutMode) {
if (holder.flavorImageView != null && m_prefs.getBoolean("headlines_show_flavor_image", true)) {
boolean showFlavorImage = "HL_DEFAULT".equals(m_prefs.getString("headline_mode", "HL_DEFAULT"));
if (holder.flavorImageView != null && showFlavorImage) {
holder.flavorImageArrow.setVisibility(View.GONE);
Document doc = Jsoup.parse(articleContent);

View File

@ -285,6 +285,9 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
m_activity.getWritableDb().execSQL("UPDATE articles SET selected = 0 ");
}
if ("HL_COMPACT".equals(m_prefs.getString("headline_mode", "HL_DEFAULT")))
m_compactLayoutMode = true;
View view = inflater.inflate(R.layout.headlines_fragment, container, false);
m_swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.headlines_swipe_container);
@ -307,6 +310,11 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
ListView list = (ListView)view.findViewById(R.id.headlines_list);
if (!m_compactLayoutMode) {
list.setDividerHeight(0);
list.setDivider(null);
}
if (m_prefs.getBoolean("headlines_mark_read_scroll", false)) {
WindowManager wm = (WindowManager) m_activity.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
@ -501,22 +509,22 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
int headlineSmallFontSize = Math.max(10, Math.min(18, headlineFontSize - 2));
if (v == null) {
int layoutId = R.layout.headlines_row;
int layoutId = m_compactLayoutMode ? R.layout.headlines_row_compact : R.layout.headlines_row;
switch (getItemViewType(position)) {
case VIEW_LOADMORE:
layoutId = R.layout.headlines_row_loadmore;
break;
case VIEW_UNREAD:
layoutId = R.layout.headlines_row_unread;
break;
case VIEW_SELECTED_UNREAD:
layoutId = R.layout.headlines_row_selected_unread;
break;
case VIEW_SELECTED:
layoutId = R.layout.headlines_row_selected;
break;
}
switch (getItemViewType(position)) {
case VIEW_LOADMORE:
layoutId = R.layout.headlines_row_loadmore;
break;
case VIEW_UNREAD:
layoutId = m_compactLayoutMode ? R.layout.headlines_row_unread_compact : R.layout.headlines_row_unread;
break;
case VIEW_SELECTED:
layoutId = m_compactLayoutMode ? R.layout.headlines_row_selected_compact : R.layout.headlines_row_selected;
break;
case VIEW_SELECTED_UNREAD:
layoutId = m_compactLayoutMode ? R.layout.headlines_row_selected_unread_compact : R.layout.headlines_row_selected_unread;
break;
}
LayoutInflater vi = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(layoutId, null);

View File

@ -20,6 +20,7 @@
android:orientation="horizontal" >
<FrameLayout
android:paddingRight="4dp"
android:id="@+id/headlines_fragment"
android:layout_width="0dp"
android:layout_height="match_parent"

View File

@ -13,8 +13,6 @@
android:id="@+id/headlines_list"
android:layout_width="match_parent"
android:layoutAnimation="@anim/layout_headline"
android:dividerHeight="0dp"
android:divider="@null"
android:layout_height="match_parent" >
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>

View File

@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headlines_row"
android:padding="8dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?headlineNormalBackground"
tools:ignore="HardcodedText" >
<CheckBox
android:id="@+id/selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_gravity="center"
android:focusable="false" />
<LinearLayout
android:layout_weight="1"
android:orientation="vertical"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:singleLine="true"
android:ellipsize="end"
android:text="Sample entry title"
android:textColor="?headlineUnreadTextColor"
android:textSize="18sp"
android:layout_span="2" />
<TextView
android:id="@+id/excerpt"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
android:textColor="?headlineExcerptTextColor"
android:textSize="13sp"
android:layout_span="2" />
<LinearLayout
android:paddingTop="2dp"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/feed_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:singleLine="true"
android:text="Example Feed AAA AAA AAAAAA AAAA AAAAA AA A A AA AA"
android:textColor="?headlineSecondaryTextColor"
android:textSize="12sp"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/headline_footer"
android:orientation="vertical"
android:layout_weight="0"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:singleLine="true"
android:ellipsize="none"
android:layout_weight="1"
android:text="Jan 01, 12:00, 1970"
android:textColor="?headlineSecondaryTextColor"
android:textSize="12sp"
/>
<ImageView
android:id="@+id/marked"
android:layout_width="16dp"
android:layout_gravity="bottom|right"
android:layout_height="16dp"
android:layout_weight="0"
android:clickable="true"
android:src="@drawable/ic_star_empty" />
</LinearLayout>
<!-- <ImageView
android:id="@+id/article_menu_button"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="16dp"
android:layout_weight="0"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:src="@drawable/ic_action_overflow" /> -->
</LinearLayout>

View File

@ -150,7 +150,7 @@
android:gravity="center_vertical"
android:singleLine="true"
android:text="by Author"
android:textColor="?headlineSecondaryTextColor"
android:textColor="?headlineSelectedSecondaryTextColor"
android:textSize="12sp"
android:textStyle="italic" />

View File

@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headlines_row"
android:padding="8dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?headlineSelectedBackground"
tools:ignore="HardcodedText" >
<CheckBox
android:id="@+id/selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_gravity="center"
android:focusable="false" />
<LinearLayout
android:layout_weight="1"
android:orientation="vertical"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:singleLine="true"
android:ellipsize="end"
android:text="Sample entry title"
android:textColor="?headlineSelectedTextColor"
android:textSize="18sp"
android:layout_span="2" />
<TextView
android:id="@+id/excerpt"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
android:textColor="?headlineSelectedExcerptTextColor"
android:textSize="13sp"
android:layout_span="2" />
<LinearLayout
android:paddingTop="2dp"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/feed_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:singleLine="true"
android:text="Example Feed AAA AAA AAAAAA AAAA AAAAA AA A A AA AA"
android:textColor="?headlineSelectedSecondaryTextColor"
android:textSize="12sp"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/headline_footer"
android:orientation="vertical"
android:layout_weight="0"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:singleLine="true"
android:ellipsize="none"
android:layout_weight="1"
android:text="Jan 01, 12:00, 1970"
android:textColor="?headlineSelectedSecondaryTextColor"
android:textSize="12sp"
/>
<ImageView
android:id="@+id/marked"
android:layout_width="16dp"
android:layout_gravity="bottom|right"
android:layout_height="16dp"
android:layout_weight="0"
android:clickable="true"
android:src="@drawable/ic_star_empty" />
</LinearLayout>
<!-- <ImageView
android:id="@+id/article_menu_button"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="16dp"
android:layout_weight="0"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:src="@drawable/ic_action_overflow" /> -->
</LinearLayout>

View File

@ -151,7 +151,7 @@
android:gravity="center_vertical"
android:singleLine="true"
android:text="by Author"
android:textColor="?headlineSecondaryTextColor"
android:textColor="?headlineSelectedSecondaryTextColor"
android:textSize="12sp"
android:textStyle="italic" />

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headlines_row"
android:padding="8dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?headlineSelectedBackground"
tools:ignore="HardcodedText" >
<CheckBox
android:id="@+id/selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_gravity="center"
android:focusable="false" />
<LinearLayout
android:layout_weight="1"
android:orientation="vertical"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:singleLine="true"
android:ellipsize="end"
android:text="Sample entry title"
android:textColor="?headlineSelectedTextColor"
android:textStyle="bold"
android:textSize="18sp"
android:layout_span="2" />
<TextView
android:id="@+id/excerpt"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
android:textColor="?headlineSelectedExcerptTextColor"
android:textSize="13sp"
android:layout_span="2" />
<LinearLayout
android:paddingTop="2dp"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/feed_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:singleLine="true"
android:text="Example Feed AAA AAA AAAAAA AAAA AAAAA AA A A AA AA"
android:textColor="?headlineSelectedSecondaryTextColor"
android:textSize="12sp"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/headline_footer"
android:orientation="vertical"
android:layout_weight="0"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:singleLine="true"
android:ellipsize="none"
android:layout_weight="1"
android:text="Jan 01, 12:00, 1970"
android:textColor="?headlineSelectedSecondaryTextColor"
android:textSize="12sp"
/>
<ImageView
android:id="@+id/marked"
android:layout_width="16dp"
android:layout_gravity="bottom|right"
android:layout_height="16dp"
android:layout_weight="0"
android:clickable="true"
android:src="@drawable/ic_star_empty" />
</LinearLayout>
<!-- <ImageView
android:id="@+id/article_menu_button"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="16dp"
android:layout_weight="0"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:src="@drawable/ic_action_overflow" /> -->
</LinearLayout>

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headlines_row"
android:padding="8dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?headlineUnreadBackground"
tools:ignore="HardcodedText" >
<CheckBox
android:id="@+id/selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_gravity="center"
android:focusable="false" />
<LinearLayout
android:layout_weight="1"
android:orientation="vertical"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:singleLine="true"
android:ellipsize="end"
android:text="Sample entry title"
android:textColor="?headlineUnreadTextColor"
android:textStyle="bold"
android:textSize="18sp"
android:layout_span="2" />
<TextView
android:id="@+id/excerpt"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
android:textColor="?headlineExcerptTextColor"
android:textSize="13sp"
android:layout_span="2" />
<LinearLayout
android:paddingTop="2dp"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/feed_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:singleLine="true"
android:text="Example Feed AAA AAA AAAAAA AAAA AAAAA AA A A AA AA"
android:textColor="?headlineSecondaryTextColor"
android:textSize="12sp"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/headline_footer"
android:orientation="vertical"
android:layout_weight="0"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:singleLine="true"
android:ellipsize="none"
android:layout_weight="1"
android:text="Jan 01, 12:00, 1970"
android:textColor="?headlineSecondaryTextColor"
android:textSize="12sp"
/>
<ImageView
android:id="@+id/marked"
android:layout_width="16dp"
android:layout_gravity="bottom|right"
android:layout_height="16dp"
android:layout_weight="0"
android:clickable="true"
android:src="@drawable/ic_star_empty" />
</LinearLayout>
<!-- <ImageView
android:id="@+id/article_menu_button"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="16dp"
android:layout_weight="0"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:src="@drawable/ic_action_overflow" /> -->
</LinearLayout>

View File

@ -11,6 +11,16 @@
<item>THEME_SEPIA</item>
<item>THEME_AMBER</item>
</string-array>
<string-array name="headline_mode_names">
<item>@string/headline_display_mode_default</item>
<item>@string/headline_display_mode_no_images</item>
<item>@string/headline_display_mode_compact</item>
</string-array>
<string-array name="headline_mode_values" translatable="false">
<item>HL_DEFAULT</item>
<item>HL_NOIMAGES</item>
<item>HL_COMPACT</item>
</string-array>
<string-array name="pref_offline_amounts" translatable="false">
<item>150</item>
<item>250</item>

View File

@ -254,5 +254,9 @@
<string name="prefs_enable_fab">Enable FAB</string>
<string name="prefs_enable_fab_long">Show floating action button when reading</string>
<string name="prefs_open_fresh_on_startup">Open Fresh articles on startup</string>
<string name="prefs_headline_display_mode">Headline display mode</string>
<string name="prefs_headline_display_mode_long">Cards, cards with images, or compact mode</string>
<string name="headline_display_mode_default">Default</string>
<string name="headline_display_mode_no_images">No images</string>
<string name="headline_display_mode_compact">Compact</string>
</resources>

View File

@ -7,7 +7,7 @@
<item name="unreadCounterColor">#909090</item>
<item name="headlinesBackground">#f0f0f0</item>
<item name="articleBackground">@android:color/white</item>
<item name="headlineSelectedBackground">?colorAccent</item>
<item name="headlineSelectedBackground">#88b0f0</item>
<item name="headlineUnreadBackground">@android:color/white</item>
<item name="headlineNormalBackground">#f5f5f5</item>
<item name="feedsSelectedBackground">?colorPrimaryDark</item>
@ -17,7 +17,7 @@
<item name="headlineSelectedTextColor">#ffffff</item>
<item name="headlineExcerptTextColor">@android:color/secondary_text_light</item>
<item name="headlineSecondaryTextColor">#909090</item>
<item name="headlineSelectedSecondaryTextColor">#606060</item>
<item name="headlineSelectedSecondaryTextColor">?headlineSelectedExcerptTextColor</item>
<item name="headlineSelectedExcerptTextColor">@android:color/secondary_text_light</item>
<item name="headlineTitleHighScoreUnreadTextColor">#008000</item>
<item name="linkColor">?colorPrimary</item>
@ -92,8 +92,8 @@
<item name="headlineSecondaryTextColor">#909090</item>
<item name="headlineTitleHighScoreUnreadTextColor">#00FF00</item>
<item name="headlineSelectedExcerptTextColor">@android:color/secondary_text_dark</item>
<item name="headlineSelectedSecondaryTextColor">#a0a0a0</item>
<item name="headlineSelectedBackground">?colorPrimary</item>
<item name="headlineSelectedSecondaryTextColor">?headlineSelectedExcerptTextColor</item>
<item name="headlineSelectedBackground">#88b0f0</item>
<item name="headlineUnreadBackground">#383c42</item>
<item name="linkColor">?colorPrimary</item>
<item name="loadingBackground">@android:color/black</item>

View File

@ -85,10 +85,10 @@
android:summary="@string/pref_headlines_show_content_long"
android:title="@string/pref_headlines_show_content" />
<CheckBoxPreference
<!-- <CheckBoxPreference
android:defaultValue="true"
android:key="headlines_show_flavor_image"
android:title="@string/prefs_headlines_show_flavor_image" />
android:title="@string/prefs_headlines_show_flavor_image" /> -->
<!-- <CheckBoxPreference
android:defaultValue="false"
@ -114,6 +114,14 @@
android:dialogMessage="@string/pref_headline_font_size"
android:title="@string/pref_headline_font_size" />
<ListPreference
android:defaultValue="HL_DEFAULT"
android:entries="@array/headline_mode_names"
android:entryValues="@array/headline_mode_values"
android:key="headline_mode"
android:summary="@string/prefs_headline_display_mode_long"
android:title="@string/prefs_headline_display_mode" />
<CheckBoxPreference
android:defaultValue="true"
android:key="open_fresh_on_startup"