Loading app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java +18 −9 Original line number Diff line number Diff line Loading @@ -70,17 +70,26 @@ public class HashTagActivity extends BaseActivity { private Filter.KeywordsAttributes keyword; private PinnedTimeline pinnedTimeline; private Pinned pinned; private ActivityHashtagBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActivityHashtagBinding binding = ActivityHashtagBinding.inflate(getLayoutInflater()); binding = ActivityHashtagBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); Bundle b = getIntent().getExtras(); if (b != null) { tag = b.getString(Helper.ARG_SEARCH_KEYWORD, null); Bundle args = getIntent().getExtras(); if (args != null) { long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1); new CachedBundle(HashTagActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { initializeAfterBundle(null); } } private void initializeAfterBundle(Bundle bundle) { if( bundle != null) { tag = bundle.getString(Helper.ARG_SEARCH_KEYWORD, null); } if (tag == null) finish(); Loading Loading @@ -147,10 +156,10 @@ public class HashTagActivity extends BaseActivity { invalidateOptionsMenu(); } Bundle bundle = new Bundle(); bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.TAG); bundle.putString(Helper.ARG_SEARCH_KEYWORD, tag); Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_tags, new FragmentMastodonTimeline(), bundle, null, null); Bundle bundleFragment = new Bundle(); bundleFragment.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.TAG); bundleFragment.putString(Helper.ARG_SEARCH_KEYWORD, tag); Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_tags, new FragmentMastodonTimeline(), bundleFragment, null, null); binding.compose.setOnClickListener(v -> { Intent intentToot = new Intent(HashTagActivity.this, ComposeActivity.class); StatusDraft statusDraft = new StatusDraft(); Loading app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java +20 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,26 @@ public class CachedBundle { } public long insertAccountBundle(Account account, BaseAccount currentUser) throws DBException { if (db == null) { throw new DBException("db is null. Wrong initialization."); } ContentValues valuesAccount = new ContentValues(); Bundle bundleAccount = new Bundle(); if (account != null) { bundleAccount.putSerializable(Helper.ARG_ACCOUNT, account); valuesAccount.put(Sqlite.COL_BUNDLE, serializeBundle(bundleAccount)); valuesAccount.put(Sqlite.COL_CREATED_AT, Helper.dateToString(new Date())); valuesAccount.put(Sqlite.COL_TARGET_ID, account.id); valuesAccount.put(Sqlite.COL_USER_ID, currentUser.user_id); valuesAccount.put(Sqlite.COL_INSTANCE, currentUser.instance); valuesAccount.put(Sqlite.COL_TYPE, CacheType.ACCOUNT.getValue()); removeIntent(currentUser, account.id); return db.insertOrThrow(Sqlite.TABLE_INTENT, null, valuesAccount); } return -1; } /** * Insert a bundle in db * Loading app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java +21 −13 Original line number Diff line number Diff line Loading @@ -279,19 +279,23 @@ public class SpannableHelper { public void onClick(@NonNull View textView) { textView.setTag(CLICKABLE_SPAN); Intent intent; Bundle b; Bundle args; if (word.startsWith("#")) { intent = new Intent(context, HashTagActivity.class); b = new Bundle(); b.putString(Helper.ARG_SEARCH_KEYWORD, word.trim()); intent.putExtras(b); args = new Bundle(); args.putString(Helper.ARG_SEARCH_KEYWORD, word.trim()); new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }); } else if (word.startsWith("@")) { intent = new Intent(context, ProfileActivity.class); b = new Bundle(); args = new Bundle(); Mention targetedMention = null; for (Mention mention : mentions) { if (word.compareToIgnoreCase("@" + mention.username) == 0) { targetedMention = mention; Loading @@ -299,13 +303,17 @@ public class SpannableHelper { } } if (targetedMention != null) { b.putString(Helper.ARG_USER_ID, targetedMention.id); args.putString(Helper.ARG_USER_ID, targetedMention.id); } else { b.putString(Helper.ARG_MENTION, word); args.putString(Helper.ARG_MENTION, word); } intent.putExtras(b); new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }); } } Loading app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AccountsVM.java +8 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ package app.fedilab.android.mastodon.viewmodel.mastodon; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see <http://www.gnu.org/licenses>. */ import static app.fedilab.android.BaseMainActivity.currentAccount; import android.app.Application; import android.net.Uri; import android.os.Handler; Loading @@ -30,6 +32,7 @@ import java.util.List; import app.fedilab.android.R; import app.fedilab.android.activities.MainActivity; import app.fedilab.android.mastodon.activities.ProfileActivity; import app.fedilab.android.mastodon.client.endpoints.MastodonAccountsService; import app.fedilab.android.mastodon.client.entities.api.Account; import app.fedilab.android.mastodon.client.entities.api.Accounts; Loading @@ -52,6 +55,7 @@ import app.fedilab.android.mastodon.client.entities.api.Suggestions; import app.fedilab.android.mastodon.client.entities.api.Tag; import app.fedilab.android.mastodon.client.entities.api.Token; 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.MutedAccounts; import app.fedilab.android.mastodon.client.entities.app.StatusCache; import app.fedilab.android.mastodon.exception.DBException; Loading Loading @@ -342,6 +346,7 @@ public class AccountsVM extends AndroidViewModel { Response<Account> accountResponse = accountCall.execute(); if (accountResponse.isSuccessful()) { account = accountResponse.body(); new CachedBundle(getApplication().getApplicationContext()).insertAccountBundle(account, currentAccount); } } catch (Exception e) { e.printStackTrace(); Loading Loading @@ -1073,6 +1078,9 @@ public class AccountsVM extends AndroidViewModel { Response<List<Account>> searchResponse = searchCall.execute(); if (searchResponse.isSuccessful()) { accountList = searchResponse.body(); if(accountList != null && accountList.size() > 0 ) { new CachedBundle(getApplication().getApplicationContext()).insertAccountBundle(accountList.get(0), currentAccount); } } } catch (Exception e) { e.printStackTrace(); Loading Loading
app/src/main/java/app/fedilab/android/mastodon/activities/HashTagActivity.java +18 −9 Original line number Diff line number Diff line Loading @@ -70,17 +70,26 @@ public class HashTagActivity extends BaseActivity { private Filter.KeywordsAttributes keyword; private PinnedTimeline pinnedTimeline; private Pinned pinned; private ActivityHashtagBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActivityHashtagBinding binding = ActivityHashtagBinding.inflate(getLayoutInflater()); binding = ActivityHashtagBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); Bundle b = getIntent().getExtras(); if (b != null) { tag = b.getString(Helper.ARG_SEARCH_KEYWORD, null); Bundle args = getIntent().getExtras(); if (args != null) { long bundleId = args.getLong(Helper.ARG_INTENT_ID, -1); new CachedBundle(HashTagActivity.this).getBundle(bundleId, currentAccount, this::initializeAfterBundle); } else { initializeAfterBundle(null); } } private void initializeAfterBundle(Bundle bundle) { if( bundle != null) { tag = bundle.getString(Helper.ARG_SEARCH_KEYWORD, null); } if (tag == null) finish(); Loading Loading @@ -147,10 +156,10 @@ public class HashTagActivity extends BaseActivity { invalidateOptionsMenu(); } Bundle bundle = new Bundle(); bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.TAG); bundle.putString(Helper.ARG_SEARCH_KEYWORD, tag); Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_tags, new FragmentMastodonTimeline(), bundle, null, null); Bundle bundleFragment = new Bundle(); bundleFragment.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.TAG); bundleFragment.putString(Helper.ARG_SEARCH_KEYWORD, tag); Helper.addFragment(getSupportFragmentManager(), R.id.nav_host_fragment_tags, new FragmentMastodonTimeline(), bundleFragment, null, null); binding.compose.setOnClickListener(v -> { Intent intentToot = new Intent(HashTagActivity.this, ComposeActivity.class); StatusDraft statusDraft = new StatusDraft(); Loading
app/src/main/java/app/fedilab/android/mastodon/client/entities/app/CachedBundle.java +20 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,26 @@ public class CachedBundle { } public long insertAccountBundle(Account account, BaseAccount currentUser) throws DBException { if (db == null) { throw new DBException("db is null. Wrong initialization."); } ContentValues valuesAccount = new ContentValues(); Bundle bundleAccount = new Bundle(); if (account != null) { bundleAccount.putSerializable(Helper.ARG_ACCOUNT, account); valuesAccount.put(Sqlite.COL_BUNDLE, serializeBundle(bundleAccount)); valuesAccount.put(Sqlite.COL_CREATED_AT, Helper.dateToString(new Date())); valuesAccount.put(Sqlite.COL_TARGET_ID, account.id); valuesAccount.put(Sqlite.COL_USER_ID, currentUser.user_id); valuesAccount.put(Sqlite.COL_INSTANCE, currentUser.instance); valuesAccount.put(Sqlite.COL_TYPE, CacheType.ACCOUNT.getValue()); removeIntent(currentUser, account.id); return db.insertOrThrow(Sqlite.TABLE_INTENT, null, valuesAccount); } return -1; } /** * Insert a bundle in db * Loading
app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java +21 −13 Original line number Diff line number Diff line Loading @@ -279,19 +279,23 @@ public class SpannableHelper { public void onClick(@NonNull View textView) { textView.setTag(CLICKABLE_SPAN); Intent intent; Bundle b; Bundle args; if (word.startsWith("#")) { intent = new Intent(context, HashTagActivity.class); b = new Bundle(); b.putString(Helper.ARG_SEARCH_KEYWORD, word.trim()); intent.putExtras(b); args = new Bundle(); args.putString(Helper.ARG_SEARCH_KEYWORD, word.trim()); new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }); } else if (word.startsWith("@")) { intent = new Intent(context, ProfileActivity.class); b = new Bundle(); args = new Bundle(); Mention targetedMention = null; for (Mention mention : mentions) { if (word.compareToIgnoreCase("@" + mention.username) == 0) { targetedMention = mention; Loading @@ -299,13 +303,17 @@ public class SpannableHelper { } } if (targetedMention != null) { b.putString(Helper.ARG_USER_ID, targetedMention.id); args.putString(Helper.ARG_USER_ID, targetedMention.id); } else { b.putString(Helper.ARG_MENTION, word); args.putString(Helper.ARG_MENTION, word); } intent.putExtras(b); new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> { Bundle bundle = new Bundle(); bundle.putLong(Helper.ARG_INTENT_ID, bundleId); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }); } } Loading
app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/AccountsVM.java +8 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ package app.fedilab.android.mastodon.viewmodel.mastodon; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see <http://www.gnu.org/licenses>. */ import static app.fedilab.android.BaseMainActivity.currentAccount; import android.app.Application; import android.net.Uri; import android.os.Handler; Loading @@ -30,6 +32,7 @@ import java.util.List; import app.fedilab.android.R; import app.fedilab.android.activities.MainActivity; import app.fedilab.android.mastodon.activities.ProfileActivity; import app.fedilab.android.mastodon.client.endpoints.MastodonAccountsService; import app.fedilab.android.mastodon.client.entities.api.Account; import app.fedilab.android.mastodon.client.entities.api.Accounts; Loading @@ -52,6 +55,7 @@ import app.fedilab.android.mastodon.client.entities.api.Suggestions; import app.fedilab.android.mastodon.client.entities.api.Tag; import app.fedilab.android.mastodon.client.entities.api.Token; 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.MutedAccounts; import app.fedilab.android.mastodon.client.entities.app.StatusCache; import app.fedilab.android.mastodon.exception.DBException; Loading Loading @@ -342,6 +346,7 @@ public class AccountsVM extends AndroidViewModel { Response<Account> accountResponse = accountCall.execute(); if (accountResponse.isSuccessful()) { account = accountResponse.body(); new CachedBundle(getApplication().getApplicationContext()).insertAccountBundle(account, currentAccount); } } catch (Exception e) { e.printStackTrace(); Loading Loading @@ -1073,6 +1078,9 @@ public class AccountsVM extends AndroidViewModel { Response<List<Account>> searchResponse = searchCall.execute(); if (searchResponse.isSuccessful()) { accountList = searchResponse.body(); if(accountList != null && accountList.size() > 0 ) { new CachedBundle(getApplication().getApplicationContext()).insertAccountBundle(accountList.get(0), currentAccount); } } } catch (Exception e) { e.printStackTrace(); Loading