Improve conversation
This commit is contained in:
parent
b921c119fd
commit
8e8394709c
|
@ -110,7 +110,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
expanded = false;
|
||||
|
||||
setContentView(R.layout.activity_show_conversation);
|
||||
|
||||
lv_status = findViewById(R.id.lv_status);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
if( theme == THEME_BLACK)
|
||||
toolbar.setBackgroundColor(ContextCompat.getColor(ShowConversationActivity.this, R.color.black));
|
||||
|
@ -247,11 +247,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, false,false, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
});
|
||||
lv_status = findViewById(R.id.lv_status);
|
||||
lv_status.addItemDecoration(new DividerItemDecoration(ShowConversationActivity.this, DividerItemDecoration.VERTICAL));
|
||||
final LinearLayoutManager mLayoutManager;
|
||||
mLayoutManager = new LinearLayoutManager(this);
|
||||
lv_status.setLayoutManager(mLayoutManager);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -288,10 +284,12 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
Toast.makeText(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext());
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
|
||||
int positionSpinnerTrans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
||||
|
||||
int position = 0;
|
||||
boolean positionFound = false;
|
||||
statuses = new ArrayList<>();
|
||||
|
@ -332,15 +330,22 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
statuses.addAll(context.getDescendants());
|
||||
}
|
||||
}
|
||||
statusListAdapter = new StatusListAdapter(ShowConversationActivity.this, position, null, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, statuses);
|
||||
|
||||
final LinearLayoutManager mLayoutManager;
|
||||
mLayoutManager = new LinearLayoutManager(this);
|
||||
|
||||
lv_status.setLayoutManager(mLayoutManager);
|
||||
lv_status.addItemDecoration(new ConversationDecoration(ShowConversationActivity.this,position));
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
|
||||
if( isRefreshed){
|
||||
position = statuses.size()-1;
|
||||
lv_status.scrollToPosition(position);
|
||||
}else {
|
||||
lv_status.smoothScrollToPosition(position);
|
||||
}
|
||||
statusListAdapter = new StatusListAdapter(ShowConversationActivity.this, position, null, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, statuses);
|
||||
// lv_status.addItemDecoration(new ConversationDecoration(ShowConversationActivity.this,position), DividerItemDecoration.VERTICAL);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
loader.setVisibility(View.GONE);
|
||||
lv_status.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -18,8 +18,10 @@ package fr.gouv.etalab.mastodon.drawers;
|
|||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import fr.gouv.etalab.mastodon.R;
|
||||
|
@ -43,36 +45,43 @@ public class ConversationDecoration extends RecyclerView.ItemDecoration{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
|
||||
canvas.save();
|
||||
int left = parent.getPaddingLeft();
|
||||
int right = parent.getWidth() - parent.getPaddingRight();
|
||||
public void onDraw(@NonNull Canvas canvas, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
|
||||
int left = parent.getPaddingLeft() + (int)Helper.convertDpToPixel(12, context);
|
||||
int right = left + (int)Helper.convertDpToPixel(4, context);
|
||||
int childCount = parent.getChildCount();
|
||||
int top = 0, bottom = 0;
|
||||
StatusListAdapter adapter = (StatusListAdapter) parent.getAdapter();
|
||||
int offSet = (int) Helper.convertDpToPixel(50, context);
|
||||
|
||||
|
||||
int offSet = (int) Helper.convertDpToPixel(30, context);
|
||||
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
|
||||
View child = parent.getChildAt(i);
|
||||
StatusListAdapter adapter = (StatusListAdapter) parent.getAdapter();
|
||||
int position = parent.getChildAdapterPosition(child);
|
||||
|
||||
Status status = adapter.getItem(position);
|
||||
|
||||
int top = 0;
|
||||
int bottom = 0;
|
||||
if( status != null){
|
||||
Status statusBefore = null;
|
||||
if( position > 0)
|
||||
statusBefore = adapter.getItem(position - 1);
|
||||
top = (statusBefore != null && statusBefore.getId().equals(status.getIn_reply_to_id()))?
|
||||
child.getBottom(): (child.getTop() + offSet);
|
||||
child.getTop(): (child.getTop() + offSet);
|
||||
Status statusAfter = null;
|
||||
if( adapter.getItemCount() > position+1)
|
||||
statusAfter = adapter.getItem(position + 1);
|
||||
bottom = (statusAfter != null && status.getId().equals(statusAfter.getIn_reply_to_id()) && position != statusOpenedPosition)?
|
||||
child.getTop():child.getTop()+offSet;
|
||||
|
||||
|
||||
bottom = (statusAfter != null && status.getId().equals(statusAfter.getIn_reply_to_id()) )?
|
||||
child.getBottom():child.getTop()+offSet;
|
||||
if( position == 0)
|
||||
top = bottom - (int)Helper.convertDpToPixel(28, context);
|
||||
}
|
||||
divider.setBounds(left, top, right, bottom);
|
||||
divider.draw(canvas);
|
||||
}
|
||||
canvas.restore();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -382,6 +382,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
|
||||
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int position) {
|
||||
|
@ -426,6 +427,22 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.status_privacy.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
|
||||
boolean isCompactMode = sharedpreferences.getBoolean(Helper.SET_COMPACT_MODE, true);
|
||||
|
||||
if( type == RetrieveFeedsAsyncTask.Type.CONTEXT && getItemViewType(position) != FOCUSED_STATUS && position != 0 ){
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
params.setMargins((int)Helper.convertDpToPixel(30, context), 0, 0, 0);
|
||||
holder.main_container.setLayoutParams(params);
|
||||
}else if(type == RetrieveFeedsAsyncTask.Type.CONTEXT && getItemViewType(position) == FOCUSED_STATUS && position != 0 ){
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
params.setMargins((int)Helper.convertDpToPixel(15, context), 0, 0, 0);
|
||||
holder.main_container.setLayoutParams(params);
|
||||
}
|
||||
|
||||
|
||||
if( getItemViewType(position) == FOCUSED_STATUS ) {
|
||||
holder.status_content.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16*textSizePercent/100);
|
||||
|
@ -639,7 +656,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.status_content_translated.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
//-------- END -> Manages translations
|
||||
|
||||
|
||||
if( status.getAccount() == null) {
|
||||
Account account = new AccountDAO(context, db).getAccountByID(sharedpreferences.getString(Helper.PREF_KEY_ID, null));
|
||||
status.setAccount(account);
|
||||
}
|
||||
//Displays name & emoji in toot header
|
||||
final String ppurl;
|
||||
if( status.getReblog() != null){
|
||||
|
@ -986,22 +1006,22 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
|
||||
|
||||
|
||||
if( theme == Helper.THEME_LIGHT){
|
||||
/* if( theme == Helper.THEME_LIGHT){
|
||||
holder.main_container.setBackgroundResource(R.color.mastodonC3__);
|
||||
}else if (theme == Helper.THEME_DARK){
|
||||
holder.main_container.setBackgroundResource(R.color.mastodonC1_);
|
||||
}else if (theme == Helper.THEME_BLACK){
|
||||
holder.main_container.setBackgroundResource(R.color.black);
|
||||
}
|
||||
}*/
|
||||
if( type == RetrieveFeedsAsyncTask.Type.CONTEXT ){
|
||||
|
||||
if( position == conversationPosition){
|
||||
if( theme == Helper.THEME_LIGHT)
|
||||
/* if( theme == Helper.THEME_LIGHT)
|
||||
holder.main_container.setBackgroundResource(R.color.mastodonC3_);
|
||||
else if( theme == Helper.THEME_DARK)
|
||||
holder.main_container.setBackgroundResource(R.color.mastodonC1___);
|
||||
else if( theme == Helper.THEME_BLACK)
|
||||
holder.main_container.setBackgroundResource(R.color.black_2);
|
||||
holder.main_container.setBackgroundResource(R.color.black_2);*/
|
||||
if( status.getCard() != null){
|
||||
|
||||
holder.status_cardview_content.setText(status.getCard().getDescription());
|
||||
|
@ -1052,12 +1072,12 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}else {
|
||||
holder.status_cardview.setVisibility(View.GONE);
|
||||
holder.status_cardview_video.setVisibility(View.GONE);
|
||||
if( theme == Helper.THEME_LIGHT)
|
||||
/*if( theme == Helper.THEME_LIGHT)
|
||||
holder.main_container.setBackgroundResource(R.color.mastodonC3__);
|
||||
else if( theme == Helper.THEME_DARK)
|
||||
holder.main_container.setBackgroundResource(R.color.mastodonC1_);
|
||||
else if (theme == Helper.THEME_BLACK)
|
||||
holder.main_container.setBackgroundResource(R.color.black);
|
||||
holder.main_container.setBackgroundResource(R.color.black);*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<size android:width="4dp" />
|
||||
<size android:height="4dp" />
|
||||
<solid android:color="?colorAccent" />
|
||||
</shape>
|
|
@ -22,7 +22,6 @@
|
|||
android:id="@+id/main_container"
|
||||
android:divider="?android:dividerHorizontal"
|
||||
android:showDividers="end"
|
||||
android:paddingTop="5dp"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -19,11 +19,9 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/main_container"
|
||||
android:divider="?android:dividerHorizontal"
|
||||
android:showDividers="end"
|
||||
android:paddingTop="5dp"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -19,11 +19,9 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/main_container"
|
||||
android:divider="?android:dividerHorizontal"
|
||||
android:showDividers="end"
|
||||
android:paddingTop="5dp"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue