diff --git a/app/build.gradle b/app/build.gradle index 56f09eca..9f2c11c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -177,7 +177,6 @@ dependencies { implementation 'androidx.browser:browser:1.7.0' implementation 'androidx.documentfile:documentfile:1.0.1' implementation 'com.github.amoskorir:avatarimagegenerator:1.5.0' - implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0' implementation 'com.google.android.exoplayer:extension-mediasession:2.19.1' implementation "com.github.mabbas007:TagsEditText:1.0.5" implementation "net.gotev:uploadservice:4.9.2" diff --git a/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java b/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java index 78b5118b..1edddce2 100644 --- a/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java +++ b/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java @@ -28,7 +28,7 @@ import android.view.View; import android.webkit.MimeTypeMap; import androidx.appcompat.app.AlertDialog; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import com.google.android.exoplayer2.ExoPlayer; import com.google.android.material.dialog.MaterialAlertDialogBuilder; @@ -38,6 +38,7 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.security.GeneralSecurityException; +import app.fedilab.android.BuildConfig; import app.fedilab.android.R; import app.fedilab.android.databinding.ActivityPeertubeBinding; import app.fedilab.android.mastodon.activities.BaseBarActivity; @@ -124,7 +125,8 @@ public class BasePeertubeActivity extends BaseBarActivity { if (PeertubeBaseMainActivity.chromecastActivated) { b.putInt("displayed", 0); intentBC.putExtras(b); - LocalBroadcastManager.getInstance(BasePeertubeActivity.this).sendBroadcast(intentBC); + intentBC.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBC); Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { binding.doubleTapPlayerView.setVisibility(View.VISIBLE); @@ -136,7 +138,8 @@ public class BasePeertubeActivity extends BaseBarActivity { b.putInt("displayed", 1); b.putSerializable("castedTube", peertube); intentBC.putExtras(b); - LocalBroadcastManager.getInstance(BasePeertubeActivity.this).sendBroadcast(intentBC); + intentBC.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBC); try { Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { diff --git a/app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java b/app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java index 1d25888c..379bc276 100644 --- a/app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java +++ b/app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java @@ -26,7 +26,7 @@ import android.os.Looper; import android.view.View; import androidx.core.content.ContextCompat; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import java.io.IOException; import java.net.InetAddress; @@ -36,6 +36,7 @@ import java.util.Collections; import java.util.Enumeration; import java.util.List; +import app.fedilab.android.BuildConfig; import app.fedilab.android.R; import app.fedilab.android.databinding.ActivityMainPeertubeBinding; import app.fedilab.android.mastodon.activities.BaseActivity; @@ -70,7 +71,8 @@ public abstract class PeertubeBaseMainActivity extends BaseActivity implements C Bundle b = new Bundle(); b.putInt("displayed", 0); intentBC.putExtras(b); - LocalBroadcastManager.getInstance(PeertubeBaseMainActivity.this).sendBroadcast(intentBC); + intentBC.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBC); }); binding.castTogglePlay.setOnClickListener(v -> { diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index 75d4f2e5..a2be8f94 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -80,7 +80,7 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.navigation.NavController; import androidx.navigation.Navigation; import androidx.navigation.ui.AppBarConfiguration; @@ -694,8 +694,9 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt Bundle b = new Bundle(); b.putBoolean(ARG_REFRESH_NOTFICATION, true); Intent intentBC = new Intent(Helper.RECEIVE_STATUS_ACTION); + intentBC.setPackage(BuildConfig.APPLICATION_ID); intentBC.putExtras(b); - LocalBroadcastManager.getInstance(activity).sendBroadcast(intentBC); + activity.sendBroadcast(intentBC); } }, 1000); intent.removeExtra(Helper.INTENT_ACTION); diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/ComposeActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/ComposeActivity.java index 57bfb246..1816d881 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/ComposeActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/ComposeActivity.java @@ -49,7 +49,7 @@ import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.core.content.ContextCompat; import androidx.lifecycle.ViewModelProvider; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.work.Data; diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/EditProfileActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/EditProfileActivity.java index 2e76069d..a69aa8c3 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/EditProfileActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/EditProfileActivity.java @@ -32,7 +32,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.lifecycle.ViewModelProvider; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import com.bumptech.glide.Glide; import com.google.android.material.dialog.MaterialAlertDialogBuilder; @@ -43,6 +43,7 @@ import java.util.List; import java.util.Locale; import app.fedilab.android.BaseMainActivity; +import app.fedilab.android.BuildConfig; import app.fedilab.android.R; import app.fedilab.android.databinding.AccountFieldItemBinding; import app.fedilab.android.databinding.ActivityEditProfileBinding; @@ -270,7 +271,8 @@ public class EditProfileActivity extends BaseBarActivity { b.putSerializable(Helper.ARG_ACCOUNT, account); Intent intentBD = new Intent(Helper.BROADCAST_DATA); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(EditProfileActivity.this).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBD); } private Intent prepareIntent() { diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java index ab93056b..83ac74a5 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java @@ -28,7 +28,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.lifecycle.ViewModelProvider; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import com.google.android.material.dialog.MaterialAlertDialogBuilder; @@ -36,6 +36,7 @@ import java.util.ArrayList; import java.util.List; 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.ActivityHashtagBinding; @@ -192,7 +193,8 @@ public class HashTagActivity extends BaseActivity { b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true); Intent intentBD = new Intent(Helper.BROADCAST_DATA); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(HashTagActivity.this).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBD); dialog.dismiss(); }); unpinConfirm.show(); @@ -246,7 +248,8 @@ public class HashTagActivity extends BaseActivity { b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true); Intent intentBD = new Intent(Helper.BROADCAST_DATA); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(HashTagActivity.this).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBD); pinnedTag = true; invalidateOptionsMenu(); } catch (DBException e) { diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/MastodonListActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/MastodonListActivity.java index a5cf710d..4b2fa6cc 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/MastodonListActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/MastodonListActivity.java @@ -30,7 +30,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -41,6 +41,7 @@ import java.util.Collections; import java.util.List; 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; @@ -290,7 +291,8 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis Intent intentBD = new Intent(Helper.BROADCAST_DATA); b.putSerializable(Helper.RECEIVE_MASTODON_LIST, mastodonListList); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(MastodonListActivity.this).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBD); }); alt_bld.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); AlertDialog alert = alt_bld.create(); @@ -325,7 +327,8 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis Intent intentBD = new Intent(Helper.BROADCAST_DATA); b.putSerializable(Helper.RECEIVE_MASTODON_LIST, mastodonListList); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(MastodonListActivity.this).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBD); }); dialog.dismiss(); } else { @@ -372,7 +375,8 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true); Intent intentBD = new Intent(Helper.BROADCAST_DATA); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(MastodonListActivity.this).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBD); } catch ( DBException e) { e.printStackTrace(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/ProfileActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/ProfileActivity.java index 5e293f14..e2ac02e8 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/ProfileActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/ProfileActivity.java @@ -57,7 +57,7 @@ import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityOptionsCompat; import androidx.core.content.ContextCompat; import androidx.lifecycle.ViewModelProvider; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -79,6 +79,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; 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.ActivityProfileBinding; @@ -904,7 +905,8 @@ public class ProfileActivity extends BaseActivity { b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true); Intent intentBD = new Intent(Helper.BROADCAST_DATA); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(ProfileActivity.this).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBD); }); } catch (DBException e) { e.printStackTrace(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/ReorderTimelinesActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/ReorderTimelinesActivity.java index de89f1e3..a0cdd267 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/ReorderTimelinesActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/ReorderTimelinesActivity.java @@ -31,7 +31,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.lifecycle.ViewModelProvider; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.LinearLayoutManager; @@ -43,6 +43,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.concurrent.TimeUnit; +import app.fedilab.android.BuildConfig; import app.fedilab.android.R; import app.fedilab.android.activities.MainActivity; import app.fedilab.android.databinding.ActivityReorderTabsBinding; @@ -288,7 +289,8 @@ public class ReorderTimelinesActivity extends BaseBarActivity implements OnStart b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true); Intent intentBD = new Intent(Helper.BROADCAST_DATA); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(ReorderTimelinesActivity.this).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBD); }); } else { runOnUiThread(() -> Toasty.warning(ReorderTimelinesActivity.this, getString(R.string.toast_instance_unavailable), Toast.LENGTH_LONG).show()); @@ -376,14 +378,16 @@ public class ReorderTimelinesActivity extends BaseBarActivity implements OnStart b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true); Intent intentBD = new Intent(Helper.BROADCAST_DATA); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(ReorderTimelinesActivity.this).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBD); } if (bottomChanges) { Bundle b = new Bundle(); b.putBoolean(Helper.RECEIVE_REDRAW_BOTTOM, true); Intent intentBD = new Intent(Helper.BROADCAST_DATA); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(ReorderTimelinesActivity.this).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentBD); } } diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminActionActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminActionActivity.java index aa82c40a..2349e3a9 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminActionActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminActionActivity.java @@ -33,7 +33,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.core.content.ContextCompat; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.gson.annotations.SerializedName; diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminDomainBlockActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminDomainBlockActivity.java index 3b579c39..4257961c 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminDomainBlockActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/admin/AdminDomainBlockActivity.java @@ -26,10 +26,11 @@ import android.widget.ArrayAdapter; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.lifecycle.ViewModelProvider; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import com.google.android.material.dialog.MaterialAlertDialogBuilder; +import app.fedilab.android.BuildConfig; import app.fedilab.android.R; import app.fedilab.android.activities.MainActivity; import app.fedilab.android.databinding.ActivityAdminDomainblockBinding; @@ -108,7 +109,8 @@ public class AdminDomainBlockActivity extends BaseBarActivity { 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); - LocalBroadcastManager.getInstance(AdminDomainBlockActivity.this).sendBroadcast(intent); + intent.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intent); finish(); } ); @@ -136,7 +138,8 @@ public class AdminDomainBlockActivity extends BaseBarActivity { 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); - LocalBroadcastManager.getInstance(AdminDomainBlockActivity.this).sendBroadcast(intent); + intent.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intent); finish(); } ); diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java index 1000709b..46772271 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java @@ -89,7 +89,7 @@ import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelStoreOwner; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; @@ -857,6 +857,7 @@ public class Helper { b.putString(RECEIVE_TOAST_CONTENT, content); intentBC.setAction(Helper.RECEIVE_TOAST_MESSAGE); intentBC.putExtras(b); + intentBC.setPackage(BuildConfig.APPLICATION_ID); context.sendBroadcast(intentBC); } @@ -1498,7 +1499,8 @@ public class Helper { b.putBoolean(Helper.RECEIVE_RECREATE_ACTIVITY, true); Intent intentBD = new Intent(Helper.BROADCAST_DATA); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(activity).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + activity.sendBroadcast(intentBD); } public static void showKeyboard(Context context, View view) { diff --git a/app/src/main/java/app/fedilab/android/mastodon/imageeditor/EditImageActivity.java b/app/src/main/java/app/fedilab/android/mastodon/imageeditor/EditImageActivity.java index eca3f114..e97d8bf5 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/imageeditor/EditImageActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/imageeditor/EditImageActivity.java @@ -22,7 +22,7 @@ import androidx.constraintlayout.widget.ConstraintSet; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import androidx.exifinterface.media.ExifInterface; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.recyclerview.widget.LinearLayoutManager; import androidx.transition.ChangeBounds; import androidx.transition.TransitionManager; @@ -39,6 +39,7 @@ import java.io.File; import java.io.IOException; 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.helper.CirclesDrawingView; @@ -327,7 +328,8 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList intentImage.putExtra("focusY", focusY); } - LocalBroadcastManager.getInstance(EditImageActivity.this).sendBroadcast(intentImage); + intentImage.setPackage(BuildConfig.APPLICATION_ID); + sendBroadcast(intentImage); finish(); } } diff --git a/app/src/main/java/app/fedilab/android/mastodon/jobs/ComposeWorker.java b/app/src/main/java/app/fedilab/android/mastodon/jobs/ComposeWorker.java index b0e055df..920f952c 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/jobs/ComposeWorker.java +++ b/app/src/main/java/app/fedilab/android/mastodon/jobs/ComposeWorker.java @@ -31,7 +31,7 @@ import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.core.app.NotificationCompat; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.preference.PreferenceManager; import androidx.work.Data; import androidx.work.ForegroundInfo; @@ -51,6 +51,7 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import app.fedilab.android.BaseMainActivity; +import app.fedilab.android.BuildConfig; import app.fedilab.android.R; import app.fedilab.android.mastodon.client.endpoints.MastodonStatusesService; import app.fedilab.android.mastodon.client.entities.api.Attachment; @@ -228,7 +229,8 @@ public class ComposeWorker extends Worker { 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); - LocalBroadcastManager.getInstance(context).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + context.sendBroadcast(intentBD); return; } if (statuses.get(i).local_only) { @@ -312,7 +314,8 @@ public class ComposeWorker extends Worker { } b.putSerializable(Helper.RECEIVE_ERROR_MESSAGE, err); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(context).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + context.sendBroadcast(intentBD); return; } } catch (IOException e) { @@ -323,7 +326,8 @@ public class ComposeWorker extends Worker { Intent intentBD = new Intent(Helper.INTENT_COMPOSE_ERROR_MESSAGE); b.putSerializable(Helper.RECEIVE_ERROR_MESSAGE, e.getMessage()); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(context).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + context.sendBroadcast(intentBD); return; } } else { @@ -377,7 +381,8 @@ public class ComposeWorker extends Worker { Intent intentBD = new Intent(Helper.BROADCAST_DATA); b.putSerializable(Helper.RECEIVE_STATUS_ACTION, firstSendMessage); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(context).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + context.sendBroadcast(intentBD); } } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java index f05f5a20..633d1f92 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java @@ -57,6 +57,7 @@ import android.os.Looper; import android.text.Html; import android.text.SpannableString; import android.text.TextUtils; +import android.util.Log; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -87,7 +88,7 @@ import androidx.fragment.app.Fragment; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelStoreOwner; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -121,6 +122,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; 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.DrawerFetchMoreBinding; @@ -2784,7 +2786,8 @@ public class StatusAdapter extends RecyclerView.Adapter } Intent intentBC = new Intent(Helper.RECEIVE_STATUS_ACTION); intentBC.putExtras(b); - LocalBroadcastManager.getInstance(context).sendBroadcast(intentBC); + intentBC.setPackage(BuildConfig.APPLICATION_ID); + context.sendBroadcast(intentBC); } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonContext.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonContext.java index 43bbc24a..d476ad8d 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonContext.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonContext.java @@ -30,7 +30,7 @@ import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.recyclerview.widget.LinearLayoutManager; import java.util.ArrayList; diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonDirectMessage.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonDirectMessage.java index c241d188..91690c06 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonDirectMessage.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonDirectMessage.java @@ -50,7 +50,7 @@ import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.work.Data; diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonNotification.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonNotification.java index 92c4afb0..a728dbb1 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonNotification.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonNotification.java @@ -31,7 +31,7 @@ import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java index 593dde70..a1647ed4 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -27,6 +27,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -36,7 +37,7 @@ import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -94,6 +95,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. @Override public void onReceive(Context context, Intent intent) { Bundle b = intent.getExtras(); + Log.v(Helper.TAG, "onReceive: " + b); 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); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java index 110589d6..daf4b4a6 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java @@ -61,7 +61,7 @@ import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.preference.PreferenceManager; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; diff --git a/app/src/main/java/app/fedilab/android/peertube/fragment/SettingsFragment.java b/app/src/main/java/app/fedilab/android/peertube/fragment/SettingsFragment.java index 57b41d7a..c535c1a5 100644 --- a/app/src/main/java/app/fedilab/android/peertube/fragment/SettingsFragment.java +++ b/app/src/main/java/app/fedilab/android/peertube/fragment/SettingsFragment.java @@ -17,7 +17,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.res.ResourcesCompat; import androidx.fragment.app.FragmentActivity; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.preference.ListPreference; import androidx.preference.MultiSelectListPreference; import androidx.preference.Preference; @@ -41,6 +41,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import app.fedilab.android.BuildConfig; import app.fedilab.android.R; import app.fedilab.android.peertube.activities.MyAccountActivity; import app.fedilab.android.peertube.activities.PeertubeMainActivity; @@ -247,7 +248,8 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared Bundle b = new Bundle(); b.putInt("state_asked", set_cast_choice.isChecked() ? 1 : 0); intentBC.putExtras(b); - LocalBroadcastManager.getInstance(requireActivity()).sendBroadcast(intentBC); + intentBC.setPackage(BuildConfig.APPLICATION_ID); + requireActivity().sendBroadcast(intentBC); } if (key.compareTo(getString(R.string.set_video_language_choice)) == 0) { MultiSelectListPreference set_video_language_choice = findPreference(getString(R.string.set_video_language_choice)); diff --git a/app/src/main/java/app/fedilab/android/peertube/helper/Helper.java b/app/src/main/java/app/fedilab/android/peertube/helper/Helper.java index 39a7a839..3197ab45 100644 --- a/app/src/main/java/app/fedilab/android/peertube/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/peertube/helper/Helper.java @@ -57,7 +57,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; + import androidx.preference.PreferenceManager; import com.avatarfirst.avatargenlib.AvatarGenerator; @@ -83,6 +83,7 @@ import java.util.List; import java.util.Locale; import java.util.regex.Pattern; +import app.fedilab.android.BuildConfig; import app.fedilab.android.R; import app.fedilab.android.mastodon.client.entities.app.BaseAccount; import app.fedilab.android.mastodon.exception.DBException; @@ -632,7 +633,8 @@ public class Helper { b.putBoolean(app.fedilab.android.mastodon.helper.Helper.RECEIVE_RECREATE_PEERTUBE_ACTIVITY, true); Intent intentBD = new Intent(app.fedilab.android.mastodon.helper.Helper.BROADCAST_DATA); intentBD.putExtras(b); - LocalBroadcastManager.getInstance(activity).sendBroadcast(intentBD); + intentBD.setPackage(BuildConfig.APPLICATION_ID); + activity.sendBroadcast(intentBD); } public static int getAttColor(Context context, int attColor) {