Add play icon to webm thumbnails

multisite
Floens 9 years ago
parent 674a1804e6
commit 59f23b2d8c
  1. 7
      Clover/app/src/main/java/org/floens/chan/ui/cell/AlbumViewCell.java
  2. 12
      Clover/app/src/main/java/org/floens/chan/ui/cell/CardPostCell.java
  3. 9
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostCell.java
  4. 8
      Clover/app/src/main/java/org/floens/chan/ui/controller/AlbumDownloadController.java
  5. 7
      Clover/app/src/main/java/org/floens/chan/ui/controller/AlbumViewController.java
  6. 3
      Clover/app/src/main/java/org/floens/chan/ui/controller/DrawerController.java
  7. 95
      Clover/app/src/main/java/org/floens/chan/ui/view/PostImageThumbnailView.java
  8. BIN
      Clover/app/src/main/res/drawable-hdpi/ic_play_circle_outline_white_24dp.png
  9. BIN
      Clover/app/src/main/res/drawable-mdpi/ic_play_circle_outline_white_24dp.png
  10. BIN
      Clover/app/src/main/res/drawable-xhdpi/ic_play_circle_outline_white_24dp.png
  11. BIN
      Clover/app/src/main/res/drawable-xxhdpi/ic_play_circle_outline_white_24dp.png
  12. BIN
      Clover/app/src/main/res/drawable-xxxhdpi/ic_play_circle_outline_white_24dp.png
  13. 2
      Clover/app/src/main/res/layout/cell_album_download.xml
  14. 2
      Clover/app/src/main/res/layout/cell_album_view.xml
  15. 9
      Clover/app/src/main/res/layout/cell_header.xml
  16. 2
      Clover/app/src/main/res/layout/cell_post.xml
  17. 2
      Clover/app/src/main/res/layout/cell_post_card.xml

