headline layout tweaks

This commit is contained in:
Andrew Dolgov 2015-07-10 22:48:28 +03:00
parent a0118d6832
commit b218b743bf
3 changed files with 190 additions and 140 deletions

View File

@ -42,6 +42,7 @@ import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.amulyakhare.textdrawable.TextDrawable;
@ -1095,6 +1096,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
holder.flavorImageView.setTag(posterUri);
holder.flavorImageView.setVisibility(View.VISIBLE);
holder.flavorVideoPlayView.setVisibility(View.VISIBLE);
maybeRepositionFlavorImage(view, bitmap);
}
@Override
@ -1174,6 +1177,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
holder.flavorImageView.setTag(thumbUri);
holder.flavorImageView.setVisibility(View.VISIBLE);
holder.flavorVideoPlayView.setVisibility(View.VISIBLE);
maybeRepositionFlavorImage(view, bitmap);
}
@Override
@ -1214,10 +1219,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
if (imgSrc.indexOf("//") == 0)
imgSrc = "http:" + imgSrc;
if (article.flavorImageCount > 1) {
holder.flavorImagePrompt.setVisibility(View.VISIBLE);
}
ViewCompat.setTransitionName(holder.flavorImageView, "TRANSITION:ARTICLE_IMAGES_PAGER");
holder.flavorImageView.setOnClickListener(new OnClickListener() {
@ -1264,6 +1265,12 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
if (bitmap.getWidth() > FLAVOR_IMG_MIN_SIZE && bitmap.getHeight() > FLAVOR_IMG_MIN_SIZE) {
holder.flavorImageView.setVisibility(View.VISIBLE);
if (article.flavorImageCount > 1) {
holder.flavorImagePrompt.setVisibility(View.VISIBLE);
}
maybeRepositionFlavorImage(view, bitmap);
}
}
@ -1286,8 +1293,11 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
} else {
holder.flavorImageView.setVisibility(View.VISIBLE);
}
if (article.flavorImageCount > 1) {
holder.flavorImagePrompt.setVisibility(View.VISIBLE);
}
}
}
}
}
@ -1360,6 +1370,32 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
return v;
}
public int pxToDp(int px) {
DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
int dp = Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
return dp;
}
private void maybeRepositionFlavorImage(View view, Bitmap bitmap) {
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) view.getLayoutParams();
int w = bitmap.getWidth();
int h = bitmap.getHeight();
float r = h != 0 ? (float)w/h : 0;
//Log.d(TAG, "XYR: " + pxToDp(w) + " " + pxToDp(h) + " " + r);
if (pxToDp(bitmap.getHeight()) < 300 || r >= 1.2) {
lp.addRule(RelativeLayout.BELOW, R.id.headline_header);
} else {
lp.addRule(RelativeLayout.BELOW, 0);
//lp.removeRule(RelativeLayout.BELOW);
}
view.setLayoutParams(lp);
}
private void adjustTitleTextView(int score, TextView tv, int position) {
int viewType = getItemViewType(position);
if (origTitleColors[viewType] == null)

View File

@ -28,28 +28,89 @@
android:id="@+id/flavorImageLoadingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<org.fox.ttrss.util.EnlargingImageView
android:id="@+id/flavor_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/headline_header"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:scaleType="fitCenter"
android:src="@drawable/drawer_header"
android:visibility="visible" />
<ImageView
android:id="@+id/flavor_video_play"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:scaleType="fitXY"
android:src="@drawable/flavor_video_play"
android:visibility="gone" />
android:visibility="visible" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<org.fox.ttrss.util.EnlargingImageView
android:id="@+id/flavor_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:scaleType="fitCenter"
android:src="@drawable/drawer_header"
android:visibility="visible"
android:layout_centerHorizontal="true" />
<RelativeLayout
android:id="@+id/headline_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ccffffff"
android:padding="16dp">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="2"
android:gravity="center_vertical"
android:paddingBottom="8dp"
android:singleLine="false"
android:text="Sample entry title"
android:textColor="?headlineExcerptTextColor"
android:textSize="18sp"
android:textStyle="normal" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:orientation="horizontal">
<TextView
android:id="@+id/feed_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
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" />
<TextView
android:id="@+id/date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ellipsize="none"
android:fontFamily="sans-serif-light"
android:gravity="right|center_vertical"
android:singleLine="true"
android:text="Jan 01, 12:00, 1970"
android:textColor="?headlineSecondaryTextColor"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="@+id/flavor_image_prompt"
@ -61,62 +122,7 @@
android:text="@string/flavor_image_prompt"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/primary_text_dark"
android:visibility="gone" />
<RelativeLayout
android:id="@+id/headline_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ccffffff"
android:padding="16dp">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="2"
android:gravity="center_vertical"
android:paddingBottom="8dp"
android:singleLine="false"
android:text="Sample entry title"
android:textColor="?headlineExcerptTextColor"
android:textSize="18sp"
android:textStyle="normal" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:orientation="horizontal">
<TextView
android:id="@+id/feed_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
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" />
<TextView
android:id="@+id/date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ellipsize="none"
android:fontFamily="sans-serif-light"
android:gravity="right|center_vertical"
android:singleLine="true"
android:text="Jan 01, 12:00, 1970"
android:textColor="?headlineSecondaryTextColor"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
android:visibility="visible" />
</FrameLayout>
</TableRow>

View File

@ -31,17 +31,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center" />
<org.fox.ttrss.util.EnlargingImageView
android:id="@+id/flavor_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:scaleType="fitCenter"
android:src="@drawable/drawer_header"
android:visibility="visible" />
<ImageView
android:id="@+id/flavor_video_play"
android:layout_width="match_parent"
@ -51,6 +40,79 @@
android:src="@drawable/flavor_video_play"
android:visibility="gone" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.fox.ttrss.util.EnlargingImageView
android:id="@+id/flavor_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:scaleType="fitCenter"
android:src="@drawable/drawer_header"
android:visibility="visible"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<RelativeLayout
android:id="@+id/headline_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ccffffff"
android:padding="16dp">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="2"
android:gravity="center_vertical"
android:paddingBottom="8dp"
android:singleLine="false"
android:text="Sample entry title"
android:textColor="?headlineUnreadTextColor"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:orientation="horizontal">
<TextView
android:id="@+id/feed_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
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" />
<TextView
android:id="@+id/date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ellipsize="none"
android:fontFamily="sans-serif-light"
android:gravity="right|center_vertical"
android:singleLine="true"
android:text="Jan 01, 12:00, 1970"
android:textColor="?headlineSecondaryTextColor"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="@+id/flavor_image_prompt"
android:layout_width="match_parent"
@ -61,62 +123,8 @@
android:text="@string/flavor_image_prompt"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/primary_text_dark"
android:visibility="gone" />
android:visibility="visible" />
<RelativeLayout
android:id="@+id/headline_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ccffffff"
android:padding="16dp">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="2"
android:gravity="center_vertical"
android:paddingBottom="8dp"
android:singleLine="false"
android:text="Sample entry title"
android:textColor="?headlineUnreadTextColor"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:orientation="horizontal">
<TextView
android:id="@+id/feed_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
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" />
<TextView
android:id="@+id/date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ellipsize="none"
android:fontFamily="sans-serif-light"
android:gravity="right|center_vertical"
android:singleLine="true"
android:text="Jan 01, 12:00, 1970"
android:textColor="?headlineSecondaryTextColor"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
</FrameLayout>
</TableRow>