use compact portrait vertical headlines layout for small screen

devices
This commit is contained in:
Andrew Dolgov 2011-11-30 09:30:19 +03:00
parent adfa14f606
commit 6b2025bb58
6 changed files with 305 additions and 4 deletions

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headlines_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?headlineNormalBackground"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?headlineSeparatorNormal"
android:paddingRight="4dip" >
</ImageView>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="3dip" >
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:singleLine="true"
android:text="There are many variations of passages of Lorem Ipsum available"
android:textSize="16sp" >
</TextView>
<LinearLayout
android:id="@+id/linerLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="@+id/excerpt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
android:textColor="#909090"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:focusable="false" />
<TextView
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Jan 01, 00:00"
android:textColor="#909090"
android:textSize="13sp" />
<ImageView
android:id="@+id/marked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:clickable="true"
android:src="@android:drawable/star_off" />
<ImageView
android:id="@+id/published"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:clickable="true"
android:src="@drawable/ic_rss_bw" >
</ImageView>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headlines_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?headlineSelectedBackground"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?headlineSeparatorSelected"
android:paddingRight="4dip" >
</ImageView>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="3dip" >
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:singleLine="true"
android:text="There are many variations of passages of Lorem Ipsum available"
android:textSize="16sp" >
</TextView>
<LinearLayout
android:id="@+id/linerLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="@+id/excerpt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
android:textColor="#909090"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:focusable="false" />
<TextView
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Jan 01, 00:00"
android:textColor="#909090"
android:textSize="13sp" />
<ImageView
android:id="@+id/marked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:clickable="true"
android:src="@android:drawable/star_off" />
<ImageView
android:id="@+id/published"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:clickable="true"
android:src="@drawable/ic_rss_bw" >
</ImageView>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headlines_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?headlineUnreadBackground"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?headlineSeparatorUnread"
android:paddingRight="4dip" >
</ImageView>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="3dip" >
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:singleLine="true"
android:text="There are many variations of passages of Lorem Ipsum available"
android:textSize="16sp" >
</TextView>
<LinearLayout
android:id="@+id/linerLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="@+id/excerpt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
android:textColor="#909090"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:focusable="false" />
<TextView
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Jan 01, 00:00"
android:textColor="#909090"
android:textSize="13sp" />
<ImageView
android:id="@+id/marked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:clickable="true"
android:src="@android:drawable/star_off" />
<ImageView
android:id="@+id/published"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:clickable="true"
android:src="@drawable/ic_rss_bw" >
</ImageView>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -66,6 +66,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
private int m_selectedFeedId; private int m_selectedFeedId;
private static final String ICON_PATH = "/org.fox.ttrss/icons/"; private static final String ICON_PATH = "/org.fox.ttrss/icons/";
private boolean m_enableFeedIcons; private boolean m_enableFeedIcons;
private boolean m_feedIconsChecked = false;
public interface OnFeedSelectedListener { public interface OnFeedSelectedListener {
public void onFeedSelected(Feed feed); public void onFeedSelected(Feed feed);
@ -118,6 +119,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
if (savedInstanceState != null) { if (savedInstanceState != null) {
m_selectedFeedId = savedInstanceState.getInt("selectedFeedId"); m_selectedFeedId = savedInstanceState.getInt("selectedFeedId");
m_feeds = savedInstanceState.getParcelable("feeds"); m_feeds = savedInstanceState.getParcelable("feeds");
m_feedIconsChecked = savedInstanceState.getBoolean("feedIconsChecked");
} }
View view = inflater.inflate(R.layout.feeds_fragment, container, false); View view = inflater.inflate(R.layout.feeds_fragment, container, false);
@ -165,6 +167,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
out.putInt("selectedFeedId", m_selectedFeedId); out.putInt("selectedFeedId", m_selectedFeedId);
out.putParcelable("feeds", m_feeds); out.putParcelable("feeds", m_feeds);
out.putBoolean("feedIconsChecked", m_feedIconsChecked);
} }
@Override @Override
@ -255,6 +258,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
GetIconsTask git = new GetIconsTask(baseUrl); GetIconsTask git = new GetIconsTask(baseUrl);
git.execute(m_feeds); git.execute(m_feeds);
m_feedIconsChecked = true;
} }
} catch (Exception e) { } catch (Exception e) {
Log.d(TAG, "Error receiving icons configuration"); Log.d(TAG, "Error receiving icons configuration");
@ -307,7 +312,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
else else
setLoadingStatus(R.string.blank, false); setLoadingStatus(R.string.blank, false);
if (m_enableFeedIcons) getFeedIcons(); if (m_enableFeedIcons && !m_feedIconsChecked) getFeedIcons();
return; return;
} }

