Broadcast

This commit is contained in:
Thomas 2024-01-11 17:05:35 +01:00
parent b052547cc4
commit 09a8b6c43c
19 changed files with 659 additions and 451 deletions

View file

@ -79,6 +79,7 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.ViewModelProvider;
import androidx.multidex.BuildConfig;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
@ -220,11 +221,13 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
private final BroadcastReceiver broadcast_error_message = new BroadcastReceiver() {
@Override
public void onReceive(android.content.Context context, Intent intent) {
Bundle b = intent.getExtras();
if (b != null) {
if (b.getBoolean(Helper.RECEIVE_COMPOSE_ERROR_MESSAGE, false)) {
String errorMessage = b.getString(Helper.RECEIVE_ERROR_MESSAGE);
StatusDraft statusDraft = (StatusDraft) b.getSerializable(Helper.ARG_STATUS_DRAFT);
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(BaseMainActivity.this).getBundle(bundleId, currentAccount, bundle -> {
if (bundle.getBoolean(Helper.RECEIVE_COMPOSE_ERROR_MESSAGE, false)) {
String errorMessage = bundle.getString(Helper.RECEIVE_ERROR_MESSAGE);
StatusDraft statusDraft = (StatusDraft) bundle.getSerializable(Helper.ARG_STATUS_DRAFT);
Snackbar snackbar = Snackbar.make(binding.getRoot(), errorMessage, 5000);
View snackbarView = snackbar.getView();
TextView textView = snackbarView.findViewById(com.google.android.material.R.id.snackbar_text);
@ -232,12 +235,20 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
snackbar
.setAction(getString(R.string.open_draft), view -> {
Intent intentCompose = new Intent(context, ComposeActivity.class);
intentCompose.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
Bundle args2 = new Bundle();
args2.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
new CachedBundle(BaseMainActivity.this).insertBundle(args2, currentAccount, bundleId2 -> {
Bundle bundle2 = new Bundle();
bundle2.putLong(Helper.ARG_INTENT_ID, bundleId2);
intentCompose.putExtras(bundle2);
intentCompose.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intentCompose);
});
})
.show();
}
});
}
}
};
@ -246,13 +257,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
private final BroadcastReceiver broadcast_data = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Bundle b = intent.getExtras();
if (b != null) {
if (b.getBoolean(Helper.RECEIVE_REDRAW_TOPBAR, false)) {
List<MastodonList> mastodonLists = (List<MastodonList>) b.getSerializable(Helper.RECEIVE_MASTODON_LIST);
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(BaseMainActivity.this).getBundle(bundleId, currentAccount, bundle -> {
if (bundle.getBoolean(Helper.RECEIVE_REDRAW_TOPBAR, false)) {
List<MastodonList> mastodonLists = (List<MastodonList>) bundle.getSerializable(Helper.RECEIVE_MASTODON_LIST);
redrawPinned(mastodonLists);
}
if (b.getBoolean(Helper.RECEIVE_REDRAW_BOTTOM, false)) {
if (bundle.getBoolean(Helper.RECEIVE_REDRAW_BOTTOM, false)) {
bottomMenu = new BottomMenu(BaseMainActivity.this).hydrate(currentAccount, binding.bottomNavView);
if (bottomMenu != null) {
//ManageClick on bottom menu items
@ -296,20 +309,20 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
return true;
});
}
} else if (b.getBoolean(Helper.RECEIVE_RECREATE_ACTIVITY, false)) {
} else if (bundle.getBoolean(Helper.RECEIVE_RECREATE_ACTIVITY, false)) {
recreate();
} else if (b.getBoolean(Helper.RECEIVE_NEW_MESSAGE, false)) {
Status statusSent = (Status) b.getSerializable(Helper.RECEIVE_STATUS_ACTION);
String statusEditId = b.getString(Helper.ARG_EDIT_STATUS_ID, null);
} else if (bundle.getBoolean(Helper.RECEIVE_NEW_MESSAGE, false)) {
Status statusSent = (Status) bundle.getSerializable(Helper.RECEIVE_STATUS_ACTION);
String statusEditId = bundle.getString(Helper.ARG_EDIT_STATUS_ID, null);
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);
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);
Bundle args2 = new Bundle();
args2.putSerializable(Helper.ARG_STATUS, statusSent);
new CachedBundle(BaseMainActivity.this).insertBundle(args2, currentAccount, bundleId2 -> {
Bundle bundle2 = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId2);
intentContext.putExtras(bundle2);
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentContext);
});
@ -334,6 +347,8 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
sendAction(context, Helper.ARG_STATUS_UPDATED, statusSent, null);
}
}
});
}
}
};
@ -707,12 +722,17 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
}
viewPager.setCurrentItem(position);
}
Bundle b = new Bundle();
b.putBoolean(ARG_REFRESH_NOTFICATION, true);
Bundle args = new Bundle();
args.putBoolean(ARG_REFRESH_NOTFICATION, true);
Intent intentBC = new Intent(Helper.RECEIVE_STATUS_ACTION);
intentBC.setPackage(BuildConfig.APPLICATION_ID);
intentBC.putExtras(b);
new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBC.putExtras(bundle);
activity.sendBroadcast(intentBC);
});
}
}, 1000);
intent.removeExtra(Helper.INTENT_ACTION);

View file

@ -120,9 +120,13 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
private final BroadcastReceiver imageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(android.content.Context context, Intent intent) {
String imgpath = intent.getStringExtra("imgpath");
float focusX = intent.getFloatExtra("focusX", -2);
float focusY = intent.getFloatExtra("focusY", -2);
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(ComposeActivity.this).getBundle(bundleId, currentAccount, bundle -> {
String imgpath = bundle.getString("imgpath");
float focusX = bundle.getFloat("focusX", -2);
float focusY = bundle.getFloat("focusY", -2);
if (imgpath != null) {
int position = 0;
for (Status status : statusList) {
@ -132,7 +136,6 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
if (focusX != -2) {
attachment.focus = focusX + "," + focusY;
}
composeAdapter.notifyItemChanged(position);
break;
}
@ -141,6 +144,8 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
position++;
}
}
});
}
}
};
private boolean promptSaveDraft;

View file

@ -41,6 +41,7 @@ import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.databinding.ActivityHashtagBinding;
import app.fedilab.android.mastodon.client.entities.api.Filter;
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.Pinned;
import app.fedilab.android.mastodon.client.entities.app.PinnedTimeline;
import app.fedilab.android.mastodon.client.entities.app.StatusDraft;
@ -158,11 +159,15 @@ public class HashTagActivity extends BaseActivity {
List<Status> statuses = new ArrayList<>();
statuses.add(status);
statusDraft.statusDraftList = statuses;
Bundle _b = new Bundle();
_b.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
intentToot.putExtras(_b);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
new CachedBundle(HashTagActivity.this).insertBundle(args, currentAccount, bundleId -> {
Bundle bundleCached = new Bundle();
bundleCached.putLong(Helper.ARG_INTENT_ID, bundleId);
intentToot.putExtras(bundleCached);
startActivity(intentToot);
});
});
}
@Override
@ -188,14 +193,19 @@ public class HashTagActivity extends BaseActivity {
}
pinnedTag = false;
invalidateOptionsMenu();
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
intentBD.putExtras(b);
new CachedBundle(HashTagActivity.this).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intentBD);
dialog.dismiss();
});
});
unpinConfirm.show();
} else {
new Thread(() -> {
@ -243,12 +253,16 @@ public class HashTagActivity extends BaseActivity {
} else {
new Pinned(HashTagActivity.this).insertPinned(pinned);
}
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
intentBD.putExtras(b);
new CachedBundle(HashTagActivity.this).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intentBD);
});
pinnedTag = true;
invalidateOptionsMenu();
} catch (DBException e) {

View file

@ -15,6 +15,8 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
@ -45,12 +47,12 @@ import java.util.Objects;
import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.BuildConfig;
import app.fedilab.android.R;
import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.databinding.ActivityListBinding;
import app.fedilab.android.databinding.PopupAddListBinding;
import app.fedilab.android.databinding.PopupManageAccountsListBinding;
import app.fedilab.android.mastodon.client.entities.api.Account;
import app.fedilab.android.mastodon.client.entities.api.MastodonList;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.client.entities.app.Pinned;
import app.fedilab.android.mastodon.client.entities.app.PinnedTimeline;
import app.fedilab.android.mastodon.client.entities.app.Timeline;
@ -175,7 +177,7 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis
timelinesVM.getAccountsInList(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, mastodonList.id, null, null, 0)
.observe(MastodonListActivity.this, accounts -> {
if (accounts != null && accounts.size() > 0) {
accountsVM.muteAccountsHome(MainActivity.currentAccount, accounts);
accountsVM.muteAccountsHome(currentAccount, accounts);
}
});
dialog.dismiss();
@ -307,14 +309,18 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis
} else {
binding.notContent.setVisibility(View.GONE);
}
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
b.putSerializable(Helper.RECEIVE_MASTODON_LIST, mastodonListList);
intentBD.putExtras(b);
args.putSerializable(Helper.RECEIVE_MASTODON_LIST, mastodonListList);
new CachedBundle(MastodonListActivity.this).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intentBD);
});
});
alt_bld.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
AlertDialog alert = alt_bld.create();
alert.show();
@ -343,14 +349,18 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis
} else {
Toasty.error(MastodonListActivity.this, getString(R.string.toast_error), Toasty.LENGTH_LONG).show();
}
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
b.putSerializable(Helper.RECEIVE_MASTODON_LIST, mastodonListList);
intentBD.putExtras(b);
args.putSerializable(Helper.RECEIVE_MASTODON_LIST, mastodonListList);
new CachedBundle(MastodonListActivity.this).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intentBD);
});
});
dialog.dismiss();
} else {
popupAddListBinding.addList.setError(getString(R.string.not_valid_list_name));
@ -392,12 +402,16 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis
new Thread(() -> {
try {
new Pinned(MastodonListActivity.this).updatePinned(pinned);
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
intentBD.putExtras(b);
new CachedBundle(MastodonListActivity.this).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intentBD);
});
} catch (
DBException e) {
e.printStackTrace();

View file

@ -84,10 +84,10 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
private final BroadcastReceiver onDownloadComplete = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
long id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
if (downloadID == id) {
DownloadManager manager = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE);
assert manager != null;
Uri uri = manager.getUriForDownloadedFile(downloadID);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);

