Loading app/src/main/java/app/fedilab/android/BaseMainActivity.java +27 −9 Original line number Diff line number Diff line Loading @@ -304,9 +304,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt Snackbar.make(binding.displaySnackBar, getString(R.string.message_has_been_sent), Snackbar.LENGTH_LONG) .setAction(getString(R.string.display), view -> { Intent intentContext = new Intent(BaseMainActivity.this, ContextActivity.class); intentContext.putExtra(Helper.ARG_STATUS, statusSent); Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, statusSent); new CachedBundle(BaseMainActivity.this).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); intentContext.putExtras(bundle); intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intentContext); }); }) .show(); //The message was edited, we need to update the timeline Loading Loading @@ -782,9 +788,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt public void federatedStatus(Status status) { if (status != null) { Intent intent = new Intent(activity, ContextActivity.class); intent.putExtra(Helper.ARG_STATUS, status); Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, status); new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activity.startActivity(intent); }); } } Loading Loading @@ -1021,9 +1033,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt public void federatedStatus(Status status) { if (status != null) { Intent intent = new Intent(activity, ContextActivity.class); intent.putExtra(Helper.ARG_STATUS, status); Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, status); new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activity.startActivity(intent); }); } else { Toasty.error(activity, activity.getString(R.string.toast_error), Toasty.LENGTH_SHORT).show(); } Loading app/src/main/java/app/fedilab/android/mastodon/activities/ContextActivity.java +75 −49 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import app.fedilab.android.R; import app.fedilab.android.activities.MainActivity; import app.fedilab.android.databinding.ActivityConversationBinding; import app.fedilab.android.mastodon.client.entities.api.Status; import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.client.entities.app.StatusCache; import app.fedilab.android.mastodon.exception.DBException; import app.fedilab.android.mastodon.helper.Helper; Loading Loading @@ -86,14 +87,24 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); } Bundle b = getIntent().getExtras(); displayCW = sharedpreferences.getBoolean(getString(R.string.SET_EXPAND_CW), false); focusedStatus = null; // or other values if (b != null) { focusedStatus = (Status) b.getSerializable(Helper.ARG_STATUS); remote_instance = b.getString(Helper.ARG_REMOTE_INSTANCE, null); focusedStatusURI = b.getString(Helper.ARG_FOCUSED_STATUS_URI, null); MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account); Bundle args = getIntent().getExtras(); if (args != null) { long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1); new CachedBundle(ContextActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { initializeAfterBundle(null); } } private void initializeAfterBundle(Bundle bundle) { if (bundle != null) { focusedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS); remote_instance = bundle.getString(Helper.ARG_REMOTE_INSTANCE, null); focusedStatusURI = bundle.getString(Helper.ARG_FOCUSED_STATUS_URI, null); } if (focusedStatus == null || currentAccount == null || currentAccount.mastodon_account == null) { finish(); Loading @@ -102,7 +113,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon if (focusedStatusURI == null && remote_instance == null) { focusedStatusURI = focusedStatus.uri; } MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this); checkRemotely = sharedpreferences.getBoolean(getString(R.string.SET_CONVERSATION_REMOTELY), false); if (!checkRemotely) { Loading @@ -113,6 +124,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon } } @Override protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); Loading @@ -120,9 +132,12 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon } private void loadLocalConversation() { Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, focusedStatus); args.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance); new CachedBundle(ContextActivity.this).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putSerializable(Helper.ARG_STATUS, focusedStatus); bundle.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); FragmentMastodonContext fragmentMastodonContext = new FragmentMastodonContext(); fragmentMastodonContext.firstMessage = this; currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, fragmentMastodonContext, bundle, null, null); Loading Loading @@ -151,6 +166,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon } }); } }); } @Override Loading Loading @@ -245,13 +261,17 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon String finalInstance = instance; statusesVM.getStatus(instance, null, remoteId).observe(ContextActivity.this, status -> { if (status != null) { Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, status); args.putString(Helper.ARG_REMOTE_INSTANCE, finalInstance); args.putString(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI); new CachedBundle(ContextActivity.this).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putSerializable(Helper.ARG_STATUS, status); bundle.putString(Helper.ARG_REMOTE_INSTANCE, finalInstance); bundle.putString(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); FragmentMastodonContext fragmentMastodonContext = new FragmentMastodonContext(); fragmentMastodonContext.firstMessage = ContextActivity.this; currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, fragmentMastodonContext, bundle, null, null); }); } else { loadLocalConversation(); } Loading Loading @@ -293,11 +313,17 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon statusesVM.getStatus(instance, null, remoteId).observe(ContextActivity.this, status -> { if (status != null) { Intent intentContext = new Intent(ContextActivity.this, ContextActivity.class); intentContext.putExtra(Helper.ARG_STATUS, status); intentContext.putExtra(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI); intentContext.putExtra(Helper.ARG_REMOTE_INSTANCE, finalInstance); Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, status); args.putString(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI); args.putString(Helper.ARG_REMOTE_INSTANCE, finalInstance); new CachedBundle(ContextActivity.this).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); intentContext.putExtras(bundle); intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intentContext); }); } else { Toasty.warning(ContextActivity.this, getString(R.string.toast_error_fetch_message), Toasty.LENGTH_SHORT).show(); } Loading app/src/main/java/app/fedilab/android/mastodon/activities/CustomSharingActivity.java +17 −5 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import app.fedilab.android.mastodon.client.entities.api.Attachment; import app.fedilab.android.mastodon.client.entities.api.Emoji; 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.CachedBundle; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.customsharing.CustomSharingAsyncTask; import app.fedilab.android.mastodon.helper.customsharing.CustomSharingResponse; Loading Loading @@ -65,23 +66,34 @@ public class CustomSharingActivity extends BaseBarActivity implements OnCustomSh protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(CustomSharingActivity.this); binding = ActivityCustomSharingBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); } Bundle b = getIntent().getExtras(); Bundle args = getIntent().getExtras(); status = null; if (b != null) { status = (Status) b.getSerializable(Helper.ARG_STATUS); if (args != null) { long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1); new CachedBundle(CustomSharingActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { initializeAfterBundle(null); } } private void initializeAfterBundle(Bundle bundle) { if (bundle != null) { status = (Status) bundle.getSerializable(Helper.ARG_STATUS); } if (status == null) { finish(); return; } SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(CustomSharingActivity.this); bundle_creator = status.account.acct; bundle_url = status.url; bundle_id = status.uri; Loading app/src/main/java/app/fedilab/android/mastodon/activities/DirectMessageActivity.java +53 −34 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import app.fedilab.android.BaseMainActivity; import app.fedilab.android.R; import app.fedilab.android.databinding.ActivityDirectMessageBinding; import app.fedilab.android.mastodon.client.entities.api.Status; import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.client.entities.app.StatusCache; import app.fedilab.android.mastodon.exception.DBException; import app.fedilab.android.mastodon.helper.Helper; Loading Loading @@ -71,31 +72,48 @@ public class DirectMessageActivity extends BaseActivity implements FragmentMasto SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this); float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f); binding.title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale); MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); } Bundle b = getIntent().getExtras(); Bundle args = getIntent().getExtras(); displayCW = sharedpreferences.getBoolean(getString(R.string.SET_EXPAND_CW), false); if (args != null) { long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1); new CachedBundle(DirectMessageActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { initializeAfterBundle(null); } } private void initializeAfterBundle(Bundle bundle) { Status focusedStatus = null; // or other values if (b != null) { focusedStatus = (Status) b.getSerializable(Helper.ARG_STATUS); remote_instance = b.getString(Helper.ARG_REMOTE_INSTANCE, null); if (bundle != null) { focusedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS); remote_instance = bundle.getString(Helper.ARG_REMOTE_INSTANCE, null); } if (focusedStatus == null || currentAccount == null || currentAccount.mastodon_account == null) { finish(); return; } MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account); Bundle bundle = new Bundle(); bundle.putSerializable(Helper.ARG_STATUS, focusedStatus); bundle.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance); Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, focusedStatus); args.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance); Status finalFocusedStatus = focusedStatus; new CachedBundle(DirectMessageActivity.this).insertBundle(args, currentAccount, bundleId -> { Bundle args2 = new Bundle(); args2.putLong(Helper.ARG_INTENT_ID, bundleId); FragmentMastodonDirectMessage FragmentMastodonDirectMessage = new FragmentMastodonDirectMessage(); FragmentMastodonDirectMessage.firstMessage = this; currentFragment = (FragmentMastodonDirectMessage) Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, FragmentMastodonDirectMessage, bundle, null, null); currentFragment = (FragmentMastodonDirectMessage) Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, FragmentMastodonDirectMessage, args2, null, null); StatusesVM timelinesVM = new ViewModelProvider(DirectMessageActivity.this).get(StatusesVM.class); timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, focusedStatus.id).observe(DirectMessageActivity.this, status -> { timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, finalFocusedStatus.id).observe(DirectMessageActivity.this, status -> { if (status != null) { StatusCache statusCache = new StatusCache(); statusCache.instance = BaseMainActivity.currentInstance; Loading @@ -116,8 +134,9 @@ public class DirectMessageActivity extends BaseActivity implements FragmentMasto }).start(); } }); } }); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Loading app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java +22 −7 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package app.fedilab.android.mastodon.activities; * see <http://www.gnu.org/licenses>. */ import static android.util.Patterns.WEB_URL; import static app.fedilab.android.BaseMainActivity.currentAccount; import android.Manifest; import android.app.DownloadManager; Loading Loading @@ -63,6 +64,7 @@ import app.fedilab.android.R; import app.fedilab.android.databinding.ActivityMediaPagerBinding; import app.fedilab.android.mastodon.client.entities.api.Attachment; 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.MediaHelper; import app.fedilab.android.mastodon.helper.TranslateHelper; Loading Loading @@ -124,13 +126,26 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload fullscreen = false; flags = getWindow().getDecorView().getSystemUiVisibility(); Bundle b = getIntent().getExtras(); if (b != null) { mediaPosition = b.getInt(Helper.ARG_MEDIA_POSITION, 1); attachments = (ArrayList<Attachment>) b.getSerializable(Helper.ARG_MEDIA_ARRAY); mediaFromProfile = b.getBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, false); status = (Status) b.getSerializable(Helper.ARG_STATUS); Bundle args = getIntent().getExtras(); if (args != null) { long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1); new CachedBundle(MediaActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { initializeAfterBundle(null); } } private void initializeAfterBundle(Bundle bundle) { if (bundle != null) { mediaPosition = bundle.getInt(Helper.ARG_MEDIA_POSITION, 1); attachments = (ArrayList<Attachment>) bundle.getSerializable(Helper.ARG_MEDIA_ARRAY); mediaFromProfile = bundle.getBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, false); status = (Status) bundle.getSerializable(Helper.ARG_STATUS); } if (mediaFromProfile && FragmentMediaProfile.mediaAttachmentProfile != null) { attachments = new ArrayList<>(); attachments.addAll(FragmentMediaProfile.mediaAttachmentProfile); Loading @@ -146,7 +161,6 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload } setTitle(""); ScreenSlidePagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager()); binding.mediaViewpager.setAdapter(mPagerAdapter); binding.mediaViewpager.setSaveEnabled(false); Loading Loading @@ -239,6 +253,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload setFullscreen(true); } private Spannable linkify(Context context, String content) { if (content == null) { return new SpannableString(""); Loading Loading
app/src/main/java/app/fedilab/android/BaseMainActivity.java +27 −9 Original line number Diff line number Diff line Loading @@ -304,9 +304,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt Snackbar.make(binding.displaySnackBar, getString(R.string.message_has_been_sent), Snackbar.LENGTH_LONG) .setAction(getString(R.string.display), view -> { Intent intentContext = new Intent(BaseMainActivity.this, ContextActivity.class); intentContext.putExtra(Helper.ARG_STATUS, statusSent); Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, statusSent); new CachedBundle(BaseMainActivity.this).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); intentContext.putExtras(bundle); intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intentContext); }); }) .show(); //The message was edited, we need to update the timeline Loading Loading @@ -782,9 +788,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt public void federatedStatus(Status status) { if (status != null) { Intent intent = new Intent(activity, ContextActivity.class); intent.putExtra(Helper.ARG_STATUS, status); Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, status); new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activity.startActivity(intent); }); } } Loading Loading @@ -1021,9 +1033,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt public void federatedStatus(Status status) { if (status != null) { Intent intent = new Intent(activity, ContextActivity.class); intent.putExtra(Helper.ARG_STATUS, status); Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, status); new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activity.startActivity(intent); }); } else { Toasty.error(activity, activity.getString(R.string.toast_error), Toasty.LENGTH_SHORT).show(); } Loading
app/src/main/java/app/fedilab/android/mastodon/activities/ContextActivity.java +75 −49 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import app.fedilab.android.R; import app.fedilab.android.activities.MainActivity; import app.fedilab.android.databinding.ActivityConversationBinding; import app.fedilab.android.mastodon.client.entities.api.Status; import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.client.entities.app.StatusCache; import app.fedilab.android.mastodon.exception.DBException; import app.fedilab.android.mastodon.helper.Helper; Loading Loading @@ -86,14 +87,24 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); } Bundle b = getIntent().getExtras(); displayCW = sharedpreferences.getBoolean(getString(R.string.SET_EXPAND_CW), false); focusedStatus = null; // or other values if (b != null) { focusedStatus = (Status) b.getSerializable(Helper.ARG_STATUS); remote_instance = b.getString(Helper.ARG_REMOTE_INSTANCE, null); focusedStatusURI = b.getString(Helper.ARG_FOCUSED_STATUS_URI, null); MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account); Bundle args = getIntent().getExtras(); if (args != null) { long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1); new CachedBundle(ContextActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { initializeAfterBundle(null); } } private void initializeAfterBundle(Bundle bundle) { if (bundle != null) { focusedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS); remote_instance = bundle.getString(Helper.ARG_REMOTE_INSTANCE, null); focusedStatusURI = bundle.getString(Helper.ARG_FOCUSED_STATUS_URI, null); } if (focusedStatus == null || currentAccount == null || currentAccount.mastodon_account == null) { finish(); Loading @@ -102,7 +113,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon if (focusedStatusURI == null && remote_instance == null) { focusedStatusURI = focusedStatus.uri; } MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this); checkRemotely = sharedpreferences.getBoolean(getString(R.string.SET_CONVERSATION_REMOTELY), false); if (!checkRemotely) { Loading @@ -113,6 +124,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon } } @Override protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); Loading @@ -120,9 +132,12 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon } private void loadLocalConversation() { Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, focusedStatus); args.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance); new CachedBundle(ContextActivity.this).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putSerializable(Helper.ARG_STATUS, focusedStatus); bundle.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); FragmentMastodonContext fragmentMastodonContext = new FragmentMastodonContext(); fragmentMastodonContext.firstMessage = this; currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, fragmentMastodonContext, bundle, null, null); Loading Loading @@ -151,6 +166,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon } }); } }); } @Override Loading Loading @@ -245,13 +261,17 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon String finalInstance = instance; statusesVM.getStatus(instance, null, remoteId).observe(ContextActivity.this, status -> { if (status != null) { Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, status); args.putString(Helper.ARG_REMOTE_INSTANCE, finalInstance); args.putString(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI); new CachedBundle(ContextActivity.this).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putSerializable(Helper.ARG_STATUS, status); bundle.putString(Helper.ARG_REMOTE_INSTANCE, finalInstance); bundle.putString(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); FragmentMastodonContext fragmentMastodonContext = new FragmentMastodonContext(); fragmentMastodonContext.firstMessage = ContextActivity.this; currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, fragmentMastodonContext, bundle, null, null); }); } else { loadLocalConversation(); } Loading Loading @@ -293,11 +313,17 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon statusesVM.getStatus(instance, null, remoteId).observe(ContextActivity.this, status -> { if (status != null) { Intent intentContext = new Intent(ContextActivity.this, ContextActivity.class); intentContext.putExtra(Helper.ARG_STATUS, status); intentContext.putExtra(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI); intentContext.putExtra(Helper.ARG_REMOTE_INSTANCE, finalInstance); Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, status); args.putString(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI); args.putString(Helper.ARG_REMOTE_INSTANCE, finalInstance); new CachedBundle(ContextActivity.this).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); intentContext.putExtras(bundle); intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intentContext); }); } else { Toasty.warning(ContextActivity.this, getString(R.string.toast_error_fetch_message), Toasty.LENGTH_SHORT).show(); } Loading
app/src/main/java/app/fedilab/android/mastodon/activities/CustomSharingActivity.java +17 −5 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import app.fedilab.android.mastodon.client.entities.api.Attachment; import app.fedilab.android.mastodon.client.entities.api.Emoji; 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.CachedBundle; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.customsharing.CustomSharingAsyncTask; import app.fedilab.android.mastodon.helper.customsharing.CustomSharingResponse; Loading Loading @@ -65,23 +66,34 @@ public class CustomSharingActivity extends BaseBarActivity implements OnCustomSh protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(CustomSharingActivity.this); binding = ActivityCustomSharingBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); } Bundle b = getIntent().getExtras(); Bundle args = getIntent().getExtras(); status = null; if (b != null) { status = (Status) b.getSerializable(Helper.ARG_STATUS); if (args != null) { long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1); new CachedBundle(CustomSharingActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { initializeAfterBundle(null); } } private void initializeAfterBundle(Bundle bundle) { if (bundle != null) { status = (Status) bundle.getSerializable(Helper.ARG_STATUS); } if (status == null) { finish(); return; } SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(CustomSharingActivity.this); bundle_creator = status.account.acct; bundle_url = status.url; bundle_id = status.uri; Loading
app/src/main/java/app/fedilab/android/mastodon/activities/DirectMessageActivity.java +53 −34 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import app.fedilab.android.BaseMainActivity; import app.fedilab.android.R; import app.fedilab.android.databinding.ActivityDirectMessageBinding; import app.fedilab.android.mastodon.client.entities.api.Status; import app.fedilab.android.mastodon.client.entities.app.CachedBundle; import app.fedilab.android.mastodon.client.entities.app.StatusCache; import app.fedilab.android.mastodon.exception.DBException; import app.fedilab.android.mastodon.helper.Helper; Loading Loading @@ -71,31 +72,48 @@ public class DirectMessageActivity extends BaseActivity implements FragmentMasto SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this); float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f); binding.title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale); MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); } Bundle b = getIntent().getExtras(); Bundle args = getIntent().getExtras(); displayCW = sharedpreferences.getBoolean(getString(R.string.SET_EXPAND_CW), false); if (args != null) { long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1); new CachedBundle(DirectMessageActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { initializeAfterBundle(null); } } private void initializeAfterBundle(Bundle bundle) { Status focusedStatus = null; // or other values if (b != null) { focusedStatus = (Status) b.getSerializable(Helper.ARG_STATUS); remote_instance = b.getString(Helper.ARG_REMOTE_INSTANCE, null); if (bundle != null) { focusedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS); remote_instance = bundle.getString(Helper.ARG_REMOTE_INSTANCE, null); } if (focusedStatus == null || currentAccount == null || currentAccount.mastodon_account == null) { finish(); return; } MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account); Bundle bundle = new Bundle(); bundle.putSerializable(Helper.ARG_STATUS, focusedStatus); bundle.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance); Bundle args = new Bundle(); args.putSerializable(Helper.ARG_STATUS, focusedStatus); args.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance); Status finalFocusedStatus = focusedStatus; new CachedBundle(DirectMessageActivity.this).insertBundle(args, currentAccount, bundleId -> { Bundle args2 = new Bundle(); args2.putLong(Helper.ARG_INTENT_ID, bundleId); FragmentMastodonDirectMessage FragmentMastodonDirectMessage = new FragmentMastodonDirectMessage(); FragmentMastodonDirectMessage.firstMessage = this; currentFragment = (FragmentMastodonDirectMessage) Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, FragmentMastodonDirectMessage, bundle, null, null); currentFragment = (FragmentMastodonDirectMessage) Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, FragmentMastodonDirectMessage, args2, null, null); StatusesVM timelinesVM = new ViewModelProvider(DirectMessageActivity.this).get(StatusesVM.class); timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, focusedStatus.id).observe(DirectMessageActivity.this, status -> { timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, finalFocusedStatus.id).observe(DirectMessageActivity.this, status -> { if (status != null) { StatusCache statusCache = new StatusCache(); statusCache.instance = BaseMainActivity.currentInstance; Loading @@ -116,8 +134,9 @@ public class DirectMessageActivity extends BaseActivity implements FragmentMasto }).start(); } }); } }); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Loading
app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java +22 −7 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package app.fedilab.android.mastodon.activities; * see <http://www.gnu.org/licenses>. */ import static android.util.Patterns.WEB_URL; import static app.fedilab.android.BaseMainActivity.currentAccount; import android.Manifest; import android.app.DownloadManager; Loading Loading @@ -63,6 +64,7 @@ import app.fedilab.android.R; import app.fedilab.android.databinding.ActivityMediaPagerBinding; import app.fedilab.android.mastodon.client.entities.api.Attachment; 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.MediaHelper; import app.fedilab.android.mastodon.helper.TranslateHelper; Loading Loading @@ -124,13 +126,26 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload fullscreen = false; flags = getWindow().getDecorView().getSystemUiVisibility(); Bundle b = getIntent().getExtras(); if (b != null) { mediaPosition = b.getInt(Helper.ARG_MEDIA_POSITION, 1); attachments = (ArrayList<Attachment>) b.getSerializable(Helper.ARG_MEDIA_ARRAY); mediaFromProfile = b.getBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, false); status = (Status) b.getSerializable(Helper.ARG_STATUS); Bundle args = getIntent().getExtras(); if (args != null) { long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1); new CachedBundle(MediaActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { initializeAfterBundle(null); } } private void initializeAfterBundle(Bundle bundle) { if (bundle != null) { mediaPosition = bundle.getInt(Helper.ARG_MEDIA_POSITION, 1); attachments = (ArrayList<Attachment>) bundle.getSerializable(Helper.ARG_MEDIA_ARRAY); mediaFromProfile = bundle.getBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, false); status = (Status) bundle.getSerializable(Helper.ARG_STATUS); } if (mediaFromProfile && FragmentMediaProfile.mediaAttachmentProfile != null) { attachments = new ArrayList<>(); attachments.addAll(FragmentMediaProfile.mediaAttachmentProfile); Loading @@ -146,7 +161,6 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload } setTitle(""); ScreenSlidePagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager()); binding.mediaViewpager.setAdapter(mPagerAdapter); binding.mediaViewpager.setSaveEnabled(false); Loading Loading @@ -239,6 +253,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload setFullscreen(true); } private Spannable linkify(Context context, String content) { if (content == null) { return new SpannableString(""); Loading