add buttons for inserting quotes and spoilers.

set the height of the preview based on the expand status.
multisite
Floens 8 years ago
parent 1e59ac664f
commit 077d3167a0
  1. 33
      Clover/app/src/main/java/org/floens/chan/core/presenter/ReplyPresenter.java
  2. 32
      Clover/app/src/main/java/org/floens/chan/ui/layout/ReplyLayout.java
  3. 38
      Clover/app/src/main/res/layout/layout_reply_input.xml
  4. 2
      Clover/app/src/main/res/values/strings.xml

@ -163,6 +163,10 @@ public class ReplyPresenter implements CaptchaCallback, ImagePickDelegate.ImageP
if (!loadable.isThreadMode()) {
callback.openSubject(moreOpen);
}
callback.openCommentQuoteButton(moreOpen);
if (board.spoilers) {
callback.openCommentSpoilerButton(moreOpen);
}
if (previewOpen) {
callback.openFileName(moreOpen);
if (board.spoilers) {
@ -273,6 +277,14 @@ public class ReplyPresenter implements CaptchaCallback, ImagePickDelegate.ImageP
highlightQuotes();
}
public void commentQuoteClicked() {
commentInsert(">");
}
public void commentSpoilerClicked() {
commentInsert("[spoiler]", "[/spoiler]");
}
public void quote(Post post, boolean withText) {
callback.loadViewsIntoDraft(draft);
@ -293,13 +305,20 @@ public class ReplyPresenter implements CaptchaCallback, ImagePickDelegate.ImageP
}
}
draft.comment = new StringBuilder(draft.comment).insert(draft.selection, textToInsert).toString();
commentInsert(textToInsert);
highlightQuotes();
}
draft.selection += textToInsert.length();
private void commentInsert(String insertBefore) {
commentInsert(insertBefore, "");
}
private void commentInsert(String insertBefore, String insertAfter) {
draft.comment = new StringBuilder(draft.comment)
.insert(draft.selection, insertBefore + insertAfter).toString();
draft.selection += insertBefore.length();
callback.loadDraftIntoViews(draft);
highlightQuotes();
}
@Override
@ -330,6 +349,8 @@ public class ReplyPresenter implements CaptchaCallback, ImagePickDelegate.ImageP
callback.openMessage(false, true, "", false);
callback.setExpanded(false);
callback.openSubject(false);
callback.openCommentQuoteButton(false);
callback.openCommentSpoilerButton(false);
callback.openNameOptions(false);
callback.openFileName(false);
callback.openSpoiler(false, false);
@ -438,6 +459,10 @@ public class ReplyPresenter implements CaptchaCallback, ImagePickDelegate.ImageP
void openSubject(boolean open);
void openCommentQuoteButton(boolean open);
void openCommentSpoilerButton(boolean open);
void openFileName(boolean open);
void setFileName(String fileName);