View file

@ -135,7 +135,6 @@ public class ProfileActivity extends BaseActivity {
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
if (bundleId != -1) {
new CachedBundle(ProfileActivity.this).getBundle(bundleId, currentAccount, bundle -> {
Account accountReceived = (Account) bundle.getSerializable(Helper.ARG_ACCOUNT);
if (bundle.getBoolean(Helper.RECEIVE_REDRAW_PROFILE, false) && accountReceived != null) {
@ -144,14 +143,6 @@ public class ProfileActivity extends BaseActivity {
}
}
});
} else {
Account accountReceived = (Account) args.getSerializable(Helper.ARG_ACCOUNT);
if (args.getBoolean(Helper.RECEIVE_REDRAW_PROFILE, false) && accountReceived != null) {
if (account != null && accountReceived.id != null && account.id != null && accountReceived.id.equalsIgnoreCase(account.id)) {
initializeView(accountReceived);
}
}
}
}
}
};
@ -926,13 +917,17 @@ public class ProfileActivity extends BaseActivity {
new Pinned(ProfileActivity.this).insertPinned(finalPinned);
}
runOnUiThread(() -> {
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
intentBD.putExtras(b);
new CachedBundle(ProfileActivity.this).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intentBD);
});
});
} catch (DBException e) {
e.printStackTrace();
}

View file

@ -15,6 +15,8 @@ package app.fedilab.android.mastodon.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
@ -48,6 +50,7 @@ import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.databinding.ActivityReorderTabsBinding;
import app.fedilab.android.databinding.PopupSearchInstanceBinding;
import app.fedilab.android.mastodon.client.entities.app.BottomMenu;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.client.entities.app.InstanceSocial;
import app.fedilab.android.mastodon.client.entities.app.Pinned;
import app.fedilab.android.mastodon.client.entities.app.PinnedTimeline;
@ -284,13 +287,17 @@ public class ReorderTimelinesActivity extends BaseBarActivity implements OnStart
}
}
reorderTabAdapter.notifyItemInserted(pinned.pinnedTimelines.size());
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
intentBD.putExtras(b);
new CachedBundle(ReorderTimelinesActivity.this).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intentBD);
});
});
} else {
runOnUiThread(() -> Toasty.warning(ReorderTimelinesActivity.this, getString(R.string.toast_instance_unavailable), Toast.LENGTH_LONG).show());
}
@ -373,20 +380,29 @@ public class ReorderTimelinesActivity extends BaseBarActivity implements OnStart
super.onPause();
if (changes) {
//Update menu
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
intentBD.putExtras(b);
new CachedBundle(ReorderTimelinesActivity.this).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intentBD);
});
}
if (bottomChanges) {
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_REDRAW_BOTTOM, true);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_REDRAW_BOTTOM, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
intentBD.putExtras(b);
new CachedBundle(ReorderTimelinesActivity.this).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intentBD);
});
}
}

View file

