Show file size on posts, with option to turn it off

multisite
Floens 10 years ago
parent fed5e5e1a9
commit b0f3a0690b
  1. 6
      Clover/app/src/main/java/org/floens/chan/core/model/Post.java
  2. 4
      Clover/app/src/main/java/org/floens/chan/core/model/PostImage.java
  3. 2
      Clover/app/src/main/java/org/floens/chan/core/net/ChanReaderRequest.java
  4. 2
      Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java
  5. 2
      Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java
  6. 12
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostCell.java
  7. 6
      Clover/app/src/main/java/org/floens/chan/ui/controller/AdvancedSettingsController.java
  8. 1
      Clover/app/src/main/res/values/strings.xml

@ -68,6 +68,8 @@ public class Post {
public boolean hasImage = false;
public PostImage image;
public String thumbnailUrl;
public String imageUrl;
@ -84,7 +86,7 @@ public class Post {
public long time = -1;
public int fileSize;
public long fileSize;
public String rawComment;
@ -173,6 +175,8 @@ public class Post {
} else {
thumbnailUrl = ChanUrls.getThumbnailUrl(board, Long.toString(tim));
}
image = new PostImage(String.valueOf(tim), thumbnailUrl, imageUrl, filename, ext, imageWidth, imageHeight, spoiler, fileSize);
}
if (!TextUtils.isEmpty(country)) {

@ -30,10 +30,11 @@ public class PostImage {
public int imageWidth;
public int imageHeight;
public boolean spoiler;
public long size;
public Type type;
public PostImage(String originalName, String thumbnailUrl, String imageUrl, String filename, String extension, int imageWidth, int imageHeight, boolean spoiler) {
public PostImage(String originalName, String thumbnailUrl, String imageUrl, String filename, String extension, int imageWidth, int imageHeight, boolean spoiler, long size) {
this.originalName = originalName;
this.thumbnailUrl = thumbnailUrl;
this.imageUrl = imageUrl;
@ -42,6 +43,7 @@ public class PostImage {
this.imageWidth = imageWidth;
this.imageHeight = imageHeight;
this.spoiler = spoiler;
this.size = size;
switch (extension) {
case "gif":

@ -269,7 +269,7 @@ public class ChanReaderRequest extends JsonReaderRequest<ChanReaderRequest.ChanR
post.imageHeight = reader.nextInt();
break;
case "fsize":
post.fileSize = reader.nextInt();
post.fileSize = reader.nextLong();
break;
case "sub":
post.subject = reader.nextString();

@ -353,7 +353,7 @@ public class ThreadPresenter implements ChanLoader.ChanLoaderCallback, PostAdapt
for (int i = 0; i < posts.size(); i++) {
Post item = posts.get(i);
if (item.hasImage) {
images.add(new PostImage(String.valueOf(item.tim), item.thumbnailUrl, item.imageUrl, item.filename, item.ext, item.imageWidth, item.imageHeight, item.spoiler));
images.add(post.image);
if (item.no == post.no) {
index = images.size() - 1;
}

@ -88,6 +88,7 @@ public class ChanSettings {
public static final BooleanSetting tapNoReply;
public static final BooleanSetting volumeKeysScrolling;
public static final BooleanSetting postFullDate;
public static final BooleanSetting postFileInfo;
public static final BooleanSetting watchEnabled;
public static final BooleanSetting watchCountdown;
@ -150,6 +151,7 @@ public class ChanSettings {
tapNoReply = new BooleanSetting(p, "preference_tap_no_reply", false);
volumeKeysScrolling = new BooleanSetting(p, "preference_volume_key_scrolling", false);
postFullDate = new BooleanSetting(p, "preference_post_full_date", false);
postFileInfo = new BooleanSetting(p, "preference_post_file_info", true);
watchEnabled = new BooleanSetting(p, "preference_watch_enabled", false, new Setting.SettingCallback<Boolean>() {
@Override

@ -52,6 +52,7 @@ import com.android.volley.toolbox.ImageLoader;
import org.floens.chan.Chan;
import org.floens.chan.R;
import org.floens.chan.core.model.Post;
import org.floens.chan.core.model.PostImage;
import org.floens.chan.core.model.PostLinkable;
import org.floens.chan.core.settings.ChanSettings;
import org.floens.chan.ui.helper.PostHelper;
@ -60,6 +61,7 @@ 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.ThumbnailView;
import org.floens.chan.utils.AndroidUtils;
import org.floens.chan.utils.Time;
import java.util.ArrayList;
@ -336,8 +338,16 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin
Resources.getSystem().updateConfiguration(c, null);
}
String fileInfo = "";
if (ChanSettings.postFileInfo.get() && post.hasImage) {
PostImage image = post.image;
fileInfo = "\n" + image.extension.toUpperCase() + " " +
AndroidUtils.getReadableFileSize(image.size, false) + " " +
image.imageWidth + "x" + image.imageHeight;
}
String noText = "No." + post.no;
SpannableString date = new SpannableString(noText + " " + time);
SpannableString date = new SpannableString(noText + " " + time + fileInfo);
date.setSpan(new ForegroundColorSpan(theme.detailsColor), 0, date.length(), 0);
date.setSpan(new AbsoluteSizeSpan(detailsSizePx), 0, date.length(), 0);
if (ChanSettings.tapNoReply.get()) {

@ -46,6 +46,7 @@ public class AdvancedSettingsController extends SettingsController {
private LinkSettingView saveLocation;
private SettingView forcePhoneLayoutSetting;
private SettingView postFullDate;
private SettingView postFileInfo;
private boolean needRestart;
public AdvancedSettingsController(Context context) {
@ -83,8 +84,8 @@ public class AdvancedSettingsController extends SettingsController {
needRestart = true;
}
if (item == postFullDate) {
EventBus.getDefault().post(new RefreshUIMessage("postdate"));
if (item == postFullDate || item == postFileInfo) {
EventBus.getDefault().post(new RefreshUIMessage("postui"));
}
}
@ -124,6 +125,7 @@ public class AdvancedSettingsController extends SettingsController {
settings.add(new BooleanSettingView(this, ChanSettings.tapNoReply, string(R.string.setting_tap_no_rely), null));
settings.add(new BooleanSettingView(this, ChanSettings.volumeKeysScrolling, string(R.string.setting_volume_key_scrolling), null));
postFullDate = settings.add(new BooleanSettingView(this, ChanSettings.postFullDate, string(R.string.setting_post_full_date), null));
postFileInfo = settings.add(new BooleanSettingView(this, ChanSettings.postFileInfo, string(R.string.setting_post_file_info), null));
groups.add(settings);

@ -330,6 +330,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="setting_tap_no_rely">Tap the post number to reply</string>
<string name="setting_volume_key_scrolling">Volume keys scroll content</string>
<string name="setting_post_full_date">Show the full date on posts</string>
<string name="setting_post_file_info">Show file info on posts</string>
<string name="settings_group_proxy">HTTP Proxy</string>
<string name="setting_proxy_enabled">Enable proxy</string>

Loading…
Cancel
Save