|
|
@ -23,8 +23,10 @@ import android.app.DialogFragment; |
|
|
|
import android.content.DialogInterface; |
|
|
|
import android.content.DialogInterface; |
|
|
|
import android.graphics.Bitmap; |
|
|
|
import android.graphics.Bitmap; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
|
|
|
|
import android.text.Editable; |
|
|
|
import android.text.Selection; |
|
|
|
import android.text.Selection; |
|
|
|
import android.text.TextUtils; |
|
|
|
import android.text.TextUtils; |
|
|
|
|
|
|
|
import android.text.TextWatcher; |
|
|
|
import android.view.Gravity; |
|
|
|
import android.view.Gravity; |
|
|
|
import android.view.KeyEvent; |
|
|
|
import android.view.KeyEvent; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.LayoutInflater; |
|
|
@ -81,6 +83,9 @@ public class ReplyFragment extends DialogFragment { |
|
|
|
private boolean gettingCaptcha = false; |
|
|
|
private boolean gettingCaptcha = false; |
|
|
|
private String captchaChallenge = ""; |
|
|
|
private String captchaChallenge = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int defaultTextColor; |
|
|
|
|
|
|
|
private int maxCommentCount; |
|
|
|
|
|
|
|
|
|
|
|
// Views
|
|
|
|
// Views
|
|
|
|
private View container; |
|
|
|
private View container; |
|
|
|
private ViewFlipper flipper; |
|
|
|
private ViewFlipper flipper; |
|
|
@ -97,6 +102,10 @@ public class ReplyFragment extends DialogFragment { |
|
|
|
private LoadView captchaContainer; |
|
|
|
private LoadView captchaContainer; |
|
|
|
private TextView captchaInput; |
|
|
|
private TextView captchaInput; |
|
|
|
private LoadView responseContainer; |
|
|
|
private LoadView responseContainer; |
|
|
|
|
|
|
|
private Button insertInline; |
|
|
|
|
|
|
|
private Button insertSpoiler; |
|
|
|
|
|
|
|
private Button insertCode; |
|
|
|
|
|
|
|
private TextView commentCountView; |
|
|
|
|
|
|
|
|
|
|
|
private Activity context; |
|
|
|
private Activity context; |
|
|
|
|
|
|
|
|
|
|
@ -180,6 +189,31 @@ public class ReplyFragment extends DialogFragment { |
|
|
|
subjectView.setVisibility(View.GONE); |
|
|
|
subjectView.setVisibility(View.GONE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defaultTextColor = commentView.getCurrentTextColor(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Board b = ChanApplication.getBoardManager().getBoardByValue(loadable.board); |
|
|
|
|
|
|
|
if (b != null) { |
|
|
|
|
|
|
|
insertSpoiler.setVisibility(b.spoilers ? View.VISIBLE : View.GONE); |
|
|
|
|
|
|
|
insertCode.setVisibility(b.codeTags ? View.VISIBLE : View.GONE); |
|
|
|
|
|
|
|
maxCommentCount = b.maxCommentChars; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commentView.addTextChangedListener(new TextWatcher() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void afterTextChanged(Editable s) { |
|
|
|
|
|
|
|
showCommentCount(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
showCommentCount(); |
|
|
|
|
|
|
|
|
|
|
|
getCaptcha(); |
|
|
|
getCaptcha(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Logger.e(TAG, "Loadable in ReplyFragment was null"); |
|
|
|
Logger.e(TAG, "Loadable in ReplyFragment was null"); |
|
|
@ -297,6 +331,32 @@ public class ReplyFragment extends DialogFragment { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
insertInline = (Button) container.findViewById(R.id.insert_inline); |
|
|
|
|
|
|
|
insertInline.setOnClickListener(new OnClickListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(View v) { |
|
|
|
|
|
|
|
insertAtCursor(">", ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
insertSpoiler = (Button) container.findViewById(R.id.insert_spoiler); |
|
|
|
|
|
|
|
insertSpoiler.setOnClickListener(new OnClickListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(View v) { |
|
|
|
|
|
|
|
insertAtCursor("[spoiler]", "[/spoiler]"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
insertCode = (Button) container.findViewById(R.id.insert_code); |
|
|
|
|
|
|
|
insertCode.setOnClickListener(new OnClickListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(View v) { |
|
|
|
|
|
|
|
insertAtCursor("[code]", "[/code]"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commentCountView = (TextView) container.findViewById(R.id.reply_comment_counter); |
|
|
|
|
|
|
|
|
|
|
|
return container; |
|
|
|
return container; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -311,6 +371,24 @@ public class ReplyFragment extends DialogFragment { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void insertAtCursor(String before, String after) { |
|
|
|
|
|
|
|
int pos = commentView.getSelectionStart(); |
|
|
|
|
|
|
|
String text = commentView.getText().toString(); |
|
|
|
|
|
|
|
text = new StringBuilder(text).insert(pos, before + after).toString(); |
|
|
|
|
|
|
|
commentView.setText(text); |
|
|
|
|
|
|
|
commentView.setSelection(pos + before.length()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void showCommentCount() { |
|
|
|
|
|
|
|
int count = commentView.getText().length(); |
|
|
|
|
|
|
|
commentCountView.setText(count + "/" + maxCommentCount); |
|
|
|
|
|
|
|
if (count > maxCommentCount) { |
|
|
|
|
|
|
|
commentCountView.setTextColor(0xffff0000); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
commentCountView.setTextColor(defaultTextColor); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void closeReply() { |
|
|
|
private void closeReply() { |
|
|
|
if (getDialog() != null) { |
|
|
|
if (getDialog() != null) { |
|
|
|
dismiss(); |
|
|
|
dismiss(); |
|
|
|