Loading app/src/main/java/app/fedilab/android/activities/ProfileActivity.java +8 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package app.fedilab.android.activities; import static app.fedilab.android.BaseMainActivity.currentAccount; import static app.fedilab.android.helper.Helper.addMutedAccount; import static app.fedilab.android.helper.Helper.removeMutedAccount; import static app.fedilab.android.ui.drawer.StatusAdapter.sendAction; import android.content.BroadcastReceiver; Loading Loading @@ -1011,12 +1013,18 @@ public class ProfileActivity extends BaseActivity { builderInner.setPositiveButton(R.string.action_unmute, (dialog, which) -> accountsVM.unmuteHome(currentAccount, account) .observe(ProfileActivity.this, account -> { homeMuted = false; if (account != null) { removeMutedAccount(account); } Toasty.info(ProfileActivity.this, getString(R.string.toast_unmute), Toasty.LENGTH_LONG).show(); })); } else { builderInner.setTitle(R.string.mute_home); builderInner.setPositiveButton(R.string.action_mute, (dialog, which) -> accountsVM.muteHome(currentAccount, account) .observe(ProfileActivity.this, account -> { if (account != null) { addMutedAccount(account); } homeMuted = true; sendAction(ProfileActivity.this, Helper.ARG_STATUS_ACCOUNT_ID_DELETED, null, account.id); Toasty.info(ProfileActivity.this, getString(R.string.toast_mute), Toasty.LENGTH_LONG).show(); Loading app/src/main/java/app/fedilab/android/client/entities/app/MutedAccounts.java +9 −1 Original line number Diff line number Diff line Loading @@ -213,9 +213,10 @@ public class MutedAccounts implements Serializable { throw new DBException("db is null. Wrong initialization."); } try { Cursor c = db.query(Sqlite.TABLE_MUTED, null, Sqlite.COL_INSTANCE + " = '" + account.instance + "' AND " + Sqlite.COL_USER_ID + " = '" + account.user_id + "'", null, null, null, null, null); Cursor c = db.query(Sqlite.TABLE_MUTED, null, Sqlite.COL_INSTANCE + " = '" + account.instance + "' AND " + Sqlite.COL_USER_ID + " = '" + account.user_id + "'", null, null, null, null, "1"); return convertCursorToMuted(c); } catch (Exception e) { e.printStackTrace(); return null; } } Loading @@ -227,12 +228,19 @@ public class MutedAccounts implements Serializable { * @return MutedAccounts */ private MutedAccounts convertCursorToMuted(Cursor c) { if (c.getCount() == 0) { c.close(); return null; } //Take the first element c.moveToFirst(); MutedAccounts mutedAccounts = new MutedAccounts(); mutedAccounts.id = c.getInt(c.getColumnIndexOrThrow(Sqlite.COL_ID)); mutedAccounts.instance = c.getString(c.getColumnIndexOrThrow(Sqlite.COL_INSTANCE)); mutedAccounts.user_id = c.getString(c.getColumnIndexOrThrow(Sqlite.COL_USER_ID)); mutedAccounts.accounts = restoreAccountsFromString(c.getString(c.getColumnIndexOrThrow(Sqlite.COL_MUTED_ACCOUNTS))); mutedAccounts.type = Timeline.TimeLineEnum.valueOf(c.getString(c.getColumnIndexOrThrow(Sqlite.COL_TYPE))); c.close(); return mutedAccounts; } } app/src/main/java/app/fedilab/android/helper/Helper.java +15 −0 Original line number Diff line number Diff line Loading @@ -1953,4 +1953,19 @@ public class Helper { public interface OnAttachmentCopied { void onAttachmentCopied(Attachment attachment); } public static void addMutedAccount(app.fedilab.android.client.entities.api.Account target) { if (MainActivity.filteredAccounts == null) { MainActivity.filteredAccounts = new ArrayList<>(); } if (!MainActivity.filteredAccounts.contains(target)) { MainActivity.filteredAccounts.add(target); } } public static void removeMutedAccount(app.fedilab.android.client.entities.api.Account target) { if (MainActivity.filteredAccounts != null) { MainActivity.filteredAccounts.remove(target); } } } app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +4 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static app.fedilab.android.helper.Helper.ARG_TIMELINE_REFRESH_ALL; import static app.fedilab.android.helper.Helper.PREF_USER_ID; import static app.fedilab.android.helper.Helper.PREF_USER_INSTANCE; import static app.fedilab.android.helper.Helper.PREF_USER_TOKEN; import static app.fedilab.android.helper.Helper.addMutedAccount; import android.annotation.SuppressLint; import android.app.Activity; Loading Loading @@ -1662,6 +1663,9 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> builderInner.setNeutralButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); builderInner.setPositiveButton(R.string.action_mute, (dialog, which) -> accountsVM.muteHome(currentAccount, statusToDeal.account) .observe((LifecycleOwner) context, account -> { if (account != null) { addMutedAccount(account); } sendAction(context, Helper.ARG_STATUS_ACCOUNT_ID_DELETED, null, statusToDeal.account.id); Toasty.info(context, context.getString(R.string.toast_mute), Toasty.LENGTH_LONG).show(); })); Loading app/src/main/res/layout/activity_list.xml +2 −2 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="@dimen/fab_margin"> android:layout_marginHorizontal="6dp" android:orientation="vertical"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/recycler_view" Loading Loading
app/src/main/java/app/fedilab/android/activities/ProfileActivity.java +8 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package app.fedilab.android.activities; import static app.fedilab.android.BaseMainActivity.currentAccount; import static app.fedilab.android.helper.Helper.addMutedAccount; import static app.fedilab.android.helper.Helper.removeMutedAccount; import static app.fedilab.android.ui.drawer.StatusAdapter.sendAction; import android.content.BroadcastReceiver; Loading Loading @@ -1011,12 +1013,18 @@ public class ProfileActivity extends BaseActivity { builderInner.setPositiveButton(R.string.action_unmute, (dialog, which) -> accountsVM.unmuteHome(currentAccount, account) .observe(ProfileActivity.this, account -> { homeMuted = false; if (account != null) { removeMutedAccount(account); } Toasty.info(ProfileActivity.this, getString(R.string.toast_unmute), Toasty.LENGTH_LONG).show(); })); } else { builderInner.setTitle(R.string.mute_home); builderInner.setPositiveButton(R.string.action_mute, (dialog, which) -> accountsVM.muteHome(currentAccount, account) .observe(ProfileActivity.this, account -> { if (account != null) { addMutedAccount(account); } homeMuted = true; sendAction(ProfileActivity.this, Helper.ARG_STATUS_ACCOUNT_ID_DELETED, null, account.id); Toasty.info(ProfileActivity.this, getString(R.string.toast_mute), Toasty.LENGTH_LONG).show(); Loading
app/src/main/java/app/fedilab/android/client/entities/app/MutedAccounts.java +9 −1 Original line number Diff line number Diff line Loading @@ -213,9 +213,10 @@ public class MutedAccounts implements Serializable { throw new DBException("db is null. Wrong initialization."); } try { Cursor c = db.query(Sqlite.TABLE_MUTED, null, Sqlite.COL_INSTANCE + " = '" + account.instance + "' AND " + Sqlite.COL_USER_ID + " = '" + account.user_id + "'", null, null, null, null, null); Cursor c = db.query(Sqlite.TABLE_MUTED, null, Sqlite.COL_INSTANCE + " = '" + account.instance + "' AND " + Sqlite.COL_USER_ID + " = '" + account.user_id + "'", null, null, null, null, "1"); return convertCursorToMuted(c); } catch (Exception e) { e.printStackTrace(); return null; } } Loading @@ -227,12 +228,19 @@ public class MutedAccounts implements Serializable { * @return MutedAccounts */ private MutedAccounts convertCursorToMuted(Cursor c) { if (c.getCount() == 0) { c.close(); return null; } //Take the first element c.moveToFirst(); MutedAccounts mutedAccounts = new MutedAccounts(); mutedAccounts.id = c.getInt(c.getColumnIndexOrThrow(Sqlite.COL_ID)); mutedAccounts.instance = c.getString(c.getColumnIndexOrThrow(Sqlite.COL_INSTANCE)); mutedAccounts.user_id = c.getString(c.getColumnIndexOrThrow(Sqlite.COL_USER_ID)); mutedAccounts.accounts = restoreAccountsFromString(c.getString(c.getColumnIndexOrThrow(Sqlite.COL_MUTED_ACCOUNTS))); mutedAccounts.type = Timeline.TimeLineEnum.valueOf(c.getString(c.getColumnIndexOrThrow(Sqlite.COL_TYPE))); c.close(); return mutedAccounts; } }
app/src/main/java/app/fedilab/android/helper/Helper.java +15 −0 Original line number Diff line number Diff line Loading @@ -1953,4 +1953,19 @@ public class Helper { public interface OnAttachmentCopied { void onAttachmentCopied(Attachment attachment); } public static void addMutedAccount(app.fedilab.android.client.entities.api.Account target) { if (MainActivity.filteredAccounts == null) { MainActivity.filteredAccounts = new ArrayList<>(); } if (!MainActivity.filteredAccounts.contains(target)) { MainActivity.filteredAccounts.add(target); } } public static void removeMutedAccount(app.fedilab.android.client.entities.api.Account target) { if (MainActivity.filteredAccounts != null) { MainActivity.filteredAccounts.remove(target); } } }
app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +4 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static app.fedilab.android.helper.Helper.ARG_TIMELINE_REFRESH_ALL; import static app.fedilab.android.helper.Helper.PREF_USER_ID; import static app.fedilab.android.helper.Helper.PREF_USER_INSTANCE; import static app.fedilab.android.helper.Helper.PREF_USER_TOKEN; import static app.fedilab.android.helper.Helper.addMutedAccount; import android.annotation.SuppressLint; import android.app.Activity; Loading Loading @@ -1662,6 +1663,9 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> builderInner.setNeutralButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); builderInner.setPositiveButton(R.string.action_mute, (dialog, which) -> accountsVM.muteHome(currentAccount, statusToDeal.account) .observe((LifecycleOwner) context, account -> { if (account != null) { addMutedAccount(account); } sendAction(context, Helper.ARG_STATUS_ACCOUNT_ID_DELETED, null, statusToDeal.account.id); Toasty.info(context, context.getString(R.string.toast_mute), Toasty.LENGTH_LONG).show(); })); Loading
app/src/main/res/layout/activity_list.xml +2 −2 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="@dimen/fab_margin"> android:layout_marginHorizontal="6dp" android:orientation="vertical"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/recycler_view" Loading