mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Apply for status
This commit is contained in:
parent
1ff15b0f93
commit
85e462e276
14 changed files with 422 additions and 181 deletions
|
@ -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);
|
||||
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intentContext);
|
||||
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
|
||||
|
@ -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);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
activity.startActivity(intent);
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
activity.startActivity(intent);
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -113,6 +124,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
@ -120,37 +132,41 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
|
|||
}
|
||||
|
||||
private void loadLocalConversation() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.ARG_STATUS, focusedStatus);
|
||||
bundle.putString(Helper.ARG_REMOTE_INSTANCE, remote_instance);
|
||||
FragmentMastodonContext fragmentMastodonContext = new FragmentMastodonContext();
|
||||
fragmentMastodonContext.firstMessage = this;
|
||||
currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, fragmentMastodonContext, bundle, null, null);
|
||||
//Update the status
|
||||
if (remote_instance == null) {
|
||||
StatusesVM timelinesVM = new ViewModelProvider(ContextActivity.this).get(StatusesVM.class);
|
||||
timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, focusedStatus.id).observe(ContextActivity.this, status -> {
|
||||
if (status != null) {
|
||||
StatusCache statusCache = new StatusCache();
|
||||
statusCache.instance = BaseMainActivity.currentInstance;
|
||||
statusCache.user_id = BaseMainActivity.currentUserID;
|
||||
statusCache.status = status;
|
||||
statusCache.status_id = status.id;
|
||||
//Update cache
|
||||
new Thread(() -> {
|
||||
try {
|
||||
new StatusCache(getApplication()).updateIfExists(statusCache);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
//Update UI
|
||||
Runnable myRunnable = () -> StatusAdapter.sendAction(ContextActivity.this, Helper.ARG_STATUS_ACTION, status, null);
|
||||
mainHandler.post(myRunnable);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
}
|
||||
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.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);
|
||||
//Update the status
|
||||
if (remote_instance == null) {
|
||||
StatusesVM timelinesVM = new ViewModelProvider(ContextActivity.this).get(StatusesVM.class);
|
||||
timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, focusedStatus.id).observe(ContextActivity.this, status -> {
|
||||
if (status != null) {
|
||||
StatusCache statusCache = new StatusCache();
|
||||
statusCache.instance = BaseMainActivity.currentInstance;
|
||||
statusCache.user_id = BaseMainActivity.currentUserID;
|
||||
statusCache.status = status;
|
||||
statusCache.status_id = status.id;
|
||||
//Update cache
|
||||
new Thread(() -> {
|
||||
try {
|
||||
new StatusCache(getApplication()).updateIfExists(statusCache);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
//Update UI
|
||||
Runnable myRunnable = () -> StatusAdapter.sendAction(ContextActivity.this, Helper.ARG_STATUS_ACTION, status, null);
|
||||
mainHandler.post(myRunnable);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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 bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.ARG_STATUS, status);
|
||||
bundle.putString(Helper.ARG_REMOTE_INSTANCE, finalInstance);
|
||||
bundle.putString(Helper.ARG_FOCUSED_STATUS_URI, focusedStatusURI);
|
||||
FragmentMastodonContext fragmentMastodonContext = new FragmentMastodonContext();
|
||||
fragmentMastodonContext.firstMessage = ContextActivity.this;
|
||||
currentFragment = Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, fragmentMastodonContext, bundle, null, 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.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();
|
||||
}
|
||||
|
@ -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);
|
||||
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intentContext);
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -71,53 +72,71 @@ 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);
|
||||
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 (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 (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);
|
||||
FragmentMastodonDirectMessage FragmentMastodonDirectMessage = new FragmentMastodonDirectMessage();
|
||||
FragmentMastodonDirectMessage.firstMessage = this;
|
||||
currentFragment = (FragmentMastodonDirectMessage) Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_content_main, FragmentMastodonDirectMessage, bundle, null, null);
|
||||
StatusesVM timelinesVM = new ViewModelProvider(DirectMessageActivity.this).get(StatusesVM.class);
|
||||
timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, focusedStatus.id).observe(DirectMessageActivity.this, status -> {
|
||||
if (status != null) {
|
||||
StatusCache statusCache = new StatusCache();
|
||||
statusCache.instance = BaseMainActivity.currentInstance;
|
||||
statusCache.user_id = BaseMainActivity.currentUserID;
|
||||
statusCache.status = status;
|
||||
statusCache.status_id = status.id;
|
||||
//Update cache
|
||||
new Thread(() -> {
|
||||
try {
|
||||
new StatusCache(getApplication()).updateIfExists(statusCache);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
//Update UI
|
||||
Runnable myRunnable = () -> StatusAdapter.sendAction(DirectMessageActivity.this, Helper.ARG_STATUS_ACTION, status, null);
|
||||
mainHandler.post(myRunnable);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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, args2, null, null);
|
||||
StatusesVM timelinesVM = new ViewModelProvider(DirectMessageActivity.this).get(StatusesVM.class);
|
||||
timelinesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, finalFocusedStatus.id).observe(DirectMessageActivity.this, status -> {
|
||||
if (status != null) {
|
||||
StatusCache statusCache = new StatusCache();
|
||||
statusCache.instance = BaseMainActivity.currentInstance;
|
||||
statusCache.user_id = BaseMainActivity.currentUserID;
|
||||
statusCache.status = status;
|
||||
statusCache.status_id = status.id;
|
||||
//Update cache
|
||||
new Thread(() -> {
|
||||
try {
|
||||
new StatusCache(getApplication()).updateIfExists(statusCache);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
//Update UI
|
||||
Runnable myRunnable = () -> StatusAdapter.sendAction(DirectMessageActivity.this, Helper.ARG_STATUS_ACTION, status, null);
|
||||
mainHandler.post(myRunnable);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
|
|
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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("");
|
||||
|
|
|
@ -15,6 +15,7 @@ package app.fedilab.android.mastodon.activities;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
import static app.fedilab.android.BaseMainActivity.currentAccount;
|
||||
import static app.fedilab.android.BaseMainActivity.currentInstance;
|
||||
import static app.fedilab.android.BaseMainActivity.currentToken;
|
||||
|
||||
|
@ -38,6 +39,7 @@ import app.fedilab.android.mastodon.client.entities.api.Account;
|
|||
import app.fedilab.android.mastodon.client.entities.api.Accounts;
|
||||
import app.fedilab.android.mastodon.client.entities.api.RelationShip;
|
||||
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.ui.drawer.AccountAdapter;
|
||||
import app.fedilab.android.mastodon.viewmodel.mastodon.AccountsVM;
|
||||
|
@ -70,12 +72,23 @@ public class StatusInfoActivity extends BaseActivity {
|
|||
}
|
||||
accountList = new ArrayList<>();
|
||||
checkRemotely = false;
|
||||
Bundle b = getIntent().getExtras();
|
||||
if (b != null) {
|
||||
type = (typeOfInfo) b.getSerializable(Helper.ARG_TYPE_OF_INFO);
|
||||
status = (Status) b.getSerializable(Helper.ARG_STATUS);
|
||||
checkRemotely = b.getBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||
Bundle args = getIntent().getExtras();
|
||||
if (args != null) {
|
||||
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
|
||||
new CachedBundle(StatusInfoActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||
} else {
|
||||
initializeAfterBundle(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeAfterBundle(Bundle bundle) {
|
||||
|
||||
if (bundle != null) {
|
||||
type = (typeOfInfo) bundle.getSerializable(Helper.ARG_TYPE_OF_INFO);
|
||||
status = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
||||
checkRemotely = bundle.getBoolean(Helper.ARG_CHECK_REMOTELY, false);
|
||||
}
|
||||
|
||||
if (type == null || status == null) {
|
||||
finish();
|
||||
return;
|
||||
|
@ -138,6 +151,7 @@ public class StatusInfoActivity extends BaseActivity {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void manageView(Accounts accounts) {
|
||||
binding.loadingNextAccounts.setVisibility(View.GONE);
|
||||
if (accountList != null && accounts != null && accounts.accounts != null) {
|
||||
|
|
|
@ -45,16 +45,25 @@ public class TimelineActivity extends BaseBarActivity {
|
|||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
Bundle b = getIntent().getExtras();
|
||||
Bundle args = getIntent().getExtras();
|
||||
if (args != null) {
|
||||
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
|
||||
new CachedBundle(TimelineActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||
} else {
|
||||
initializeAfterBundle(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeAfterBundle(Bundle bundle) {
|
||||
Timeline.TimeLineEnum timelineType = null;
|
||||
String lemmy_post_id = null;
|
||||
PinnedTimeline pinnedTimeline = null;
|
||||
Status status = null;
|
||||
if (b != null) {
|
||||
timelineType = (Timeline.TimeLineEnum) b.get(Helper.ARG_TIMELINE_TYPE);
|
||||
lemmy_post_id = b.getString(Helper.ARG_LEMMY_POST_ID, null);
|
||||
pinnedTimeline = (PinnedTimeline) b.getSerializable(Helper.ARG_REMOTE_INSTANCE);
|
||||
status = (Status) b.getSerializable(Helper.ARG_STATUS);
|
||||
if (bundle != null) {
|
||||
timelineType = (Timeline.TimeLineEnum) bundle.get(Helper.ARG_TIMELINE_TYPE);
|
||||
lemmy_post_id = bundle.getString(Helper.ARG_LEMMY_POST_ID, null);
|
||||
pinnedTimeline = (PinnedTimeline) bundle.getSerializable(Helper.ARG_REMOTE_INSTANCE);
|
||||
status = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
||||
}
|
||||
if (pinnedTimeline != null && pinnedTimeline.remoteInstance != null) {
|
||||
setTitle(pinnedTimeline.remoteInstance.host);
|
||||
|
@ -68,13 +77,12 @@ public class TimelineActivity extends BaseBarActivity {
|
|||
args.putSerializable(Helper.ARG_STATUS, status);
|
||||
}
|
||||
new CachedBundle(TimelineActivity.this).insertBundle(args, currentAccount, bundleId -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||
fragmentMastodonTimeline.setArguments(bundle);
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||
fragmentMastodonTimeline.setArguments(bundle1);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add(R.id.fragment_container_view, fragmentMastodonTimeline).commit();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -627,9 +627,15 @@ public class SpannableHelper {
|
|||
@Override
|
||||
public void federatedStatus(Status status) {
|
||||
Intent intent = new Intent(context, ContextActivity.class);
|
||||
intent.putExtra(Helper.ARG_STATUS, status);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, status);
|
||||
new CachedBundle(context).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);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -663,9 +669,15 @@ public class SpannableHelper {
|
|||
@Override
|
||||
public void federatedStatus(Status status) {
|
||||
Intent intent = new Intent(context, ContextActivity.class);
|
||||
intent.putExtra(Helper.ARG_STATUS, status);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, status);
|
||||
new CachedBundle(context).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);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -699,9 +711,15 @@ public class SpannableHelper {
|
|||
@Override
|
||||
public void federatedStatus(Status status) {
|
||||
Intent intent = new Intent(context, ContextActivity.class);
|
||||
intent.putExtra(Helper.ARG_STATUS, status);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, status);
|
||||
new CachedBundle(context).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);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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;
|
||||
|
@ -49,13 +51,14 @@ import app.fedilab.android.R;
|
|||
import app.fedilab.android.databinding.DrawerConversationBinding;
|
||||
import app.fedilab.android.databinding.ThumbnailBinding;
|
||||
import app.fedilab.android.mastodon.activities.ContextActivity;
|
||||
import app.fedilab.android.mastodon.activities.DirectMessageActivity;
|
||||
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;
|
||||
import app.fedilab.android.mastodon.activities.DirectMessageActivity;
|
||||
|
||||
|
||||
public class ConversationAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -89,13 +92,19 @@ public class ImageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
|
||||
holder.binding.media.setOnLongClickListener(v -> {
|
||||
Intent intentContext = new Intent(context, ContextActivity.class);
|
||||
Bundle args = new Bundle();
|
||||
if (attachment != null) {
|
||||
intentContext.putExtra(Helper.ARG_STATUS, attachment.status);
|
||||
args.putSerializable(Helper.ARG_STATUS, attachment.status);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intentContext);
|
||||
new CachedBundle(context).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);
|
||||
context.startActivity(intentContext);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -503,8 +503,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
return;
|
||||
}
|
||||
Intent intent = new Intent(context, ContextActivity.class);
|
||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal.quote);
|
||||
context.startActivity(intent);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, statusToDeal.quote);
|
||||
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.quotedMessage.cardviewContainer.setStrokeColor(ThemeHelper.getAttColor(context, R.attr.colorPrimary));
|
||||
holder.binding.quotedMessage.statusContent.setText(
|
||||
|
@ -1773,20 +1779,32 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
holder.binding.reblogInfo.setOnClickListener(v -> {
|
||||
if (statusToDeal.reblogs_count > 0) {
|
||||
Intent intent = new Intent(context, StatusInfoActivity.class);
|
||||
intent.putExtra(Helper.ARG_TYPE_OF_INFO, StatusInfoActivity.typeOfInfo.BOOSTED_BY);
|
||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
||||
intent.putExtra(Helper.ARG_CHECK_REMOTELY, remote);
|
||||
context.startActivity(intent);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||
args.putSerializable(Helper.ARG_TYPE_OF_INFO, StatusInfoActivity.typeOfInfo.BOOSTED_BY);
|
||||
args.putBoolean(Helper.ARG_CHECK_REMOTELY, remote);
|
||||
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.favouriteInfo.setOnClickListener(v -> {
|
||||
if (statusToDeal.favourites_count > 0) {
|
||||
Intent intent = new Intent(context, StatusInfoActivity.class);
|
||||
intent.putExtra(Helper.ARG_TYPE_OF_INFO, StatusInfoActivity.typeOfInfo.LIKED_BY);
|
||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
||||
intent.putExtra(Helper.ARG_CHECK_REMOTELY, remote);
|
||||
context.startActivity(intent);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||
args.putSerializable(Helper.ARG_TYPE_OF_INFO, StatusInfoActivity.typeOfInfo.LIKED_BY);
|
||||
args.putBoolean(Helper.ARG_CHECK_REMOTELY, remote);
|
||||
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||
intent.putExtras(bundle);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2002,22 +2020,31 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
return;
|
||||
}
|
||||
if (context instanceof ContextActivity && !remote) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||
Fragment fragment = Helper.addFragment(((AppCompatActivity) context).getSupportFragmentManager(), R.id.nav_host_fragment_content_main, new FragmentMastodonContext(), bundle, null, FragmentMastodonContext.class.getName());
|
||||
((ContextActivity) context).setCurrentFragment((FragmentMastodonContext) fragment);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||
Fragment fragment = Helper.addFragment(((AppCompatActivity) context).getSupportFragmentManager(), R.id.nav_host_fragment_content_main, new FragmentMastodonContext(), bundle, null, FragmentMastodonContext.class.getName());
|
||||
((ContextActivity) context).setCurrentFragment((FragmentMastodonContext) fragment);
|
||||
});
|
||||
} else {
|
||||
if (remote) {
|
||||
//Lemmy main post that should open Lemmy threads
|
||||
if (adapter instanceof StatusAdapter && ((StatusAdapter) adapter).type == RemoteInstance.InstanceType.LEMMY && status.lemmy_post_id != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.ARG_REMOTE_INSTANCE, ((StatusAdapter) adapter).pinnedTimeline);
|
||||
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.REMOTE);
|
||||
bundle.putString(Helper.ARG_LEMMY_POST_ID, status.lemmy_post_id);
|
||||
bundle.putSerializable(Helper.ARG_STATUS, status);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_REMOTE_INSTANCE, ((StatusAdapter) adapter).pinnedTimeline);
|
||||
args.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.REMOTE);
|
||||
args.putString(Helper.ARG_LEMMY_POST_ID, status.lemmy_post_id);
|
||||
args.putSerializable(Helper.ARG_STATUS, status);
|
||||
Intent intent = new Intent(context, TimelineActivity.class);
|
||||
intent.putExtras(bundle);
|
||||
context.startActivity(intent);
|
||||
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||
intent.putExtras(bundle);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
} //Classic other cases for remote instances that will search the remote context
|
||||
else if (!(context instanceof ContextActivity)) { //We are not already checking a remote conversation
|
||||
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
||||
|
@ -2026,8 +2053,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
||||
Status fetchedStatus = results.statuses.get(0);
|
||||
Intent intent = new Intent(context, ContextActivity.class);
|
||||
intent.putExtra(Helper.ARG_STATUS, fetchedStatus);
|
||||
context.startActivity(intent);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, fetchedStatus);
|
||||
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();
|
||||
}
|
||||
|
@ -2047,8 +2080,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
}
|
||||
} else {
|
||||
Intent intent = new Intent(context, ContextActivity.class);
|
||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
||||
context.startActivity(intent);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||
intent.putExtras(bundle);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -2262,8 +2301,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
return true;
|
||||
} else if (itemId == R.id.action_report) {
|
||||
Intent intent = new Intent(context, ReportActivity.class);
|
||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
||||
context.startActivity(intent);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||
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 if (itemId == R.id.action_copy) {
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
String content;
|
||||
|
@ -2317,8 +2362,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
|
||||
} else if (itemId == R.id.action_custom_sharing) {
|
||||
Intent intent = new Intent(context, CustomSharingActivity.class);
|
||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
||||
context.startActivity(intent);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||
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 if (itemId == R.id.action_mention) {
|
||||
Intent intent = new Intent(context, ComposeActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
|
@ -3183,8 +3234,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
});
|
||||
holder.bindingArt.bottomBanner.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, ContextActivity.class);
|
||||
intent.putExtra(Helper.ARG_STATUS, status);
|
||||
context.startActivity(intent);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, 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);
|
||||
});
|
||||
});
|
||||
} else if (viewHolder.getItemViewType() == STATUS_PIXELFED) {
|
||||
Status statusToDeal = status.reblog != null ? status.reblog : status;
|
||||
|
@ -3223,8 +3280,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
});
|
||||
holder.bindingPixelfed.bottomBanner.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, ContextActivity.class);
|
||||
intent.putExtra(Helper.ARG_STATUS, statusToDeal);
|
||||
context.startActivity(intent);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_STATUS, statusToDeal);
|
||||
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||
intent.putExtras(bundle);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ package app.fedilab.android.mastodon.ui.fragment.timeline;
|
|||
* 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 static app.fedilab.android.mastodon.activities.ContextActivity.displayCW;
|
||||
import static app.fedilab.android.mastodon.activities.ContextActivity.expand;
|
||||
|
||||
|
@ -42,6 +43,7 @@ import app.fedilab.android.databinding.FragmentPaginationBinding;
|
|||
import app.fedilab.android.mastodon.activities.ContextActivity;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Context;
|
||||
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.Timeline;
|
||||
import app.fedilab.android.mastodon.helper.DividerDecoration;
|
||||
import app.fedilab.android.mastodon.helper.Helper;
|
||||
|
@ -158,10 +160,21 @@ public class FragmentMastodonContext extends Fragment {
|
|||
pullToRefresh = false;
|
||||
focusedStatusURI = null;
|
||||
refresh = true;
|
||||
binding = FragmentPaginationBinding.inflate(inflater, container, false);
|
||||
if (getArguments() != null) {
|
||||
focusedStatus = (Status) getArguments().getSerializable(Helper.ARG_STATUS);
|
||||
remote_instance = getArguments().getString(Helper.ARG_REMOTE_INSTANCE, null);
|
||||
focusedStatusURI = getArguments().getString(Helper.ARG_FOCUSED_STATUS_URI, null);
|
||||
long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1);
|
||||
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||
} else {
|
||||
initializeAfterBundle(null);
|
||||
}
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
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 (remote_instance != null) {
|
||||
user_instance = remote_instance;
|
||||
|
@ -174,7 +187,7 @@ public class FragmentMastodonContext extends Fragment {
|
|||
getChildFragmentManager().beginTransaction().remove(this).commit();
|
||||
}
|
||||
|
||||
binding = FragmentPaginationBinding.inflate(inflater, container, false);
|
||||
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
boolean displayScrollBar = sharedpreferences.getBoolean(getString(R.string.SET_TIMELINE_SCROLLBAR), false);
|
||||
binding.recyclerView.setVerticalScrollBarEnabled(displayScrollBar);
|
||||
|
@ -202,9 +215,9 @@ public class FragmentMastodonContext extends Fragment {
|
|||
}
|
||||
|
||||
ContextCompat.registerReceiver(requireActivity(), receive_action, new IntentFilter(Helper.RECEIVE_STATUS_ACTION), ContextCompat.RECEIVER_NOT_EXPORTED);
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
public void refresh() {
|
||||
if (statuses != null) {
|
||||
for (Status status : statuses) {
|
||||
|
|
|
@ -82,6 +82,7 @@ import app.fedilab.android.mastodon.client.entities.api.Context;
|
|||
import app.fedilab.android.mastodon.client.entities.api.Mention;
|
||||
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.app.CachedBundle;
|
||||
import app.fedilab.android.mastodon.client.entities.app.StatusDraft;
|
||||
import app.fedilab.android.mastodon.exception.DBException;
|
||||
import app.fedilab.android.mastodon.helper.Helper;
|
||||
|
@ -131,8 +132,21 @@ public class FragmentMastodonDirectMessage extends Fragment {
|
|||
|
||||
focusedStatus = null;
|
||||
pullToRefresh = false;
|
||||
binding = FragmentDirectMessageBinding.inflate(inflater, container, false);
|
||||
if (getArguments() != null) {
|
||||
focusedStatus = (Status) getArguments().getSerializable(Helper.ARG_STATUS);
|
||||
long bundleId = getArguments().getLong(Helper.ARG_INTENT_ID, -1);
|
||||
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, this::initializeAfterBundle);
|
||||
} else {
|
||||
initializeAfterBundle(null);
|
||||
}
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
private void initializeAfterBundle(Bundle bundle) {
|
||||
|
||||
if (bundle != null) {
|
||||
focusedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS);
|
||||
}
|
||||
user_instance = MainActivity.currentInstance;
|
||||
user_token = MainActivity.currentToken;
|
||||
|
@ -140,7 +154,7 @@ public class FragmentMastodonDirectMessage extends Fragment {
|
|||
if (focusedStatus == null) {
|
||||
getChildFragmentManager().beginTransaction().remove(this).commit();
|
||||
}
|
||||
binding = FragmentDirectMessageBinding.inflate(inflater, container, false);
|
||||
|
||||
statusesVM = new ViewModelProvider(FragmentMastodonDirectMessage.this).get(StatusesVM.class);
|
||||
binding.recyclerView.setNestedScrollingEnabled(true);
|
||||
this.statuses = new ArrayList<>();
|
||||
|
@ -216,10 +230,8 @@ public class FragmentMastodonDirectMessage extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
private void onSubmit(StatusDraft statusDraft) {
|
||||
new Thread(() -> {
|
||||
if (statusDraft.instance == null) {
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.json.JSONObject;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.IDN;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
|
|
Loading…
Reference in a new issue