Commit 2e20e78b authored by Thomas's avatar Thomas
Browse files

Apply changes when serializing accounts

parent 8040a063
Loading
Loading
Loading
Loading
+37 −17
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ import app.fedilab.android.mastodon.client.entities.api.Tag;
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.BottomMenu;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.client.entities.app.MutedAccounts;
import app.fedilab.android.mastodon.client.entities.app.Pinned;
import app.fedilab.android.mastodon.client.entities.app.PinnedTimeline;
@@ -659,16 +660,26 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
            Status status = (Status) bundle.getSerializable(Helper.INTENT_TARGETED_STATUS);
            if (account != null) {
                Intent intentAccount = new Intent(activity, ProfileActivity.class);
                Bundle b = new Bundle();
                b.putSerializable(Helper.ARG_ACCOUNT, account);
                intentAccount.putExtras(b);
                Bundle args = new Bundle();
                args.putSerializable(Helper.ARG_ACCOUNT, account);
                new CachedBundle(activity).insertBundle(args, bundleId -> {
                    Bundle bundleCached = new Bundle();
                    bundleCached.putLong(Helper.ARG_INTENT_ID, bundleId);
                    intentAccount.putExtras(bundleCached);
                    intentAccount.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    activity.startActivity(intentAccount);
                });
            } else if (status != null) {
                Intent intentContext = new Intent(activity, ContextActivity.class);
                intentContext.putExtra(Helper.ARG_STATUS, status);
                Bundle args = new Bundle();
                args.putSerializable(Helper.ARG_STATUS, status);
                new CachedBundle(activity).insertBundle(args, bundleId -> {
                    Bundle bundleCached = new Bundle();
                    bundleCached.putLong(Helper.ARG_INTENT_ID, bundleId);
                    intentContext.putExtras(bundleCached);
                    intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    activity.startActivity(intentContext);
                });
            }
        }
        final Handler handler = new Handler();
