Add option to show filenames on posts

multisite
Floens 10 years ago
parent 139d9bfb77
commit f1881efdc1
  1. 2
      Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java
  2. 46
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostCell.java
  3. 4
      Clover/app/src/main/java/org/floens/chan/ui/controller/AdvancedSettingsController.java
  4. 1
      Clover/app/src/main/res/values/strings.xml

@ -89,6 +89,7 @@ public class ChanSettings {
public static final BooleanSetting volumeKeysScrolling;
public static final BooleanSetting postFullDate;
public static final BooleanSetting postFileInfo;
public static final BooleanSetting postFilename;
public static final BooleanSetting watchEnabled;
public static final BooleanSetting watchCountdown;
@ -152,6 +153,7 @@ public class ChanSettings {
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);
postFilename = new BooleanSetting(p, "preference_post_filename", false);
watchEnabled = new BooleanSetting(p, "preference_watch_enabled", false, new Setting.SettingCallback<Boolean>() {
@Override

@ -38,6 +38,7 @@ import android.text.style.BackgroundColorSpan;
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@ -314,15 +315,14 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin
thumbnailView.setUrl(null, 0, 0);
}
CharSequence[] titleParts = new CharSequence[post.subjectSpan == null ? 2 : 4];
int titlePartsCount = 0;
List<CharSequence> titleParts = new ArrayList<>(5);
if (post.subjectSpan != null) {
titleParts[titlePartsCount++] = post.subjectSpan;
titleParts[titlePartsCount++] = "\n";
titleParts.add(post.subjectSpan);
titleParts.add("\n");
}
titleParts[titlePartsCount++] = post.nameTripcodeIdCapcodeSpan;
titleParts.add(post.nameTripcodeIdCapcodeSpan);
CharSequence time;
if (ChanSettings.postFullDate.get()) {
@ -338,24 +338,38 @@ 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 + fileInfo);
SpannableString date = new SpannableString(noText + " " + time);
date.setSpan(new ForegroundColorSpan(theme.detailsColor), 0, date.length(), 0);
date.setSpan(new AbsoluteSizeSpan(detailsSizePx), 0, date.length(), 0);
titleParts.add(date);
if (ChanSettings.tapNoReply.get()) {
date.setSpan(new NoClickableSpan(), 0, noText.length(), 0);
}
titleParts[titlePartsCount] = date;
title.setText(TextUtils.concat(titleParts));
if (post.hasImage) {
PostImage image = post.image;
boolean postFileName = ChanSettings.postFilename.get();
if (postFileName) {
SpannableString fileInfo = new SpannableString("\n" + image.filename + "." + image.extension);
fileInfo.setSpan(new ForegroundColorSpan(theme.detailsColor), 0, fileInfo.length(), 0);
fileInfo.setSpan(new AbsoluteSizeSpan(detailsSizePx), 0, fileInfo.length(), 0);
fileInfo.setSpan(new UnderlineSpan(), 0, fileInfo.length(), 0);
titleParts.add(fileInfo);
}
if (ChanSettings.postFileInfo.get()) {
SpannableString fileInfo = new SpannableString((postFileName ? " " : "\n") + image.extension.toUpperCase() + " " +
AndroidUtils.getReadableFileSize(image.size, false) + " " +
image.imageWidth + "x" + image.imageHeight);
fileInfo.setSpan(new ForegroundColorSpan(theme.detailsColor), 0, fileInfo.length(), 0);
fileInfo.setSpan(new AbsoluteSizeSpan(detailsSizePx), 0, fileInfo.length(), 0);
titleParts.add(fileInfo);
}
}
title.setText(TextUtils.concat(titleParts.toArray(new CharSequence[titleParts.size()])));
iconsSpannable = new SpannableString("");

@ -48,6 +48,7 @@ public class AdvancedSettingsController extends SettingsController {
private SettingView forcePhoneLayoutSetting;
private SettingView postFullDate;
private SettingView postFileInfo;
private SettingView postFilename;
private SettingView anonymize;
private SettingView anonymizeIds;
private SettingView tapNoReply;
@ -87,7 +88,7 @@ public class AdvancedSettingsController extends SettingsController {
needRestart = true;
}
if (item == postFullDate || item == postFileInfo || item == anonymize || item == anonymizeIds || item == tapNoReply) {
if (item == postFullDate || item == postFileInfo || item == anonymize || item == anonymizeIds || item == tapNoReply || item == postFilename) {
EventBus.getDefault().post(new RefreshUIMessage("postui"));
}
}
@ -129,6 +130,7 @@ public class AdvancedSettingsController extends SettingsController {
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));
postFilename = settings.add(new BooleanSettingView(this, ChanSettings.postFilename, string(R.string.setting_post_filename), null));
groups.add(settings);

@ -346,6 +346,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<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="setting_post_filename">Show filename on posts</string>
<string name="settings_group_proxy">HTTP Proxy</string>
<string name="setting_proxy_enabled">Enable proxy</string>

Loading…
Cancel
Save