@ -14,6 +14,7 @@ package app.fedilab.android.mastodon.activities.admin;
* 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.admin.AdminActionActivity.AdminEnum.ACCOUNT;
import static app.fedilab.android.mastodon.activities.admin.AdminActionActivity.AdminEnum.DOMAIN;
import static app.fedilab.android.mastodon.activities.admin.AdminActionActivity.AdminEnum.REPORT;
@ -43,6 +44,7 @@ import app.fedilab.android.databinding.PopupAdminFilterAccountsBinding;
import app.fedilab.android.databinding.PopupAdminFilterReportsBinding;
import app.fedilab.android.mastodon.activities.BaseBarActivity;
import app.fedilab.android.mastodon.client.entities.api.admin.AdminDomainBlock;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.ThemeHelper;
import app.fedilab.android.mastodon.ui.fragment.admin.FragmentAdminAccount;
@ -63,19 +65,22 @@ public class AdminActionActivity extends BaseBarActivity {
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Bundle b = intent.getExtras();
if (b != null) {
AdminDomainBlock adminDomainBlock = (AdminDomainBlock) b.getSerializable(Helper.ARG_ADMIN_DOMAINBLOCK);
AdminDomainBlock adminDomainBlockDelete = (AdminDomainBlock) b.getSerializable(Helper.ARG_ADMIN_DOMAINBLOCK_DELETE);
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(AdminActionActivity.this).getBundle(bundleId, currentAccount, bundle -> {
AdminDomainBlock adminDomainBlock = (AdminDomainBlock) bundle.getSerializable(Helper.ARG_ADMIN_DOMAINBLOCK);
AdminDomainBlock adminDomainBlockDelete = (AdminDomainBlock) bundle.getSerializable(Helper.ARG_ADMIN_DOMAINBLOCK_DELETE);
if (adminDomainBlock != null && adminDomainBlock.domain != null && fragmentAdminDomain != null) {
fragmentAdminDomain.update(adminDomainBlock);
}
if (adminDomainBlockDelete != null && fragmentAdminDomain != null) {
fragmentAdminDomain.delete(adminDomainBlockDelete);
}
}
});
}
}
};
@Override

View file

@ -15,6 +15,8 @@ package app.fedilab.android.mastodon.activities.admin;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
@ -37,6 +39,7 @@ import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.databinding.ActivityAdminDomainblockBinding;
import app.fedilab.android.mastodon.activities.BaseBarActivity;
import app.fedilab.android.mastodon.client.entities.api.admin.AdminDomainBlock;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.viewmodel.mastodon.AdminVM;
import es.dmoral.toasty.Toasty;
@ -109,10 +112,17 @@ public class AdminDomainBlockActivity extends BaseBarActivity {
} else {
Toasty.error(AdminDomainBlockActivity.this, getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
}
Intent intent = new Intent(Helper.BROADCAST_DATA).putExtra(Helper.ARG_ADMIN_DOMAINBLOCK, adminDomainBlockResult);
Intent intent = new Intent(Helper.BROADCAST_DATA);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ADMIN_DOMAINBLOCK, adminDomainBlockResult);
new CachedBundle(AdminDomainBlockActivity.this).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
intent.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intent);
finish();
});
}
);
});
@ -138,10 +148,18 @@ public class AdminDomainBlockActivity extends BaseBarActivity {
.setPositiveButton(R.string.unblock_domain, (dialog, which) -> {
adminVM.deleteDomain(MainActivity.currentInstance, MainActivity.currentToken, adminDomainBlock.id)
.observe(AdminDomainBlockActivity.this, adminDomainBlockResult -> {
Intent intent = new Intent(Helper.BROADCAST_DATA).putExtra(Helper.ARG_ADMIN_DOMAINBLOCK_DELETE, adminDomainBlock);
Intent intent = new Intent(Helper.BROADCAST_DATA);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ADMIN_DOMAINBLOCK_DELETE, adminDomainBlock);
new CachedBundle(AdminDomainBlockActivity.this).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
intent.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intent);
finish();
});
}
);
dialog.dismiss();

View file