@ -24,6 +24,7 @@ import android.widget.TextView;
import org.floens.chan.R;
import org.floens.chan.core.model.PostImage;
import org.floens.chan.ui.view.PostImageThumbnailView;
import org.floens.chan.ui.view.ThumbnailView;
import org.floens.chan.utils.AndroidUtils;
@ -33,7 +34,7 @@ import static org.floens.chan.utils.AndroidUtils.getString;
public class AlbumViewCell extends FrameLayout {
private PostImage postImage;
private ThumbnailView thumbnailView;
private PostImageThumbnailView thumbnailView;
private TextView text;
public AlbumViewCell(Context context) {
@ -51,7 +52,7 @@ public class AlbumViewCell extends FrameLayout {
@Override
protected void onFinishInflate() {
super.onFinishInflate();
thumbnailView = (ThumbnailView) findViewById(R.id.thumbnail_view);
thumbnailView = (PostImageThumbnailView) findViewById(R.id.thumbnail_view);
text = (TextView) findViewById(R.id.text);
}
@ -59,7 +60,7 @@ public class AlbumViewCell extends FrameLayout {
this.postImage = postImage;
// Keep this the same as the normal thumbnails to improve performance
int thumbnailSize = getDimen(getContext(), R.dimen.cell_post_thumbnail_size);
thumbnailView.setUrl(postImage.thumbnailUrl, thumbnailSize, thumbnailSize);
thumbnailView.setPostImage(postImage, thumbnailSize, thumbnailSize);
String filename = postImage.spoiler ? getString(R.string.image_spoiler_filename) : postImage.filename + "." + postImage.extension;
String details = postImage.extension.toUpperCase() + " " + postImage.imageWidth + "x" + postImage.imageHeight +

@ -31,12 +31,12 @@ import org.floens.chan.R;
import org.floens.chan.core.model.Post;
import org.floens.chan.core.settings.ChanSettings;
import org.floens.chan.ui.layout.FixedRatioLinearLayout;
import org.floens.chan.ui.text.FastTextView;
import org.floens.chan.ui.theme.Theme;
import org.floens.chan.ui.theme.ThemeHelper;
import org.floens.chan.ui.text.FastTextView;
import org.floens.chan.ui.view.FixedRatioThumbnailView;
import org.floens.chan.ui.view.FloatingMenu;
import org.floens.chan.ui.view.FloatingMenuItem;
import org.floens.chan.ui.view.PostImageThumbnailView;
import org.floens.chan.ui.view.ThumbnailView;
import java.util.ArrayList;
@ -53,7 +53,7 @@ public class CardPostCell extends CardView implements PostCellInterface, View.On
private PostCellInterface.PostCellCallback callback;
private FixedRatioLinearLayout content;
private FixedRatioThumbnailView thumbnailView;
private PostImageThumbnailView thumbnailView;
private TextView title;
private FastTextView comment;
private TextView replies;
@ -78,7 +78,7 @@ public class CardPostCell extends CardView implements PostCellInterface, View.On
content = (FixedRatioLinearLayout) findViewById(R.id.card_content);
content.setRatio(9f / 16f);
thumbnailView = (FixedRatioThumbnailView) findViewById(R.id.thumbnail);
thumbnailView = (PostImageThumbnailView) findViewById(R.id.thumbnail);
thumbnailView.setRatio(16f / 9f);
thumbnailView.setOnClickListener(this);
title = (TextView) findViewById(R.id.title);
@ -186,10 +186,10 @@ public class CardPostCell extends CardView implements PostCellInterface, View.On
if (post.hasImage) {
thumbnailView.setVisibility(View.VISIBLE);
thumbnailView.setUrl(post.thumbnailUrl, thumbnailView.getWidth(), thumbnailView.getHeight());
thumbnailView.setPostImage(post.image, thumbnailView.getWidth(), thumbnailView.getHeight());
} else {
thumbnailView.setVisibility(View.GONE);
thumbnailView.setUrl(null, 0, 0);
thumbnailView.setPostImage(null, 0, 0);
}
if (post.filterHighlightedColor != 0) {

@ -65,6 +65,7 @@ import org.floens.chan.ui.theme.Theme;
import org.floens.chan.ui.theme.ThemeHelper;
import org.floens.chan.ui.view.FloatingMenu;
import org.floens.chan.ui.view.FloatingMenuItem;
import org.floens.chan.ui.view.PostImageThumbnailView;
import org.floens.chan.ui.view.ThumbnailView;
import org.floens.chan.utils.AndroidUtils;
import org.floens.chan.utils.Time;
@ -83,7 +84,7 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin
private static final String TAG = "PostCell";
private static final int COMMENT_MAX_LENGTH_BOARD = 350;
private ThumbnailView thumbnailView;
private PostImageThumbnailView thumbnailView;
private FastTextView title;
private PostIcons icons;
private TextView comment;
@ -137,7 +138,7 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin
protected void onFinishInflate() {
super.onFinishInflate();
thumbnailView = (ThumbnailView) findViewById(R.id.thumbnail_view);
thumbnailView = (PostImageThumbnailView) findViewById(R.id.thumbnail_view);
title = (FastTextView) findViewById(R.id.title);
icons = (PostIcons) findViewById(R.id.icons);
comment = (TextView) findViewById(R.id.comment);
@ -322,10 +323,10 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin
if (post.hasImage) {
thumbnailView.setVisibility(View.VISIBLE);
thumbnailView.setUrl(post.thumbnailUrl, thumbnailView.getLayoutParams().width, thumbnailView.getLayoutParams().height);
thumbnailView.setPostImage(post.image, thumbnailView.getLayoutParams().width, thumbnailView.getLayoutParams().height);
} else {
thumbnailView.setVisibility(View.GONE);
thumbnailView.setUrl(null, 0, 0);
thumbnailView.setPostImage(null, 0, 0);
}
List<CharSequence> titleParts = new ArrayList<>(5);

@ -42,7 +42,7 @@ import org.floens.chan.ui.toolbar.ToolbarMenu;
import org.floens.chan.ui.toolbar.ToolbarMenuItem;
import org.floens.chan.ui.view.FloatingMenuItem;
import org.floens.chan.ui.view.GridRecyclerView;
import org.floens.chan.ui.view.ThumbnailView;
import org.floens.chan.ui.view.PostImageThumbnailView;
import org.floens.chan.utils.RecyclerUtils;
import java.util.ArrayList;
@ -211,7 +211,7 @@ public class AlbumDownloadController extends Controller implements ToolbarMenuIt
public void onBindViewHolder(AlbumDownloadCell holder, int position) {
AlbumDownloadItem item = items.get(position);
holder.thumbnailView.setUrl(item.postImage.thumbnailUrl, dp(100), dp(100));
holder.thumbnailView.setPostImage(item.postImage, dp(100), dp(100));
setItemChecked(holder, item.checked, false);
}
@ -228,13 +228,13 @@ public class AlbumDownloadController extends Controller implements ToolbarMenuIt
private class AlbumDownloadCell extends RecyclerView.ViewHolder implements View.OnClickListener {
private ImageView checkbox;
private ThumbnailView thumbnailView;
private PostImageThumbnailView thumbnailView;
public AlbumDownloadCell(View itemView) {
super(itemView);
itemView.getLayoutParams().height = recyclerView.getRealSpanWidth();
checkbox = (ImageView) itemView.findViewById(R.id.checkbox);
thumbnailView = (ThumbnailView) itemView.findViewById(R.id.thumbnail_view);
thumbnailView = (PostImageThumbnailView) itemView.findViewById(R.id.thumbnail_view);
itemView.setOnClickListener(this);
}

@ -33,6 +33,7 @@ import org.floens.chan.ui.toolbar.ToolbarMenu;
import org.floens.chan.ui.toolbar.ToolbarMenuItem;
import org.floens.chan.ui.view.FloatingMenuItem;
import org.floens.chan.ui.view.GridRecyclerView;
import org.floens.chan.ui.view.PostImageThumbnailView;
import org.floens.chan.ui.view.ThumbnailView;
import java.util.ArrayList;
@ -93,7 +94,7 @@ public class AlbumViewController extends Controller implements ImageViewerContro
@Override
public void onSubMenuItemClicked(ToolbarMenuItem parent, FloatingMenuItem item) {
switch ((Integer)item.getId()) {
switch ((Integer) item.getId()) {
case SAVE_ALBUM_ID:
AlbumDownloadController albumDownloadController = new AlbumDownloadController(context);
albumDownloadController.setPostImages(loadable, postImages);
@ -183,12 +184,12 @@ public class AlbumViewController extends Controller implements ImageViewerContro
private class AlbumItemCellHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private AlbumViewCell cell;
private ThumbnailView thumbnailView;
private PostImageThumbnailView thumbnailView;
public AlbumItemCellHolder(View itemView) {
super(itemView);
cell = (AlbumViewCell) itemView;
thumbnailView = (ThumbnailView) itemView.findViewById(R.id.thumbnail_view);
thumbnailView = (PostImageThumbnailView) itemView.findViewById(R.id.thumbnail_view);
thumbnailView.setOnClickListener(this);
}

@ -40,6 +40,7 @@ import org.floens.chan.controller.Controller;
import org.floens.chan.controller.NavigationController;
import org.floens.chan.core.manager.WatchManager;
import org.floens.chan.core.model.Pin;
import org.floens.chan.core.settings.ChanSettings;
import org.floens.chan.ui.adapter.PinAdapter;
import org.floens.chan.utils.AndroidUtils;
@ -155,7 +156,7 @@ public class DrawerController extends Controller implements PinAdapter.Callback,
if (headerAction == PinAdapter.HeaderAction.SETTINGS) {
openController(new WatchSettingsController(context));
} else if (headerAction == PinAdapter.HeaderAction.CLEAR || headerAction == PinAdapter.HeaderAction.CLEAR_ALL) {
boolean all = headerAction == PinAdapter.HeaderAction.CLEAR_ALL;
boolean all = headerAction == PinAdapter.HeaderAction.CLEAR_ALL || !ChanSettings.watchEnabled.get();
final List<Pin> pins = watchManager.clearPins(all);
if (!pins.isEmpty()) {
String text = context.getResources().getQuantityString(R.plurals.bookmark, pins.size(), pins.size());

@ -0,0 +1,95 @@
/*
* Clover - 4chan browser https://github.com/Floens/Clover/
* Copyright (C) 2014 Floens
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.floens.chan.ui.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import org.floens.chan.R;
import org.floens.chan.core.model.PostImage;
public class PostImageThumbnailView extends ThumbnailView {
private PostImage postImage;
private Drawable playIcon;
private Rect bounds = new Rect();
private float ratio = 0f;
public PostImageThumbnailView(Context context) {
this(context, null);
}
public PostImageThumbnailView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@SuppressWarnings("deprecation")
public PostImageThumbnailView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
playIcon = getResources().getDrawable(R.drawable.ic_play_circle_outline_white_24dp);
}
public void setPostImage(PostImage postImage, int width, int height) {
if (this.postImage != postImage) {
this.postImage = postImage;
if (postImage != null) {
setUrl(postImage.thumbnailUrl, width, height);
} else {
setUrl(null, width, height);
}
}
}
public void setRatio(float ratio) {
this.ratio = ratio;
}
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
if (postImage != null && postImage.type == PostImage.Type.MOVIE) {
int x = (int) (getWidth() / 2.0 - playIcon.getIntrinsicWidth() / 2.0);
int y = (int) (getHeight() / 2.0 - playIcon.getIntrinsicHeight() / 2.0);
bounds.set(x, y, x + playIcon.getIntrinsicWidth(), y + playIcon.getIntrinsicHeight());
playIcon.setBounds(bounds);
playIcon.draw(canvas);
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (ratio == 0f) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
} else {
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
if (MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY && (heightMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.AT_MOST)) {
int width = MeasureSpec.getSize(widthMeasureSpec);
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec((int) (width / ratio), MeasureSpec.EXACTLY));
} else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1023 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:layout_height="0dp"
tools:ignore="ContentDescription,RtlHardcoded,RtlSymmetry">
<org.floens.chan.ui.view.ThumbnailView
<org.floens.chan.ui.view.PostImageThumbnailView
android:id="@+id/thumbnail_view"
android:layout_width="match_parent"
android:layout_height="match_parent"

@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:layout_height="wrap_content"
android:layout_margin="1dp">
<org.floens.chan.ui.view.ThumbnailView
<org.floens.chan.ui.view.PostImageThumbnailView
android:id="@+id/thumbnail_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />

@ -39,8 +39,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:layout_width="56dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:scaleType="center"
tools:ignore="ContentDescription" />
@ -49,8 +49,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:layout_width="56dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:layout_marginRight="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:scaleType="center"
tools:ignore="ContentDescription" />

@ -34,7 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:layout_width="match_parent"
android:layout_height="wrap_content">
<org.floens.chan.ui.view.ThumbnailView
<org.floens.chan.ui.view.PostImageThumbnailView
android:id="@+id/thumbnail_view"
android:layout_width="@dimen/cell_post_thumbnail_size"
android:layout_height="@dimen/cell_post_thumbnail_size"

@ -36,7 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:layout_width="match_parent"
android:layout_height="wrap_content">
<org.floens.chan.ui.view.FixedRatioThumbnailView
<org.floens.chan.ui.view.PostImageThumbnailView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

Loading…
Cancel
Save