move some code

This commit is contained in:
Thomas 2020-07-13 19:19:53 +02:00
parent f864ebd969
commit 441807c7cd
8 changed files with 99 additions and 202 deletions

View File

@ -58,12 +58,15 @@ android {
sourceSets {
playstore {
manifest.srcFile "src/main/AndroidManifest.xml"
java.srcDirs = ['src/main/java', 'src/playstore/java','src/common/java']
}
fdroid {
manifest.srcFile "src/main/AndroidManifest.xml"
java.srcDirs = ['src/main/java', 'src/fdroid/java','src/common/java']
}
lite {
manifest.srcFile "src/lite/AndroidManifest.xml"
java.srcDirs = ['src/main/java', 'src/lite/java']
}
}
@ -147,7 +150,7 @@ dependencies {
implementation 'com.github.duanhong169:colorpicker:1.1.6'
implementation 'com.github.penfeizhou.android.animation:glide-plugin:2.2.0'
implementation 'com.github.stom79:Android-WYSIWYG-Editor:3.2.1'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation 'com.github.smarteist:autoimageslider:1.3.2'
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.2'
@ -157,7 +160,7 @@ dependencies {
//Playstore
playstoreImplementation "io.github.kobakei:ratethisapp:1.2.0"
playstoreImplementation "org.conscrypt:conscrypt-android:2.4.0"
playstoreImplementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
playstoreImplementation 'com.github.stom79:country-picker-android:1.2.0'
playstoreImplementation 'com.vanniktech:emoji-one:0.6.0'
playstoreImplementation 'ja.burhanrashid52:photoeditor:0.4.0'
@ -165,7 +168,6 @@ dependencies {
//Fdroid
fdroidImplementation "org.conscrypt:conscrypt-android:2.4.0"
fdroidImplementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
fdroidImplementation 'com.github.stom79:country-picker-android:1.2.0'
fdroidImplementation 'com.vanniktech:emoji-one:0.6.0'
fdroidImplementation 'ja.burhanrashid52:photoeditor:0.4.0'

View File

@ -1,4 +1,4 @@
package app.fedilab.android.drawer;
package app.fedilab.android.drawers;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of Fedilab
@ -13,19 +13,21 @@ package app.fedilab.android.drawer;
*
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.inputmethod.InputMethodManager;
import com.vanniktech.emoji.EmojiManager;
import com.vanniktech.emoji.EmojiPopup;
import com.vanniktech.emoji.one.EmojiOneProvider;
import app.fedilab.android.activities.OwnerNotificationChartsActivity;
import app.fedilab.android.asynctasks.PostActionAsyncTask;
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
import app.fedilab.android.client.API;
import app.fedilab.android.client.Entities.Reaction;
import app.fedilab.android.client.Entities.StatusDrawerParams;
import app.fedilab.android.drawers.BaseStatusListAdapter;
import static android.content.Context.INPUT_METHOD_SERVICE;
@ -74,4 +76,12 @@ public class StatusListAdapter extends BaseStatusListAdapter {
emojiPopup.toggle();
}
protected void notificationCharts(){
Intent intent = new Intent(context, OwnerNotificationChartsActivity.class);
Bundle b = new Bundle();
b.putString("status_id", status.getReblog() != null ? status.getReblog().getId() : status.getId());
intent.putExtras(b);
context.startActivity(intent);
}
}

View File

@ -1,8 +1,12 @@
package app.fedilab.android.activities;
import android.annotation.SuppressLint;
import com.vanniktech.emoji.EmojiManager;
import com.vanniktech.emoji.one.EmojiOneProvider;
import app.fedilab.android.helper.Helper;
/**
* Created by Thomas on 12/12/2017.

View File

@ -329,10 +329,6 @@
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:theme="@style/AppThemeDark_NoActionBar" />
<activity
android:name="app.fedilab.android.activities.PhotoEditorActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name" />
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="@style/Base.Theme.AppCompat" />
@ -376,25 +372,7 @@
android:label="@string/app_name"
android:theme="@style/AppThemeDark_NoActionBar"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity
android:name="app.fedilab.android.activities.OwnerStatusActivity"
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask"
android:theme="@style/AppThemeDark_NoActionBar"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity-alias
android:name=".activities.OwnerNotificationChartsActivity"
tools:node="remove"
android:targetActivity=".activities.OwnerNotificationChartsActivity" />
<activity-alias
android:name=".activities.OwnerChartsActivity"
tools:node="remove"
android:targetActivity=".activities.OwnerChartsActivity" />
<activity-alias
android:name=".activities.OwnerNotificationActivity"
tools:node="remove"
android:targetActivity=".activities.OwnerNotificationActivity" />
<activity
android:name="app.fedilab.android.activities.AboutActivity"
android:configChanges="orientation|screenSize"

View File

@ -1,5 +1,18 @@
package app.fedilab.android.activities;
/* 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>. */
import android.annotation.SuppressLint;

View File

@ -1,4 +1,4 @@
package app.fedilab.android.drawer;
package app.fedilab.android.drawers;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of Fedilab
@ -13,17 +13,11 @@ package app.fedilab.android.drawer;
*
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
import android.os.AsyncTask;
import android.view.inputmethod.InputMethodManager;
import app.fedilab.android.asynctasks.PostActionAsyncTask;
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
import app.fedilab.android.client.API;
import app.fedilab.android.client.Entities.Reaction;
import android.app.Activity;
import android.view.WindowManager;
import app.fedilab.android.client.Entities.StatusDrawerParams;
import app.fedilab.android.drawers.BaseStatusListAdapter;
import static android.content.Context.INPUT_METHOD_SERVICE;
public class StatusListAdapter extends BaseStatusListAdapter {
public StatusListAdapter(StatusDrawerParams statusDrawerParams) {
@ -31,7 +25,10 @@ public class StatusListAdapter extends BaseStatusListAdapter {
}
protected void statusAddReactionClick(){
((Activity)context).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
protected void notificationCharts(){
}
}

View File

@ -94,9 +94,6 @@ import com.github.stom79.mytransl.client.HttpsConnectionException;
import com.github.stom79.mytransl.client.Results;
import com.github.stom79.mytransl.translate.Translate;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.vanniktech.emoji.EmojiManager;
import com.vanniktech.emoji.EmojiPopup;
import com.vanniktech.emoji.one.EmojiOneProvider;
import com.varunest.sparkbutton.SparkButton;
import org.jetbrains.annotations.NotNull;
@ -119,7 +116,6 @@ import app.fedilab.android.activities.BaseActivity;
import app.fedilab.android.activities.BaseMainActivity;
import app.fedilab.android.activities.CustomSharingActivity;
import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.activities.OwnerNotificationChartsActivity;
import app.fedilab.android.activities.PeertubeActivity;
import app.fedilab.android.activities.ShowAccountActivity;
import app.fedilab.android.activities.ShowConversationActivity;
@ -146,7 +142,6 @@ import app.fedilab.android.client.Entities.ManageTimelines;
import app.fedilab.android.client.Entities.Notification;
import app.fedilab.android.client.Entities.Poll;
import app.fedilab.android.client.Entities.PollOptions;
import app.fedilab.android.client.Entities.Reaction;
import app.fedilab.android.client.Entities.Relationship;
import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.client.Entities.StatusDrawerParams;
@ -197,7 +192,7 @@ import static app.fedilab.android.helper.Helper.makeEmojis;
* Created by Thomas on 24/04/2017.
* Adapter for Status
*/
public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnPostActionInterface, OnRetrieveFeedsInterface, OnRetrieveImageInterface, OnRetrieveEmojiInterface, OnRetrieveRepliesInterface, OnRetrieveCardInterface, OnPollInterface, OnRefreshCachedStatusInterface, OnRetrieveSearcAccountshInterface, OnRetrieveSearchInterface, OnPostStatusActionInterface, OnRetrieveRelationshipQuickReplyInterface, OnSyncBookmarksInterface {
public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements OnPostActionInterface, OnRetrieveFeedsInterface, OnRetrieveImageInterface, OnRetrieveEmojiInterface, OnRetrieveRepliesInterface, OnRetrieveCardInterface, OnPollInterface, OnRefreshCachedStatusInterface, OnRetrieveSearcAccountshInterface, OnRetrieveSearchInterface, OnPostStatusActionInterface, OnRetrieveRelationshipQuickReplyInterface, OnSyncBookmarksInterface {
public static final int DISPLAYED_STATUS = 1;
public static final int COMPACT_STATUS = 3;
@ -206,11 +201,13 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
private static final int FOCUSED_STATUS = 2;
public static boolean fetch_all_more = false;
private final Object lock = new Object();
private Context context;
protected Context context;
protected Status status;
protected ViewHolder holder;
private List<Status> statuses;
private boolean isOnWifi;
private StatusListAdapter statusListAdapter;
private RetrieveFeedsAsyncTask.Type type;
private BaseStatusListAdapter statusListAdapter;
protected RetrieveFeedsAsyncTask.Type type;
private String targetedId;
private int conversationPosition;
private boolean redraft;
@ -248,9 +245,9 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
}
};
private Handler mHandler = new Handler();
private int style;
protected int style;
public StatusListAdapter(StatusDrawerParams statusDrawerParams) {
public BaseStatusListAdapter(StatusDrawerParams statusDrawerParams) {
statuses = statusDrawerParams.getStatuses();
isOnWifi = statusDrawerParams.isOnWifi();
statusListAdapter = this;
@ -319,7 +316,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
if (refreshedStatus.getCreated_at() == null) {
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
new TimelineCacheDAO(context, db).remove(refreshedStatus.getId());
new PostActionAsyncTask(context, API.StatusAction.UNSTATUS, refreshedStatus.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new PostActionAsyncTask(context, API.StatusAction.UNSTATUS, refreshedStatus.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
statusListAdapter.notifyStatusChanged(refreshedStatus);
}
@ -501,7 +498,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
toot.setContent(context, tootContent);
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
new PostStatusAsyncTask(context, social, account, toot, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new PostStatusAsyncTask(context, social, account, toot, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return;
}
@ -614,10 +611,10 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
if (viewHolder.getItemViewType() != HIDDEN_STATUS) {
final ViewHolder holder = (ViewHolder) viewHolder;
holder = (ViewHolder) viewHolder;
holder.startUpdateTimer();
final Status status = statuses.get(i);
status = statuses.get(i);
if (status == null)
@ -834,11 +831,11 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
if (choice[0] == -1)
return;
}
new ManagePollAsyncTask(context, ManagePollAsyncTask.type_s.SUBMIT, status, choice, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new ManagePollAsyncTask(context, ManagePollAsyncTask.type_s.SUBMIT, status, choice, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
});
}
holder.refresh_poll.setOnClickListener(v -> new ManagePollAsyncTask(context, ManagePollAsyncTask.type_s.REFRESH, status, null, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR));
holder.refresh_poll.setOnClickListener(v -> new ManagePollAsyncTask(context, ManagePollAsyncTask.type_s.REFRESH, status, null, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR));
holder.poll_container.setVisibility(View.VISIBLE);
holder.number_votes.setText(context.getResources().getQuantityString(R.plurals.number_of_voters, poll.getVoters_count(), poll.getVoters_count()));
if (poll.isExpired()) {
@ -877,7 +874,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
String comment = input.getText().toString();
if (comment.trim().length() > 0) {
new PostActionAsyncTask(context, PeertubeActivity.video_id, comment, status.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new PostActionAsyncTask(context, PeertubeActivity.video_id, comment, status.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
dialog.dismiss();
}
});
@ -902,7 +899,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
builderInner.setMessage(R.string.delete_comment_confirm);
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
new PostActionAsyncTask(context, API.StatusAction.PEERTUBEDELETECOMMENT, PeertubeActivity.video_id, null, status.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new PostActionAsyncTask(context, API.StatusAction.PEERTUBEDELETECOMMENT, PeertubeActivity.video_id, null, status.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
dialog.dismiss();
});
builderInner.show();
@ -1016,111 +1013,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
holder.reactions_view.setLayoutManager(layoutManager);
holder.status_add_reaction.setOnClickListener(v -> {
EmojiManager.install(new EmojiOneProvider());
final EmojiPopup emojiPopup = EmojiPopup.Builder.fromRootView(holder.status_add_reaction).setOnEmojiPopupDismissListener(() -> {
InputMethodManager imm = (InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);
assert imm != null;
imm.hideSoftInputFromWindow(holder.status_add_reaction.getWindowToken(), 0);
}).setOnEmojiClickListener((emoji, imageView) -> {
String emojiStr = imageView.getUnicode();
boolean alreadyAdded = false;
for (Reaction reaction : status.getReactions()) {
if (reaction.getName().compareTo(emojiStr) == 0) {
alreadyAdded = true;
reaction.setCount(reaction.getCount() - 1);
if (reaction.getCount() == 0) {
status.getReactions().remove(reaction);
}
notifyStatusChanged(status);
break;
}
}
if (!alreadyAdded) {
Reaction reaction = new Reaction();
reaction.setMe(true);
reaction.setCount(1);
reaction.setName(emojiStr);
status.getReactions().add(0, reaction);
notifyStatusChanged(status);
}
API.StatusAction statusAction;
if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
statusAction = alreadyAdded ? API.StatusAction.REMOVE_REACTION : API.StatusAction.ADD_REACTION;
} else {
statusAction = alreadyAdded ? API.StatusAction.REMOVE_PLEROMA_REACTION : API.StatusAction.ADD_PLEROMA_REACTION;
}
new PostActionAsyncTask(context, statusAction, status.getId(), null, emojiStr, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
})
.build(holder.fake_edittext);
emojiPopup.toggle();
});
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
holder.status_add_custom_emoji.setVisibility(View.GONE);
}
holder.status_add_custom_emoji.setOnClickListener(v -> {
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
List<Emojis> emojis = new CustomEmojiDAO(context, db).getAllEmojis(account.getInstance());
if (theme == Helper.THEME_DARK) {
style = R.style.DialogDark;
} else if (theme == Helper.THEME_BLACK) {
style = R.style.DialogBlack;
} else {
style = R.style.Dialog;
}
final AlertDialog.Builder builder = new AlertDialog.Builder(context, style);
int paddingPixel = 15;
float density = context.getResources().getDisplayMetrics().density;
int paddingDp = (int) (paddingPixel * density);
builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builder.setTitle(R.string.insert_emoji);
if (emojis != null && emojis.size() > 0) {
GridView gridView = new GridView(context);
gridView.setAdapter(new CustomEmojiAdapter(emojis));
gridView.setNumColumns(5);
gridView.setOnItemClickListener((parent, view, position, id) -> {
boolean alreadyAdded = false;
for (Reaction reaction : status.getReactions()) {
if (reaction.getName().compareTo(emojis.get(position).getShortcode()) == 0) {
alreadyAdded = true;
reaction.setCount(reaction.getCount() - 1);
if (reaction.getCount() == 0) {
status.getReactions().remove(reaction);
}
notifyStatusChanged(status);
break;
}
}
if (!alreadyAdded) {
Reaction reaction = new Reaction();
reaction.setMe(true);
reaction.setCount(1);
reaction.setName(emojis.get(position).getShortcode());
reaction.setUrl(emojis.get(position).getUrl());
status.getReactions().add(0, reaction);
notifyStatusChanged(status);
}
API.StatusAction statusAction;
if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
statusAction = alreadyAdded ? API.StatusAction.REMOVE_REACTION : API.StatusAction.ADD_REACTION;
} else {
statusAction = alreadyAdded ? API.StatusAction.REMOVE_PLEROMA_REACTION : API.StatusAction.ADD_PLEROMA_REACTION;
}
new PostActionAsyncTask(context, statusAction, status.getId(), null, emojis.get(position).getShortcode(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
alertDialogEmoji.dismiss();
});
gridView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
builder.setView(gridView);
} else {
TextView textView = new TextView(context);
textView.setText(context.getString(R.string.no_emoji));
textView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
builder.setView(textView);
}
alertDialogEmoji = builder.show();
});
holder.status_add_reaction.setOnClickListener(v -> statusAddReactionClick());
}
holder.status_cardview_title.setTextColor(ContextCompat.getColor(context, R.color.dark_text_toot_header));
@ -1175,7 +1068,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} else {
holder.cached_status.setVisibility(View.GONE);
}
holder.cached_status.setOnClickListener(v -> new ManageCachedStatusAsyncTask(context, status.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR));
holder.cached_status.setOnClickListener(v -> new ManageCachedStatusAsyncTask(context, status.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR));
}
if (holder.fedilab_features != null && !fedilab_features_button)
@ -1266,11 +1159,11 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
TooltipCompat.setTooltipText(holder.custom_feature_cache, context.getString(R.string.refresh_cache));
holder.custom_feature_cache.setOnClickListener(view -> {
if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
new ManageCachedStatusAsyncTask(context, status.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new ManageCachedStatusAsyncTask(context, status.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
status.setCustomFeaturesDisplayed(false);
notifyStatusChanged(status);
} else {
new SyncBookmarksAsyncTask(context, status.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new SyncBookmarksAsyncTask(context, status.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
@ -2167,7 +2060,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
imm.hideSoftInputFromWindow(holder.quick_reply_button.getWindowToken(), 0);
});
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
holder.quick_reply_button.setOnLongClickListener(v -> {
android.widget.PopupMenu popup = new android.widget.PopupMenu(context, holder.quick_reply_button);
popup.getMenuInflater()
@ -2330,7 +2223,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
b.putInt("position", 1);
intent.putExtras(b);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation((Activity) context, holder.webview_preview, attachment.getUrl());
// start the new activity
@ -2363,7 +2256,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
});
holder.status_reply.setOnClickListener(v -> {
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED || (quick_reply && type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS)) {
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED || (quick_reply && type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS)) {
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
holder.quick_reply_switch_to_full.setVisibility(View.GONE);
@ -2377,7 +2270,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
holder.warning_message.setVisibility(View.GONE);
if (status.getWarningFetched() == -1) {
warning_message = holder.warning_message;
new RetrieveRelationshipQuickReplyAsyncTask(context, status, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRelationshipQuickReplyAsyncTask(context, status, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else if (status.getWarningFetched() == 1) {
holder.warning_message.setVisibility(View.VISIBLE);
@ -2408,7 +2301,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} else {
holder.quick_reply_text.setText(status.getQuickReplyContent());
}
TextWatcher textWatcher = TootActivity.initializeTextWatcher(context, social, status, holder.quick_reply_text, content_cw, holder.toot_space_left, null, null, StatusListAdapter.this, StatusListAdapter.this, StatusListAdapter.this);
TextWatcher textWatcher = TootActivity.initializeTextWatcher(context, social, status, holder.quick_reply_text, content_cw, holder.toot_space_left, null, null, BaseStatusListAdapter.this, BaseStatusListAdapter.this, BaseStatusListAdapter.this);
toot_content = holder.quick_reply_text;
int newInputType = toot_content.getInputType() & (toot_content.getInputType() ^ InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
@ -2548,7 +2441,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
status.setFavAnimated(true);
notifyStatusChanged(status);
}
CrossActions.doCrossAction(context, type, status, null, (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) ? API.StatusAction.UNFAVOURITE : API.StatusAction.FAVOURITE, statusListAdapter, StatusListAdapter.this, true);
CrossActions.doCrossAction(context, type, status, null, (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) ? API.StatusAction.UNFAVOURITE : API.StatusAction.FAVOURITE, statusListAdapter, BaseStatusListAdapter.this, true);
});
holder.spark_button_fav.setOnClickListener(v -> {
if (!status.isFavourited() && confirmFav)
@ -2557,7 +2450,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
status.setFavAnimated(true);
notifyStatusChanged(status);
}
CrossActions.doCrossAction(context, type, status, null, (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) ? API.StatusAction.UNFAVOURITE : API.StatusAction.FAVOURITE, statusListAdapter, StatusListAdapter.this, true);
CrossActions.doCrossAction(context, type, status, null, (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) ? API.StatusAction.UNFAVOURITE : API.StatusAction.FAVOURITE, statusListAdapter, BaseStatusListAdapter.this, true);
});
holder.status_reblog_count.setOnClickListener(v -> {
@ -2567,7 +2460,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
status.setBoostAnimated(true);
notifyStatusChanged(status);
}
CrossActions.doCrossAction(context, type, status, null, (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) ? API.StatusAction.UNREBLOG : API.StatusAction.REBLOG, statusListAdapter, StatusListAdapter.this, true);
CrossActions.doCrossAction(context, type, status, null, (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) ? API.StatusAction.UNREBLOG : API.StatusAction.REBLOG, statusListAdapter, BaseStatusListAdapter.this, true);
});
holder.spark_button_reblog.setOnClickListener(v -> {
if (!status.isReblogged() && confirmBoost)
@ -2576,9 +2469,9 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
status.setBoostAnimated(true);
notifyStatusChanged(status);
}
CrossActions.doCrossAction(context, type, status, null, (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) ? API.StatusAction.UNREBLOG : API.StatusAction.REBLOG, statusListAdapter, StatusListAdapter.this, true);
CrossActions.doCrossAction(context, type, status, null, (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) ? API.StatusAction.UNREBLOG : API.StatusAction.REBLOG, statusListAdapter, BaseStatusListAdapter.this, true);
});
holder.status_pin.setOnClickListener(v -> CrossActions.doCrossAction(context, type, status, null, (status.isPinned() || (status.getReblog() != null && status.getReblog().isPinned())) ? API.StatusAction.UNPIN : API.StatusAction.PIN, statusListAdapter, StatusListAdapter.this, true));
holder.status_pin.setOnClickListener(v -> CrossActions.doCrossAction(context, type, status, null, (status.isPinned() || (status.getReblog() != null && status.getReblog().isPinned())) ? API.StatusAction.UNPIN : API.StatusAction.PIN, statusListAdapter, BaseStatusListAdapter.this, true));
int style;
if (theme == Helper.THEME_DARK) {
style = R.style.DialogDark;
@ -2610,7 +2503,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
String targetedId = status.getId();
new PostActionAsyncTask(context, doAction, targetedId, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new PostActionAsyncTask(context, doAction, targetedId, BaseStatusListAdapter.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();
@ -2621,7 +2514,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
toot.setSpoiler_text(status.getSpoiler_text().trim());
toot.setContent(context, status.getContent());
toot.setVisibility(status.getVisibility());
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ONESTATUS, status.getIn_reply_to_id(), null, false, false, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ONESTATUS, status.getIn_reply_to_id(), null, false, false, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
toot = new Status();
toot.setSensitive(status.isSensitive());
@ -2646,12 +2539,12 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
});
if (!status.getVisibility().equals("direct"))
holder.spark_button_fav.setOnLongClickListener(view -> {
CrossActions.doCrossAction(context, type, status, null, API.StatusAction.FAVOURITE, statusListAdapter, StatusListAdapter.this, false);
CrossActions.doCrossAction(context, type, status, null, API.StatusAction.FAVOURITE, statusListAdapter, BaseStatusListAdapter.this, false);
return true;
});
if (!status.getVisibility().equals("direct"))
holder.spark_button_reblog.setOnLongClickListener(view -> {
CrossActions.doCrossAction(context, type, status, null, API.StatusAction.REBLOG, statusListAdapter, StatusListAdapter.this, false);
CrossActions.doCrossAction(context, type, status, null, API.StatusAction.REBLOG, statusListAdapter, BaseStatusListAdapter.this, false);
return true;
});
@ -2715,7 +2608,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} else {
popup.getMenu().findItem(R.id.action_stats).setVisible(false);
popup.getMenu().findItem(R.id.action_redraft).setVisible(false);
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA && (isAdmin || isModerator)) {
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA && (isAdmin || isModerator)) {
popup.getMenu().findItem(R.id.action_remove).setVisible(true);
} else {
popup.getMenu().findItem(R.id.action_remove).setVisible(false);
@ -2725,7 +2618,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
stringArrayConf = context.getResources().getStringArray(R.array.more_action_confirm);
}
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
if (social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
popup.getMenu().findItem(R.id.action_info).setVisible(false);
popup.getMenu().findItem(R.id.action_report).setVisible(false);
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
@ -2738,7 +2631,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
popup.getMenu().findItem(R.id.action_schedule_boost).setVisible(false);
popup.getMenu().findItem(R.id.action_mention).setVisible(false);
}
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
if (social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON && social != UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
popup.getMenu().findItem(R.id.action_admin).setVisible(false);
} else {
boolean display_admin_statuses = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ADMIN_STATUSES + userId + Helper.getLiveInstance(context), false);
@ -2820,7 +2713,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
else
doAction = API.StatusAction.MUTE_CONVERSATION;
new PostActionAsyncTask(context, doAction, status.getId(), StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new PostActionAsyncTask(context, doAction, status.getId(), BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return true;
case R.id.action_bookmark:
if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
@ -2855,11 +2748,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
}
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);
notificationCharts();
return true;
case R.id.action_timed_mute:
timedMuteAction(status);
@ -2977,7 +2866,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
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);
new PostActionAsyncTask(context, doAction, targetedId, BaseStatusListAdapter.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();
@ -2993,7 +2882,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} 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);
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ONESTATUS, status.getIn_reply_to_id(), null, false, false, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
toot = new Status();
toot.setSensitive(status.isSensitive());
@ -3021,7 +2910,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
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);
new PostActionAsyncTask(context, doAction, status.getId(), status, comment, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
String targetedId;
if (item.getItemId() == R.id.action_block_domain) {
@ -3029,7 +2918,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} else {
targetedId = status.getAccount().getId();
}
new PostActionAsyncTask(context, doAction, targetedId, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new PostActionAsyncTask(context, doAction, targetedId, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
dialog.dismiss();
});
@ -3074,7 +2963,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
instance = matcher.group(1);
}
account.setInstance(instance);
if (BaseMainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
if (social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
CrossActions.doCrossProfile(context, account);
else {
Intent intent = new Intent(context, ShowAccountActivity.class);
@ -3095,7 +2984,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
instance = matcher.group(1);
}
account.setInstance(instance);
if (BaseMainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
if (social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
CrossActions.doCrossProfile(context, account);
else {
Intent intent = new Intent(context, ShowAccountActivity.class);
@ -3110,7 +2999,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
});
}
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
if (getItemViewType(viewHolder.getAdapterPosition()) == FOCUSED_STATUS && status.getApplication() != null && status.getApplication().getName() != null && status.getApplication().getName().length() > 0) {
Application application = status.getApplication();
holder.status_toot_app.setText(application.getName());
@ -3128,6 +3017,8 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
}
protected abstract void statusAddReactionClick();
protected abstract void notificationCharts();
private void loadAttachments(final Status status, final ViewHolder holder, boolean blur) {
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
@ -3751,7 +3642,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
content = status.getQuickReplyContent();
}
toot.setContent(context, content);
new PostStatusAsyncTask(context, social, account, toot, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new PostStatusAsyncTask(context, social, account, toot, BaseStatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
status.setQuickReplyPrivacy(null);
status.setQuickReplyContent(null);
}
@ -4011,7 +3902,7 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
}
}
class ViewHolder extends RecyclerView.ViewHolder {
protected class ViewHolder extends RecyclerView.ViewHolder {
LinearLayout status_content_container;
LinearLayout status_spoiler_container;
CustomTextView status_spoiler;
@ -4113,9 +4004,10 @@ public class StatusListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
TextView translation_label;
LinearLayout status_reactions;
ImageView status_add_reaction, status_add_custom_emoji;
public ImageView status_add_reaction;
ImageView status_add_custom_emoji;
RecyclerView reactions_view;
MastalabAutoCompleteTextView fake_edittext;
public MastalabAutoCompleteTextView fake_edittext;
@SuppressLint("SetJavaScriptEnabled")
ViewHolder(View itemView) {

View File

@ -51,6 +51,7 @@ import app.fedilab.android.client.Entities.Results;
import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.client.GNUAPI;
import app.fedilab.android.drawers.AccountsSearchAdapter;
import app.fedilab.android.drawers.BaseStatusListAdapter;
import app.fedilab.android.drawers.PixelfedListAdapter;
import app.fedilab.android.drawers.StatusListAdapter;
import app.fedilab.android.interfaces.OnPostActionInterface;
@ -487,7 +488,7 @@ public class CrossActions {
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
public static void doCrossBookmark(final Context context, Status status, StatusListAdapter statusListAdapter, boolean limitedToOwner) {
public static void doCrossBookmark(final Context context, Status status, BaseStatusListAdapter statusListAdapter, boolean limitedToOwner) {
List<Account> accounts = connectedAccounts(context, status, false);
API.StatusAction doAction;
//Only bookmark the initial status