Add entity for params
This commit is contained in:
parent
cfc0704806
commit
7bd52ca212
|
@ -53,6 +53,7 @@ import app.fedilab.android.client.API;
|
|||
import app.fedilab.android.client.APIResponse;
|
||||
import app.fedilab.android.client.Entities.Account;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.StatusDrawerParams;
|
||||
import app.fedilab.android.drawers.StatusListAdapter;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.interfaces.OnRetrieveFeedsInterface;
|
||||
|
@ -181,7 +182,12 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
|
|||
statuses = apiResponse.getStatuses();
|
||||
if (statuses != null && statuses.size() > 0) {
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(BookmarkActivity.this);
|
||||
statusListAdapter = new StatusListAdapter(RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS, null, isOnWifi, this.statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS);
|
||||
statusDrawerParams.setTargetedId(null);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(this.statuses);
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
lv_status.setLayoutManager(mLayoutManager);
|
||||
} else {
|
||||
|
@ -206,7 +212,12 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
|
|||
.setPositiveButton(R.string.yes, (dialogConfirm, which) -> {
|
||||
statuses = new ArrayList<>();
|
||||
statuses.clear();
|
||||
statusListAdapter = new StatusListAdapter(RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS, null, isOnWifi, statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS);
|
||||
statusDrawerParams.setTargetedId(null);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(this.statuses);
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
textviewNoAction.setVisibility(View.VISIBLE);
|
||||
|
@ -225,7 +236,12 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
|
|||
statuses.clear();
|
||||
statuses.addAll(bookmarks);
|
||||
final boolean isOnWifi = Helper.isOnWIFI(BookmarkActivity.this);
|
||||
statusListAdapter = new StatusListAdapter(RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS, null, isOnWifi, statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS);
|
||||
statusDrawerParams.setTargetedId(null);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(this.statuses);
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
if (statuses.size() == 0) {
|
||||
|
|
|
@ -39,6 +39,7 @@ import app.fedilab.android.R;
|
|||
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
|
||||
import app.fedilab.android.client.APIResponse;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.StatusDrawerParams;
|
||||
import app.fedilab.android.drawers.StatusListAdapter;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.interfaces.OnRetrieveFeedsInterface;
|
||||
|
@ -120,7 +121,12 @@ public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterf
|
|||
textviewNoAction = findViewById(R.id.no_action);
|
||||
mainLoader.setVisibility(View.VISIBLE);
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
statusListAdapter = new StatusListAdapter(RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, null, isOnWifi, this.statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE);
|
||||
statusDrawerParams.setTargetedId(null);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(this.statuses);
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
setTitle(String.format("!%s", groupname));
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
|
|
|
@ -41,6 +41,7 @@ import app.fedilab.android.R;
|
|||
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
|
||||
import app.fedilab.android.client.APIResponse;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.StatusDrawerParams;
|
||||
import app.fedilab.android.drawers.StatusListAdapter;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.interfaces.OnRetrieveFeedsInterface;
|
||||
|
@ -119,7 +120,12 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
|
|||
textviewNoAction = findViewById(R.id.no_action);
|
||||
mainLoader.setVisibility(View.VISIBLE);
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
statusListAdapter = new StatusListAdapter(RetrieveFeedsAsyncTask.Type.TAG, null, isOnWifi, this.statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.TAG);
|
||||
statusDrawerParams.setTargetedId(null);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(this.statuses);
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
setTitle(String.format("#%s", tag));
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
|
|
|
@ -48,6 +48,7 @@ import app.fedilab.android.asynctasks.ManageListsAsyncTask;
|
|||
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
|
||||
import app.fedilab.android.client.APIResponse;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.StatusDrawerParams;
|
||||
import app.fedilab.android.drawers.StatusListAdapter;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.interfaces.OnListActionInterface;
|
||||
|
@ -121,8 +122,12 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
|
|||
mainLoader.setVisibility(View.VISIBLE);
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
boolean isOnWifi = Helper.isOnWIFI(ListActivity.this);
|
||||
|
||||
statusListAdapter = new StatusListAdapter(RetrieveFeedsAsyncTask.Type.LIST, null, isOnWifi, this.statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.LIST);
|
||||
statusDrawerParams.setTargetedId(null);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(this.statuses);
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
mLayoutManager = new LinearLayoutManager(ListActivity.this);
|
||||
|
|
|
@ -70,6 +70,7 @@ import app.fedilab.android.client.APIResponse;
|
|||
import app.fedilab.android.client.Entities.Account;
|
||||
import app.fedilab.android.client.Entities.Statistics;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.StatusDrawerParams;
|
||||
import app.fedilab.android.drawers.StatusListAdapter;
|
||||
import app.fedilab.android.helper.FilterToots;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
|
@ -204,7 +205,12 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
|
|||
boolean isOnWifi = Helper.isOnWIFI(OwnerStatusActivity.this);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
statusListAdapter = new StatusListAdapter(RetrieveFeedsAsyncTask.Type.CACHE_STATUS, userId, isOnWifi, this.statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.CACHE_STATUS);
|
||||
statusDrawerParams.setTargetedId(userId);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(this.statuses);
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
mLayoutManager = new LinearLayoutManager(OwnerStatusActivity.this);
|
||||
lv_status.setLayoutManager(mLayoutManager);
|
||||
|
|
|
@ -95,6 +95,7 @@ import app.fedilab.android.client.Entities.Error;
|
|||
import app.fedilab.android.client.Entities.Peertube;
|
||||
import app.fedilab.android.client.Entities.Playlist;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.StatusDrawerParams;
|
||||
import app.fedilab.android.client.TLSSocketFactory;
|
||||
import app.fedilab.android.drawers.StatusListAdapter;
|
||||
import app.fedilab.android.helper.CrossActions;
|
||||
|
@ -765,7 +766,12 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
boolean isOnWifi = Helper.isOnWIFI(PeertubeActivity.this);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
StatusListAdapter statusListAdapter = new StatusListAdapter(RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE, userId, isOnWifi, statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
|
||||
statusDrawerParams.setTargetedId(userId);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(statuses);
|
||||
StatusListAdapter statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this);
|
||||
lv_comments.setLayoutManager(mLayoutManager);
|
||||
lv_comments.setNestedScrollingEnabled(false);
|
||||
|
|
|
@ -94,6 +94,7 @@ import app.fedilab.android.client.Entities.ManageTimelines;
|
|||
import app.fedilab.android.client.Entities.Relationship;
|
||||
import app.fedilab.android.client.Entities.RemoteInstance;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.StatusDrawerParams;
|
||||
import app.fedilab.android.client.Entities.UserNote;
|
||||
import app.fedilab.android.client.HttpsConnection;
|
||||
import app.fedilab.android.drawers.IdentityProofsAdapter;
|
||||
|
@ -214,7 +215,12 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
show_replies = true;
|
||||
statuses = new ArrayList<>();
|
||||
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext());
|
||||
statusListAdapter = new StatusListAdapter(RetrieveFeedsAsyncTask.Type.USER, accountId, isOnWifi, this.statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setType(RetrieveFeedsAsyncTask.Type.USER);
|
||||
statusDrawerParams.setTargetedId(accountId);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(statuses);
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
|
||||
showMediaOnly = false;
|
||||
showPinned = false;
|
||||
|
|
|
@ -46,6 +46,7 @@ import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
|
|||
import app.fedilab.android.client.APIResponse;
|
||||
import app.fedilab.android.client.Entities.Account;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.StatusDrawerParams;
|
||||
import app.fedilab.android.drawers.StatusListAdapter;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.interfaces.OnRetrieveContextInterface;
|
||||
|
@ -233,7 +234,13 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
statuses.add(initialStatus);
|
||||
else
|
||||
statuses.add(detailsStatus);
|
||||
statusListAdapter = new StatusListAdapter(0, null, isOnWifi, statuses);
|
||||
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setPosition(0);
|
||||
statusDrawerParams.setTargetedId(null);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(statuses);
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
|
||||
final LinearLayoutManager mLayoutManager;
|
||||
mLayoutManager = new LinearLayoutManager(this);
|
||||
|
@ -361,7 +368,12 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
for (Status status : apiResponse.getContext().getAncestors()) {
|
||||
statuses.add(0, status);
|
||||
}
|
||||
statusListAdapter = new StatusListAdapter((statuses.size() - 1 - i), null, isOnWifi, statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setPosition((statuses.size() - 1 - i));
|
||||
statusDrawerParams.setTargetedId(null);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(statuses);
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
statusListAdapter.setConversationPosition((statuses.size() - 1 - i));
|
||||
decorate(0);
|
||||
final LinearLayoutManager mLayoutManager;
|
||||
|
|
|
@ -1,4 +1,86 @@
|
|||
package app.fedilab.android.client.Entities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
|
||||
|
||||
/* Copyright 2020 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Fedilab
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
public class StatusDrawerParams {
|
||||
private List<Status> statuses;
|
||||
private RetrieveFeedsAsyncTask.Type type;
|
||||
private String targetedId;
|
||||
private boolean isOnWifi;
|
||||
private String instanceType;
|
||||
private TagTimeline tagTimeline;
|
||||
private int position;
|
||||
|
||||
|
||||
public List<Status> getStatuses() {
|
||||
return statuses;
|
||||
}
|
||||
|
||||
public void setStatuses(List<Status> statuses) {
|
||||
this.statuses = statuses;
|
||||
}
|
||||
|
||||
public RetrieveFeedsAsyncTask.Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(RetrieveFeedsAsyncTask.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getTargetedId() {
|
||||
return targetedId;
|
||||
}
|
||||
|
||||
public void setTargetedId(String targetedId) {
|
||||
this.targetedId = targetedId;
|
||||
}
|
||||
|
||||
public boolean isOnWifi() {
|
||||
return isOnWifi;
|
||||
}
|
||||
|
||||
public void setOnWifi(boolean onWifi) {
|
||||
isOnWifi = onWifi;
|
||||
}
|
||||
|
||||
public String getInstanceType() {
|
||||
return instanceType;
|
||||
}
|
||||
|
||||
public void setInstanceType(String instanceType) {
|
||||
this.instanceType = instanceType;
|
||||
}
|
||||
|
||||
public TagTimeline getTagTimeline() {
|
||||
return tagTimeline;
|
||||
}
|
||||
|
||||
public void setTagTimeline(TagTimeline tagTimeline) {
|
||||
this.tagTimeline = tagTimeline;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ import app.fedilab.android.client.Entities.Emojis;
|
|||
import app.fedilab.android.client.Entities.Error;
|
||||
import app.fedilab.android.client.Entities.Notification;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.StatusDrawerParams;
|
||||
import app.fedilab.android.helper.CrossActions;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastalabAutoCompleteTextView;
|
||||
|
@ -456,7 +457,12 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
holder.pixelfed_comments.setVisibility(View.VISIBLE);
|
||||
in_reply_to_status = status.getReblog() != null ? status.getReblog().getId() : status.getId();
|
||||
if (status.isCommentsFetched()) {
|
||||
StatusListAdapter statusListAdapter = new StatusListAdapter(0, status.getId(), true, status.getComments());
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setPosition(0);
|
||||
statusDrawerParams.setTargetedId(status.getId());
|
||||
statusDrawerParams.setOnWifi(true);
|
||||
statusDrawerParams.setStatuses(status.getComments());
|
||||
StatusListAdapter statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
final LinearLayoutManager mLayoutManager;
|
||||
mLayoutManager = new LinearLayoutManager(context);
|
||||
holder.lv_comments.setLayoutManager(mLayoutManager);
|
||||
|
|
|
@ -19,7 +19,6 @@ import android.app.Activity;
|
|||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
@ -56,7 +55,6 @@ import android.webkit.WebViewClient;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
|
@ -144,6 +142,7 @@ import app.fedilab.android.client.Entities.Poll;
|
|||
import app.fedilab.android.client.Entities.PollOptions;
|
||||
import app.fedilab.android.client.Entities.Relationship;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.StatusDrawerParams;
|
||||
import app.fedilab.android.client.Entities.StoredStatus;
|
||||
import app.fedilab.android.client.Entities.TagTimeline;
|
||||
import app.fedilab.android.fragments.DisplayStatusFragment;
|
||||
|
@ -225,6 +224,26 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
private Status statusForQuickReply;
|
||||
private String instanceType;
|
||||
|
||||
|
||||
|
||||
public StatusListAdapter(StatusDrawerParams statusDrawerParams){
|
||||
statuses = statusDrawerParams.getStatuses();
|
||||
isOnWifi = statusDrawerParams.isOnWifi();
|
||||
statusListAdapter = this;
|
||||
type = statusDrawerParams.getType();
|
||||
targetedId = statusDrawerParams.getTargetedId();
|
||||
tagTimeline = statusDrawerParams.getTagTimeline();
|
||||
conversationPosition = statusDrawerParams.getPosition();
|
||||
redraft = false;
|
||||
lstHolders = new ArrayList<>();
|
||||
toot_content = null;
|
||||
toot_cw_content = null;
|
||||
tootReply = null;
|
||||
currentToId = -1;
|
||||
instanceType = statusDrawerParams.getInstanceType();
|
||||
}
|
||||
|
||||
|
||||
private Runnable updateAnimatedEmoji = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -248,86 +267,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
|
||||
private Handler mHandler = new Handler();
|
||||
|
||||
public StatusListAdapter(RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, List<Status> statuses) {
|
||||
super();
|
||||
this.statuses = statuses;
|
||||
this.isOnWifi = isOnWifi;
|
||||
statusListAdapter = this;
|
||||
this.type = type;
|
||||
this.targetedId = targetedId;
|
||||
redraft = false;
|
||||
lstHolders = new ArrayList<>();
|
||||
toot_content = null;
|
||||
toot_cw_content = null;
|
||||
tootReply = null;
|
||||
currentToId = -1;
|
||||
}
|
||||
|
||||
public StatusListAdapter(String instanceType, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, List<Status> statuses) {
|
||||
super();
|
||||
this.statuses = statuses;
|
||||
this.isOnWifi = isOnWifi;
|
||||
statusListAdapter = this;
|
||||
this.type = type;
|
||||
this.targetedId = targetedId;
|
||||
redraft = false;
|
||||
lstHolders = new ArrayList<>();
|
||||
toot_content = null;
|
||||
toot_cw_content = null;
|
||||
tootReply = null;
|
||||
currentToId = -1;
|
||||
this.instanceType = instanceType;
|
||||
}
|
||||
|
||||
public StatusListAdapter(TagTimeline tagTimeline, String targetedId, boolean isOnWifi, List<Status> statuses) {
|
||||
super();
|
||||
this.statuses = statuses;
|
||||
this.isOnWifi = isOnWifi;
|
||||
statusListAdapter = this;
|
||||
this.type = RetrieveFeedsAsyncTask.Type.TAG;
|
||||
this.targetedId = targetedId;
|
||||
redraft = false;
|
||||
this.tagTimeline = tagTimeline;
|
||||
lstHolders = new ArrayList<>();
|
||||
toot_content = null;
|
||||
toot_cw_content = null;
|
||||
tootReply = null;
|
||||
currentToId = -1;
|
||||
}
|
||||
|
||||
public StatusListAdapter(String instanceType, TagTimeline tagTimeline, String targetedId, boolean isOnWifi, List<Status> statuses) {
|
||||
super();
|
||||
this.statuses = statuses;
|
||||
this.isOnWifi = isOnWifi;
|
||||
statusListAdapter = this;
|
||||
this.type = RetrieveFeedsAsyncTask.Type.TAG;
|
||||
this.targetedId = targetedId;
|
||||
redraft = false;
|
||||
this.tagTimeline = tagTimeline;
|
||||
this.instanceType = instanceType;
|
||||
lstHolders = new ArrayList<>();
|
||||
toot_content = null;
|
||||
toot_cw_content = null;
|
||||
tootReply = null;
|
||||
currentToId = -1;
|
||||
}
|
||||
|
||||
public StatusListAdapter(int position, String targetedId, boolean isOnWifi, List<Status> statuses) {
|
||||
this.statuses = statuses;
|
||||
this.isOnWifi = isOnWifi;
|
||||
statusListAdapter = this;
|
||||
this.type = RetrieveFeedsAsyncTask.Type.CONTEXT;
|
||||
this.conversationPosition = position;
|
||||
this.targetedId = targetedId;
|
||||
redraft = false;
|
||||
lstHolders = new ArrayList<>();
|
||||
toot_content = null;
|
||||
toot_cw_content = null;
|
||||
tootReply = null;
|
||||
currentToId = -1;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(@NotNull RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
|
@ -1041,7 +980,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.status_toot_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float)(12 * textSizePercent) / 100);
|
||||
holder.status_content_translated.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float)(14 * textSizePercent) / 100);
|
||||
}
|
||||
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
|
||||
|
||||
holder.status_spoiler.setTextSize(TypedValue.COMPLEX_UNIT_SP, (float)(14 * textSizePercent) / 100);
|
||||
|
||||
|
@ -1348,7 +1286,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.status_spoiler.setOnClickListener(v -> {
|
||||
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
int position = closePanels();
|
||||
Bundle b = new Bundle();
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
|
||||
b.putString("conversationId", status.getConversationId());
|
||||
|
@ -1569,15 +1506,12 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
accountForUrl = status.getReblog().getAccount();
|
||||
holder.status_account_displayname.setVisibility(View.VISIBLE);
|
||||
holder.status_account_displayname.setText(context.getResources().getString(R.string.reblog_by, status.getAccount().getUsername()));
|
||||
holder.status_account_displayname.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("account", status.getAccount());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
holder.status_account_displayname.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("account", status.getAccount());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
if (status.getReblog().getAccount().getDisplay_name().length() > 0)
|
||||
holder.status_account_displayname_owner.setText(status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
|
@ -2285,32 +2219,29 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.status_cardview_video.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
holder.webview_preview.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String url = finalSrc;
|
||||
if (url != null) {
|
||||
boolean invidious = sharedpreferences.getBoolean(Helper.SET_INVIDIOUS, false);
|
||||
if (invidious) {
|
||||
Matcher matcher = Helper.youtubePattern.matcher(url);
|
||||
while (matcher.find()) {
|
||||
final String youtubeId = matcher.group(3);
|
||||
String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, Helper.DEFAULT_INVIDIOUS_HOST).toLowerCase();
|
||||
if (matcher.group(2) != null && matcher.group(2).equals("youtu.be")) {
|
||||
url = url.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + invidiousHost + "/watch?v=" + youtubeId + "&local=true"));
|
||||
} else {
|
||||
url = url.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + invidiousHost + "/" + youtubeId + "&local=true"));
|
||||
}
|
||||
holder.webview_preview.setOnClickListener(v -> {
|
||||
String url = finalSrc;
|
||||
if (url != null) {
|
||||
boolean invidious = sharedpreferences.getBoolean(Helper.SET_INVIDIOUS, false);
|
||||
if (invidious) {
|
||||
Matcher matcher = Helper.youtubePattern.matcher(url);
|
||||
while (matcher.find()) {
|
||||
final String youtubeId = matcher.group(3);
|
||||
String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, Helper.DEFAULT_INVIDIOUS_HOST).toLowerCase();
|
||||
if (matcher.group(2) != null && matcher.group(2).equals("youtu.be")) {
|
||||
url = url.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + invidiousHost + "/watch?v=" + youtubeId + "&local=true"));
|
||||
} else {
|
||||
url = url.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + invidiousHost + "/" + youtubeId + "&local=true"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status.getReblog() == null) {
|
||||
status.setWebviewURL(url);
|
||||
} else {
|
||||
status.getReblog().setWebviewURL(url);
|
||||
}
|
||||
notifyStatusChanged(status);
|
||||
}
|
||||
if (status.getReblog() == null) {
|
||||
status.setWebviewURL(url);
|
||||
} else {
|
||||
status.getReblog().setWebviewURL(url);
|
||||
}
|
||||
notifyStatusChanged(status);
|
||||
});
|
||||
} else {
|
||||
holder.status_cardview.setVisibility(View.GONE);
|
||||
|
@ -2736,305 +2667,292 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
popup.getMenu().findItem(R.id.action_custom_sharing).setVisible(true);
|
||||
MenuItem itemBookmark = popup.getMenu().findItem(R.id.action_bookmark);
|
||||
if (itemBookmark.getActionView() != null)
|
||||
itemBookmark.getActionView().setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
CrossActions.doCrossBookmark(context, status, statusListAdapter, true);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
AlertDialog.Builder builderInner;
|
||||
final API.StatusAction doAction;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_redraft:
|
||||
builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[1]);
|
||||
redraft = true;
|
||||
doAction = API.StatusAction.UNSTATUS;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent()));
|
||||
break;
|
||||
case R.id.action_schedule_boost:
|
||||
scheduleBoost(status);
|
||||
return true;
|
||||
case R.id.action_admin:
|
||||
String account_id = status.getReblog() != null ? status.getReblog().getAccount().getId() : status.getAccount().getId();
|
||||
String acct = status.getReblog() != null ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct();
|
||||
Intent intent = new Intent(context, AccountReportActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
|
||||
b.putString("account_id", account_id);
|
||||
} else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
||||
b.putString("account_id", acct);
|
||||
}
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
case R.id.action_info:
|
||||
tootInformation(status);
|
||||
return true;
|
||||
case R.id.action_open_browser:
|
||||
Helper.openBrowser(context, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl());
|
||||
return true;
|
||||
case R.id.action_remove:
|
||||
builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[0]);
|
||||
doAction = API.StatusAction.UNSTATUS;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
//noinspection deprecation
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent()));
|
||||
break;
|
||||
case R.id.action_block_domain:
|
||||
builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[3]);
|
||||
doAction = API.StatusAction.BLOCK_DOMAIN;
|
||||
String domain = status.getAccount().getAcct().split("@")[1];
|
||||
builderInner.setMessage(context.getString(R.string.block_domain_confirm_message, domain));
|
||||
break;
|
||||
case R.id.action_mute:
|
||||
builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[0]);
|
||||
builderInner.setMessage(status.getAccount().getAcct());
|
||||
doAction = API.StatusAction.MUTE;
|
||||
break;
|
||||
case R.id.action_mute_conversation:
|
||||
if (status.isMuted())
|
||||
doAction = API.StatusAction.UNMUTE_CONVERSATION;
|
||||
else
|
||||
doAction = API.StatusAction.MUTE_CONVERSATION;
|
||||
|
||||
new PostActionAsyncTask(context, doAction, status.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
return true;
|
||||
case R.id.action_bookmark:
|
||||
if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
|
||||
status.setBookmarked(!status.isBookmarked());
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
try {
|
||||
if (status.isBookmarked()) {
|
||||
new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status);
|
||||
Toasty.success(context, context.getString(R.string.status_bookmarked), Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, status);
|
||||
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
notifyStatusChanged(status);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else {
|
||||
int position = 0;
|
||||
for (Status statustmp : statuses) {
|
||||
if (statustmp.getId().equals(status.getId())) {
|
||||
statuses.remove(status);
|
||||
statusListAdapter.notifyItemRemoved(position);
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, statustmp);
|
||||
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
}
|
||||
position++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case R.id.action_stats:
|
||||
intent = new Intent(context, OwnerNotificationChartsActivity.class);
|
||||
b = new Bundle();
|
||||
b.putString("status_id", status.getReblog() != null ? status.getReblog().getId() : status.getId());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
case R.id.action_timed_mute:
|
||||
timedMuteAction(status);
|
||||
return true;
|
||||
case R.id.action_block:
|
||||
builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[1]);
|
||||
doAction = API.StatusAction.BLOCK;
|
||||
break;
|
||||
case R.id.action_translate:
|
||||
if (translator == Helper.TRANS_NONE)
|
||||
Toasty.info(context, R.string.toast_error_translations_disabled, Toast.LENGTH_SHORT).show();
|
||||
else
|
||||
translateToot(status);
|
||||
return true;
|
||||
case R.id.action_report:
|
||||
builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[2]);
|
||||
doAction = API.StatusAction.REPORT;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
//noinspection deprecation
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent()));
|
||||
break;
|
||||
case R.id.action_copy:
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
final String content;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
content = Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
else
|
||||
//noinspection deprecation
|
||||
content = Html.fromHtml(status.getContent()).toString();
|
||||
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, content);
|
||||
if (clipboard != null) {
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(context, context.getString(R.string.clipboard), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_copy_link:
|
||||
clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
|
||||
clip = ClipData.newPlainText(Helper.CLIP_BOARD, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl());
|
||||
if (clipboard != null) {
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(context, context.getString(R.string.clipboard_url), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_share:
|
||||
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
|
||||
String url;
|
||||
|
||||
if (status.getReblog() != null) {
|
||||
if (status.getReblog().getUri().startsWith("http"))
|
||||
url = status.getReblog().getUri();
|
||||
else
|
||||
url = status.getReblog().getUrl();
|
||||
} else {
|
||||
if (status.getUri().startsWith("http"))
|
||||
url = status.getUri();
|
||||
else
|
||||
url = status.getUrl();
|
||||
}
|
||||
String extra_text;
|
||||
|
||||
if (share_details) {
|
||||
extra_text = (status.getReblog() != null) ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct();
|
||||
if (extra_text.split("@").length == 1)
|
||||
extra_text = "@" + extra_text + "@" + Helper.getLiveInstance(context);
|
||||
else
|
||||
extra_text = "@" + extra_text;
|
||||
extra_text += " " + Helper.shortnameToUnicode(":link:", true) + " " + url + "\r\n-\n";
|
||||
final String contentToot;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
else
|
||||
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent()).toString();
|
||||
extra_text += contentToot;
|
||||
} else {
|
||||
extra_text = url;
|
||||
}
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
|
||||
sendIntent.setType("text/plain");
|
||||
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
|
||||
return true;
|
||||
case R.id.action_custom_sharing:
|
||||
Intent intentCustomSharing = new Intent(context, CustomSharingActivity.class);
|
||||
Bundle bCustomSharing = new Bundle();
|
||||
if (status.getReblog() != null) {
|
||||
bCustomSharing.putParcelable("status", status.getReblog());
|
||||
} else {
|
||||
bCustomSharing.putParcelable("status", status);
|
||||
}
|
||||
intentCustomSharing.putExtras(bCustomSharing);
|
||||
context.startActivity(intentCustomSharing);
|
||||
return true;
|
||||
case R.id.action_mention:
|
||||
mention(status);
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
//Text for report
|
||||
EditText input = null;
|
||||
if (doAction == API.StatusAction.REPORT) {
|
||||
input = new EditText(context);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
input.setLayoutParams(lp);
|
||||
builderInner.setView(input);
|
||||
}
|
||||
builderInner.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
final EditText finalInput = input;
|
||||
builderInner.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (doAction == API.StatusAction.UNSTATUS) {
|
||||
String targetedId = status.getId();
|
||||
new PostActionAsyncTask(context, doAction, targetedId, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
if (redraft) {
|
||||
if (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().trim().equals("null")) {
|
||||
toot = new Status();
|
||||
toot.setIn_reply_to_id(status.getIn_reply_to_id());
|
||||
toot.setSensitive(status.isSensitive());
|
||||
toot.setMedia_attachments(status.getMedia_attachments());
|
||||
if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0)
|
||||
toot.setSpoiler_text(status.getSpoiler_text().trim());
|
||||
toot.setContent(context, status.getContent());
|
||||
toot.setVisibility(status.getVisibility());
|
||||
if (status.getPoll() != null) {
|
||||
toot.setPoll(status.getPoll());
|
||||
} else if (status.getReblog() != null && status.getReblog().getPoll() != null) {
|
||||
toot.setPoll(status.getPoll());
|
||||
}
|
||||
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ONESTATUS, status.getIn_reply_to_id(), null, false, false, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
toot = new Status();
|
||||
toot.setSensitive(status.isSensitive());
|
||||
toot.setMedia_attachments(status.getMedia_attachments());
|
||||
if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0)
|
||||
toot.setSpoiler_text(status.getSpoiler_text().trim());
|
||||
toot.setVisibility(status.getVisibility());
|
||||
toot.setContent(context, status.getContent());
|
||||
if (status.getPoll() != null) {
|
||||
toot.setPoll(status.getPoll());
|
||||
} else if (status.getReblog() != null && status.getReblog().getPoll() != null) {
|
||||
toot.setPoll(status.getPoll());
|
||||
}
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
long id = new StatusStoredDAO(context, db).insertStatus(toot, null);
|
||||
Intent intentToot = new Intent(context, TootActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putLong("restored", id);
|
||||
b.putBoolean("removed", true);
|
||||
intentToot.putExtras(b);
|
||||
context.startActivity(intentToot);
|
||||
}
|
||||
}
|
||||
} else if (doAction == API.StatusAction.REPORT) {
|
||||
String comment = null;
|
||||
if (finalInput.getText() != null)
|
||||
comment = finalInput.getText().toString();
|
||||
new PostActionAsyncTask(context, doAction, status.getId(), status, comment, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
String targetedId;
|
||||
if (item.getItemId() == R.id.action_block_domain) {
|
||||
targetedId = status.getAccount().getAcct().split("@")[1];
|
||||
} else {
|
||||
targetedId = status.getAccount().getId();
|
||||
}
|
||||
new PostActionAsyncTask(context, doAction, targetedId, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderInner.show();
|
||||
itemBookmark.getActionView().setOnLongClickListener(v1 -> {
|
||||
CrossActions.doCrossBookmark(context, status, statusListAdapter, true);
|
||||
return true;
|
||||
});
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
AlertDialog.Builder builderInner;
|
||||
final API.StatusAction doAction;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_redraft:
|
||||
builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[1]);
|
||||
redraft = true;
|
||||
doAction = API.StatusAction.UNSTATUS;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent()));
|
||||
break;
|
||||
case R.id.action_schedule_boost:
|
||||
scheduleBoost(status);
|
||||
return true;
|
||||
case R.id.action_admin:
|
||||
String account_id = status.getReblog() != null ? status.getReblog().getAccount().getId() : status.getAccount().getId();
|
||||
String acct = status.getReblog() != null ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct();
|
||||
Intent intent = new Intent(context, AccountReportActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
|
||||
b.putString("account_id", account_id);
|
||||
} else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
||||
b.putString("account_id", acct);
|
||||
}
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
case R.id.action_info:
|
||||
tootInformation(status);
|
||||
return true;
|
||||
case R.id.action_open_browser:
|
||||
Helper.openBrowser(context, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl());
|
||||
return true;
|
||||
case R.id.action_remove:
|
||||
builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[0]);
|
||||
doAction = API.StatusAction.UNSTATUS;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
//noinspection deprecation
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent()));
|
||||
break;
|
||||
case R.id.action_block_domain:
|
||||
builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[3]);
|
||||
doAction = API.StatusAction.BLOCK_DOMAIN;
|
||||
String domain = status.getAccount().getAcct().split("@")[1];
|
||||
builderInner.setMessage(context.getString(R.string.block_domain_confirm_message, domain));
|
||||
break;
|
||||
case R.id.action_mute:
|
||||
builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[0]);
|
||||
builderInner.setMessage(status.getAccount().getAcct());
|
||||
doAction = API.StatusAction.MUTE;
|
||||
break;
|
||||
case R.id.action_mute_conversation:
|
||||
if (status.isMuted())
|
||||
doAction = API.StatusAction.UNMUTE_CONVERSATION;
|
||||
else
|
||||
doAction = API.StatusAction.MUTE_CONVERSATION;
|
||||
|
||||
new PostActionAsyncTask(context, doAction, status.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
return true;
|
||||
case R.id.action_bookmark:
|
||||
if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
|
||||
status.setBookmarked(!status.isBookmarked());
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
try {
|
||||
if (status.isBookmarked()) {
|
||||
new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status);
|
||||
Toasty.success(context, context.getString(R.string.status_bookmarked), Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, status);
|
||||
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
notifyStatusChanged(status);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else {
|
||||
int position = 0;
|
||||
for (Status statustmp : statuses) {
|
||||
if (statustmp.getId().equals(status.getId())) {
|
||||
statuses.remove(status);
|
||||
statusListAdapter.notifyItemRemoved(position);
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, statustmp);
|
||||
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
}
|
||||
position++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case R.id.action_stats:
|
||||
intent = new Intent(context, OwnerNotificationChartsActivity.class);
|
||||
b = new Bundle();
|
||||
b.putString("status_id", status.getReblog() != null ? status.getReblog().getId() : status.getId());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
case R.id.action_timed_mute:
|
||||
timedMuteAction(status);
|
||||
return true;
|
||||
case R.id.action_block:
|
||||
builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[1]);
|
||||
doAction = API.StatusAction.BLOCK;
|
||||
break;
|
||||
case R.id.action_translate:
|
||||
if (translator == Helper.TRANS_NONE)
|
||||
Toasty.info(context, R.string.toast_error_translations_disabled, Toast.LENGTH_SHORT).show();
|
||||
else
|
||||
translateToot(status);
|
||||
return true;
|
||||
case R.id.action_report:
|
||||
builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[2]);
|
||||
doAction = API.StatusAction.REPORT;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
//noinspection deprecation
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent()));
|
||||
break;
|
||||
case R.id.action_copy:
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
final String content;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
content = Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
else
|
||||
//noinspection deprecation
|
||||
content = Html.fromHtml(status.getContent()).toString();
|
||||
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, content);
|
||||
if (clipboard != null) {
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(context, context.getString(R.string.clipboard), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_copy_link:
|
||||
clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
|
||||
clip = ClipData.newPlainText(Helper.CLIP_BOARD, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl());
|
||||
if (clipboard != null) {
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toasty.info(context, context.getString(R.string.clipboard_url), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_share:
|
||||
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
|
||||
String url;
|
||||
|
||||
if (status.getReblog() != null) {
|
||||
if (status.getReblog().getUri().startsWith("http"))
|
||||
url = status.getReblog().getUri();
|
||||
else
|
||||
url = status.getReblog().getUrl();
|
||||
} else {
|
||||
if (status.getUri().startsWith("http"))
|
||||
url = status.getUri();
|
||||
else
|
||||
url = status.getUrl();
|
||||
}
|
||||
String extra_text;
|
||||
|
||||
if (share_details) {
|
||||
extra_text = (status.getReblog() != null) ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct();
|
||||
if (extra_text.split("@").length == 1)
|
||||
extra_text = "@" + extra_text + "@" + Helper.getLiveInstance(context);
|
||||
else
|
||||
extra_text = "@" + extra_text;
|
||||
extra_text += " " + Helper.shortnameToUnicode(":link:", true) + " " + url + "\r\n-\n";
|
||||
final String contentToot;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
else
|
||||
contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent()).toString();
|
||||
extra_text += contentToot;
|
||||
} else {
|
||||
extra_text = url;
|
||||
}
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
|
||||
sendIntent.setType("text/plain");
|
||||
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
|
||||
return true;
|
||||
case R.id.action_custom_sharing:
|
||||
Intent intentCustomSharing = new Intent(context, CustomSharingActivity.class);
|
||||
Bundle bCustomSharing = new Bundle();
|
||||
if (status.getReblog() != null) {
|
||||
bCustomSharing.putParcelable("status", status.getReblog());
|
||||
} else {
|
||||
bCustomSharing.putParcelable("status", status);
|
||||
}
|
||||
intentCustomSharing.putExtras(bCustomSharing);
|
||||
context.startActivity(intentCustomSharing);
|
||||
return true;
|
||||
case R.id.action_mention:
|
||||
mention(status);
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
//Text for report
|
||||
EditText input = null;
|
||||
if (doAction == API.StatusAction.REPORT) {
|
||||
input = new EditText(context);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
input.setLayoutParams(lp);
|
||||
builderInner.setView(input);
|
||||
}
|
||||
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
final EditText finalInput = input;
|
||||
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
if (doAction == API.StatusAction.UNSTATUS) {
|
||||
String targetedId = status.getId();
|
||||
new PostActionAsyncTask(context, doAction, targetedId, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
if (redraft) {
|
||||
if (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().trim().equals("null")) {
|
||||
toot = new Status();
|
||||
toot.setIn_reply_to_id(status.getIn_reply_to_id());
|
||||
toot.setSensitive(status.isSensitive());
|
||||
toot.setMedia_attachments(status.getMedia_attachments());
|
||||
if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0)
|
||||
toot.setSpoiler_text(status.getSpoiler_text().trim());
|
||||
toot.setContent(context, status.getContent());
|
||||
toot.setVisibility(status.getVisibility());
|
||||
if (status.getPoll() != null) {
|
||||
toot.setPoll(status.getPoll());
|
||||
} else if (status.getReblog() != null && status.getReblog().getPoll() != null) {
|
||||
toot.setPoll(status.getPoll());
|
||||
}
|
||||
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ONESTATUS, status.getIn_reply_to_id(), null, false, false, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
toot = new Status();
|
||||
toot.setSensitive(status.isSensitive());
|
||||
toot.setMedia_attachments(status.getMedia_attachments());
|
||||
if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0)
|
||||
toot.setSpoiler_text(status.getSpoiler_text().trim());
|
||||
toot.setVisibility(status.getVisibility());
|
||||
toot.setContent(context, status.getContent());
|
||||
if (status.getPoll() != null) {
|
||||
toot.setPoll(status.getPoll());
|
||||
} else if (status.getReblog() != null && status.getReblog().getPoll() != null) {
|
||||
toot.setPoll(status.getPoll());
|
||||
}
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
long id = new StatusStoredDAO(context, db).insertStatus(toot, null);
|
||||
Intent intentToot = new Intent(context, TootActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putLong("restored", id);
|
||||
b.putBoolean("removed", true);
|
||||
intentToot.putExtras(b);
|
||||
context.startActivity(intentToot);
|
||||
}
|
||||
}
|
||||
} else if (doAction == API.StatusAction.REPORT) {
|
||||
String comment = null;
|
||||
if (finalInput.getText() != null)
|
||||
comment = finalInput.getText().toString();
|
||||
new PostActionAsyncTask(context, doAction, status.getId(), status, comment, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
String targetedId;
|
||||
if (item.getItemId() == R.id.action_block_domain) {
|
||||
targetedId = status.getAccount().getAcct().split("@")[1];
|
||||
} else {
|
||||
targetedId = status.getAccount().getId();
|
||||
}
|
||||
new PostActionAsyncTask(context, doAction, targetedId, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
builderInner.show();
|
||||
return true;
|
||||
});
|
||||
popup.show();
|
||||
});
|
||||
|
|
|
@ -73,6 +73,7 @@ import app.fedilab.android.client.Entities.Peertube;
|
|||
import app.fedilab.android.client.Entities.RemoteInstance;
|
||||
import app.fedilab.android.client.Entities.RetrieveFeedsParam;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.StatusDrawerParams;
|
||||
import app.fedilab.android.client.Entities.TagTimeline;
|
||||
import app.fedilab.android.drawers.ArtListAdapter;
|
||||
import app.fedilab.android.drawers.PeertubeAdapter;
|
||||
|
@ -233,12 +234,24 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
List<TagTimeline> tagTimelines = new SearchDAO(context, db).getTimelineInfo(tag);
|
||||
if (tagTimelines != null && tagTimelines.size() > 0) {
|
||||
tagTimeline = tagTimelines.get(0);
|
||||
statusListAdapter = new StatusListAdapter(tagTimeline, targetedId, isOnWifi, this.statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setTagTimeline(tagTimelines.get(0));
|
||||
statusDrawerParams.setTargetedId(targetedId);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(this.statuses);
|
||||
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
}
|
||||
} else {
|
||||
BaseMainActivity.displayPeertube = null;
|
||||
statusListAdapter = new StatusListAdapter(instanceType, type, targetedId, isOnWifi, this.statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setType(type);
|
||||
statusDrawerParams.setInstanceType(instanceType);
|
||||
statusDrawerParams.setTargetedId(targetedId);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(this.statuses);
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
}
|
||||
} else if (instanceType.equals("PEERTUBE")) {
|
||||
|
@ -546,7 +559,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
//If no item were inserted previously the adapter is created
|
||||
if (previousPosition == 0) {
|
||||
boolean isOnWifi = Helper.isOnWIFI(context);
|
||||
statusListAdapter = new StatusListAdapter(instanceType, type, targetedId, isOnWifi, this.statuses);
|
||||
StatusDrawerParams statusDrawerParams = new StatusDrawerParams();
|
||||
statusDrawerParams.setInstanceType(instanceType);
|
||||
statusDrawerParams.setType(type);
|
||||
statusDrawerParams.setTargetedId(targetedId);
|
||||
statusDrawerParams.setOnWifi(isOnWifi);
|
||||
statusDrawerParams.setStatuses(this.statuses);
|
||||
statusListAdapter = new StatusListAdapter(statusDrawerParams);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
} else {
|
||||
statusListAdapter.notifyItemRangeInserted(previousPosition, apiResponse.getStatuses().size());
|
||||
|
|
Loading…
Reference in New Issue