Release 2.37.0-beta-2

This commit is contained in:
Thomas 2021-01-18 19:00:43 +01:00
parent 3e4f027377
commit 7e264d1f91
13 changed files with 3031 additions and 3108 deletions

View File

@ -6,8 +6,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
versionCode 377 versionCode 378
versionName "2.37.0-beta-1" versionName "2.37.0-beta-2"
multiDexEnabled true multiDexEnabled true
renderscriptTargetApi 28 as int renderscriptTargetApi 28 as int
renderscriptSupportModeEnabled true renderscriptSupportModeEnabled true

View File

@ -207,17 +207,17 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
lv_ux.setAdapter(accountSearchWebAdapterUxUiDesigners); lv_ux.setAdapter(accountSearchWebAdapterUxUiDesigners);
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
new RetrieveRemoteDataAsyncTask(AboutActivity.this, "fedilab", "toot.fedilab.app", AboutActivity.this).execute(); new RetrieveRemoteDataAsyncTask(AboutActivity.this, "apps", "toot.fedilab.app", AboutActivity.this).execute();
new RetrieveRemoteDataAsyncTask(AboutActivity.this, "mmarif", "mastodon.social", AboutActivity.this).execute(); new RetrieveRemoteDataAsyncTask(AboutActivity.this, "mmarif", "mastodon.social", AboutActivity.this).execute();
new RetrieveRemoteDataAsyncTask(AboutActivity.this, "PhotonQyv", "mastodon.xyz", AboutActivity.this).execute(); new RetrieveRemoteDataAsyncTask(AboutActivity.this, "PhotonQyv", "mastodon.xyz", AboutActivity.this).execute();
new RetrieveRemoteDataAsyncTask(AboutActivity.this, "angrytux", "social.tchncs.de", AboutActivity.this).execute(); new RetrieveRemoteDataAsyncTask(AboutActivity.this, "angrytux", "social.tchncs.de", AboutActivity.this).execute();
new RetrieveRemoteDataAsyncTask(AboutActivity.this, "guzzisti", "mastodon.social", AboutActivity.this).execute(); new RetrieveRemoteDataAsyncTask(AboutActivity.this, "guzzisti", "mastodon.social", AboutActivity.this).execute();
} else { } else {
SpannableString name = new SpannableString("@fedilab@toot.fedilab.app"); SpannableString name = new SpannableString("@apps@toot.fedilab.app");
name.setSpan(new UnderlineSpan(), 0, name.length(), 0); name.setSpan(new UnderlineSpan(), 0, name.length(), 0);
txt_developers.setText(name); txt_developers.setText(name);
txt_developers.setVisibility(View.VISIBLE); txt_developers.setVisibility(View.VISIBLE);
txt_developers.setOnClickListener(v -> Helper.openBrowser(AboutActivity.this, "https://toot.fedilab.app/@fedilab")); txt_developers.setOnClickListener(v -> Helper.openBrowser(AboutActivity.this, "https://toot.fedilab.app/@apps"));
name = new SpannableString("@mmarif@mastodon.social"); name = new SpannableString("@mmarif@mastodon.social");
name.setSpan(new UnderlineSpan(), 0, name.length(), 0); name.setSpan(new UnderlineSpan(), 0, name.length(), 0);
txt_ux.setText(name); txt_ux.setText(name);
@ -259,7 +259,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
account = accounts.get(0); account = accounts.get(0);
account.setFollowing(true); account.setFollowing(true);
switch (account.getUsername()) { switch (account.getUsername()) {
case "fedilab": case "apps":
developers.add(account); developers.add(account);
accountSearchWebAdapterDeveloper.notifyDataSetChanged(); accountSearchWebAdapterDeveloper.notifyDataSetChanged();
break; break;

View File

@ -35,15 +35,15 @@ import app.fedilab.android.interfaces.OnRetrieveRemoteAccountInterface;
public class RetrieveRemoteDataAsyncTask extends AsyncTask<Void, Void, Void> { public class RetrieveRemoteDataAsyncTask extends AsyncTask<Void, Void, Void> {
private OnRetrieveRemoteAccountInterface listener; private final OnRetrieveRemoteAccountInterface listener;
private String url; private final String url;
private Results results; private Results results;
private WeakReference<Context> contextReference; private final WeakReference<Context> contextReference;
private boolean developerAccount = false; private boolean developerAccount = false;
public RetrieveRemoteDataAsyncTask(Context context, OnRetrieveRemoteAccountInterface onRetrieveRemoteAccountInterface) { public RetrieveRemoteDataAsyncTask(Context context, OnRetrieveRemoteAccountInterface onRetrieveRemoteAccountInterface) {
this.url = "https://toot.fedilab.app/@fedilab"; this.url = "https://toot.fedilab.app/@apps";
developerAccount = true; developerAccount = true;
this.listener = onRetrieveRemoteAccountInterface; this.listener = onRetrieveRemoteAccountInterface;
this.contextReference = new WeakReference<>(context); this.contextReference = new WeakReference<>(context);

View File

@ -56,7 +56,6 @@ import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.DatePicker; import android.widget.DatePicker;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.GridView; import android.widget.GridView;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
@ -92,6 +91,7 @@ import com.bumptech.glide.request.transition.Transition;
import com.github.stom79.mytransl.MyTransL; import com.github.stom79.mytransl.MyTransL;
import com.github.stom79.mytransl.client.HttpsConnectionException; import com.github.stom79.mytransl.client.HttpsConnectionException;
import com.github.stom79.mytransl.client.Results; import com.github.stom79.mytransl.client.Results;
import com.github.stom79.mytransl.translate.DeepLParams;
import com.github.stom79.mytransl.translate.Translate; import com.github.stom79.mytransl.translate.Translate;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.varunest.sparkbutton.SparkButton; import com.varunest.sparkbutton.SparkButton;
@ -148,6 +148,7 @@ import app.fedilab.android.client.Entities.StatusDrawerParams;
import app.fedilab.android.client.Entities.StoredStatus; import app.fedilab.android.client.Entities.StoredStatus;
import app.fedilab.android.client.Entities.TagTimeline; import app.fedilab.android.client.Entities.TagTimeline;
import app.fedilab.android.fragments.DisplayStatusFragment; import app.fedilab.android.fragments.DisplayStatusFragment;
import app.fedilab.android.helper.CommentDecorationHelper;
import app.fedilab.android.helper.CrossActions; import app.fedilab.android.helper.CrossActions;
import app.fedilab.android.helper.CustomTextView; import app.fedilab.android.helper.CustomTextView;
import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.Helper;
@ -204,14 +205,14 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
protected Context context; protected Context context;
protected RetrieveFeedsAsyncTask.Type type; protected RetrieveFeedsAsyncTask.Type type;
protected int style; protected int style;
private List<Status> statuses; private final List<Status> statuses;
private boolean isOnWifi; private final boolean isOnWifi;
private BaseStatusListAdapter statusListAdapter; private final BaseStatusListAdapter statusListAdapter;
private String targetedId; private final String targetedId;
private int conversationPosition; private int conversationPosition;
private boolean redraft; private boolean redraft;
private Status toot; private Status toot;
private TagTimeline tagTimeline; private final TagTimeline tagTimeline;
private AlertDialog alertDialogEmoji; private AlertDialog alertDialogEmoji;
private MastalabAutoCompleteTextView toot_content; private MastalabAutoCompleteTextView toot_content;
private EditText toot_cw_content; private EditText toot_cw_content;
@ -225,8 +226,9 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
private RecyclerView mRecyclerView; private RecyclerView mRecyclerView;
private List<Emojis> emojisPicker; private List<Emojis> emojisPicker;
private Status statusForQuickReply; private Status statusForQuickReply;
private String instanceType; private final String instanceType;
private Runnable updateAnimatedEmoji = new Runnable() {
private final Runnable updateAnimatedEmoji = new Runnable() {
@Override @Override
public void run() { public void run() {
synchronized (lock) { synchronized (lock) {
@ -242,7 +244,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
} }
} }
}; };
private Handler mHandler = new Handler(); private final Handler mHandler = new Handler();
public BaseStatusListAdapter(StatusDrawerParams statusDrawerParams) { public BaseStatusListAdapter(StatusDrawerParams statusDrawerParams) {
statuses = statusDrawerParams.getStatuses(); statuses = statusDrawerParams.getStatuses();
@ -630,48 +632,17 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
holder.status_privacy.setContentDescription(context.getString(R.string.toot_visibility_tilte) + ": " + v); holder.status_privacy.setContentDescription(context.getString(R.string.toot_visibility_tilte) + ": " + v);
}); });
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT && holder.status_reply_indicator_top != null) { holder.decoration_container.removeAllViews();
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT && holder.decoration_container != null && status.getIn_reply_to_id() != null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { int ident = CommentDecorationHelper.getIndentation(status.getIn_reply_to_id(), statuses);
holder.status_reply_indicator_top.setBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC4)); for (int j = 0; j <= ident; j++) {
holder.status_reply_indicator_bottom.setBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC4)); View view = new View(context);
holder.reply_indicator_dot.setBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC4)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, LinearLayout.LayoutParams.MATCH_PARENT);
} else { params.setMargins((int) Helper.convertDpToPixel(5, context), 0, 0, 0);
holder.status_reply_indicator_top.setBackgroundColor(ContextCompat.getColor(context, R.color.cyanea_accent_reference)); view.setLayoutParams(params);
holder.status_reply_indicator_bottom.setBackgroundColor(ContextCompat.getColor(context, R.color.cyanea_accent_reference)); holder.decoration_container.addView(view, 0);
holder.reply_indicator_dot.setBackgroundColor(ContextCompat.getColor(context, R.color.cyanea_accent_reference)); view.setBackgroundResource(R.color.cyanea_accent_reference);
}
if (status.isShowTopLine()) {
holder.status_reply_indicator_top.setVisibility(View.VISIBLE);
holder.reply_indicator_dot.setVisibility(View.VISIBLE);
if (holder.status_reply_indicator_diag_top != null) {
holder.status_reply_indicator_diag_top.setBackgroundResource(R.drawable.diag_top);
holder.status_reply_indicator_diag_top.setVisibility(View.VISIBLE);
}
}
if (status.isShowBottomLine()) {
holder.reply_indicator_dot.setVisibility(View.VISIBLE);
holder.status_reply_indicator_bottom.setVisibility(View.VISIBLE);
if (holder.status_reply_indicator_diag_bottom != null) {
holder.status_reply_indicator_diag_bottom.setBackgroundResource(R.drawable.diag_bottom);
holder.status_reply_indicator_diag_bottom.setVisibility(View.VISIBLE);
}
}
if (!status.isShowTopLine()) {
holder.status_reply_indicator_top.setVisibility(View.GONE);
if (holder.status_reply_indicator_diag_top != null) {
holder.status_reply_indicator_diag_top.setVisibility(View.GONE);
}
}
if (!status.isShowBottomLine()) {
holder.status_reply_indicator_bottom.setVisibility(View.GONE);
if (holder.status_reply_indicator_diag_bottom != null) {
holder.status_reply_indicator_diag_bottom.setVisibility(View.GONE);
}
}
if (!status.isShowTopLine() && !status.isShowBottomLine()) {
holder.reply_indicator_dot.setVisibility(View.GONE);
} }
} }
@ -702,7 +673,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
boolean quick_reply = sharedpreferences.getBoolean(Helper.SET_QUICK_REPLY, true); boolean quick_reply = sharedpreferences.getBoolean(Helper.SET_QUICK_REPLY, true);
int translator = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX); int translator = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE);
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS); int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
if (status.getReblog() == null) { if (status.getReblog() == null) {
@ -1600,7 +1571,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
if ((isCompactMode || isConsoleMode) && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS) { if ((isCompactMode || isConsoleMode) && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS) {
if ((status.getReblog() == null && status.getReplies_count() > 1) || (status.getReblog() != null && status.getReblog().getReplies_count() > 1)) { if ((status.getReblog() == null && status.getReplies_count() > 1) || (status.getReblog() != null && status.getReblog().getReplies_count() > 1)) {
Drawable img = context.getResources().getDrawable(R.drawable.ic_plus_one); Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_plus_one);
holder.status_reply_count.setCompoundDrawablesWithIntrinsicBounds(null, null, img, null); holder.status_reply_count.setCompoundDrawablesWithIntrinsicBounds(null, null, img, null);
} else { } else {
holder.status_reply_count.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); holder.status_reply_count.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
@ -1975,11 +1946,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
if (!status.isFavAnimated()) { if (!status.isFavAnimated()) {
if (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) { holder.spark_button_fav.setChecked(status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited()));
holder.spark_button_fav.setChecked(true);
} else {
holder.spark_button_fav.setChecked(false);
}
} else { } else {
status.setFavAnimated(false); status.setFavAnimated(false);
holder.spark_button_fav.setChecked(true); holder.spark_button_fav.setChecked(true);
@ -1987,11 +1954,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
holder.spark_button_fav.playAnimation(); holder.spark_button_fav.playAnimation();
} }
if (!status.isBoostAnimated()) { if (!status.isBoostAnimated()) {
if (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) { holder.spark_button_reblog.setChecked(status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged()));
holder.spark_button_reblog.setChecked(true);
} else {
holder.spark_button_reblog.setChecked(false);
}
} else { } else {
status.setBoostAnimated(false); status.setBoostAnimated(false);
holder.spark_button_reblog.setChecked(true); holder.spark_button_reblog.setChecked(true);
@ -2037,18 +2000,14 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
if (status.getReblog() == null) { if (status.getReblog() == null) {
if (status.getWebviewURL() != null) { if (status.getWebviewURL() != null) {
holder.status_cardview_video.setVisibility(View.VISIBLE); holder.status_cardview_video.setVisibility(View.VISIBLE);
holder.webview_preview.setVisibility(View.GONE);
} else { } else {
holder.status_cardview_video.setVisibility(View.GONE); holder.status_cardview_video.setVisibility(View.GONE);
holder.webview_preview.setVisibility(View.VISIBLE);
} }
} else { } else {
if (status.getReblog().getWebviewURL() != null) { if (status.getReblog().getWebviewURL() != null) {
holder.status_cardview_video.setVisibility(View.VISIBLE); holder.status_cardview_video.setVisibility(View.VISIBLE);
holder.webview_preview.setVisibility(View.GONE);
} else { } else {
holder.status_cardview_video.setVisibility(View.GONE); holder.status_cardview_video.setVisibility(View.GONE);
holder.webview_preview.setVisibility(View.VISIBLE);
} }
} }
@ -2068,19 +2027,15 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
.inflate(R.menu.main_content_type, popup.getMenu()); .inflate(R.menu.main_content_type, popup.getMenu());
popup.setOnMenuItemClickListener(item -> { popup.setOnMenuItemClickListener(item -> {
String contentType = null; String contentType = null;
switch (item.getItemId()) { int itemId = item.getItemId();
case R.id.action_plain_text: if (itemId == R.id.action_plain_text) {
contentType = "text/plain"; contentType = "text/plain";
break; } else if (itemId == R.id.action_html) {
case R.id.action_html: contentType = "text/html";
contentType = "text/html"; } else if (itemId == R.id.action_markdown) {
break; contentType = "text/markdown";
case R.id.action_markdown: } else if (itemId == R.id.action_bbcode) {
contentType = "text/markdown"; contentType = "text/bbcode";
break;
case R.id.action_bbcode:
contentType = "text/bbcode";
break;
} }
popup.dismiss(); popup.dismiss();
sendToot(status, contentType); sendToot(status, contentType);
@ -2195,7 +2150,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
} }
final String finalSrc = src; final String finalSrc = src;
holder.webview_preview.setOnClickListener(v -> { holder.status_cardview_video.setOnClickListener(v -> {
String url = finalSrc; String url = finalSrc;
if (url != null) { if (url != null) {
boolean invidious = Helper.getSharedValue(context, Helper.SET_INVIDIOUS); boolean invidious = Helper.getSharedValue(context, Helper.SET_INVIDIOUS);
@ -2226,7 +2181,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
intent.putExtras(b); intent.putExtras(b);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation((Activity) context, holder.webview_preview, attachment.getUrl()); .makeSceneTransitionAnimation((Activity) context, holder.status_cardview_video, attachment.getUrl());
// start the new activity // start the new activity
context.startActivity(intent, options.toBundle()); context.startActivity(intent, options.toBundle());
} else { } else {
@ -2452,11 +2407,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
}); });
//Spoiler opens //Spoiler opens
holder.status_spoiler_button.setOnClickListener(v -> { holder.status_spoiler_button.setOnClickListener(v -> {
if (expand_cw && !status.isSpoilerShown()) { status.setAutoHiddenCW(expand_cw && !status.isSpoilerShown());
status.setAutoHiddenCW(true);
} else {
status.setAutoHiddenCW(false);
}
status.setSpoilerShown(!status.isSpoilerShown()); status.setSpoilerShown(!status.isSpoilerShown());
notifyStatusChanged(status); notifyStatusChanged(status);
}); });
@ -2500,11 +2451,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
} else { } else {
popup.getMenu().findItem(R.id.action_stats).setVisible(false); popup.getMenu().findItem(R.id.action_stats).setVisible(false);
popup.getMenu().findItem(R.id.action_redraft).setVisible(false); popup.getMenu().findItem(R.id.action_redraft).setVisible(false);
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA && (isAdmin || isModerator)) { popup.getMenu().findItem(R.id.action_remove).setVisible(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);
}
//Same instance //Same instance
if (status.getAccount().getAcct().split("@").length < 2) if (status.getAccount().getAcct().split("@").length < 2)
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false); popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
@ -2544,203 +2491,199 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
popup.setOnMenuItemClickListener(item -> { popup.setOnMenuItemClickListener(item -> {
AlertDialog.Builder builderInner; AlertDialog.Builder builderInner;
final API.StatusAction doAction; final API.StatusAction doAction;
switch (item.getItemId()) { int itemId = item.getItemId();
case R.id.action_redraft: if (itemId == R.id.action_redraft) {
builderInner = new AlertDialog.Builder(context, style); builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[1]); builderInner.setTitle(stringArrayConf[1]);
redraft = true; redraft = true;
doAction = API.StatusAction.UNSTATUS; doAction = API.StatusAction.UNSTATUS;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY)); builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
else else
builderInner.setMessage(Html.fromHtml(status.getContent())); builderInner.setMessage(Html.fromHtml(status.getContent()));
break; } else if (itemId == R.id.action_schedule_boost) {
case R.id.action_schedule_boost: scheduleBoost(status);
scheduleBoost(status); return true;
return true; } else if (itemId == R.id.action_admin) {
case R.id.action_admin: String account_id = status.getReblog() != null ? status.getReblog().getAccount().getId() : status.getAccount().getId();
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();
String acct = status.getReblog() != null ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct(); Intent intent = new Intent(context, AccountReportActivity.class);
Intent intent = new Intent(context, AccountReportActivity.class); Bundle b = new Bundle();
Bundle b = new Bundle(); if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) { b.putString("account_id", account_id);
b.putString("account_id", account_id); } else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
} else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { b.putString("account_id", acct);
b.putString("account_id", acct); }
} intent.putExtras(b);
intent.putExtras(b); context.startActivity(intent);
context.startActivity(intent); return true;
return true; } else if (itemId == R.id.action_info) {
case R.id.action_info: tootInformation(status);
tootInformation(status); return true;
return true; } else if (itemId == R.id.action_open_browser) {
case R.id.action_open_browser: Helper.openBrowser(context, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl());
Helper.openBrowser(context, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl()); return true;
return true; } else if (itemId == R.id.action_remove) {
case R.id.action_remove: builderInner = new AlertDialog.Builder(context, style);
builderInner = new AlertDialog.Builder(context, style); builderInner.setTitle(stringArrayConf[0]);
builderInner.setTitle(stringArrayConf[0]); doAction = API.StatusAction.UNSTATUS;
doAction = API.StatusAction.UNSTATUS; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY)); else
else builderInner.setMessage(Html.fromHtml(status.getContent()));
builderInner.setMessage(Html.fromHtml(status.getContent())); } else if (itemId == R.id.action_block_domain) {
break; builderInner = new AlertDialog.Builder(context, style);
case R.id.action_block_domain: builderInner.setTitle(stringArrayConf[3]);
builderInner = new AlertDialog.Builder(context, style); doAction = API.StatusAction.BLOCK_DOMAIN;
builderInner.setTitle(stringArrayConf[3]); String domain = status.getAccount().getAcct().split("@")[1];
doAction = API.StatusAction.BLOCK_DOMAIN; builderInner.setMessage(context.getString(R.string.block_domain_confirm_message, domain));
String domain = status.getAccount().getAcct().split("@")[1]; } else if (itemId == R.id.action_mute) {
builderInner.setMessage(context.getString(R.string.block_domain_confirm_message, domain)); builderInner = new AlertDialog.Builder(context, style);
break; builderInner.setTitle(stringArrayConf[0]);
case R.id.action_mute: builderInner.setMessage(status.getAccount().getAcct());
builderInner = new AlertDialog.Builder(context, style); doAction = API.StatusAction.MUTE;
builderInner.setTitle(stringArrayConf[0]); } else if (itemId == R.id.action_mute_conversation) {
builderInner.setMessage(status.getAccount().getAcct()); if (status.isMuted())
doAction = API.StatusAction.MUTE; doAction = API.StatusAction.UNMUTE_CONVERSATION;
break; else
case R.id.action_mute_conversation: doAction = API.StatusAction.MUTE_CONVERSATION;
if (status.isMuted())
doAction = API.StatusAction.UNMUTE_CONVERSATION;
else
doAction = API.StatusAction.MUTE_CONVERSATION;
new PostActionAsyncTask(context, doAction, status.getId(), BaseStatusListAdapter.this).execute(); new PostActionAsyncTask(context, doAction, status.getId(), BaseStatusListAdapter.this).execute();
return true; return true;
case R.id.action_bookmark: } else if (itemId == R.id.action_bookmark) {
if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) { if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
status.setBookmarked(!status.isBookmarked()); status.setBookmarked(!status.isBookmarked());
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
try { try {
if (status.isBookmarked()) { if (status.isBookmarked()) {
new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status); new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status);
Toasty.success(context, context.getString(R.string.status_bookmarked), Toast.LENGTH_LONG).show(); Toasty.success(context, context.getString(R.string.status_bookmarked), Toast.LENGTH_LONG).show();
} else { } else {
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, status); new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, status);
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show(); 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 { notifyStatusChanged(status);
int position = 0; } catch (Exception e) {
for (Status statustmp : statuses) { e.printStackTrace();
if (statustmp.getId().equals(status.getId())) { Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
statuses.remove(status); }
statusListAdapter.notifyItemRemoved(position); } else {
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); int position = 0;
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, statustmp); for (Status statustmp : statuses) {
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show(); if (statustmp.getId().equals(status.getId())) {
break; statuses.remove(status);
} statusListAdapter.notifyItemRemoved(position);
position++; final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), 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: return true;
notificationCharts(status); } else if (itemId == R.id.action_stats) {
return true; notificationCharts(status);
case R.id.action_timed_mute: return true;
timedMuteAction(status); } else if (itemId == R.id.action_timed_mute) {
return true; timedMuteAction(status);
case R.id.action_block: return true;
builderInner = new AlertDialog.Builder(context, style); } else if (itemId == R.id.action_block) {
builderInner.setTitle(stringArrayConf[1]); builderInner = new AlertDialog.Builder(context, style);
doAction = API.StatusAction.BLOCK; builderInner.setTitle(stringArrayConf[1]);
break; doAction = API.StatusAction.BLOCK;
case R.id.action_translate: } else if (itemId == R.id.action_translate) {
if (translator == Helper.TRANS_NONE) if (translator == Helper.TRANS_NONE)
Toasty.info(context, R.string.toast_error_translations_disabled, Toast.LENGTH_SHORT).show(); Toasty.info(context, R.string.toast_error_translations_disabled, Toast.LENGTH_SHORT).show();
else
translateToot(status, holder.status_content_translated);
return true;
} else if (itemId == 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
builderInner.setMessage(Html.fromHtml(status.getContent()));
} else if (itemId == 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
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;
} else if (itemId == R.id.action_copy_link) {
ClipboardManager clipboard;
ClipData clip;
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;
} else if (itemId == 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 else
translateToot(status, holder.status_content_translated); url = status.getReblog().getUrl();
return true; } else {
case R.id.action_report: if (status.getUri().startsWith("http"))
builderInner = new AlertDialog.Builder(context, style); url = status.getUri();
builderInner.setTitle(stringArrayConf[2]); else
doAction = API.StatusAction.REPORT; 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 += " \uD83D\uDD17 " + url + "\r\n-\n";
final String contentToot;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY)); contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
else else
builderInner.setMessage(Html.fromHtml(status.getContent())); contentToot = Html.fromHtml((status.getReblog() != null) ? status.getReblog().getContent() : status.getContent()).toString();
break; extra_text += contentToot;
case R.id.action_copy: } else {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); extra_text = url;
final String content; }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
content = Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString(); sendIntent.setType("text/plain");
else context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
content = Html.fromHtml(status.getContent()).toString(); return true;
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, content); } else if (itemId == R.id.action_custom_sharing) {
if (clipboard != null) { Intent intentCustomSharing = new Intent(context, CustomSharingActivity.class);
clipboard.setPrimaryClip(clip); Bundle bCustomSharing = new Bundle();
Toasty.info(context, context.getString(R.string.clipboard), Toast.LENGTH_LONG).show(); if (status.getReblog() != null) {
} bCustomSharing.putParcelable("status", status.getReblog());
return true; } else {
case R.id.action_copy_link: bCustomSharing.putParcelable("status", status);
clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); }
intentCustomSharing.putExtras(bCustomSharing);
clip = ClipData.newPlainText(Helper.CLIP_BOARD, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl()); context.startActivity(intentCustomSharing);
if (clipboard != null) { return true;
clipboard.setPrimaryClip(clip); } else if (itemId == R.id.action_mention) {
Toasty.info(context, context.getString(R.string.clipboard_url), Toast.LENGTH_LONG).show(); mention(status);
} return true;
return true; } else {
case R.id.action_share: return true;
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 += " \uD83D\uDD17 " + 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 //Text for report
@ -3127,14 +3070,19 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
else else
holder.status_prev1_play.setVisibility(View.GONE); holder.status_prev1_play.setVisibility(View.GONE);
else { else {
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) { switch (attachment.getType().toLowerCase()) {
holder.status_prev1_play_h.setImageResource(R.drawable.ic_video_preview); case "video":
holder.status_prev1_play.setImageResource(R.drawable.ic_video_preview); case "audio":
} else if (attachment.getType().toLowerCase().equals("gifv")) { holder.status_prev1_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev1_play.setImageResource(R.drawable.ic_gif_preview); holder.status_prev1_play.setImageResource(R.drawable.ic_video_preview);
holder.status_prev1_play_h.setImageResource(R.drawable.ic_gif_preview); break;
} else if (attachment.getType().toLowerCase().equals("web")) { case "gifv":
holder.status_prev1_play.setImageResource(R.drawable.ic_http); holder.status_prev1_play.setImageResource(R.drawable.ic_gif_preview);
holder.status_prev1_play_h.setImageResource(R.drawable.ic_gif_preview);
break;
case "web":
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
break;
} }
if (fullAttachement) if (fullAttachement)
holder.status_prev1_play_h.setVisibility(View.VISIBLE); holder.status_prev1_play_h.setVisibility(View.VISIBLE);
@ -3149,14 +3097,19 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
else else
holder.status_prev2_play.setVisibility(View.GONE); holder.status_prev2_play.setVisibility(View.GONE);
else { else {
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) { switch (attachment.getType().toLowerCase()) {
holder.status_prev2_play_h.setImageResource(R.drawable.ic_video_preview); case "video":
holder.status_prev2_play.setImageResource(R.drawable.ic_video_preview); case "audio":
} else if (attachment.getType().toLowerCase().equals("gifv")) { holder.status_prev2_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev2_play_h.setImageResource(R.drawable.ic_gif_preview); holder.status_prev2_play.setImageResource(R.drawable.ic_video_preview);
holder.status_prev2_play.setImageResource(R.drawable.ic_gif_preview); break;
} else if (attachment.getType().toLowerCase().equals("web")) { case "gifv":
holder.status_prev1_play.setImageResource(R.drawable.ic_http); holder.status_prev2_play_h.setImageResource(R.drawable.ic_gif_preview);
holder.status_prev2_play.setImageResource(R.drawable.ic_gif_preview);
break;
case "web":
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
break;
} }
if (fullAttachement) if (fullAttachement)
holder.status_prev2_play_h.setVisibility(View.VISIBLE); holder.status_prev2_play_h.setVisibility(View.VISIBLE);
@ -3171,14 +3124,19 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
else else
holder.status_prev3_play.setVisibility(View.GONE); holder.status_prev3_play.setVisibility(View.GONE);
else { else {
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) { switch (attachment.getType().toLowerCase()) {
holder.status_prev3_play_h.setImageResource(R.drawable.ic_video_preview); case "video":
holder.status_prev3_play.setImageResource(R.drawable.ic_video_preview); case "audio":
} else if (attachment.getType().toLowerCase().equals("gifv")) { holder.status_prev3_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev3_play_h.setImageResource(R.drawable.ic_gif_preview); holder.status_prev3_play.setImageResource(R.drawable.ic_video_preview);
holder.status_prev3_play.setImageResource(R.drawable.ic_gif_preview); break;
} else if (attachment.getType().toLowerCase().equals("web")) { case "gifv":
holder.status_prev1_play.setImageResource(R.drawable.ic_http); holder.status_prev3_play_h.setImageResource(R.drawable.ic_gif_preview);
holder.status_prev3_play.setImageResource(R.drawable.ic_gif_preview);
break;
case "web":
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
break;
} }
if (fullAttachement) if (fullAttachement)
holder.status_prev3_play_h.setVisibility(View.VISIBLE); holder.status_prev3_play_h.setVisibility(View.VISIBLE);
@ -3193,14 +3151,19 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
else else
holder.status_prev4_play.setVisibility(View.GONE); holder.status_prev4_play.setVisibility(View.GONE);
else { else {
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) { switch (attachment.getType().toLowerCase()) {
holder.status_prev4_play_h.setImageResource(R.drawable.ic_video_preview); case "video":
holder.status_prev4_play.setImageResource(R.drawable.ic_video_preview); case "audio":
} else if (attachment.getType().toLowerCase().equals("gifv")) { holder.status_prev4_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev4_play_h.setImageResource(R.drawable.ic_gif_preview); holder.status_prev4_play.setImageResource(R.drawable.ic_video_preview);
holder.status_prev4_play.setImageResource(R.drawable.ic_gif_preview); break;
} else if (attachment.getType().toLowerCase().equals("web")) { case "gifv":
holder.status_prev1_play.setImageResource(R.drawable.ic_http); holder.status_prev4_play_h.setImageResource(R.drawable.ic_gif_preview);
holder.status_prev4_play.setImageResource(R.drawable.ic_gif_preview);
break;
case "web":
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
break;
} }
if (fullAttachement) if (fullAttachement)
holder.status_prev4_play_h.setVisibility(View.VISIBLE); holder.status_prev4_play_h.setVisibility(View.VISIBLE);
@ -3739,10 +3702,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
int position = 0; int position = 0;
for (Status status : statuses) { for (Status status : statuses) {
if (status.getId().equals(targetedId)) { if (status.getId().equals(targetedId)) {
if (statusAction == API.StatusAction.PIN) status.setPinned(statusAction == API.StatusAction.PIN);
status.setPinned(true);
else
status.setPinned(false);
statusListAdapter.notifyItemChanged(position); statusListAdapter.notifyItemChanged(position);
break; break;
} }
@ -3764,7 +3724,6 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
public void notifyStatusChanged(Status status) { public void notifyStatusChanged(Status status) {
for (int i = 0; i < statusListAdapter.getItemCount(); i++) { for (int i = 0; i < statusListAdapter.getItemCount(); i++) {
//noinspection ConstantConditions
if (statusListAdapter.getItemAt(i) != null && statusListAdapter.getItemAt(i).getId().equals(status.getId())) { if (statusListAdapter.getItemAt(i) != null && statusListAdapter.getItemAt(i).getId().equals(status.getId())) {
try { try {
statuses.get(i).setFavourites_count(status.getFavourites_count()); statuses.get(i).setFavourites_count(status.getFavourites_count());
@ -3810,7 +3769,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
private void translateToot(Status status, TextView view) { private void translateToot(Status status, TextView view) {
//Manages translations //Manages translations
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
int trans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX); int trans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE);
MyTransL.translatorEngine et = MyTransL.translatorEngine.YANDEX; MyTransL.translatorEngine et = MyTransL.translatorEngine.YANDEX;
String api_key; String api_key;
@ -3819,8 +3778,11 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
et = MyTransL.translatorEngine.DEEPL; et = MyTransL.translatorEngine.DEEPL;
} else if (trans == Helper.TRANS_SYSTRAN) { } else if (trans == Helper.TRANS_SYSTRAN) {
et = MyTransL.translatorEngine.SYSTRAN; et = MyTransL.translatorEngine.SYSTRAN;
} else if (trans == Helper.TRANS_LIBRETRANSLATE) {
et = MyTransL.translatorEngine.LIBRETRANSLATE;
} }
final MyTransL myTransL = MyTransL.getInstance(et); final MyTransL myTransL = MyTransL.getInstance(et);
DeepLParams deepLParams = null;
myTransL.setObfuscation(true); myTransL.setObfuscation(true);
if (trans == Helper.TRANS_YANDEX) { if (trans == Helper.TRANS_YANDEX) {
api_key = sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, Helper.YANDEX_KEY); api_key = sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, Helper.YANDEX_KEY);
@ -3831,6 +3793,11 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
} else if (trans == Helper.TRANS_SYSTRAN) { } else if (trans == Helper.TRANS_SYSTRAN) {
api_key = sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, ""); api_key = sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, "");
myTransL.setSystranAPIKey(api_key); myTransL.setSystranAPIKey(api_key);
} else if (trans == Helper.TRANS_LIBRETRANSLATE) {
deepLParams = new DeepLParams();
deepLParams.setSplit_sentences(false);
deepLParams.setSource_lang("auto");
myTransL.setLibretranslateDomain("translate.fedilab.app");
} }
@ -3840,8 +3807,8 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString(); statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
else else
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent()).toString(); statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent()).toString();
//TODO: removes the replaceAll once fixed with the lib
myTransL.translate(statusToTranslate, myTransL.getLocale(), new Results() { myTransL.translate(statusToTranslate, MyTransL.getLocale(), deepLParams, new Results() {
@Override @Override
public void onSuccess(Translate translate) { public void onSuccess(Translate translate) {
if (translate.getTranslatedContent() != null) { if (translate.getTranslatedContent() != null) {
@ -3978,10 +3945,9 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
LinearLayout status_cardview; LinearLayout status_cardview;
ImageView status_cardview_image; ImageView status_cardview_image;
TextView status_cardview_title, status_cardview_content, status_cardview_url; TextView status_cardview_title, status_cardview_content, status_cardview_url;
FrameLayout status_cardview_video; RelativeLayout status_cardview_video;
ImageView hide_preview, hide_preview_h; ImageView hide_preview, hide_preview_h;
TextView status_toot_app; TextView status_toot_app;
RelativeLayout webview_preview;
ImageView webview_preview_card; ImageView webview_preview_card;
LinearLayout left_buttons; LinearLayout left_buttons;
Button status_show_more_content; Button status_show_more_content;
@ -4009,12 +3975,11 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
ImageView quick_reply_emoji; ImageView quick_reply_emoji;
Button quick_reply_button; Button quick_reply_button;
ImageView quick_reply_privacy; ImageView quick_reply_privacy;
View status_reply_indicator_top, reply_indicator_dot, status_reply_indicator_bottom, status_reply_indicator_diag_top, status_reply_indicator_diag_bottom;
RelativeLayout main_card_container; RelativeLayout main_card_container;
LinearLayout main_linear_container; LinearLayout main_linear_container;
View translation_border_view; View translation_border_view;
TextView translation_label; TextView translation_label;
LinearLayout status_reactions; LinearLayout status_reactions, decoration_container;
ImageView status_add_custom_emoji; ImageView status_add_custom_emoji;
RecyclerView reactions_view; RecyclerView reactions_view;
@ -4023,8 +3988,6 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
super(itemView); super(itemView);
fetch_more = itemView.findViewById(R.id.fetch_more); fetch_more = itemView.findViewById(R.id.fetch_more);
webview_preview_card = itemView.findViewById(R.id.webview_preview_card); webview_preview_card = itemView.findViewById(R.id.webview_preview_card);
webview_preview = itemView.findViewById(R.id.webview_preview);
status_horizontal_document_container = itemView.findViewById(R.id.status_horizontal_document_container); status_horizontal_document_container = itemView.findViewById(R.id.status_horizontal_document_container);
status_document_container = itemView.findViewById(R.id.status_document_container); status_document_container = itemView.findViewById(R.id.status_document_container);
status_horizontal_document_container = itemView.findViewById(R.id.status_horizontal_document_container); status_horizontal_document_container = itemView.findViewById(R.id.status_horizontal_document_container);
@ -4134,11 +4097,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
warning_message = itemView.findViewById(R.id.warning_message); warning_message = itemView.findViewById(R.id.warning_message);
status_reply_indicator_bottom = itemView.findViewById(R.id.status_reply_indicator_bottom); decoration_container = itemView.findViewById(R.id.decoration_container);
status_reply_indicator_top = itemView.findViewById(R.id.status_reply_indicator_top);
status_reply_indicator_diag_top = itemView.findViewById(R.id.status_reply_indicator_diag_top);
status_reply_indicator_diag_bottom = itemView.findViewById(R.id.status_reply_indicator_diag_bottom);
reply_indicator_dot = itemView.findViewById(R.id.reply_indicator_dot);
main_card_container = itemView.findViewById(R.id.main_card_container); main_card_container = itemView.findViewById(R.id.main_card_container);
main_linear_container = itemView.findViewById(R.id.main_linear_container); main_linear_container = itemView.findViewById(R.id.main_linear_container);
translation_border_view = itemView.findViewById(R.id.translation_border_view); translation_border_view = itemView.findViewById(R.id.translation_border_view);

View File

@ -127,9 +127,9 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
private static final int DISPLAYED_STATUS = 1; private static final int DISPLAYED_STATUS = 1;
private final int HIDDEN_STATUS = 0; private final int HIDDEN_STATUS = 0;
private Context context; private Context context;
private List<Status> statuses; private final List<Status> statuses;
private PixelfedListAdapter pixelfedListAdapter; private final PixelfedListAdapter pixelfedListAdapter;
private RetrieveFeedsAsyncTask.Type type; private final RetrieveFeedsAsyncTask.Type type;
private MastalabAutoCompleteTextView comment_content; private MastalabAutoCompleteTextView comment_content;
private String in_reply_to_status; private String in_reply_to_status;
private String visibility; private String visibility;
@ -825,7 +825,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
doAction = API.StatusAction.BLOCK; doAction = API.StatusAction.BLOCK;
break; break;
case R.id.action_translate: case R.id.action_translate:
int translator = sharedpreferences1.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX); int translator = sharedpreferences1.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE);
if (translator == Helper.TRANS_NONE) if (translator == Helper.TRANS_NONE)
Toasty.info(context, R.string.toast_error_translations_disabled, Toast.LENGTH_SHORT).show(); Toasty.info(context, R.string.toast_error_translations_disabled, Toast.LENGTH_SHORT).show();
else else
@ -1008,11 +1008,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
holder.pf_share.setColors(R.color.boost_icon, R.color.boost_icon); holder.pf_share.setColors(R.color.boost_icon, R.color.boost_icon);
if (!status.isFavAnimated()) { if (!status.isFavAnimated()) {
if (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) { holder.pf_fav.setChecked(status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited()));
holder.pf_fav.setChecked(true);
} else {
holder.pf_fav.setChecked(false);
}
} else { } else {
status.setFavAnimated(false); status.setFavAnimated(false);
holder.pf_fav.setChecked(true); holder.pf_fav.setChecked(true);
@ -1021,11 +1017,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
} }
if (!status.isBoostAnimated()) { if (!status.isBoostAnimated()) {
if (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) { holder.pf_share.setChecked(status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged()));
holder.pf_share.setChecked(true);
} else {
holder.pf_share.setChecked(false);
}
} else { } else {
status.setBoostAnimated(false); status.setBoostAnimated(false);
holder.pf_share.setChecked(true); holder.pf_share.setChecked(true);
@ -1060,7 +1052,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
private void translateToot(Status status) { private void translateToot(Status status) {
//Manages translations //Manages translations
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
int trans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX); int trans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE);
MyTransL.translatorEngine et = MyTransL.translatorEngine.YANDEX; MyTransL.translatorEngine et = MyTransL.translatorEngine.YANDEX;
String api_key; String api_key;
@ -1091,7 +1083,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
else else
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent()).toString(); statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent()).toString();
//TODO: removes the replaceAll once fixed with the lib //TODO: removes the replaceAll once fixed with the lib
myTransL.translate(statusToTranslate, myTransL.getLocale(), new Results() { myTransL.translate(statusToTranslate, MyTransL.getLocale(), new Results() {
@Override @Override
public void onSuccess(Translate translate) { public void onSuccess(Translate translate) {
if (translate.getTranslatedContent() != null) { if (translate.getTranslatedContent() != null) {
@ -1199,10 +1191,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
int position = 0; int position = 0;
for (Status status : statuses) { for (Status status : statuses) {
if (status.getId().equals(targetedId)) { if (status.getId().equals(targetedId)) {
if (statusAction == API.StatusAction.PIN) status.setPinned(statusAction == API.StatusAction.PIN);
status.setPinned(true);
else
status.setPinned(false);
pixelfedListAdapter.notifyItemChanged(position); pixelfedListAdapter.notifyItemChanged(position);
break; break;
} }

View File

@ -128,7 +128,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
private Context context; private Context context;
private AsyncTask asyncTask; private AsyncTask asyncTask;
private int countTrans, countLanguage, notificationCount, ledCount, videoSpinnerCount, liveNotificationCount; private int countTrans, countLanguage, notificationCount, ledCount, videoSpinnerCount, liveNotificationCount;
private List<Account> translators = new ArrayList<>(); private final List<Account> translators = new ArrayList<>();
private AccountSearchDevAdapter translatorManager; private AccountSearchDevAdapter translatorManager;
private TextView set_folder; private TextView set_folder;
private EditText your_api_key; private EditText your_api_key;
@ -1178,24 +1178,29 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
translation_layout_spinner.setAdapter(adapterTrans); translation_layout_spinner.setAdapter(adapterTrans);
int positionSpinnerTrans; int positionSpinnerTrans;
your_api_key = rootView.findViewById(R.id.translation_key); your_api_key = rootView.findViewById(R.id.translation_key);
switch (sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX)) { switch (sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE)) {
case Helper.TRANS_YANDEX: case Helper.TRANS_LIBRETRANSLATE:
positionSpinnerTrans = 0; positionSpinnerTrans = 0;
your_api_key.setVisibility(View.GONE);
your_api_key.setText("");
break;
case Helper.TRANS_YANDEX:
positionSpinnerTrans = 1;
your_api_key.setVisibility(View.VISIBLE); your_api_key.setVisibility(View.VISIBLE);
your_api_key.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, "")); your_api_key.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, ""));
break; break;
case Helper.TRANS_DEEPL: case Helper.TRANS_DEEPL:
positionSpinnerTrans = 1; positionSpinnerTrans = 2;
your_api_key.setVisibility(View.VISIBLE); your_api_key.setVisibility(View.VISIBLE);
your_api_key.setText(sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, "")); your_api_key.setText(sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, ""));
break; break;
case Helper.TRANS_SYSTRAN: case Helper.TRANS_SYSTRAN:
positionSpinnerTrans = 2; positionSpinnerTrans = 3;
your_api_key.setVisibility(View.VISIBLE); your_api_key.setVisibility(View.VISIBLE);
your_api_key.setText(sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, "")); your_api_key.setText(sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, ""));
break; break;
case Helper.TRANS_NONE: case Helper.TRANS_NONE:
positionSpinnerTrans = 3; positionSpinnerTrans = 4;
your_api_key.setVisibility(View.GONE); your_api_key.setVisibility(View.GONE);
break; break;
default: default:
@ -1211,25 +1216,32 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
SharedPreferences.Editor editor = sharedpreferences.edit(); SharedPreferences.Editor editor = sharedpreferences.edit();
switch (position) { switch (position) {
case 0: case 0:
your_api_key.setVisibility(View.VISIBLE); your_api_key.setVisibility(View.GONE);
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX); editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE);
editor.commit(); editor.commit();
your_api_key.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, "")); your_api_key.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, ""));
break; break;
case 1: case 1:
your_api_key.setVisibility(View.VISIBLE);
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
editor.commit();
your_api_key.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, ""));
break;
case 2:
your_api_key.setVisibility(View.VISIBLE); your_api_key.setVisibility(View.VISIBLE);
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_DEEPL); editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_DEEPL);
editor.commit(); editor.commit();
your_api_key.setText(sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, "")); your_api_key.setText(sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, ""));
break; break;
case 2: case 3:
your_api_key.setVisibility(View.VISIBLE); your_api_key.setVisibility(View.VISIBLE);
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_SYSTRAN); editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_SYSTRAN);
editor.commit(); editor.commit();
your_api_key.setText(sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, "")); your_api_key.setText(sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, ""));
break; break;
case 3: case 4:
your_api_key.setVisibility(View.GONE); your_api_key.setVisibility(View.GONE);
set_trans_forced.isChecked(); set_trans_forced.isChecked();
editor.putBoolean(Helper.SET_TRANS_FORCED, false); editor.putBoolean(Helper.SET_TRANS_FORCED, false);
@ -1488,7 +1500,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
SharedPreferences.Editor editor = sharedpreferences.edit(); SharedPreferences.Editor editor = sharedpreferences.edit();
int translatore = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX); int translatore = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE);
String store = null; String store = null;
if (translatore == Helper.TRANS_YANDEX) if (translatore == Helper.TRANS_YANDEX)
store = Helper.SET_YANDEX_API_KEY; store = Helper.SET_YANDEX_API_KEY;

View File

@ -408,10 +408,11 @@ public class BaseHelper {
public static final int LED_COLOUR = 0; public static final int LED_COLOUR = 0;
public static final int TRANS_YANDEX = 0; public static final int TRANS_YANDEX = 4;
public static final int TRANS_DEEPL = 1; public static final int TRANS_DEEPL = 1;
public static final int TRANS_NONE = 3; public static final int TRANS_NONE = 3;
public static final int TRANS_SYSTRAN = 2; public static final int TRANS_SYSTRAN = 2;
public static final int TRANS_LIBRETRANSLATE = 0;
public static final int ACTION_SILENT = 0; public static final int ACTION_SILENT = 0;
public static final int ACTION_ACTIVE = 1; public static final int ACTION_ACTIVE = 1;
@ -3015,7 +3016,6 @@ public class BaseHelper {
return; return;
} }
try { try {
assert url != null;
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE || disableGif || (!url.endsWith(".gif") && account.getAvatar_static().compareTo(account.getAvatar()) == 0)) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE || disableGif || (!url.endsWith(".gif") && account.getAvatar_static().compareTo(account.getAvatar()) == 0)) {
Glide.with(imageView.getContext()) Glide.with(imageView.getContext())
.asDrawable() .asDrawable()
@ -4132,7 +4132,7 @@ public class BaseHelper {
new AsyncTask<Void, Void, List<String>>() { new AsyncTask<Void, Void, List<String>>() {
APIResponse apiResponse; APIResponse apiResponse;
private WeakReference<Context> contextReference = new WeakReference<>(context); private final WeakReference<Context> contextReference = new WeakReference<>(context);
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
@ -4306,7 +4306,7 @@ public class BaseHelper {
new AsyncTask<Void, Void, List<String>>() { new AsyncTask<Void, Void, List<String>>() {
APIResponse apiResponse; APIResponse apiResponse;
private WeakReference<Context> contextReference = new WeakReference<>(context); private final WeakReference<Context> contextReference = new WeakReference<>(context);
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
@ -4516,7 +4516,7 @@ public class BaseHelper {
public static class CacheTask extends AsyncTask<Void, Void, Void> { public static class CacheTask extends AsyncTask<Void, Void, Void> {
private float cacheSize; private float cacheSize;
private WeakReference<Context> contextReference; private final WeakReference<Context> contextReference;
public CacheTask(Context context) { public CacheTask(Context context) {
contextReference = new WeakReference<>(context); contextReference = new WeakReference<>(context);

View File

@ -0,0 +1,48 @@
package app.fedilab.android.helper;
/* Copyright 2021 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 org.jetbrains.annotations.NotNull;
import java.util.List;
import app.fedilab.android.client.Entities.Status;
public class CommentDecorationHelper {
public static int getIndentation(@NotNull String replyToCommentId, List<Status> statuses) {
return numberOfIndentation(0, replyToCommentId, statuses);
}
private static int numberOfIndentation(int currentIdentation, String replyToCommentId, List<Status> statuses) {
String targetedComment = null;
for (Status status : statuses) {
if (replyToCommentId.compareTo(status.getId()) == 0) {
targetedComment = status.getIn_reply_to_id();
break;
}
}
if (targetedComment != null) {
currentIdentation++;
return numberOfIndentation(currentIdentation, targetedComment, statuses);
} else {
return Math.min(currentIdentation, 15);
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -403,7 +403,7 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<FrameLayout <RelativeLayout
android:id="@+id/status_cardview_video" android:id="@+id/status_cardview_video"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="220dp" android:layout_height="220dp"
@ -412,26 +412,20 @@
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:visibility="gone"> android:visibility="gone">
<RelativeLayout <ImageView
android:id="@+id/webview_preview" android:id="@+id/webview_preview_card"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:contentDescription="@string/image_preview"
android:scaleType="centerCrop" />
<ImageView <ImageView
android:id="@+id/webview_preview_card" android:layout_width="30dp"
android:layout_width="match_parent" android:layout_height="30dp"
android:layout_height="match_parent" android:layout_centerInParent="true"
android:scaleType="centerCrop" /> android:contentDescription="@string/play_video"
android:src="@drawable/ic_play_arrow" />
<ImageView </RelativeLayout>
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:contentDescription="@string/play_video"
android:src="@drawable/ic_play_arrow" />
</RelativeLayout>
</FrameLayout>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"

File diff suppressed because it is too large Load Diff

View File

@ -341,6 +341,7 @@
<string-array name="settings_translation" translatable="false"> <string-array name="settings_translation" translatable="false">
<item>LibreTranslate</item>
<item>Yandex</item> <item>Yandex</item>
<item>DeepL</item> <item>DeepL</item>
<item>Systran</item> <item>Systran</item>