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