View File

@ -50,6 +50,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
private ArticleList m_selectedArticles = new ArticleList(); private ArticleList m_selectedArticles = new ArticleList();
private ArticleOps m_articleOps; private ArticleOps m_articleOps;
private boolean m_smallScreenMode = false;
private boolean m_portraitMode = false;
public ArticleList getSelectedArticles() { public ArticleList getSelectedArticles() {
return m_selectedArticles; return m_selectedArticles;
@ -74,11 +76,14 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
m_portraitMode = getActivity().getWindowManager().getDefaultDisplay().getOrientation() % 2 == 0;
if (savedInstanceState != null) { if (savedInstanceState != null) {
m_feed = savedInstanceState.getParcelable("feed"); m_feed = savedInstanceState.getParcelable("feed");
m_articles = savedInstanceState.getParcelable("articles"); m_articles = savedInstanceState.getParcelable("articles");
m_activeArticleId = savedInstanceState.getInt("activeArticleId"); m_activeArticleId = savedInstanceState.getInt("activeArticleId");
m_selectedArticles = savedInstanceState.getParcelable("selectedArticles"); m_selectedArticles = savedInstanceState.getParcelable("selectedArticles");
m_smallScreenMode = savedInstanceState.getBoolean("smallScreenMode");
} }
View view = inflater.inflate(R.layout.headlines_fragment, container, false); View view = inflater.inflate(R.layout.headlines_fragment, container, false);
@ -103,6 +108,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);
m_feed = ((MainActivity)activity).getActiveFeed(); m_feed = ((MainActivity)activity).getActiveFeed();
m_smallScreenMode = ((MainActivity)activity).getSmallScreenMode();
m_articleOps = (ArticleOps) activity; m_articleOps = (ArticleOps) activity;
} }
@ -168,6 +174,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
out.putParcelable("articles", m_articles); out.putParcelable("articles", m_articles);
out.putInt("activeArticleId", m_activeArticleId); out.putInt("activeArticleId", m_activeArticleId);
out.putParcelable("selectedArticles", m_selectedArticles); out.putParcelable("selectedArticles", m_selectedArticles);
out.putBoolean("smallScreenMode", m_smallScreenMode);
} }
public void setLoadingStatus(int status, boolean showProgress) { public void setLoadingStatus(int status, boolean showProgress) {
@ -286,14 +293,14 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
final Article article = items.get(position); final Article article = items.get(position);
if (v == null) { if (v == null) {
int layoutId = R.layout.headlines_row; int layoutId = (m_smallScreenMode && m_portraitMode) ? R.layout.headlines_row_small : R.layout.headlines_row;
switch (getItemViewType(position)) { switch (getItemViewType(position)) {
case VIEW_UNREAD: case VIEW_UNREAD:
layoutId = R.layout.headlines_row_unread; layoutId = (m_smallScreenMode && m_portraitMode) ? R.layout.headlines_row_small_unread : R.layout.headlines_row_unread;
break; break;
case VIEW_SELECTED: case VIEW_SELECTED:
layoutId = R.layout.headlines_row_selected; layoutId = (m_smallScreenMode && m_portraitMode) ? R.layout.headlines_row_small_selected : R.layout.headlines_row_selected;
break; break;
} }

View File

@ -1235,4 +1235,8 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
Log.d(TAG, "onCatSelected"); Log.d(TAG, "onCatSelected");
viewCategory(cat, m_prefs.getBoolean("browse_cats_like_feeds", false)); viewCategory(cat, m_prefs.getBoolean("browse_cats_like_feeds", false));
} }
public boolean getSmallScreenMode() {
return m_smallScreenMode;
}
} }