@ -872,13 +872,17 @@ public class Helper {
*/
public static void sendToastMessage(Context context, String type, String content) {
Intent intentBC = new Intent(context, ToastMessage.class);
Bundle b = new Bundle();
b.putString(RECEIVE_TOAST_TYPE, type);
b.putString(RECEIVE_TOAST_CONTENT, content);
Bundle args = new Bundle();
args.putString(RECEIVE_TOAST_TYPE, type);
args.putString(RECEIVE_TOAST_CONTENT, content);
intentBC.setAction(Helper.RECEIVE_TOAST_MESSAGE);
intentBC.putExtras(b);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBC.putExtras(bundle);
intentBC.setPackage(BuildConfig.APPLICATION_ID);
context.sendBroadcast(intentBC);
});
}
/**
@ -1514,12 +1518,16 @@ public class Helper {
* @param activity - Activity
*/
public static void recreateMainActivity(Activity activity) {
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_RECREATE_ACTIVITY, true);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_RECREATE_ACTIVITY, true);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
intentBD.putExtras(b);
new CachedBundle(activity).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
activity.sendBroadcast(intentBD);
});
}
public static void showKeyboard(Context context, View view) {

View file

@ -1,6 +1,8 @@
package app.fedilab.android.mastodon.imageeditor;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
@ -41,6 +43,7 @@ import java.io.InputStream;
import app.fedilab.android.BuildConfig;
import app.fedilab.android.R;
import app.fedilab.android.databinding.ActivityEditImageBinding;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.helper.CirclesDrawingView;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.imageeditor.base.BaseActivity;
@ -283,7 +286,8 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList
binding.photoEditorView.getSource().setImageURI(Uri.fromFile(new File(imagePath)));
if (exit) {
Intent intentImage = new Intent(Helper.INTENT_SEND_MODIFIED_IMAGE);
intentImage.putExtra("imgpath", imagePath);
Bundle args = new Bundle();
args.putString("imgpath", imagePath);
CirclesDrawingView.CircleArea circleArea = binding.focusCircle.getTouchedCircle();
if (circleArea != null) {
//Dimension of the editor containing the image
@ -323,13 +327,16 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList
} else if (focusY < -1) {
focusY = -1;
}
intentImage.putExtra("focusX", focusX);
intentImage.putExtra("focusY", focusY);
args.putFloat("focusX", focusX);
args.putFloat("focusY", focusY);
}
new CachedBundle(EditImageActivity.this).insertBundle(args, currentAccount, bundleId -> {
intentImage.putExtras(args);
intentImage.setPackage(BuildConfig.APPLICATION_ID);
sendBroadcast(intentImage);
finish();
});
}
}

View file

