From 7e264d1f9164d3ba803c5ff539e141d901fd36c4 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 18 Jan 2021 19:00:43 +0100 Subject: [PATCH] Release 2.37.0-beta-2 --- app/build.gradle | 4 +- .../android/activities/AboutActivity.java | 8 +- .../RetrieveRemoteDataAsyncTask.java | 8 +- .../drawers/BaseStatusListAdapter.java | 623 +++--- .../android/drawers/PixelfedListAdapter.java | 29 +- .../fragments/ContentSettingsFragment.java | 34 +- .../fedilab/android/helper/BaseHelper.java | 10 +- .../helper/CommentDecorationHelper.java | 48 + app/src/main/res/layout/drawer_status.xml | 1904 ++++++++--------- .../main/res/layout/drawer_status_compact.xml | 1857 ++++++++-------- .../main/res/layout/drawer_status_console.xml | 32 +- .../main/res/layout/drawer_status_focused.xml | 1581 +++++++------- app/src/main/res/values/strings.xml | 1 + 13 files changed, 3031 insertions(+), 3108 deletions(-) create mode 100644 app/src/main/java/app/fedilab/android/helper/CommentDecorationHelper.java diff --git a/app/build.gradle b/app/build.gradle index ca39347f1..11c56e7b6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 diff --git a/app/src/main/java/app/fedilab/android/activities/AboutActivity.java b/app/src/main/java/app/fedilab/android/activities/AboutActivity.java index e63ad7111..92042f598 100644 --- a/app/src/main/java/app/fedilab/android/activities/AboutActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/AboutActivity.java @@ -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; diff --git a/app/src/main/java/app/fedilab/android/asynctasks/RetrieveRemoteDataAsyncTask.java b/app/src/main/java/app/fedilab/android/asynctasks/RetrieveRemoteDataAsyncTask.java index 4f39eb846..38fb95aec 100644 --- a/app/src/main/java/app/fedilab/android/asynctasks/RetrieveRemoteDataAsyncTask.java +++ b/app/src/main/java/app/fedilab/android/asynctasks/RetrieveRemoteDataAsyncTask.java @@ -35,15 +35,15 @@ import app.fedilab.android.interfaces.OnRetrieveRemoteAccountInterface; public class RetrieveRemoteDataAsyncTask extends AsyncTask { - private OnRetrieveRemoteAccountInterface listener; - private String url; + private final OnRetrieveRemoteAccountInterface listener; + private final String url; private Results results; - private WeakReference contextReference; + private final WeakReference 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); diff --git a/app/src/main/java/app/fedilab/android/drawers/BaseStatusListAdapter.java b/app/src/main/java/app/fedilab/android/drawers/BaseStatusListAdapter.java index 4f0b4b382..a35b03fb8 100644 --- a/app/src/main/java/app/fedilab/android/drawers/BaseStatusListAdapter.java +++ b/app/src/main/java/app/fedilab/android/drawers/BaseStatusListAdapter.java @@ -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 statuses; - private boolean isOnWifi; - private BaseStatusListAdapter statusListAdapter; - private String targetedId; + private final List 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 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 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 { 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 { + 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= 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 { - 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 { 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 statuses; - private PixelfedListAdapter pixelfedListAdapter; - private RetrieveFeedsAsyncTask.Type type; + private final List 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 translators = new ArrayList<>(); + private final List 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; diff --git a/app/src/main/java/app/fedilab/android/helper/BaseHelper.java b/app/src/main/java/app/fedilab/android/helper/BaseHelper.java index 01ed49e52..fee838124 100644 --- a/app/src/main/java/app/fedilab/android/helper/BaseHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/BaseHelper.java @@ -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>() { APIResponse apiResponse; - private WeakReference contextReference = new WeakReference<>(context); + private final WeakReference contextReference = new WeakReference<>(context); @Override protected void onPreExecute() { @@ -4306,7 +4306,7 @@ public class BaseHelper { new AsyncTask>() { APIResponse apiResponse; - private WeakReference contextReference = new WeakReference<>(context); + private final WeakReference contextReference = new WeakReference<>(context); @Override protected void onPreExecute() { @@ -4516,7 +4516,7 @@ public class BaseHelper { public static class CacheTask extends AsyncTask { private float cacheSize; - private WeakReference contextReference; + private final WeakReference contextReference; public CacheTask(Context context) { contextReference = new WeakReference<>(context); diff --git a/app/src/main/java/app/fedilab/android/helper/CommentDecorationHelper.java b/app/src/main/java/app/fedilab/android/helper/CommentDecorationHelper.java new file mode 100644 index 000000000..6ffb3f5b2 --- /dev/null +++ b/app/src/main/java/app/fedilab/android/helper/CommentDecorationHelper.java @@ -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 . */ + + +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 statuses) { + return numberOfIndentation(0, replyToCommentId, statuses); + } + + + private static int numberOfIndentation(int currentIdentation, String replyToCommentId, List 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); + } + } + +} diff --git a/app/src/main/res/layout/drawer_status.xml b/app/src/main/res/layout/drawer_status.xml index 24b4b52fe..837a7b244 100644 --- a/app/src/main/res/layout/drawer_status.xml +++ b/app/src/main/res/layout/drawer_status.xml @@ -15,529 +15,510 @@ see . --> - - + android:layout_height="wrap_content" + android:clickable="true" + android:divider="?android:dividerHorizontal" + android:focusable="true" + android:orientation="horizontal" + android:showDividers="end"> - - - - + - - - - + + android:layout_height="wrap_content"> + + + + + + + + + + + + + + app:layout_constraintTop_toBottomOf="@id/status_boosted_by_info" + app:layout_goneMarginTop="8dp" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/content_start_marker" + app:layout_constraintTop_toBottomOf="@id/barrier_account_info_bottom"> - - -