Add warning for too large filesize

captchafix
Floens 11 years ago
parent 8be192aa61
commit dc5a465f29
  1. 18
      Clover/app/src/main/java/org/floens/chan/ui/fragment/ReplyFragment.java
  2. 11
      Clover/app/src/main/res/layout/reply_input.xml
  3. 2
      Clover/app/src/main/res/values/strings.xml

@ -105,6 +105,7 @@ public class ReplyFragment extends DialogFragment {
private Button insertSpoiler; private Button insertSpoiler;
private Button insertCode; private Button insertCode;
private TextView commentCountView; private TextView commentCountView;
private TextView fileStatusView;
private Activity context; private Activity context;
@ -357,6 +358,8 @@ public class ReplyFragment extends DialogFragment {
commentCountView = (TextView) container.findViewById(R.id.reply_comment_counter); commentCountView = (TextView) container.findViewById(R.id.reply_comment_counter);
fileStatusView = (TextView) container.findViewById(R.id.reply_file_status);
return container; return container;
} }
@ -457,6 +460,7 @@ public class ReplyFragment extends DialogFragment {
fileNameView.setVisibility(View.GONE); fileNameView.setVisibility(View.GONE);
spoilerImageView.setVisibility(View.GONE); spoilerImageView.setVisibility(View.GONE);
spoilerImageView.setChecked(false); spoilerImageView.setChecked(false);
fileStatusView.setVisibility(View.GONE);
} else { } else {
fileButton.setImageResource(ThemeHelper.getInstance().getTheme().isLightTheme ? R.drawable.ic_action_cancel : R.drawable.ic_action_cancel_dark); fileButton.setImageResource(ThemeHelper.getInstance().getTheme().isLightTheme ? R.drawable.ic_action_cancel : R.drawable.ic_action_cancel_dark);
fileNameView.setVisibility(View.VISIBLE); fileNameView.setVisibility(View.VISIBLE);
@ -465,6 +469,20 @@ public class ReplyFragment extends DialogFragment {
Board b = ChanApplication.getBoardManager().getBoardByValue(loadable.board); Board b = ChanApplication.getBoardManager().getBoardByValue(loadable.board);
spoilerImageView.setVisibility(b != null && b.spoilers ? View.VISIBLE : View.GONE); spoilerImageView.setVisibility(b != null && b.spoilers ? View.VISIBLE : View.GONE);
if (b != null) {
boolean probablyWebm = name.endsWith(".webm");
int maxSize = probablyWebm ? b.maxWebmSize : b.maxFileSize;
if (file.length() > maxSize) {
String fileSize = Utils.getReadableFileSize((int) file.length(), false);
String maxSizeString = Utils.getReadableFileSize(maxSize, false);
String text = getString(probablyWebm ? R.string.reply_webm_too_big : R.string.reply_file_too_big, fileSize, maxSizeString);
fileStatusView.setVisibility(View.VISIBLE);
fileStatusView.setText(text);
} else {
fileStatusView.setVisibility(View.GONE);
}
}
imageViewContainer.setVisibility(View.VISIBLE); imageViewContainer.setVisibility(View.VISIBLE);
imageViewContainer.setView(null); imageViewContainer.setView(null);
imageViewContainer.post(new Runnable() { imageViewContainer.post(new Runnable() {

@ -67,9 +67,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:id="@+id/reply_comment_counter" android:id="@+id/reply_comment_counter"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingRight="8dp"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentTop="true" /> android:layout_alignParentTop="true"
android:paddingRight="8dp" />
</RelativeLayout> </RelativeLayout>
@ -133,6 +133,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/reply_file_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:textSize="14sp" />
<CheckBox <CheckBox
android:id="@+id/reply_spoiler_image" android:id="@+id/reply_spoiler_image"
android:layout_width="match_parent" android:layout_width="match_parent"

@ -116,6 +116,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="reply_subject">Subject</string> <string name="reply_subject">Subject</string>
<string name="reply_comment">Comment</string> <string name="reply_comment">Comment</string>
<string name="reply_file_name">File name</string> <string name="reply_file_name">File name</string>
<string name="reply_file_too_big">Warning: File size too big (%1$s / %2$s)</string>
<string name="reply_webm_too_big">Warning: WebM size too big (%1$s / %2$s)</string>
<string name="reply_spoiler_image">Spoiler image</string> <string name="reply_spoiler_image">Spoiler image</string>
<string name="reply_no_preview">No preview available</string> <string name="reply_no_preview">No preview available</string>

Loading…
Cancel
Save