@ -60,6 +60,7 @@ import app.fedilab.android.mastodon.client.entities.api.ScheduledStatus;
import app.fedilab.android.mastodon.client.entities.api.Status;
import app.fedilab.android.mastodon.client.entities.app.Account;
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.PostState;
import app.fedilab.android.mastodon.client.entities.app.StatusDraft;
@ -223,14 +224,24 @@ public class ComposeWorker extends Worker {
}
Call<Status> statusCall;
if (error) {
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_COMPOSE_ERROR_MESSAGE, true);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_COMPOSE_ERROR_MESSAGE, true);
Intent intentBD = new Intent(Helper.INTENT_COMPOSE_ERROR_MESSAGE);
b.putSerializable(Helper.RECEIVE_ERROR_MESSAGE, context.getString(R.string.media_cannot_be_uploaded));
b.putSerializable(Helper.ARG_STATUS_DRAFT, dataPost.statusDraft);
intentBD.putExtras(b);
args.putSerializable(Helper.RECEIVE_ERROR_MESSAGE, context.getString(R.string.media_cannot_be_uploaded));
args.putSerializable(Helper.ARG_STATUS_DRAFT, dataPost.statusDraft);
BaseAccount account = null;
try {
account = new Account(context).getAccountByToken(dataPost.token);
} catch (DBException e) {
e.printStackTrace();
}
new CachedBundle(context).insertBundle(args, account, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
context.sendBroadcast(intentBD);
});
return;
}
if (statuses.get(i).local_only) {
@ -304,30 +315,51 @@ public class ComposeWorker extends Worker {
}
}
} else if (statusResponse.errorBody() != null) {
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_COMPOSE_ERROR_MESSAGE, true);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_COMPOSE_ERROR_MESSAGE, true);
Intent intentBD = new Intent(Helper.INTENT_COMPOSE_ERROR_MESSAGE);
b.putSerializable(Helper.ARG_STATUS_DRAFT, dataPost.statusDraft);
args.putSerializable(Helper.ARG_STATUS_DRAFT, dataPost.statusDraft);
String err = statusResponse.errorBody().string();
if (err.contains("{\"error\":\"")) {
err = err.replaceAll("\\{\"error\":\"(.*)\"\\}", "$1");
}
b.putSerializable(Helper.RECEIVE_ERROR_MESSAGE, err);
intentBD.putExtras(b);
args.putSerializable(Helper.RECEIVE_ERROR_MESSAGE, err);
BaseAccount account = null;
try {
account = new Account(context).getAccountByToken(dataPost.token);
} catch (DBException e) {
e.printStackTrace();
}
new CachedBundle(context).insertBundle(args, account, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
context.sendBroadcast(intentBD);
});
return;
}
} catch (IOException e) {
e.printStackTrace();
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_COMPOSE_ERROR_MESSAGE, true);
b.putSerializable(Helper.ARG_STATUS_DRAFT, dataPost.statusDraft);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_COMPOSE_ERROR_MESSAGE, true);
args.putSerializable(Helper.ARG_STATUS_DRAFT, dataPost.statusDraft);
Intent intentBD = new Intent(Helper.INTENT_COMPOSE_ERROR_MESSAGE);
b.putSerializable(Helper.RECEIVE_ERROR_MESSAGE, e.getMessage());
intentBD.putExtras(b);
args.putSerializable(Helper.RECEIVE_ERROR_MESSAGE, e.getMessage());
BaseAccount account = null;
try {
account = new Account(context).getAccountByToken(dataPost.token);
} catch (DBException e2) {
e2.printStackTrace();
}
new CachedBundle(context).insertBundle(args, account, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
context.sendBroadcast(intentBD);
});
return;
}
} else {
@ -375,14 +407,24 @@ public class ComposeWorker extends Worker {
}
if (dataPost.scheduledDate == null && dataPost.token != null && firstSendMessage != null) {
Bundle b = new Bundle();
b.putBoolean(Helper.RECEIVE_NEW_MESSAGE, true);
b.putString(Helper.ARG_EDIT_STATUS_ID, dataPost.statusEditId);
Bundle args = new Bundle();
args.putBoolean(Helper.RECEIVE_NEW_MESSAGE, true);
args.putString(Helper.ARG_EDIT_STATUS_ID, dataPost.statusEditId);
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
b.putSerializable(Helper.RECEIVE_STATUS_ACTION, firstSendMessage);
intentBD.putExtras(b);
args.putSerializable(Helper.RECEIVE_STATUS_ACTION, firstSendMessage);
BaseAccount account = null;
try {
account = new Account(context).getAccountByToken(dataPost.token);
} catch (DBException e2) {
e2.printStackTrace();
}
new CachedBundle(context).insertBundle(args, account, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBD.putExtras(bundle);
intentBD.setPackage(BuildConfig.APPLICATION_ID);
context.sendBroadcast(intentBD);
});
}
}

View file

@ -2171,9 +2171,15 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
statusDeleted.id = null;
statusDraft.statusDraftList.add(statusDeleted);
intent.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
intent.putExtra(Helper.ARG_STATUS_REPLY_ID, statusDeleted.in_reply_to_id);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
args.putSerializable(Helper.ARG_STATUS_REPLY_ID, statusDeleted.in_reply_to_id);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intent.putExtras(bundle);
context.startActivity(intent);
});
sendAction(context, Helper.ARG_STATUS_DELETED, statusToDeal, null);
});
}
@ -2194,10 +2200,16 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
statusToDeal.spoilerChecked = true;
}
statusDraft.statusDraftList.add(statusToDeal);
intent.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
intent.putExtra(Helper.ARG_EDIT_STATUS_ID, statusToDeal.id);
intent.putExtra(Helper.ARG_STATUS_REPLY_ID, statusToDeal.in_reply_to_id);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
args.putString(Helper.ARG_EDIT_STATUS_ID, statusToDeal.id);
args.putString(Helper.ARG_STATUS_REPLY_ID, statusToDeal.in_reply_to_id);
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.error(context, context.getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
}
@ -2372,10 +2384,14 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
});
} else if (itemId == R.id.action_mention) {
Intent intent = new Intent(context, ComposeActivity.class);
Bundle b = new Bundle();
b.putSerializable(Helper.ARG_STATUS_MENTION, statusToDeal);
intent.putExtras(b);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_MENTION, 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_open_with) {
new Thread(() -> {
try {
@ -2475,19 +2491,31 @@ 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, ComposeActivity.class);
intent.putExtra(Helper.ARG_STATUS_REPLY, fetchedStatus);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_REPLY, 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();
}
});
} else {
Intent intent = new Intent(context, ComposeActivity.class);
intent.putExtra(Helper.ARG_STATUS_REPLY, statusToDeal);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_REPLY, statusToDeal);
if (status.reblog != null) {
intent.putExtra(Helper.ARG_MENTION_BOOSTER, status.account);
args.putSerializable(Helper.ARG_MENTION_BOOSTER, status.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);
});
}
});
//For reports
@ -2811,20 +2839,24 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
* @param id - Id of an account (can be null)
*/
public static void sendAction(@NonNull Context context, @NonNull String type, @Nullable Status status, @Nullable String id) {
Bundle b = new Bundle();
Bundle args = new Bundle();
if (status != null) {
b.putSerializable(type, status);
args.putSerializable(type, status);
}
if (id != null) {
b.putString(type, id);
args.putString(type, id);
}
if (type.equals(ARG_TIMELINE_REFRESH_ALL)) {
b.putBoolean(ARG_TIMELINE_REFRESH_ALL, true);
args.putBoolean(ARG_TIMELINE_REFRESH_ALL, true);
}
Intent intentBC = new Intent(Helper.RECEIVE_STATUS_ACTION);
intentBC.putExtras(b);
new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
Bundle bundle = new Bundle();
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
intentBC.putExtras(bundle);
intentBC.setPackage(BuildConfig.APPLICATION_ID);
context.sendBroadcast(intentBC);
});
}

View file

@ -15,9 +15,12 @@ package app.fedilab.android.mastodon.ui.drawer;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -39,6 +42,7 @@ import app.fedilab.android.databinding.DrawerStatusDraftBinding;
import app.fedilab.android.mastodon.activities.ComposeActivity;
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.client.entities.app.StatusDraft;
import app.fedilab.android.mastodon.exception.DBException;
import app.fedilab.android.mastodon.helper.Helper;
@ -100,10 +104,15 @@ public class StatusDraftAdapter extends RecyclerView.Adapter<StatusDraftAdapter.
holder.binding.cardviewContainer.setOnClickListener(v -> {
Intent intent = new Intent(context, ComposeActivity.class);
intent.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
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.delete.setOnClickListener(v -> {
AlertDialog.Builder unfollowConfirm = new MaterialAlertDialogBuilder(context);

View file

@ -16,10 +16,12 @@ package app.fedilab.android.mastodon.ui.drawer;
import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY;
import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.text.SpannableString;
import android.view.LayoutInflater;
@ -44,6 +46,7 @@ import app.fedilab.android.R;
import app.fedilab.android.databinding.DrawerStatusScheduledBinding;
import app.fedilab.android.mastodon.activities.ComposeActivity;
import app.fedilab.android.mastodon.client.entities.api.ScheduledStatus;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.client.entities.app.ScheduledBoost;
import app.fedilab.android.mastodon.client.entities.app.StatusDraft;
import app.fedilab.android.mastodon.exception.DBException;
@ -126,10 +129,15 @@ public class StatusScheduledAdapter extends RecyclerView.Adapter<StatusScheduled
holder.binding.cardviewContainer.setOnClickListener(v -> {
if (statusDraft != null) {
Intent intent = new Intent(context, ComposeActivity.class);
intent.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
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.delete.setOnClickListener(v -> {
AlertDialog.Builder unfollowConfirm = new MaterialAlertDialogBuilder(context);

View file

@ -63,13 +63,15 @@ public class FragmentMastodonContext extends Fragment {
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
@Override
public void onReceive(android.content.Context context, Intent intent) {
Bundle b = intent.getExtras();
if (b != null) {
Status receivedStatus = (Status) b.getSerializable(Helper.ARG_STATUS_ACTION);
String delete_statuses_for_user = b.getString(Helper.ARG_STATUS_ACCOUNT_ID_DELETED);
Status status_to_delete = (Status) b.getSerializable(Helper.ARG_STATUS_DELETED);
Status statusPosted = (Status) b.getSerializable(Helper.ARG_STATUS_POSTED);
Status status_to_update = (Status) b.getSerializable(Helper.ARG_STATUS_UPDATED);
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, bundle -> {
Status receivedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS_ACTION);
String delete_statuses_for_user = bundle.getString(Helper.ARG_STATUS_ACCOUNT_ID_DELETED);
Status status_to_delete = (Status) bundle.getSerializable(Helper.ARG_STATUS_DELETED);
Status statusPosted = (Status) bundle.getSerializable(Helper.ARG_STATUS_POSTED);
Status status_to_update = (Status) bundle.getSerializable(Helper.ARG_STATUS_UPDATED);
if (receivedStatus != null && statusAdapter != null) {
int position = getPosition(receivedStatus);
if (position >= 0) {
@ -124,6 +126,8 @@ public class FragmentMastodonContext extends Fragment {
}
}
}
});
}
}
};

View file

@ -112,17 +112,19 @@ public class FragmentMastodonDirectMessage extends Fragment {
private final BroadcastReceiver broadcast_data = new BroadcastReceiver() {
@Override
public void onReceive(android.content.Context context, Intent intent) {
Bundle b = intent.getExtras();
if (b != null) {
if (b.getBoolean(Helper.RECEIVE_NEW_MESSAGE, false)) {
Status statusReceived = (Status) b.getSerializable(Helper.RECEIVE_STATUS_ACTION);
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, bundle -> {
if (bundle.getBoolean(Helper.RECEIVE_NEW_MESSAGE, false)) {
Status statusReceived = (Status) bundle.getSerializable(Helper.RECEIVE_STATUS_ACTION);
if (statusReceived != null) {
statuses.add(statusReceived);
statusDirectMessageAdapter.notifyItemInserted(statuses.size() - 1);
initiliazeStatus();
}
}
});
}
}
};

View file

@ -14,6 +14,8 @@ 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 android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@ -47,6 +49,7 @@ import app.fedilab.android.databinding.FragmentPaginationBinding;
import app.fedilab.android.mastodon.client.entities.api.Notification;
import app.fedilab.android.mastodon.client.entities.api.Notifications;
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.client.entities.app.Timeline;
import app.fedilab.android.mastodon.exception.DBException;
@ -71,11 +74,13 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Bundle b = intent.getExtras();
if (b != null) {
Status receivedStatus = (Status) b.getSerializable(Helper.ARG_STATUS_ACTION);
String delete_all_for_account_id = b.getString(Helper.ARG_DELETE_ALL_FOR_ACCOUNT_ID);
boolean refreshNotifications = b.getBoolean(Helper.ARG_REFRESH_NOTFICATION, false);
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, bundle -> {
Status receivedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS_ACTION);
String delete_all_for_account_id = bundle.getString(Helper.ARG_DELETE_ALL_FOR_ACCOUNT_ID);
boolean refreshNotifications = bundle.getBoolean(Helper.ARG_REFRESH_NOTFICATION, false);
if (refreshNotifications) {
scrollToTop();
} else if (receivedStatus != null && notificationAdapter != null) {
@ -108,6 +113,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
}
}
}
});
}
}
};

View file

@ -94,15 +94,17 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Bundle b = intent.getExtras();
if (b != null) {
Status receivedStatus = (Status) b.getSerializable(Helper.ARG_STATUS_ACTION);
String delete_statuses_for_user = b.getString(Helper.ARG_STATUS_ACCOUNT_ID_DELETED);
String delete_all_for_account_id = b.getString(Helper.ARG_DELETE_ALL_FOR_ACCOUNT_ID);
Status status_to_delete = (Status) b.getSerializable(Helper.ARG_STATUS_DELETED);
Status status_to_update = (Status) b.getSerializable(Helper.ARG_STATUS_UPDATED);
Status statusPosted = (Status) b.getSerializable(Helper.ARG_STATUS_DELETED);
boolean refreshAll = b.getBoolean(Helper.ARG_TIMELINE_REFRESH_ALL, false);
Bundle args = intent.getExtras();
if (args != null) {
long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
new CachedBundle(requireActivity()).getBundle(bundleId, currentAccount, bundle -> {
Status receivedStatus = (Status) bundle.getSerializable(Helper.ARG_STATUS_ACTION);
String delete_statuses_for_user = bundle.getString(Helper.ARG_STATUS_ACCOUNT_ID_DELETED);
String delete_all_for_account_id = bundle.getString(Helper.ARG_DELETE_ALL_FOR_ACCOUNT_ID);
Status status_to_delete = (Status) bundle.getSerializable(Helper.ARG_STATUS_DELETED);
Status status_to_update = (Status) bundle.getSerializable(Helper.ARG_STATUS_UPDATED);
Status statusPosted = (Status) bundle.getSerializable(Helper.ARG_STATUS_DELETED);
boolean refreshAll = bundle.getBoolean(Helper.ARG_TIMELINE_REFRESH_ALL, false);
if (receivedStatus != null && statusAdapter != null) {
int position = getPosition(receivedStatus);
if (position >= 0) {
@ -176,6 +178,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
} else if (refreshAll) {
refreshAllAdapters();
}
});
}
}
};