diff options
Diffstat (limited to 'app/src/main/java/app/fedilab/android/mastodon/ui')
38 files changed, 1137 insertions, 650 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountAdapter.java index 428048fa6..10e470ccb 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountAdapter.java @@ -15,7 +15,8 @@ package app.fedilab.android.mastodon.ui.drawer; * see <http://www.gnu.org/licenses>. */ -import android.app.Activity; +import static app.fedilab.android.BaseMainActivity.currentAccount; + import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -29,7 +30,6 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; -import androidx.core.app.ActivityOptionsCompat; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelStoreOwner; @@ -48,6 +48,7 @@ import app.fedilab.android.activities.MainActivity; import app.fedilab.android.databinding.DrawerAccountBinding; import app.fedilab.android.mastodon.activities.ProfileActivity; import app.fedilab.android.mastodon.client.entities.api.Account; +import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.MastodonHelper; import app.fedilab.android.mastodon.helper.ThemeHelper; @@ -94,9 +95,9 @@ public class AccountAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder accountViewHolder.binding.muteHome.setChecked(muted); accountViewHolder.binding.muteHome.setOnClickListener(v -> { if (muted) { - accountsVM.unmuteHome(MainActivity.currentAccount, account).observe((LifecycleOwner) context, account1 -> adapter.notifyItemChanged(accountViewHolder.getLayoutPosition())); + accountsVM.unmuteHome(currentAccount, account).observe((LifecycleOwner) context, account1 -> adapter.notifyItemChanged(accountViewHolder.getLayoutPosition())); } else { - accountsVM.muteHome(MainActivity.currentAccount, account).observe((LifecycleOwner) context, account1 -> adapter.notifyItemChanged(accountViewHolder.getLayoutPosition())); + accountsVM.muteHome(currentAccount, account).observe((LifecycleOwner) context, account1 -> adapter.notifyItemChanged(accountViewHolder.getLayoutPosition())); } }); } else { @@ -111,11 +112,14 @@ public class AccountAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder accountViewHolder.binding.avatar.setOnClickListener(v -> { if (remoteInstance == null) { Intent intent = new Intent(context, ProfileActivity.class); - Bundle b = new Bundle(); - b.putSerializable(Helper.ARG_ACCOUNT, account); - intent.putExtras(b); - // start the new activity - context.startActivity(intent); + Bundle args = new Bundle(); + args.putSerializable(Helper.ARG_ACCOUNT, account); + new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { + Bundle bundle = new Bundle(); + bundle.putLong(Helper.ARG_INTENT_ID, bundleId); + intent.putExtras(bundle); + context.startActivity(intent); + }); } else { Toasty.info(context, context.getString(R.string.retrieve_remote_account), Toasty.LENGTH_SHORT).show(); SearchVM searchVM = new ViewModelProvider((ViewModelStoreOwner) context).get(SearchVM.class); @@ -124,11 +128,14 @@ public class AccountAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder if (results != null && results.accounts != null && results.accounts.size() > 0) { Account accountSearch = results.accounts.get(0); Intent intent = new Intent(context, ProfileActivity.class); - Bundle b = new Bundle(); - b.putSerializable(Helper.ARG_ACCOUNT, accountSearch); - intent.putExtras(b); - // start the new activity - context.startActivity(intent); + Bundle args = new Bundle(); + args.putSerializable(Helper.ARG_ACCOUNT, accountSearch); + new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { + Bundle bundle = new Bundle(); + bundle.putLong(Helper.ARG_INTENT_ID, bundleId); + intent.putExtras(bundle); + context.startActivity(intent); + }); } else { Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountFollowRequestAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountFollowRequestAdapter.java index a765d851b..537f1be38 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountFollowRequestAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountFollowRequestAdapter.java @@ -14,7 +14,8 @@ package app.fedilab.android.mastodon.ui.drawer; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see <http://www.gnu.org/licenses>. */ -import android.app.Activity; +import static app.fedilab.android.BaseMainActivity.currentAccount; + import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -24,7 +25,6 @@ import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; -import androidx.core.app.ActivityOptionsCompat; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelStoreOwner; @@ -38,6 +38,7 @@ import app.fedilab.android.R; import app.fedilab.android.databinding.DrawerFollowBinding; import app.fedilab.android.mastodon.activities.ProfileActivity; import app.fedilab.android.mastodon.client.entities.api.Account; +import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.MastodonHelper; import app.fedilab.android.mastodon.viewmodel.mastodon.AccountsVM; @@ -103,11 +104,14 @@ public class AccountFollowRequestAdapter extends RecyclerView.Adapter<RecyclerVi })); holderFollow.binding.avatar.setOnClickListener(v -> { Intent intent = new Intent(context, ProfileActivity.class); - Bundle b = new Bundle(); - b.putSerializable(Helper.ARG_ACCOUNT, account); - intent.putExtras(b); - // start the new activity - context.startActivity(intent); + Bundle args = new Bundle(); + args.putSerializable(Helper.ARG_ACCOUNT, account); + new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { + Bundle bundle = new Bundle(); + bundle.putLong(Helper.ARG_INTENT_ID, bundleId); + intent.putExtras(bundle); + context.startActivity(intent); + }); }); } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountsSearchTopBarAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountsSearchTopBarAdapter.java index 60eb910c7..18f144d6a 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountsSearchTopBarAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/AccountsSearchTopBarAdapter.java @@ -14,7 +14,8 @@ package app.fedilab.android.mastodon.ui.drawer; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see <http://www.gnu.org/licenses>. */ -import android.app.Activity; +import static app.fedilab.android.BaseMainActivity.currentAccount; + import android.content.Context; import android.content.Intent; import android.database.Cursor; @@ -22,10 +23,8 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; import androidx.appcompat.widget.LinearLayoutCompat; -import androidx.core.app.ActivityOptionsCompat; import androidx.cursoradapter.widget.SimpleCursorAdapter; import java.util.List; @@ -33,6 +32,7 @@ import java.util.List; import app.fedilab.android.R; import app.fedilab.android.mastodon.activities.ProfileActivity; import app.fedilab.android.mastodon.client.entities.api.Account; +import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.helper.Helper; @@ -61,16 +61,18 @@ public class AccountsSearchTopBarAdapter extends SimpleCursorAdapter { LinearLayoutCompat container = view.findViewById(R.id.account_container); container.setTag(cursor.getPosition()); - ImageView account_pp = view.findViewById(R.id.account_pp); container.setOnClickListener(v -> { int position = (int) v.getTag(); if (accountList != null && accountList.size() > position) { Intent intent = new Intent(context, ProfileActivity.class); - Bundle b = new Bundle(); - b.putSerializable(Helper.ARG_ACCOUNT, accountList.get(position)); - intent.putExtras(b); - // start the new activity - context.startActivity(intent); + Bundle args = new Bundle(); + args.putSerializable(Helper.ARG_ACCOUNT, accountList.get(position)); + new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { + Bundle bundle = new Bundle(); + bundle.putLong(Helper.ARG_INTENT_ID, bundleId); + intent.putExtras(bundle); + context.startActivity(intent); + }); } }); } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java index 97bd72f23..38fd8a43f 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java @@ -51,7 +51,6 @@ import android.view.inputmethod.InputMethodManager; import android.webkit.URLUtil; import android.widget.ArrayAdapter; import android.widget.Button; -import android.widget.GridView; import android.widget.LinearLayout; import android.widget.TextView; @@ -110,7 +109,6 @@ import app.fedilab.android.databinding.DrawerStatusComposeBinding; import app.fedilab.android.databinding.DrawerStatusSimpleBinding; import app.fedilab.android.mastodon.activities.ComposeActivity; import app.fedilab.android.mastodon.activities.MediaActivity; -import app.fedilab.android.mastodon.activities.SearchResultTabActivity; import app.fedilab.android.mastodon.client.entities.api.Account; import app.fedilab.android.mastodon.client.entities.api.Attachment; import app.fedilab.android.mastodon.client.entities.api.Emoji; @@ -120,6 +118,7 @@ import app.fedilab.android.mastodon.client.entities.api.Poll; import app.fedilab.android.mastodon.client.entities.api.Status; import app.fedilab.android.mastodon.client.entities.api.Tag; import app.fedilab.android.mastodon.client.entities.app.BaseAccount; +import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.client.entities.app.CamelTag; import app.fedilab.android.mastodon.client.entities.app.Languages; import app.fedilab.android.mastodon.client.entities.app.Quotes; @@ -549,7 +548,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); String defaultFormat = sharedpreferences.getString(context.getString(R.string.SET_THREAD_MESSAGE), context.getString(R.string.DEFAULT_THREAD_VALUE)); //User asked to be prompted for threading long messages - if(defaultFormat.compareToIgnoreCase("ASK") == 0 && !splitChoiceDone) { + if (defaultFormat.compareToIgnoreCase("ASK") == 0 && !splitChoiceDone) { splitChoiceDone = true; AlertDialog.Builder threadConfirm = new MaterialAlertDialogBuilder(context); threadConfirm.setTitle(context.getString(R.string.thread_long_this_message)); @@ -561,29 +560,29 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder holder.binding.content.setText(splitText.get(0)); int statusListSize = statusList.size(); int i = 0; - for(String message: splitText) { - if(i==0) { + for (String message : splitText) { + if (i == 0) { i++; continue; } - manageDrafts.onItemDraftAdded(statusListSize+(i-1), message); + manageDrafts.onItemDraftAdded(statusListSize + (i - 1), message); buttonVisibility(holder); i++; } dialog.dismiss(); }); threadConfirm.show(); - } else if(defaultFormat.compareToIgnoreCase("ENABLE") == 0) { //User wants to automatically thread long messages + } else if (defaultFormat.compareToIgnoreCase("ENABLE") == 0) { //User wants to automatically thread long messages proceedToSplit = true; ArrayList<String> splitText = ComposeHelper.splitToots(s.toString(), max_car); int statusListSize = statusList.size(); int i = 0; - for(String message: splitText) { - if(i==0) { + for (String message : splitText) { + if (i == 0) { i++; continue; } - manageDrafts.onItemDraftAdded(statusListSize+(i-1), message); + manageDrafts.onItemDraftAdded(statusListSize + (i - 1), message); buttonVisibility(holder); i++; } @@ -594,7 +593,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder @Override public void afterTextChanged(Editable s) { String contentString = s.toString(); - if(proceedToSplit) { + if (proceedToSplit) { int max_car = MastodonHelper.getInstanceMaxChars(context); ArrayList<String> splitText = ComposeHelper.splitToots(contentString, max_car); contentString = splitText.get(0); @@ -891,6 +890,13 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder Tag tag = new Tag(); tag.name = camelTag; if (!results.hashtags.contains(tag)) { + + for(Tag realTag: results.hashtags) { + if(realTag.name.equalsIgnoreCase(camelTag)) { + tag.history = realTag.history; + break; + } + } results.hashtags.add(0, tag); } } @@ -1352,30 +1358,34 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder if (getItemViewType(position) == TYPE_NORMAL) { Status status = statusList.get(position); StatusSimpleViewHolder holder = (StatusSimpleViewHolder) viewHolder; - if(status.media_attachments != null && status.media_attachments.size() > 0 ) { + if (status.media_attachments != null && status.media_attachments.size() > 0) { holder.binding.simpleMedia.removeAllViews(); List<Attachment> attachmentList = statusList.get(position).media_attachments; - for(Attachment attachment: attachmentList) { + for (Attachment attachment : attachmentList) { DrawerMediaListBinding drawerMediaListBinding = DrawerMediaListBinding.inflate(LayoutInflater.from(context), holder.binding.simpleMedia, false); Glide.with(drawerMediaListBinding.media.getContext()) .load(attachment.preview_url) .into(drawerMediaListBinding.media); - if(attachment.filename != null) { + if (attachment.filename != null) { drawerMediaListBinding.mediaName.setText(attachment.filename); - } else if (attachment.preview_url != null){ + } else if (attachment.preview_url != null) { drawerMediaListBinding.mediaName.setText(URLUtil.guessFileName(attachment.preview_url, null, null)); } - drawerMediaListBinding.getRoot().setOnClickListener(v->{ + drawerMediaListBinding.getRoot().setOnClickListener(v -> { Intent mediaIntent = new Intent(context, MediaActivity.class); - Bundle b = new Bundle(); + Bundle args = new Bundle(); ArrayList<Attachment> attachments = new ArrayList<>(); attachments.add(attachment); - b.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments); - mediaIntent.putExtras(b); - ActivityOptionsCompat options = ActivityOptionsCompat - .makeSceneTransitionAnimation((Activity) context, drawerMediaListBinding.media, attachment.url); - context.startActivity(mediaIntent, options.toBundle()); + args.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments); + new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { + Bundle bundle = new Bundle(); + bundle.putLong(Helper.ARG_INTENT_ID, bundleId); + mediaIntent.putExtras(bundle); + ActivityOptionsCompat options = ActivityOptionsCompat + .makeSceneTransitionAnimation((Activity) context, drawerMediaListBinding.media, attachment.url); + context.startActivity(mediaIntent, options.toBundle()); + }); }); holder.binding.simpleMedia.addView(drawerMediaListBinding.getRoot()); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ConversationAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ConversationAdapter.java index 08a2b11aa..fb35d988a 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ConversationAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ConversationAdapter.java @@ -15,6 +15,7 @@ package app.fedilab.android.mastodon.ui.drawer; * see <http://www.gnu.org/licenses>. */ +import static app.fedilab.android.BaseMainActivity.currentAccount; import static app.fedilab.android.BaseMainActivity.currentNightMode; import android.annotation.SuppressLint; @@ -22,6 +23,7 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.LayoutInflater; @@ -54,6 +56,7 @@ import app.fedilab.android.mastodon.client.entities.api.Account; import app.fedilab.android.mastodon.client.entities.api.Attachment; import app.fedilab.android.mastodon.client.entities.api.Conversation; import app.fedilab.android.mastodon.client.entities.api.Status; +import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.MastodonHelper; @@ -220,8 +223,14 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH } else { intent = new Intent(context, ContextActivity.class); } - intent.putExtra(Helper.ARG_STATUS, conversation.last_status); - context.startActivity(intent); + Bundle args = new Bundle(); + args.putSerializable(Helper.ARG_STATUS, conversation.last_status); + new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { + Bundle bundle = new Bundle(); + bundle.putLong(Helper.ARG_INTENT_ID, bundleId); + intent.putExtras(bundle); + context.startActivity(intent); + }); }); holder.binding.attachmentsListContainer.setOnTouchListener((v, event) -> { @@ -232,8 +241,14 @@ public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH } else { intent = new Intent(context, ContextActivity.class); } - intent.putExtra(Helper.ARG_STATUS, conversation.last_status); - context.startActivity(intent); + Bundle args = new Bundle(); + args.putSerializable(Helper.ARG_STATUS, conversation.last_status); + new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { + Bundle bundle = new Bundle(); + bundle.putLong(Helper.ARG_INTENT_ID, bundleId); + intent.putExtras(bundle); + context.startActivity(intent); + }); } return false; }); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ImageAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ImageAdapter.java index 9b4304ed3..817b79eda 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ImageAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ImageAdapter.java @@ -14,6 +14,8 @@ package app.fedilab.android.mastodon.ui.drawer; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see <http://www.gnu.org/licenses>. */ +import static app.fedilab.android.BaseMainActivity.currentAccount; + import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -31,6 +33,7 @@ import app.fedilab.android.databinding.DrawerMediaBinding; import app.fedilab.android.mastodon.activities.ContextActivity; import app.fedilab.android.mastodon.activities.MediaActivity; import app.fedilab.android.mastodon.client.entities.api.Attachment; +import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.ui.fragment.media.FragmentMediaProfile; @@ -72,30 +75,37 @@ public class ImageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> } holder.binding.media.setOnClickListener(v -> { Intent mediaIntent = new Intent(context, MediaActivity.class); - Bundle b = new Bundle(); - b.putInt(Helper.ARG_MEDIA_POSITION, position + 1); - b.putBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, true); - mediaIntent.putExtras(b); - ActivityOptionsCompat options = null; + Bundle args = new Bundle(); + args.putInt(Helper.ARG_MEDIA_POSITION, position + 1); + args.putBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, true); if (attachment != null) { - options = ActivityOptionsCompat - .makeSceneTransitionAnimation((Activity) context, holder.binding.media, attachment.url); - } else { - return; + new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { + Bundle bundle = new Bundle(); + bundle.putLong(Helper.ARG_INTENT_ID, bundleId); + mediaIntent.putExtras(bundle); + ActivityOptionsCompat options = null; + options = ActivityOptionsCompat + .makeSceneTransitionAnimation((Activity) context, holder.binding.media, attachment.url); + context.startActivity(mediaIntent, options.toBundle()); + }); } - // start the new activity - context.startActivity(mediaIntent, options.toBundle()); |