mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 08:40:03 +02:00
Broadcast
This commit is contained in:
parent
b052547cc4
commit
09a8b6c43c
19 changed files with 659 additions and 451 deletions
|
@ -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,24 +221,34 @@ 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);
|
||||
Snackbar snackbar = Snackbar.make(binding.getRoot(), errorMessage, 5000);
|
||||
View snackbarView = snackbar.getView();
|
||||
TextView textView = snackbarView.findViewById(com.google.android.material.R.id.snackbar_text);
|
||||
textView.setMaxLines(5);
|
||||
snackbar
|
||||
.setAction(getString(R.string.open_draft), view -> {
|
||||
Intent intentCompose = new Intent(context, ComposeActivity.class);
|
||||
intentCompose.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
|
||||
intentCompose.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intentCompose);
|
||||
})
|
||||
.show();
|
||||
}
|
||||
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);
|
||||
textView.setMaxLines(5);
|
||||
snackbar
|
||||
.setAction(getString(R.string.open_draft), view -> {
|
||||
Intent intentCompose = new Intent(context, ComposeActivity.class);
|
||||
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,94 +257,98 @@ 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);
|
||||
redrawPinned(mastodonLists);
|
||||
}
|
||||
if (b.getBoolean(Helper.RECEIVE_REDRAW_BOTTOM, false)) {
|
||||
bottomMenu = new BottomMenu(BaseMainActivity.this).hydrate(currentAccount, binding.bottomNavView);
|
||||
if (bottomMenu != null) {
|
||||
//ManageClick on bottom menu items
|
||||
if (binding.bottomNavView.findViewById(R.id.nav_home) != null) {
|
||||
binding.bottomNavView.findViewById(R.id.nav_home).setOnLongClickListener(view -> {
|
||||
int position = BottomMenu.getPosition(bottomMenu, R.id.nav_home);
|
||||
if (position >= 0) {
|
||||
manageFilters(position);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
if (binding.bottomNavView.findViewById(R.id.nav_local) != null) {
|
||||
binding.bottomNavView.findViewById(R.id.nav_local).setOnLongClickListener(view -> {
|
||||
int position = BottomMenu.getPosition(bottomMenu, R.id.nav_local);
|
||||
if (position >= 0) {
|
||||
manageFilters(position);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
if (binding.bottomNavView.findViewById(R.id.nav_public) != null) {
|
||||
binding.bottomNavView.findViewById(R.id.nav_public).setOnLongClickListener(view -> {
|
||||
int position = BottomMenu.getPosition(bottomMenu, R.id.nav_public);
|
||||
if (position >= 0) {
|
||||
manageFilters(position);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
binding.bottomNavView.setOnItemSelectedListener(item -> {
|
||||
int itemId = item.getItemId();
|
||||
int position = BottomMenu.getPosition(bottomMenu, itemId);
|
||||
if (position >= 0) {
|
||||
if (binding.viewPager.getCurrentItem() == position) {
|
||||
scrollToTop();
|
||||
} else {
|
||||
binding.viewPager.setCurrentItem(position, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
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);
|
||||
}
|
||||
} else if (b.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);
|
||||
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);
|
||||
intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intentContext);
|
||||
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
|
||||
if (binding.bottomNavView.findViewById(R.id.nav_home) != null) {
|
||||
binding.bottomNavView.findViewById(R.id.nav_home).setOnLongClickListener(view -> {
|
||||
int position = BottomMenu.getPosition(bottomMenu, R.id.nav_home);
|
||||
if (position >= 0) {
|
||||
manageFilters(position);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
})
|
||||
.show();
|
||||
//The message was edited, we need to update the timeline
|
||||
if (statusEditId != null) {
|
||||
//Update message in cache
|
||||
new Thread(() -> {
|
||||
StatusCache statusCache = new StatusCache();
|
||||
statusCache.instance = BaseMainActivity.currentInstance;
|
||||
statusCache.user_id = BaseMainActivity.currentUserID;
|
||||
statusCache.status = statusSent;
|
||||
statusCache.status_id = statusEditId;
|
||||
try {
|
||||
new StatusCache(BaseMainActivity.this).updateIfExists(statusCache);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
//Update timelines
|
||||
sendAction(context, Helper.ARG_STATUS_UPDATED, statusSent, null);
|
||||
if (binding.bottomNavView.findViewById(R.id.nav_local) != null) {
|
||||
binding.bottomNavView.findViewById(R.id.nav_local).setOnLongClickListener(view -> {
|
||||
int position = BottomMenu.getPosition(bottomMenu, R.id.nav_local);
|
||||
if (position >= 0) {
|
||||
manageFilters(position);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
if (binding.bottomNavView.findViewById(R.id.nav_public) != null) {
|
||||
binding.bottomNavView.findViewById(R.id.nav_public).setOnLongClickListener(view -> {
|
||||
int position = BottomMenu.getPosition(bottomMenu, R.id.nav_public);
|
||||
if (position >= 0) {
|
||||
manageFilters(position);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
binding.bottomNavView.setOnItemSelectedListener(item -> {
|
||||
int itemId = item.getItemId();
|
||||
int position = BottomMenu.getPosition(bottomMenu, itemId);
|
||||
if (position >= 0) {
|
||||
if (binding.viewPager.getCurrentItem() == position) {
|
||||
scrollToTop();
|
||||
} else {
|
||||
binding.viewPager.setCurrentItem(position, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
} else if (bundle.getBoolean(Helper.RECEIVE_RECREATE_ACTIVITY, false)) {
|
||||
recreate();
|
||||
} 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 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);
|
||||
});
|
||||
})
|
||||
.show();
|
||||
//The message was edited, we need to update the timeline
|
||||
if (statusEditId != null) {
|
||||
//Update message in cache
|
||||
new Thread(() -> {
|
||||
StatusCache statusCache = new StatusCache();
|
||||
statusCache.instance = BaseMainActivity.currentInstance;
|
||||
statusCache.user_id = BaseMainActivity.currentUserID;
|
||||
statusCache.status = statusSent;
|
||||
statusCache.status_id = statusEditId;
|
||||
try {
|
||||
new StatusCache(BaseMainActivity.this).updateIfExists(statusCache);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
//Update timelines
|
||||
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);
|
||||
activity.sendBroadcast(intentBC);
|
||||
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);
|
||||
|
|
|
@ -120,26 +120,31 @@ 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);
|
||||
if (imgpath != null) {
|
||||
int position = 0;
|
||||
for (Status status : statusList) {
|
||||
if (status.media_attachments != null && status.media_attachments.size() > 0) {
|
||||
for (Attachment attachment : status.media_attachments) {
|
||||
if (attachment.local_path != null && attachment.local_path.equalsIgnoreCase(imgpath)) {
|
||||
if (focusX != -2) {
|
||||
attachment.focus = focusX + "," + focusY;
|
||||
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) {
|
||||
if (status.media_attachments != null && status.media_attachments.size() > 0) {
|
||||
for (Attachment attachment : status.media_attachments) {
|
||||
if (attachment.local_path != null && attachment.local_path.equalsIgnoreCase(imgpath)) {
|
||||
if (focusX != -2) {
|
||||
attachment.focus = focusX + "," + focusY;
|
||||
}
|
||||
composeAdapter.notifyItemChanged(position);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
composeAdapter.notifyItemChanged(position);
|
||||
break;
|
||||
}
|
||||
position++;
|
||||
}
|
||||
}
|
||||
position++;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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,10 +159,14 @@ 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);
|
||||
startActivity(intentToot);
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -188,13 +193,18 @@ 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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intentBD);
|
||||
dialog.dismiss();
|
||||
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 {
|
||||
|
@ -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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intentBD);
|
||||
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) {
|
||||
|
|
|
@ -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,13 +309,17 @@ 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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intentBD);
|
||||
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();
|
||||
|
@ -343,13 +349,17 @@ 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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intentBD);
|
||||
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 {
|
||||
|
@ -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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intentBD);
|
||||
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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -135,23 +135,14 @@ 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) {
|
||||
if (account != null && accountReceived.id != null && account.id != null && accountReceived.id.equalsIgnoreCase(account.id)) {
|
||||
initializeView(accountReceived);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Account accountReceived = (Account) args.getSerializable(Helper.ARG_ACCOUNT);
|
||||
if (args.getBoolean(Helper.RECEIVE_REDRAW_PROFILE, false) && accountReceived != null) {
|
||||
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) {
|
||||
if (account != null && accountReceived.id != null && account.id != null && accountReceived.id.equalsIgnoreCase(account.id)) {
|
||||
initializeView(accountReceived);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -926,12 +917,16 @@ 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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intentBD);
|
||||
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();
|
||||
|
|
|
@ -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,12 +287,16 @@ 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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intentBD);
|
||||
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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intentBD);
|
||||
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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intentBD);
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,18 +65,21 @@ 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);
|
||||
if (adminDomainBlock != null && adminDomainBlock.domain != null && fragmentAdminDomain != null) {
|
||||
fragmentAdminDomain.update(adminDomainBlock);
|
||||
}
|
||||
if (adminDomainBlockDelete != null && fragmentAdminDomain != null) {
|
||||
fragmentAdminDomain.delete(adminDomainBlockDelete);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intent);
|
||||
finish();
|
||||
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.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intent);
|
||||
finish();
|
||||
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();
|
||||
|
|
|
@ -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);
|
||||
intentBC.setPackage(BuildConfig.APPLICATION_ID);
|
||||
context.sendBroadcast(intentBC);
|
||||
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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
activity.sendBroadcast(intentBD);
|
||||
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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
intentImage.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intentImage);
|
||||
finish();
|
||||
new CachedBundle(EditImageActivity.this).insertBundle(args, currentAccount, bundleId -> {
|
||||
intentImage.putExtras(args);
|
||||
intentImage.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intentImage);
|
||||
finish();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
context.sendBroadcast(intentBD);
|
||||
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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
context.sendBroadcast(intentBD);
|
||||
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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
context.sendBroadcast(intentBD);
|
||||
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);
|
||||
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
||||
context.sendBroadcast(intentBD);
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
context.startActivity(intent);
|
||||
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);
|
||||
context.startActivity(intent);
|
||||
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);
|
||||
context.startActivity(intent);
|
||||
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);
|
||||
context.startActivity(intent);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
});
|
||||
}
|
||||
});
|
||||
//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);
|
||||
intentBC.setPackage(BuildConfig.APPLICATION_ID);
|
||||
context.sendBroadcast(intentBC);
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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,11 +104,16 @@ 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);
|
||||
context.startActivity(intent);
|
||||
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);
|
||||
unfollowConfirm.setMessage(context.getString(R.string.remove_draft));
|
||||
|
|
|
@ -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);
|
||||
context.startActivity(intent);
|
||||
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);
|
||||
|
|
|
@ -63,67 +63,71 @@ 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);
|
||||
if (receivedStatus != null && statusAdapter != null) {
|
||||
int position = getPosition(receivedStatus);
|
||||
if (position >= 0) {
|
||||
statuses.get(position).reblog = receivedStatus.reblog;
|
||||
statuses.get(position).reblogged = receivedStatus.reblogged;
|
||||
statuses.get(position).favourited = receivedStatus.favourited;
|
||||
statuses.get(position).bookmarked = receivedStatus.bookmarked;
|
||||
statuses.get(position).reblogs_count = receivedStatus.reblogs_count;
|
||||
statuses.get(position).favourites_count = receivedStatus.favourites_count;
|
||||
statusAdapter.notifyItemChanged(position);
|
||||
}
|
||||
} else if (delete_statuses_for_user != null && statusAdapter != null) {
|
||||
List<Status> statusesToRemove = new ArrayList<>();
|
||||
for (Status status : statuses) {
|
||||
if (status.account.id.equals(delete_statuses_for_user)) {
|
||||
statusesToRemove.add(status);
|
||||
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) {
|
||||
statuses.get(position).reblog = receivedStatus.reblog;
|
||||
statuses.get(position).reblogged = receivedStatus.reblogged;
|
||||
statuses.get(position).favourited = receivedStatus.favourited;
|
||||
statuses.get(position).bookmarked = receivedStatus.bookmarked;
|
||||
statuses.get(position).reblogs_count = receivedStatus.reblogs_count;
|
||||
statuses.get(position).favourites_count = receivedStatus.favourites_count;
|
||||
statusAdapter.notifyItemChanged(position);
|
||||
}
|
||||
}
|
||||
for (Status statusToRemove : statusesToRemove) {
|
||||
int position = getPosition(statusToRemove);
|
||||
} else if (delete_statuses_for_user != null && statusAdapter != null) {
|
||||
List<Status> statusesToRemove = new ArrayList<>();
|
||||
for (Status status : statuses) {
|
||||
if (status.account.id.equals(delete_statuses_for_user)) {
|
||||
statusesToRemove.add(status);
|
||||
}
|
||||
}
|
||||
for (Status statusToRemove : statusesToRemove) {
|
||||
int position = getPosition(statusToRemove);
|
||||
if (position >= 0) {
|
||||
statuses.remove(position);
|
||||
statusAdapter.notifyItemRemoved(position);
|
||||
}
|
||||
}
|
||||
} else if (status_to_delete != null && statusAdapter != null) {
|
||||
int position = getPosition(status_to_delete);
|
||||
if (position >= 0) {
|
||||
statuses.remove(position);
|
||||
statusAdapter.notifyItemRemoved(position);
|
||||
}
|
||||
}
|
||||
} else if (status_to_delete != null && statusAdapter != null) {
|
||||
int position = getPosition(status_to_delete);
|
||||
if (position >= 0) {
|
||||
statuses.remove(position);
|
||||
statusAdapter.notifyItemRemoved(position);
|
||||
}
|
||||
} else if (status_to_update != null && statusAdapter != null) {
|
||||
int position = getPosition(status_to_update);
|
||||
if (position >= 0) {
|
||||
statuses.set(position, status_to_update);
|
||||
statusAdapter.notifyItemChanged(position);
|
||||
}
|
||||
} else if (statusPosted != null && statusAdapter != null) {
|
||||
if (requireActivity() instanceof ContextActivity) {
|
||||
int i = 0;
|
||||
for (Status status : statuses) {
|
||||
if (status.id.equals(statusPosted.in_reply_to_id)) {
|
||||
statuses.add((i + 1), statusPosted);
|
||||
statusAdapter.notifyItemInserted((i + 1));
|
||||
if (requireActivity() instanceof ContextActivity) {
|
||||
//Redraw decorations
|
||||
statusAdapter.notifyItemRangeChanged(0, statuses.size());
|
||||
} else if (status_to_update != null && statusAdapter != null) {
|
||||
int position = getPosition(status_to_update);
|
||||
if (position >= 0) {
|
||||
statuses.set(position, status_to_update);
|
||||
statusAdapter.notifyItemChanged(position);
|
||||
}
|
||||
} else if (statusPosted != null && statusAdapter != null) {
|
||||
if (requireActivity() instanceof ContextActivity) {
|
||||
int i = 0;
|
||||
for (Status status : statuses) {
|
||||
if (status.id.equals(statusPosted.in_reply_to_id)) {
|
||||
statuses.add((i + 1), statusPosted);
|
||||
statusAdapter.notifyItemInserted((i + 1));
|
||||
if (requireActivity() instanceof ContextActivity) {
|
||||
//Redraw decorations
|
||||
statusAdapter.notifyItemRangeChanged(0, statuses.size());
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
if (statusReceived != null) {
|
||||
statuses.add(statusReceived);
|
||||
statusDirectMessageAdapter.notifyItemInserted(statuses.size() - 1);
|
||||
initiliazeStatus();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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,43 +74,46 @@ 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);
|
||||
if (refreshNotifications) {
|
||||
scrollToTop();
|
||||
} else if (receivedStatus != null && notificationAdapter != null) {
|
||||
int position = getPosition(receivedStatus);
|
||||
if (position >= 0) {
|
||||
if (notificationList.get(position).status != null) {
|
||||
notificationList.get(position).status.reblog = receivedStatus.reblog;
|
||||
notificationList.get(position).status.reblogged = receivedStatus.reblogged;
|
||||
notificationList.get(position).status.favourited = receivedStatus.favourited;
|
||||
notificationList.get(position).status.bookmarked = receivedStatus.bookmarked;
|
||||
notificationList.get(position).status.favourites_count = receivedStatus.favourites_count;
|
||||
notificationList.get(position).status.reblogs_count = receivedStatus.reblogs_count;
|
||||
notificationAdapter.notifyItemChanged(position);
|
||||
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) {
|
||||
int position = getPosition(receivedStatus);
|
||||
if (position >= 0) {
|
||||
if (notificationList.get(position).status != null) {
|
||||
notificationList.get(position).status.reblog = receivedStatus.reblog;
|
||||
notificationList.get(position).status.reblogged = receivedStatus.reblogged;
|
||||
notificationList.get(position).status.favourited = receivedStatus.favourited;
|
||||
notificationList.get(position).status.bookmarked = receivedStatus.bookmarked;
|
||||
notificationList.get(position).status.favourites_count = receivedStatus.favourites_count;
|
||||
notificationList.get(position).status.reblogs_count = receivedStatus.reblogs_count;
|
||||
notificationAdapter.notifyItemChanged(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (delete_all_for_account_id != null) {
|
||||
List<Notification> toRemove = new ArrayList<>();
|
||||
if (notificationList != null) {
|
||||
for (int position = 0; position < notificationList.size(); position++) {
|
||||
if (notificationList.get(position).account.id.equals(delete_all_for_account_id)) {
|
||||
toRemove.add(notificationList.get(position));
|
||||
} else if (delete_all_for_account_id != null) {
|
||||
List<Notification> toRemove = new ArrayList<>();
|
||||
if (notificationList != null) {
|
||||
for (int position = 0; position < notificationList.size(); position++) {
|
||||
if (notificationList.get(position).account.id.equals(delete_all_for_account_id)) {
|
||||
toRemove.add(notificationList.get(position));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toRemove.size() > 0) {
|
||||
for (int i = 0; i < toRemove.size(); i++) {
|
||||
int position = getPosition(toRemove.get(i));
|
||||
notificationList.remove(position);
|
||||
notificationAdapter.notifyItemRemoved(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toRemove.size() > 0) {
|
||||
for (int i = 0; i < toRemove.size(); i++) {
|
||||
int position = getPosition(toRemove.get(i));
|
||||
notificationList.remove(position);
|
||||
notificationAdapter.notifyItemRemoved(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -94,88 +94,91 @@ 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);
|
||||
if (receivedStatus != null && statusAdapter != null) {
|
||||
int position = getPosition(receivedStatus);
|
||||
if (position >= 0) {
|
||||
if (receivedStatus.reblog != null) {
|
||||
timelineStatuses.get(position).reblog = receivedStatus.reblog;
|
||||
}
|
||||
if (timelineStatuses.get(position).reblog != null) {
|
||||
timelineStatuses.get(position).reblog.reblogged = receivedStatus.reblogged;
|
||||
timelineStatuses.get(position).reblog.favourited = receivedStatus.favourited;
|
||||
timelineStatuses.get(position).reblog.bookmarked = receivedStatus.bookmarked;
|
||||
timelineStatuses.get(position).reblog.reblogs_count = receivedStatus.reblogs_count;
|
||||
timelineStatuses.get(position).reblog.favourites_count = receivedStatus.favourites_count;
|
||||
} else {
|
||||
timelineStatuses.get(position).reblogged = receivedStatus.reblogged;
|
||||
timelineStatuses.get(position).favourited = receivedStatus.favourited;
|
||||
timelineStatuses.get(position).bookmarked = receivedStatus.bookmarked;
|
||||
timelineStatuses.get(position).reblogs_count = receivedStatus.reblogs_count;
|
||||
timelineStatuses.get(position).favourites_count = receivedStatus.favourites_count;
|
||||
}
|
||||
|
||||
|
||||
statusAdapter.notifyItemChanged(position);
|
||||
}
|
||||
} else if (delete_statuses_for_user != null && statusAdapter != null) {
|
||||
List<Status> statusesToRemove = new ArrayList<>();
|
||||
for (Status status : timelineStatuses) {
|
||||
if (status != null && status.account != null && status.account.id != null && status.account.id.equals(delete_statuses_for_user)) {
|
||||
statusesToRemove.add(status);
|
||||
}
|
||||
}
|
||||
for (Status statusToRemove : statusesToRemove) {
|
||||
int position = getPosition(statusToRemove);
|
||||
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) {
|
||||
timelineStatuses.remove(position);
|
||||
statusAdapter.notifyItemRemoved(position);
|
||||
if (receivedStatus.reblog != null) {
|
||||
timelineStatuses.get(position).reblog = receivedStatus.reblog;
|
||||
}
|
||||
if (timelineStatuses.get(position).reblog != null) {
|
||||
timelineStatuses.get(position).reblog.reblogged = receivedStatus.reblogged;
|
||||
timelineStatuses.get(position).reblog.favourited = receivedStatus.favourited;
|
||||
timelineStatuses.get(position).reblog.bookmarked = receivedStatus.bookmarked;
|
||||
timelineStatuses.get(position).reblog.reblogs_count = receivedStatus.reblogs_count;
|
||||
timelineStatuses.get(position).reblog.favourites_count = receivedStatus.favourites_count;
|
||||
} else {
|
||||
timelineStatuses.get(position).reblogged = receivedStatus.reblogged;
|
||||
timelineStatuses.get(position).favourited = receivedStatus.favourited;
|
||||
timelineStatuses.get(position).bookmarked = receivedStatus.bookmarked;
|
||||
timelineStatuses.get(position).reblogs_count = receivedStatus.reblogs_count;
|
||||
timelineStatuses.get(position).favourites_count = receivedStatus.favourites_count;
|
||||
}
|
||||
|
||||
|
||||
statusAdapter.notifyItemChanged(position);
|
||||
}
|
||||
}
|
||||
} else if (status_to_delete != null && statusAdapter != null) {
|
||||
int position = getPosition(status_to_delete);
|
||||
if (position >= 0) {
|
||||
timelineStatuses.remove(position);
|
||||
statusAdapter.notifyItemRemoved(position);
|
||||
}
|
||||
} else if (status_to_update != null && statusAdapter != null) {
|
||||
int position = getPosition(status_to_update);
|
||||
if (position >= 0) {
|
||||
timelineStatuses.set(position, status_to_update);
|
||||
statusAdapter.notifyItemChanged(position);
|
||||
}
|
||||
} else if (statusPosted != null && statusAdapter != null && timelineType == Timeline.TimeLineEnum.HOME) {
|
||||
timelineStatuses.add(0, statusPosted);
|
||||
statusAdapter.notifyItemInserted(0);
|
||||
} else if (delete_all_for_account_id != null) {
|
||||
List<Status> toRemove = new ArrayList<>();
|
||||
if (timelineStatuses != null) {
|
||||
for (int position = 0; position < timelineStatuses.size(); position++) {
|
||||
if (timelineStatuses.get(position).account.id.equals(delete_all_for_account_id)) {
|
||||
toRemove.add(timelineStatuses.get(position));
|
||||
} else if (delete_statuses_for_user != null && statusAdapter != null) {
|
||||
List<Status> statusesToRemove = new ArrayList<>();
|
||||
for (Status status : timelineStatuses) {
|
||||
if (status != null && status.account != null && status.account.id != null && status.account.id.equals(delete_statuses_for_user)) {
|
||||
statusesToRemove.add(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toRemove.size() > 0) {
|
||||
for (int i = 0; i < toRemove.size(); i++) {
|
||||
int position = getPosition(toRemove.get(i));
|
||||
for (Status statusToRemove : statusesToRemove) {
|
||||
int position = getPosition(statusToRemove);
|
||||
if (position >= 0) {
|
||||
timelineStatuses.remove(position);
|
||||
statusAdapter.notifyItemRemoved(position);
|
||||
}
|
||||
}
|
||||
} else if (status_to_delete != null && statusAdapter != null) {
|
||||
int position = getPosition(status_to_delete);
|
||||
if (position >= 0) {
|
||||
timelineStatuses.remove(position);
|
||||
statusAdapter.notifyItemRemoved(position);
|
||||
}
|
||||
} else if (status_to_update != null && statusAdapter != null) {
|
||||
int position = getPosition(status_to_update);
|
||||
if (position >= 0) {
|
||||
timelineStatuses.set(position, status_to_update);
|
||||
statusAdapter.notifyItemChanged(position);
|
||||
}
|
||||
} else if (statusPosted != null && statusAdapter != null && timelineType == Timeline.TimeLineEnum.HOME) {
|
||||
timelineStatuses.add(0, statusPosted);
|
||||
statusAdapter.notifyItemInserted(0);
|
||||
} else if (delete_all_for_account_id != null) {
|
||||
List<Status> toRemove = new ArrayList<>();
|
||||
if (timelineStatuses != null) {
|
||||
for (int position = 0; position < timelineStatuses.size(); position++) {
|
||||
if (timelineStatuses.get(position).account.id.equals(delete_all_for_account_id)) {
|
||||
toRemove.add(timelineStatuses.get(position));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toRemove.size() > 0) {
|
||||
for (int i = 0; i < toRemove.size(); i++) {
|
||||
int position = getPosition(toRemove.get(i));
|
||||
if (position >= 0) {
|
||||
timelineStatuses.remove(position);
|
||||
statusAdapter.notifyItemRemoved(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (refreshAll) {
|
||||
refreshAllAdapters();
|
||||
}
|
||||
} else if (refreshAll) {
|
||||
refreshAllAdapters();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue