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 {
minSdkVersion 21
targetSdkVersion 29
versionCode 377
versionName "2.37.0-beta-1"
versionCode 378
versionName "2.37.0-beta-2"
multiDexEnabled true
renderscriptTargetApi 28 as int
renderscriptSupportModeEnabled true

View File

@ -207,17 +207,17 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
lv_ux.setAdapter(accountSearchWebAdapterUxUiDesigners);
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, "PhotonQyv", "mastodon.xyz", AboutActivity.this).execute();
new RetrieveRemoteDataAsyncTask(AboutActivity.this, "angrytux", "social.tchncs.de", AboutActivity.this).execute();
new RetrieveRemoteDataAsyncTask(AboutActivity.this, "guzzisti", "mastodon.social", AboutActivity.this).execute();
} 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);
txt_developers.setText(name);
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.setSpan(new UnderlineSpan(), 0, name.length(), 0);
txt_ux.setText(name);
@ -259,7 +259,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
account = accounts.get(0);
account.setFollowing(true);
switch (account.getUsername()) {
case "fedilab":
case "apps":
developers.add(account);
accountSearchWebAdapterDeveloper.notifyDataSetChanged();
break;

View File

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

View File

@ -56,7 +56,6 @@ import android.widget.Button;
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.ImageButton;
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.client.HttpsConnectionException;
import com.github.stom79.mytransl.client.Results;
import com.github.stom79.mytransl.translate.DeepLParams;
import com.github.stom79.mytransl.translate.Translate;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
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.TagTimeline;
import app.fedilab.android.fragments.DisplayStatusFragment;
import app.fedilab.android.helper.CommentDecorationHelper;
import app.fedilab.android.helper.CrossActions;
import app.fedilab.android.helper.CustomTextView;
import app.fedilab.android.helper.Helper;
@ -204,14 +205,14 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
protected Context context;
protected RetrieveFeedsAsyncTask.Type type;
protected int style;
private List<Status> statuses;
private boolean isOnWifi;
private BaseStatusListAdapter statusListAdapter;
private String targetedId;
private final List<Status> statuses;
private final boolean isOnWifi;
private final BaseStatusListAdapter statusListAdapter;
private final String targetedId;
private int conversationPosition;
private boolean redraft;
private Status toot;
private TagTimeline tagTimeline;
private final TagTimeline tagTimeline;
private AlertDialog alertDialogEmoji;
private MastalabAutoCompleteTextView toot_content;
private EditText toot_cw_content;
@ -225,8 +226,9 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
private RecyclerView mRecyclerView;
private List<Emojis> emojisPicker;
private Status statusForQuickReply;
private String instanceType;
private Runnable updateAnimatedEmoji = new Runnable() {
private final String instanceType;
private final Runnable updateAnimatedEmoji = new Runnable() {
@Override
public void run() {
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) {
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);
});
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) {
holder.status_reply_indicator_top.setBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC4));
holder.status_reply_indicator_bottom.setBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC4));
holder.reply_indicator_dot.setBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC4));
} else {
holder.status_reply_indicator_top.setBackgroundColor(ContextCompat.getColor(context, R.color.cyanea_accent_reference));
holder.status_reply_indicator_bottom.setBackgroundColor(ContextCompat.getColor(context, R.color.cyanea_accent_reference));
holder.reply_indicator_dot.setBackgroundColor(ContextCompat.getColor(context, 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);
int ident = CommentDecorationHelper.getIndentation(status.getIn_reply_to_id(), statuses);
for (int j = 0; j <= ident; j++) {
View view = new View(context);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, LinearLayout.LayoutParams.MATCH_PARENT);
params.setMargins((int) Helper.convertDpToPixel(5, context), 0, 0, 0);
view.setLayoutParams(params);
holder.decoration_container.addView(view, 0);
view.setBackgroundResource(R.color.cyanea_accent_reference);
}
}
@ -702,7 +673,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
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);
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 ((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);
} else {
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.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) {
holder.spark_button_fav.setChecked(true);
} else {
holder.spark_button_fav.setChecked(false);
}
holder.spark_button_fav.setChecked(status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited()));
} else {
status.setFavAnimated(false);
holder.spark_button_fav.setChecked(true);
@ -1987,11 +1954,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
holder.spark_button_fav.playAnimation();
}
if (!status.isBoostAnimated()) {
if (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) {
holder.spark_button_reblog.setChecked(true);
} else {
holder.spark_button_reblog.setChecked(false);
}
holder.spark_button_reblog.setChecked(status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged()));
} else {
status.setBoostAnimated(false);
holder.spark_button_reblog.setChecked(true);
@ -2037,18 +2000,14 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
if (status.getReblog() == null) {
if (status.getWebviewURL() != null) {
holder.status_cardview_video.setVisibility(View.VISIBLE);
holder.webview_preview.setVisibility(View.GONE);
} else {
holder.status_cardview_video.setVisibility(View.GONE);
holder.webview_preview.setVisibility(View.VISIBLE);
}
} else {
if (status.getReblog().getWebviewURL() != null) {
holder.status_cardview_video.setVisibility(View.VISIBLE);
holder.webview_preview.setVisibility(View.GONE);
} else {
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());
popup.setOnMenuItemClickListener(item -> {
String contentType = null;
switch (item.getItemId()) {
case R.id.action_plain_text:
contentType = "text/plain";
break;
case R.id.action_html:
contentType = "text/html";
break;
case R.id.action_markdown:
contentType = "text/markdown";
break;
case R.id.action_bbcode:
contentType = "text/bbcode";
break;
int itemId = item.getItemId();
if (itemId == R.id.action_plain_text) {
contentType = "text/plain";
} else if (itemId == R.id.action_html) {
contentType = "text/html";
} else if (itemId == R.id.action_markdown) {
contentType = "text/markdown";
} else if (itemId == R.id.action_bbcode) {
contentType = "text/bbcode";
}
popup.dismiss();
sendToot(status, contentType);
@ -2195,7 +2150,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
}
final String finalSrc = src;
holder.webview_preview.setOnClickListener(v -> {
holder.status_cardview_video.setOnClickListener(v -> {
String url = finalSrc;
if (url != null) {
boolean invidious = Helper.getSharedValue(context, Helper.SET_INVIDIOUS);
@ -2226,7 +2181,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
intent.putExtras(b);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation((Activity) context, holder.webview_preview, attachment.getUrl());
.makeSceneTransitionAnimation((Activity) context, holder.status_cardview_video, attachment.getUrl());
// start the new activity
context.startActivity(intent, options.toBundle());
} else {
@ -2452,11 +2407,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
});
//Spoiler opens
holder.status_spoiler_button.setOnClickListener(v -> {
if (expand_cw && !status.isSpoilerShown()) {
status.setAutoHiddenCW(true);
} else {
status.setAutoHiddenCW(false);
}
status.setAutoHiddenCW(expand_cw && !status.isSpoilerShown());
status.setSpoilerShown(!status.isSpoilerShown());
notifyStatusChanged(status);
});
@ -2500,11 +2451,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
} else {
popup.getMenu().findItem(R.id.action_stats).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(true);
} else {
popup.getMenu().findItem(R.id.action_remove).setVisible(false);
}
popup.getMenu().findItem(R.id.action_remove).setVisible(social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA && (isAdmin || isModerator));
//Same instance
if (status.getAccount().getAcct().split("@").length < 2)
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 -> {
AlertDialog.Builder builderInner;
final API.StatusAction doAction;
switch (item.getItemId()) {
case R.id.action_redraft:
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[1]);
redraft = true;
doAction = API.StatusAction.UNSTATUS;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
else
builderInner.setMessage(Html.fromHtml(status.getContent()));
break;
case R.id.action_schedule_boost:
scheduleBoost(status);
return true;
case R.id.action_admin:
String account_id = status.getReblog() != null ? status.getReblog().getAccount().getId() : status.getAccount().getId();
String acct = status.getReblog() != null ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct();
Intent intent = new Intent(context, AccountReportActivity.class);
Bundle b = new Bundle();
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
b.putString("account_id", account_id);
} else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
b.putString("account_id", acct);
}
intent.putExtras(b);
context.startActivity(intent);
return true;
case R.id.action_info:
tootInformation(status);
return true;
case R.id.action_open_browser:
Helper.openBrowser(context, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl());
return true;
case R.id.action_remove:
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[0]);
doAction = API.StatusAction.UNSTATUS;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
else
builderInner.setMessage(Html.fromHtml(status.getContent()));
break;
case R.id.action_block_domain:
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[3]);
doAction = API.StatusAction.BLOCK_DOMAIN;
String domain = status.getAccount().getAcct().split("@")[1];
builderInner.setMessage(context.getString(R.string.block_domain_confirm_message, domain));
break;
case R.id.action_mute:
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[0]);
builderInner.setMessage(status.getAccount().getAcct());
doAction = API.StatusAction.MUTE;
break;
case R.id.action_mute_conversation:
if (status.isMuted())
doAction = API.StatusAction.UNMUTE_CONVERSATION;
else
doAction = API.StatusAction.MUTE_CONVERSATION;
int itemId = item.getItemId();
if (itemId == R.id.action_redraft) {
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[1]);
redraft = true;
doAction = API.StatusAction.UNSTATUS;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
else
builderInner.setMessage(Html.fromHtml(status.getContent()));
} else if (itemId == R.id.action_schedule_boost) {
scheduleBoost(status);
return true;
} else if (itemId == R.id.action_admin) {
String account_id = status.getReblog() != null ? status.getReblog().getAccount().getId() : status.getAccount().getId();
String acct = status.getReblog() != null ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct();
Intent intent = new Intent(context, AccountReportActivity.class);
Bundle b = new Bundle();
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
b.putString("account_id", account_id);
} else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
b.putString("account_id", acct);
}
intent.putExtras(b);
context.startActivity(intent);
return true;
} else if (itemId == R.id.action_info) {
tootInformation(status);
return true;
} else if (itemId == R.id.action_open_browser) {
Helper.openBrowser(context, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl());
return true;
} else if (itemId == R.id.action_remove) {
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[0]);
doAction = API.StatusAction.UNSTATUS;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
else
builderInner.setMessage(Html.fromHtml(status.getContent()));
} else if (itemId == R.id.action_block_domain) {
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[3]);
doAction = API.StatusAction.BLOCK_DOMAIN;
String domain = status.getAccount().getAcct().split("@")[1];
builderInner.setMessage(context.getString(R.string.block_domain_confirm_message, domain));
} else if (itemId == R.id.action_mute) {
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[0]);
builderInner.setMessage(status.getAccount().getAcct());
doAction = API.StatusAction.MUTE;
} else if (itemId == R.id.action_mute_conversation) {
if (status.isMuted())
doAction = API.StatusAction.UNMUTE_CONVERSATION;
else
doAction = API.StatusAction.MUTE_CONVERSATION;
new PostActionAsyncTask(context, doAction, status.getId(), BaseStatusListAdapter.this).execute();
return true;
case R.id.action_bookmark:
if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
status.setBookmarked(!status.isBookmarked());
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
try {
if (status.isBookmarked()) {
new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status);
Toasty.success(context, context.getString(R.string.status_bookmarked), Toast.LENGTH_LONG).show();
} else {
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, status);
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
}
notifyStatusChanged(status);
} catch (Exception e) {
e.printStackTrace();
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
new PostActionAsyncTask(context, doAction, status.getId(), BaseStatusListAdapter.this).execute();
return true;
} else if (itemId == R.id.action_bookmark) {
if (type != RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS) {
status.setBookmarked(!status.isBookmarked());
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
try {
if (status.isBookmarked()) {
new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status);
Toasty.success(context, context.getString(R.string.status_bookmarked), Toast.LENGTH_LONG).show();
} else {
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, status);
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
}
} else {
int position = 0;
for (Status statustmp : statuses) {
if (statustmp.getId().equals(status.getId())) {
statuses.remove(status);
statusListAdapter.notifyItemRemoved(position);
final SQLiteDatabase db = Sqlite.getInstance(context.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++;
notifyStatusChanged(status);
} catch (Exception e) {
e.printStackTrace();
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
} else {
int position = 0;
for (Status statustmp : statuses) {
if (statustmp.getId().equals(status.getId())) {
statuses.remove(status);
statusListAdapter.notifyItemRemoved(position);
final SQLiteDatabase db = Sqlite.getInstance(context.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:
notificationCharts(status);
return true;
case R.id.action_timed_mute:
timedMuteAction(status);
return true;
case R.id.action_block:
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[1]);
doAction = API.StatusAction.BLOCK;
break;
case R.id.action_translate:
if (translator == Helper.TRANS_NONE)
Toasty.info(context, R.string.toast_error_translations_disabled, Toast.LENGTH_SHORT).show();
}
return true;
} else if (itemId == R.id.action_stats) {
notificationCharts(status);
return true;
} else if (itemId == R.id.action_timed_mute) {
timedMuteAction(status);
return true;
} else if (itemId == R.id.action_block) {
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[1]);
doAction = API.StatusAction.BLOCK;
} else if (itemId == R.id.action_translate) {
if (translator == Helper.TRANS_NONE)
Toasty.info(context, R.string.toast_error_translations_disabled, Toast.LENGTH_SHORT).show();
else
translateToot(status, 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
translateToot(status, holder.status_content_translated);
return true;
case R.id.action_report:
builderInner = new AlertDialog.Builder(context, style);
builderInner.setTitle(stringArrayConf[2]);
doAction = API.StatusAction.REPORT;
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)
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
builderInner.setMessage(Html.fromHtml(status.getContent()));
break;
case R.id.action_copy:
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
final String content;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
content = Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
else
content = Html.fromHtml(status.getContent()).toString();
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, content);
if (clipboard != null) {
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.clipboard), Toast.LENGTH_LONG).show();
}
return true;
case R.id.action_copy_link:
clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clip = ClipData.newPlainText(Helper.CLIP_BOARD, status.getReblog() != null ? status.getReblog().getUrl() : status.getUrl());
if (clipboard != null) {
clipboard.setPrimaryClip(clip);
Toasty.info(context, context.getString(R.string.clipboard_url), Toast.LENGTH_LONG).show();
}
return true;
case R.id.action_share:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
String url;
if (status.getReblog() != null) {
if (status.getReblog().getUri().startsWith("http"))
url = status.getReblog().getUri();
else
url = status.getReblog().getUrl();
} else {
if (status.getUri().startsWith("http"))
url = status.getUri();
else
url = status.getUrl();
}
String extra_text;
if (share_details) {
extra_text = (status.getReblog() != null) ? status.getReblog().getAccount().getAcct() : status.getAccount().getAcct();
if (extra_text.split("@").length == 1)
extra_text = "@" + extra_text + "@" + Helper.getLiveInstance(context);
else
extra_text = "@" + extra_text;
extra_text += " \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;
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;
} else if (itemId == 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;
} else if (itemId == R.id.action_mention) {
mention(status);
return true;
} else {
return true;
}
//Text for report
@ -3127,14 +3070,19 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
else
holder.status_prev1_play.setVisibility(View.GONE);
else {
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) {
holder.status_prev1_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev1_play.setImageResource(R.drawable.ic_video_preview);
} else if (attachment.getType().toLowerCase().equals("gifv")) {
holder.status_prev1_play.setImageResource(R.drawable.ic_gif_preview);
holder.status_prev1_play_h.setImageResource(R.drawable.ic_gif_preview);
} else if (attachment.getType().toLowerCase().equals("web")) {
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
switch (attachment.getType().toLowerCase()) {
case "video":
case "audio":
holder.status_prev1_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev1_play.setImageResource(R.drawable.ic_video_preview);
break;
case "gifv":
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)
holder.status_prev1_play_h.setVisibility(View.VISIBLE);
@ -3149,14 +3097,19 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
else
holder.status_prev2_play.setVisibility(View.GONE);
else {
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) {
holder.status_prev2_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev2_play.setImageResource(R.drawable.ic_video_preview);
} else if (attachment.getType().toLowerCase().equals("gifv")) {
holder.status_prev2_play_h.setImageResource(R.drawable.ic_gif_preview);
holder.status_prev2_play.setImageResource(R.drawable.ic_gif_preview);
} else if (attachment.getType().toLowerCase().equals("web")) {
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
switch (attachment.getType().toLowerCase()) {
case "video":
case "audio":
holder.status_prev2_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev2_play.setImageResource(R.drawable.ic_video_preview);
break;
case "gifv":
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)
holder.status_prev2_play_h.setVisibility(View.VISIBLE);
@ -3171,14 +3124,19 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
else
holder.status_prev3_play.setVisibility(View.GONE);
else {
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) {
holder.status_prev3_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev3_play.setImageResource(R.drawable.ic_video_preview);
} else if (attachment.getType().toLowerCase().equals("gifv")) {
holder.status_prev3_play_h.setImageResource(R.drawable.ic_gif_preview);
holder.status_prev3_play.setImageResource(R.drawable.ic_gif_preview);
} else if (attachment.getType().toLowerCase().equals("web")) {
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
switch (attachment.getType().toLowerCase()) {
case "video":
case "audio":
holder.status_prev3_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev3_play.setImageResource(R.drawable.ic_video_preview);
break;
case "gifv":
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)
holder.status_prev3_play_h.setVisibility(View.VISIBLE);
@ -3193,14 +3151,19 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
else
holder.status_prev4_play.setVisibility(View.GONE);
else {
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) {
holder.status_prev4_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev4_play.setImageResource(R.drawable.ic_video_preview);
} else if (attachment.getType().toLowerCase().equals("gifv")) {
holder.status_prev4_play_h.setImageResource(R.drawable.ic_gif_preview);
holder.status_prev4_play.setImageResource(R.drawable.ic_gif_preview);
} else if (attachment.getType().toLowerCase().equals("web")) {
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
switch (attachment.getType().toLowerCase()) {
case "video":
case "audio":
holder.status_prev4_play_h.setImageResource(R.drawable.ic_video_preview);
holder.status_prev4_play.setImageResource(R.drawable.ic_video_preview);
break;
case "gifv":
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)
holder.status_prev4_play_h.setVisibility(View.VISIBLE);
@ -3739,10 +3702,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
int position = 0;
for (Status status : statuses) {
if (status.getId().equals(targetedId)) {
if (statusAction == API.StatusAction.PIN)
status.setPinned(true);
else
status.setPinned(false);
status.setPinned(statusAction == API.StatusAction.PIN);
statusListAdapter.notifyItemChanged(position);
break;
}
@ -3764,7 +3724,6 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
public void notifyStatusChanged(Status status) {
for (int i = 0; i < statusListAdapter.getItemCount(); i++) {
//noinspection ConstantConditions
if (statusListAdapter.getItemAt(i) != null && statusListAdapter.getItemAt(i).getId().equals(status.getId())) {
try {
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) {
//Manages translations
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;
String api_key;
@ -3819,8 +3778,11 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
et = MyTransL.translatorEngine.DEEPL;
} else if (trans == Helper.TRANS_SYSTRAN) {
et = MyTransL.translatorEngine.SYSTRAN;
} else if (trans == Helper.TRANS_LIBRETRANSLATE) {
et = MyTransL.translatorEngine.LIBRETRANSLATE;
}
final MyTransL myTransL = MyTransL.getInstance(et);
DeepLParams deepLParams = null;
myTransL.setObfuscation(true);
if (trans == Helper.TRANS_YANDEX) {
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) {
api_key = sharedpreferences.getString(Helper.SET_SYSTRAN_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();
else
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
public void onSuccess(Translate translate) {
if (translate.getTranslatedContent() != null) {
@ -3978,10 +3945,9 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
LinearLayout status_cardview;
ImageView status_cardview_image;
TextView status_cardview_title, status_cardview_content, status_cardview_url;
FrameLayout status_cardview_video;
RelativeLayout status_cardview_video;
ImageView hide_preview, hide_preview_h;
TextView status_toot_app;
RelativeLayout webview_preview;
ImageView webview_preview_card;
LinearLayout left_buttons;
Button status_show_more_content;
@ -4009,12 +3975,11 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
ImageView quick_reply_emoji;
Button quick_reply_button;
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;
LinearLayout main_linear_container;
View translation_border_view;
TextView translation_label;
LinearLayout status_reactions;
LinearLayout status_reactions, decoration_container;
ImageView status_add_custom_emoji;
RecyclerView reactions_view;
@ -4023,8 +3988,6 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
super(itemView);
fetch_more = itemView.findViewById(R.id.fetch_more);
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_document_container = itemView.findViewById(R.id.status_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);
status_reply_indicator_bottom = itemView.findViewById(R.id.status_reply_indicator_bottom);
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);
decoration_container = itemView.findViewById(R.id.decoration_container);
main_card_container = itemView.findViewById(R.id.main_card_container);
main_linear_container = itemView.findViewById(R.id.main_linear_container);
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 final int HIDDEN_STATUS = 0;
private Context context;
private List<Status> statuses;
private PixelfedListAdapter pixelfedListAdapter;
private RetrieveFeedsAsyncTask.Type type;
private final List<Status> statuses;
private final PixelfedListAdapter pixelfedListAdapter;
private final RetrieveFeedsAsyncTask.Type type;
private MastalabAutoCompleteTextView comment_content;
private String in_reply_to_status;
private String visibility;
@ -825,7 +825,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
doAction = API.StatusAction.BLOCK;
break;
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)
Toasty.info(context, R.string.toast_error_translations_disabled, Toast.LENGTH_SHORT).show();
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);
if (!status.isFavAnimated()) {
if (status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) {
holder.pf_fav.setChecked(true);
} else {
holder.pf_fav.setChecked(false);
}
holder.pf_fav.setChecked(status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited()));
} else {
status.setFavAnimated(false);
holder.pf_fav.setChecked(true);
@ -1021,11 +1017,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
}
if (!status.isBoostAnimated()) {
if (status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged())) {
holder.pf_share.setChecked(true);
} else {
holder.pf_share.setChecked(false);
}
holder.pf_share.setChecked(status.isReblogged() || (status.getReblog() != null && status.getReblog().isReblogged()));
} else {
status.setBoostAnimated(false);
holder.pf_share.setChecked(true);
@ -1060,7 +1052,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
private void translateToot(Status status) {
//Manages translations
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;
String api_key;
@ -1091,7 +1083,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
else
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(), new Results() {
@Override
public void onSuccess(Translate translate) {
if (translate.getTranslatedContent() != null) {
@ -1199,10 +1191,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
int position = 0;
for (Status status : statuses) {
if (status.getId().equals(targetedId)) {
if (statusAction == API.StatusAction.PIN)
status.setPinned(true);
else
status.setPinned(false);
status.setPinned(statusAction == API.StatusAction.PIN);
pixelfedListAdapter.notifyItemChanged(position);
break;
}

View File

@ -128,7 +128,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
private Context context;
private AsyncTask asyncTask;
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 TextView set_folder;
private EditText your_api_key;
@ -1178,24 +1178,29 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
translation_layout_spinner.setAdapter(adapterTrans);
int positionSpinnerTrans;
your_api_key = rootView.findViewById(R.id.translation_key);
switch (sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX)) {
case Helper.TRANS_YANDEX:
switch (sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE)) {
case Helper.TRANS_LIBRETRANSLATE:
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.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, ""));
break;
case Helper.TRANS_DEEPL:
positionSpinnerTrans = 1;
positionSpinnerTrans = 2;
your_api_key.setVisibility(View.VISIBLE);
your_api_key.setText(sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, ""));
break;
case Helper.TRANS_SYSTRAN:
positionSpinnerTrans = 2;
positionSpinnerTrans = 3;
your_api_key.setVisibility(View.VISIBLE);
your_api_key.setText(sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, ""));
break;
case Helper.TRANS_NONE:
positionSpinnerTrans = 3;
positionSpinnerTrans = 4;
your_api_key.setVisibility(View.GONE);
break;
default:
@ -1211,25 +1216,32 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
SharedPreferences.Editor editor = sharedpreferences.edit();
switch (position) {
case 0:
your_api_key.setVisibility(View.VISIBLE);
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
your_api_key.setVisibility(View.GONE);
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_LIBRETRANSLATE);
editor.commit();
your_api_key.setText(sharedpreferences.getString(Helper.SET_YANDEX_API_KEY, ""));
break;
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);
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_DEEPL);
editor.commit();
your_api_key.setText(sharedpreferences.getString(Helper.SET_DEEPL_API_KEY, ""));
break;
case 2:
case 3:
your_api_key.setVisibility(View.VISIBLE);
editor.putInt(Helper.SET_TRANSLATOR, Helper.TRANS_SYSTRAN);
editor.commit();
your_api_key.setText(sharedpreferences.getString(Helper.SET_SYSTRAN_API_KEY, ""));
break;
case 3:
case 4:
your_api_key.setVisibility(View.GONE);
set_trans_forced.isChecked();
editor.putBoolean(Helper.SET_TRANS_FORCED, false);
@ -1488,7 +1500,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
@Override
public void afterTextChanged(Editable s) {
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;
if (translatore == Helper.TRANS_YANDEX)
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 TRANS_YANDEX = 0;
public static final int TRANS_YANDEX = 4;
public static final int TRANS_DEEPL = 1;
public static final int TRANS_NONE = 3;
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_ACTIVE = 1;
@ -3015,7 +3016,6 @@ public class BaseHelper {
return;
}
try {
assert url != null;
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE || disableGif || (!url.endsWith(".gif") && account.getAvatar_static().compareTo(account.getAvatar()) == 0)) {
Glide.with(imageView.getContext())
.asDrawable()
@ -4132,7 +4132,7 @@ public class BaseHelper {
new AsyncTask<Void, Void, List<String>>() {
APIResponse apiResponse;
private WeakReference<Context> contextReference = new WeakReference<>(context);
private final WeakReference<Context> contextReference = new WeakReference<>(context);
@Override
protected void onPreExecute() {
@ -4306,7 +4306,7 @@ public class BaseHelper {
new AsyncTask<Void, Void, List<String>>() {
APIResponse apiResponse;
private WeakReference<Context> contextReference = new WeakReference<>(context);
private final WeakReference<Context> contextReference = new WeakReference<>(context);
@Override
protected void onPreExecute() {
@ -4516,7 +4516,7 @@ public class BaseHelper {
public static class CacheTask extends AsyncTask<Void, Void, Void> {
private float cacheSize;
private WeakReference<Context> contextReference;
private final WeakReference<Context> contextReference;
public CacheTask(Context 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>
<FrameLayout
<RelativeLayout
android:id="@+id/status_cardview_video"
android:layout_width="match_parent"
android:layout_height="220dp"
@ -412,26 +412,20 @@
android:layout_marginBottom="10dp"
android:visibility="gone">
<RelativeLayout
android:id="@+id/webview_preview"
<ImageView
android:id="@+id/webview_preview_card"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:contentDescription="@string/image_preview"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/webview_preview_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<ImageView
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>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:contentDescription="@string/play_video"
android:src="@drawable/ic_play_arrow" />
</RelativeLayout>
<RelativeLayout
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">
<item>LibreTranslate</item>
<item>Yandex</item>
<item>DeepL</item>
<item>Systran</item>