@ -27,7 +27,9 @@ import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.FrameLayout;
@ -85,6 +87,9 @@ public class ReplyLayout extends LoadView implements View.OnClickListener, Reply
private EditText options;
private EditText fileName;
private LinearLayout nameOptions;
private ViewGroup commentButtons;
private Button commentQuoteButton;
private Button commentSpoilerButton;
private SelectionListeningEditText comment;
private TextView commentCounter;
private CheckBox spoiler;
@ -133,6 +138,9 @@ public class ReplyLayout extends LoadView implements View.OnClickListener, Reply
options = replyInputLayout.findViewById(R.id.options);
fileName = replyInputLayout.findViewById(R.id.file_name);
nameOptions = replyInputLayout.findViewById(R.id.name_options);
commentButtons = replyInputLayout.findViewById(R.id.comment_buttons);
commentQuoteButton = replyInputLayout.findViewById(R.id.comment_quote);
commentSpoilerButton = replyInputLayout.findViewById(R.id.comment_spoiler);
comment = replyInputLayout.findViewById(R.id.comment);
commentCounter = replyInputLayout.findViewById(R.id.comment_counter);
spoiler = replyInputLayout.findViewById(R.id.spoiler);
@ -143,6 +151,9 @@ public class ReplyLayout extends LoadView implements View.OnClickListener, Reply
submit = replyInputLayout.findViewById(R.id.submit);
// Setup reply layout views
commentQuoteButton.setOnClickListener(this);
commentSpoilerButton.setOnClickListener(this);
comment.addTextChangedListener(this);
comment.setSelectionChangedListener(this);
@ -224,6 +235,10 @@ public class ReplyLayout extends LoadView implements View.OnClickListener, Reply
// TODO
}*/ else if (v == captchaHardReset) {
authenticationLayout.hardReset();
} else if (v == commentQuoteButton) {
presenter.commentQuoteClicked();
} else if (v == commentSpoilerButton) {
presenter.commentSpoilerClicked();
}
}
@ -336,6 +351,11 @@ public class ReplyLayout extends LoadView implements View.OnClickListener, Reply
comment.setMaxLines(expanded ? 15 : 6);
preview.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
expanded ? dp(150) : dp(100)
));
ValueAnimator animator = ValueAnimator.ofFloat(expanded ? 0f : 1f, expanded ? 1f : 0f);
animator.setInterpolator(new DecelerateInterpolator(2f));
animator.setDuration(400);
@ -355,6 +375,16 @@ public class ReplyLayout extends LoadView implements View.OnClickListener, Reply
subject.setVisibility(open ? View.VISIBLE : View.GONE);
}
@Override
public void openCommentQuoteButton(boolean open) {
commentQuoteButton.setVisibility(open ? View.VISIBLE : View.GONE);
}
@Override
public void openCommentSpoilerButton(boolean open) {
commentSpoilerButton.setVisibility(open ? View.VISIBLE : View.GONE);
}
@Override
public void openFileName(boolean open) {
fileName.setVisibility(open ? View.VISIBLE : View.GONE);
@ -386,7 +416,7 @@ public class ReplyLayout extends LoadView implements View.OnClickListener, Reply
}
if (show) {
ImageDecoder.decodeFileOnBackgroundThread(previewFile, dp(300), dp(200), this);
ImageDecoder.decodeFileOnBackgroundThread(previewFile, dp(400), dp(300), this);
} else {
spoiler.setVisibility(View.GONE);
preview.setVisibility(View.GONE);

@ -118,6 +118,40 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</RelativeLayout>
<LinearLayout
android:id="@+id/comment_buttons"
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
tools:ignore="SpUsage">
<Button
android:id="@+id/comment_quote"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="0dp"
android:padding="0dp"
android:text="@string/reply_comment_button_quote"
android:textAllCaps="false"
android:textSize="15dp"
android:visibility="gone" />
<Button
android:id="@+id/comment_spoiler"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="0dp"
android:padding="0dp"
android:text="@string/reply_comment_button_spoiler"
android:textAllCaps="false"
android:textSize="15dp"
android:visibility="gone" />
</LinearLayout>
<CheckBox
android:id="@+id/spoiler"
android:layout_width="match_parent"
@ -129,8 +163,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<ImageView
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="150dp"
android:scaleType="centerInside"
android:layout_height="100dp"
android:scaleType="fitCenter"
android:visibility="gone" />
<TextView

@ -291,6 +291,8 @@ Re-enable this permission in the app settings if you permanently disabled it."</
<string name="reply_success">Post successful</string>
<string name="reply_captcha_text">Type the text</string>
<string name="reply_more_hint">More options here!</string>
<string name="reply_comment_button_quote">&gt;</string>
<string name="reply_comment_button_spoiler">[s]</string>
<string name="delete_confirm">Delete your post?</string>
<string name="delete_wait">Deleting post&#8230;</string>

Loading…
Cancel
Save