@@ -1035,11 +1046,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
                            public void federatedAccount(app.fedilab.android.mastodon.client.entities.api.Account account) {
                                if (account != null) {
                                    Intent intent = new Intent(activity, ProfileActivity.class);
                                    Bundle b = new Bundle();
                                    b.putSerializable(Helper.ARG_ACCOUNT, account);
                                    intent.putExtras(b);
                                    Bundle args = new Bundle();
                                    args.putSerializable(Helper.ARG_ACCOUNT, account);
                                    new CachedBundle(activity).insertBundle(args, bundleId -> {
                                        Bundle bundle = new Bundle();
                                        bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
                                        intent.putExtras(bundle);
                                        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                        activity.startActivity(intent);
                                    });
                                } else {
                                    Toasty.error(activity, activity.getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
                                }
@@ -1418,12 +1433,17 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
        headerMainBinding.instanceInfo.setOnClickListener(v -> (new InstanceHealthActivity()).show(getSupportFragmentManager(), null));
        headerMainBinding.accountProfilePicture.setOnClickListener(v -> {
            Intent intent = new Intent(BaseMainActivity.this, ProfileActivity.class);
            Bundle b = new Bundle();
            b.putSerializable(Helper.ARG_ACCOUNT, currentAccount.mastodon_account);
            intent.putExtras(b);
            Bundle args = new Bundle();
            args.putSerializable(Helper.ARG_ACCOUNT, currentAccount.mastodon_account);
            new CachedBundle(BaseMainActivity.this).insertBundle(args, bundleId -> {
                Bundle bundle = new Bundle();
                bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
                intent.putExtras(bundle);
                startActivity(intent);
            });

        });

        headerMainBinding.accountAcc.setOnClickListener(v -> headerMainBinding.changeAccount.callOnClick());
        headerMainBinding.changeAccount.setOnClickListener(v -> {
            headerMenuOpen = !headerMenuOpen;
+9 −4
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import app.fedilab.android.mastodon.activities.BaseBarActivity;
import app.fedilab.android.mastodon.activities.ProfileActivity;
import app.fedilab.android.mastodon.client.entities.api.Account;
import app.fedilab.android.mastodon.client.entities.api.Status;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.helper.CrossActionHelper;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.MastodonHelper;
@@ -119,11 +120,15 @@ public class AboutActivity extends BaseBarActivity {
                    binding.accountUn.setText(account.acct);
                    binding.accountPp.setOnClickListener(v -> {
                        Intent intent = new Intent(AboutActivity.this, ProfileActivity.class);
                        Bundle b = new Bundle();
                        b.putSerializable(Helper.ARG_ACCOUNT, account);
                        intent.putExtras(b);
                        Bundle args = new Bundle();
                        args.putSerializable(Helper.ARG_ACCOUNT, account);
                        new CachedBundle(AboutActivity.this).insertBundle(args, bundleId -> {
                            Bundle bundle = new Bundle();
                            bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
                            intent.putExtras(bundle);
                            startActivity(intent);
                        });
                    });
                    AccountsVM accountsVM = new ViewModelProvider(AboutActivity.this).get(AccountsVM.class);
                    List<String> ids = new ArrayList<>();
                    ids.add(account.id);
+17 −8
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import app.fedilab.android.databinding.ActivityAdminReportBinding;
import app.fedilab.android.mastodon.client.entities.api.Status;
import app.fedilab.android.mastodon.client.entities.api.admin.AdminAccount;
import app.fedilab.android.mastodon.client.entities.api.admin.AdminReport;
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.drawer.StatusReportAdapter;
@@ -48,7 +49,7 @@ public class AccountReportActivity extends BaseBarActivity {
    private AdminReport report;
    private ActivityAdminReportBinding binding;
    private AdminVM adminVM;

    private AdminAccount targeted_account;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -61,12 +62,21 @@ public class AccountReportActivity extends BaseBarActivity {
        }

        report = null;
        AdminAccount targeted_account = null;
        Bundle b = getIntent().getExtras();
        if (b != null) {
            account_id = b.getString(Helper.ARG_ACCOUNT_ID, null);
            targeted_account = (AdminAccount) b.getSerializable(Helper.ARG_ACCOUNT);
            report = (AdminReport) b.getSerializable(Helper.ARG_REPORT);
        targeted_account = null;
        Bundle args = getIntent().getExtras();
        if (args != null) {
            long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1);
            new CachedBundle(AccountReportActivity.this).getBundle(bundleId, this::initializeAfterBundle);
        } else {
            initializeAfterBundle(null);
        }
    }
    private void initializeAfterBundle(Bundle bundle) {

        if(bundle != null) {
            account_id = bundle.getString(Helper.ARG_ACCOUNT_ID, null);
            targeted_account = (AdminAccount) bundle.getSerializable(Helper.ARG_ACCOUNT);
            report = (AdminReport) bundle.getSerializable(Helper.ARG_REPORT);
        }

        binding.allow.getBackground().setColorFilter(ThemeHelper.getAttColor(this, R.attr.colorPrimary), PorterDuff.Mode.MULTIPLY);
@@ -103,7 +113,6 @@ public class AccountReportActivity extends BaseBarActivity {
            account_id = targeted_account.username;
        }


    }

    private void fillReport(AdminAccount accountAdmin, actionType type) {
+6 −18
Original line number Diff line number Diff line
@@ -100,24 +100,12 @@ public class ActionActivity extends BaseBarActivity {

        }
        switch (type) {
            case MUTED_TIMELINE:
                setTitle(R.string.muted_menu);
                break;
            case FAVOURITE_TIMELINE:
                setTitle(R.string.favourite);
                break;
            case BLOCKED_TIMELINE:
                setTitle(R.string.blocked_menu);
                break;
            case BOOKMARK_TIMELINE:
                setTitle(R.string.bookmarks);
                break;
            case BLOCKED_DOMAIN_TIMELINE:
                setTitle(R.string.blocked_domains);
                break;
            case MUTED_TIMELINE_HOME:
                setTitle(R.string.muted_menu_home);
                break;
            case MUTED_TIMELINE -> setTitle(R.string.muted_menu);
            case FAVOURITE_TIMELINE -> setTitle(R.string.favourite);
            case BLOCKED_TIMELINE -> setTitle(R.string.blocked_menu);
            case BOOKMARK_TIMELINE -> setTitle(R.string.bookmarks);
            case BLOCKED_DOMAIN_TIMELINE -> setTitle(R.string.blocked_domains);
            case MUTED_TIMELINE_HOME -> setTitle(R.string.muted_menu_home);
        }
    }

+279 −260
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ import app.fedilab.android.mastodon.client.entities.api.Mention;
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.BaseAccount;
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.DividerDecorationSimple;
@@ -484,6 +485,19 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
        binding.title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
        statusList = new ArrayList<>();
        Bundle b = getIntent().getExtras();
        if(b != null) {
            long bundleId = b.getLong(Helper.ARG_INTENT_ID, -1);
            if(bundleId != -1 ) {
                new CachedBundle(ComposeActivity.this).getBundle(bundleId, this::initializeAfterBundle);
            } else {
                initializeAfterBundle(b);
            }
        }
    }

    private void initializeAfterBundle(Bundle b) {
        SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
        new Thread(()->{
            if (b != null) {
                statusReply = (Status) b.getSerializable(Helper.ARG_STATUS_REPLY);
                statusQuoted = (Status) b.getSerializable(Helper.ARG_QUOTED_MESSAGE);
@@ -515,7 +529,8 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
                sharedDescription = b.getString(Helper.ARG_SHARE_DESCRIPTION, null);
                shareURL = b.getString(Helper.ARG_SHARE_URL, null);
            }

            Handler mainHandler = new Handler(Looper.getMainLooper());
            Runnable myRunnable = () -> {
                if (sharedContent != null && shareURL != null && sharedContent.compareTo(shareURL) == 0) {
                    sharedContent = "";
                }
@@ -774,8 +789,12 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
                        }
                    }
                });
            };
            mainHandler.post(myRunnable);
        }).start();
    }


    @Override
    public void onItemDraftAdded(int position, String initialContent) {
        Status status = new Status();
Loading