Change behavior when hidden or shown
This commit is contained in:
parent
1a0a017782
commit
3775db50da
|
@ -138,6 +138,7 @@ public class Status implements Parcelable{
|
||||||
private boolean cached = false;
|
private boolean cached = false;
|
||||||
private boolean autoHiddenCW = false;
|
private boolean autoHiddenCW = false;
|
||||||
private boolean customFeaturesDisplayed = false;
|
private boolean customFeaturesDisplayed = false;
|
||||||
|
private boolean shortReply = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
@ -199,6 +200,7 @@ public class Status implements Parcelable{
|
||||||
dest.writeByte(this.cached ? (byte) 1 : (byte) 0);
|
dest.writeByte(this.cached ? (byte) 1 : (byte) 0);
|
||||||
dest.writeByte(this.autoHiddenCW ? (byte) 1 : (byte) 0);
|
dest.writeByte(this.autoHiddenCW ? (byte) 1 : (byte) 0);
|
||||||
dest.writeByte(this.customFeaturesDisplayed ? (byte) 1 : (byte) 0);
|
dest.writeByte(this.customFeaturesDisplayed ? (byte) 1 : (byte) 0);
|
||||||
|
dest.writeByte(this.shortReply ? (byte) 1 : (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Status(Parcel in) {
|
protected Status(Parcel in) {
|
||||||
|
@ -262,6 +264,7 @@ public class Status implements Parcelable{
|
||||||
this.cached = in.readByte() != 0;
|
this.cached = in.readByte() != 0;
|
||||||
this.autoHiddenCW = in.readByte() != 0;
|
this.autoHiddenCW = in.readByte() != 0;
|
||||||
this.customFeaturesDisplayed = in.readByte() != 0;
|
this.customFeaturesDisplayed = in.readByte() != 0;
|
||||||
|
this.shortReply = in.readByte() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<Status> CREATOR = new Creator<Status>() {
|
public static final Creator<Status> CREATOR = new Creator<Status>() {
|
||||||
|
@ -334,6 +337,13 @@ public class Status implements Parcelable{
|
||||||
this.content = Helper.remove_tracking_param(content);
|
this.content = Helper.remove_tracking_param(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShortReply() {
|
||||||
|
return shortReply;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShortReply(boolean shortReply) {
|
||||||
|
this.shortReply = shortReply;
|
||||||
|
}
|
||||||
public Status getReblog() {
|
public Status getReblog() {
|
||||||
return reblog;
|
return reblog;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.webkit.URLUtil;
|
import android.webkit.URLUtil;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
|
@ -88,6 +89,8 @@ import com.github.stom79.mytransl.client.Results;
|
||||||
import com.github.stom79.mytransl.translate.Translate;
|
import com.github.stom79.mytransl.translate.Translate;
|
||||||
import com.varunest.sparkbutton.SparkButton;
|
import com.varunest.sparkbutton.SparkButton;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -115,6 +118,7 @@ import app.fedilab.android.client.Entities.TagTimeline;
|
||||||
import app.fedilab.android.helper.CrossActions;
|
import app.fedilab.android.helper.CrossActions;
|
||||||
import app.fedilab.android.helper.CustomTextView;
|
import app.fedilab.android.helper.CustomTextView;
|
||||||
import app.fedilab.android.helper.Helper;
|
import app.fedilab.android.helper.Helper;
|
||||||
|
import app.fedilab.android.helper.MastalabAutoCompleteTextView;
|
||||||
import app.fedilab.android.jobs.ScheduledBoostsSyncJob;
|
import app.fedilab.android.jobs.ScheduledBoostsSyncJob;
|
||||||
import app.fedilab.android.sqlite.AccountDAO;
|
import app.fedilab.android.sqlite.AccountDAO;
|
||||||
import app.fedilab.android.sqlite.Sqlite;
|
import app.fedilab.android.sqlite.Sqlite;
|
||||||
|
@ -181,6 +185,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
private Status toot;
|
private Status toot;
|
||||||
private TagTimeline tagTimeline;
|
private TagTimeline tagTimeline;
|
||||||
public static boolean fetch_all_more = false;
|
public static boolean fetch_all_more = false;
|
||||||
|
private RecyclerView mRecyclerView;
|
||||||
|
|
||||||
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, List<Status> statuses){
|
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, List<Status> statuses){
|
||||||
super();
|
super();
|
||||||
|
@ -384,6 +389,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
TextView number_votes, remaining_time;
|
TextView number_votes, remaining_time;
|
||||||
Button submit_vote, refresh_poll;
|
Button submit_vote, refresh_poll;
|
||||||
|
|
||||||
|
|
||||||
|
MastalabAutoCompleteTextView quick_reply_text;
|
||||||
|
ImageView quick_reply_switch_to_full;
|
||||||
|
TextView toot_space_left;
|
||||||
|
ImageView quick_reply_emoji;
|
||||||
|
Button quick_reply_button;
|
||||||
|
|
||||||
public View getView(){
|
public View getView(){
|
||||||
return itemView;
|
return itemView;
|
||||||
}
|
}
|
||||||
|
@ -495,6 +507,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
status_account_bot = itemView.findViewById(R.id.status_account_bot);
|
status_account_bot = itemView.findViewById(R.id.status_account_bot);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
quick_reply_text = itemView.findViewById(R.id.quick_reply_text);
|
||||||
|
quick_reply_switch_to_full = itemView.findViewById(R.id.quick_reply_switch_to_full);
|
||||||
|
toot_space_left = itemView.findViewById(R.id.toot_space_left);
|
||||||
|
quick_reply_emoji = itemView.findViewById(R.id.quick_reply_emoji);
|
||||||
|
quick_reply_button = itemView.findViewById(R.id.quick_reply_button);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2121,14 +2140,30 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
holder.status_cardview_video.setVisibility(View.GONE);
|
holder.status_cardview_video.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( status.isShortReply()){
|
||||||
|
holder.quick_reply_container.setVisibility(View.VISIBLE);
|
||||||
|
}else{
|
||||||
|
holder.quick_reply_container.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
holder.status_reply.setOnClickListener(new View.OnClickListener() {
|
holder.status_reply.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (holder.quick_reply_container.getVisibility() == View.GONE)
|
status.setShortReply(!status.isShortReply());
|
||||||
holder.quick_reply_container.setVisibility(View.VISIBLE);
|
if( status.isShortReply()){
|
||||||
else
|
holder.quick_reply_text.requestFocus();
|
||||||
holder.quick_reply_container.setVisibility(View.GONE);
|
|
||||||
//CrossActions.doCrossReply(context, status, type, true);
|
InputMethodManager inputMethodManager =
|
||||||
|
(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
inputMethodManager.toggleSoftInputFromWindow(
|
||||||
|
holder.quick_reply_text.getApplicationWindowToken(),
|
||||||
|
InputMethodManager.SHOW_FORCED, 0);
|
||||||
|
tryMoveSelection(i);
|
||||||
|
}else{
|
||||||
|
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||||
|
imm.hideSoftInputFromWindow(holder.quick_reply_text.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
notifyStatusChanged(status);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3609,4 +3644,21 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
public void setConversationPosition(int position){
|
public void setConversationPosition(int position){
|
||||||
this.conversationPosition = position;
|
this.conversationPosition = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachedToRecyclerView(@NotNull final RecyclerView recyclerView) {
|
||||||
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
|
|
||||||
|
mRecyclerView = recyclerView;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tryMoveSelection(int mSelectedItem) {
|
||||||
|
if (mSelectedItem >= 0 && mSelectedItem+1 < getItemCount()) {
|
||||||
|
mRecyclerView.smoothScrollBy(mSelectedItem, (int) Helper.convertDpToPixel(250, context));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue