diff options
Diffstat (limited to 'app/src/main/java/app/fedilab')
91 files changed, 3180 insertions, 1745 deletions
diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index 850de4dec..9b5af2dae 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -36,7 +36,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; -import android.content.res.Configuration; import android.database.MatrixCursor; import android.graphics.PorterDuff; import android.graphics.drawable.BitmapDrawable; @@ -72,8 +71,8 @@ import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.SearchView; +import androidx.appcompat.widget.Toolbar; import androidx.core.app.ActivityCompat; -import androidx.core.app.ActivityOptionsCompat; import androidx.core.content.ContextCompat; import androidx.core.view.GravityCompat; import androidx.cursoradapter.widget.CursorAdapter; @@ -81,7 +80,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; @@ -99,6 +98,7 @@ import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.transition.Transition; +import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.navigation.NavigationView; @@ -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; @@ -222,24 +223,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(); + } + }); + } } }; @@ -248,88 +259,97 @@ 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); + Bundle args = intent.getExtras(); + |