2023-01-22 15:22:59 +01:00
|
|
|
package app.fedilab.android.mastodon.activities;
|
2022-04-27 15:20:42 +02:00
|
|
|
/* Copyright 2022 Thomas Schneider
|
|
|
|
*
|
|
|
|
* This file is a part of Fedilab
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
|
|
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
|
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
|
|
* Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
|
|
|
* see <http://www.gnu.org/licenses>. */
|
|
|
|
|
|
|
|
|
2022-06-21 17:09:34 +02:00
|
|
|
import static app.fedilab.android.BaseMainActivity.currentAccount;
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
2022-04-29 17:12:03 +02:00
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Looper;
|
2022-04-27 15:20:42 +02:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.appcompat.app.ActionBar;
|
2022-12-12 11:57:41 +01:00
|
|
|
import androidx.appcompat.app.AlertDialog;
|
2022-11-15 10:51:46 +01:00
|
|
|
import androidx.lifecycle.ViewModelProvider;
|
2023-12-12 17:27:05 +01:00
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
|
2023-01-17 14:36:51 +01:00
|
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2022-11-26 16:46:26 +01:00
|
|
|
import app.fedilab.android.BaseMainActivity;
|
2023-12-12 17:27:05 +01:00
|
|
|
import app.fedilab.android.BuildConfig;
|
2022-04-27 15:20:42 +02:00
|
|
|
import app.fedilab.android.R;
|
2023-01-22 15:22:59 +01:00
|
|
|
import app.fedilab.android.activities.MainActivity;
|
2022-04-27 15:20:42 +02:00
|
|
|
import app.fedilab.android.databinding.ActivityHashtagBinding;
|
2023-01-22 15:22:59 +01:00
|
|
|
import app.fedilab.android.mastodon.client.entities.api.Filter;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.api.Status;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.app.Pinned;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.app.PinnedTimeline;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.app.StatusDraft;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.app.TagTimeline;
|
|
|
|
import app.fedilab.android.mastodon.client.entities.app.Timeline;
|
|
|
|
import app.fedilab.android.mastodon.exception.DBException;
|
|
|
|
import app.fedilab.android.mastodon.helper.Helper;
|
|
|
|
import app.fedilab.android.mastodon.ui.fragment.timeline.FragmentMastodonTimeline;
|
|
|
|
import app.fedilab.android.mastodon.viewmodel.mastodon.FiltersVM;
|
|
|
|
import app.fedilab.android.mastodon.viewmodel.mastodon.ReorderVM;
|
|
|
|
import app.fedilab.android.mastodon.viewmodel.mastodon.TagVM;
|
2022-04-27 15:20:42 +02:00
|
|
|
import es.dmoral.toasty.Toasty;
|
|
|
|
|
|
|
|
|
|
|
|
public class HashTagActivity extends BaseActivity {
|
|
|
|
|
|
|
|
|
|
|
|
public static int position;
|
|
|
|
private String tag;
|
2022-12-12 18:29:49 +01:00
|
|
|
private String stripTag;
|
2022-12-12 11:57:41 +01:00
|
|
|
private Boolean pinnedTag;
|
|
|
|
private Boolean followedTag;
|
|
|
|
private Boolean mutedTag;
|
2022-11-15 10:51:46 +01:00
|
|
|
private TagVM tagVM;
|
2022-11-26 16:46:26 +01:00
|
|
|
private Filter fedilabFilter;
|
2022-12-12 11:57:41 +01:00
|
|
|
private Filter.KeywordsAttributes keyword;
|
|
|
|
private PinnedTimeline pinnedTimeline;
|
|
|
|
private Pinned pinned;
|
2022-04-27 15:20:42 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
2022-11-28 10:37:57 +01:00
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
ActivityHashtagBinding binding = ActivityHashtagBinding.inflate(getLayoutInflater());
|
|
|
|
|
|
|
|
setContentView(binding.getRoot());
|
|
|
|
Bundle b = getIntent().getExtras();
|
|
|
|
if (b != null) {
|
|
|
|
tag = b.getString(Helper.ARG_SEARCH_KEYWORD, null);
|
|
|
|
}
|
|
|
|
if (tag == null)
|
|
|
|
finish();
|
2022-12-12 11:57:41 +01:00
|
|
|
pinnedTag = null;
|
|
|
|
followedTag = null;
|
|
|
|
mutedTag = null;
|
2022-12-12 18:29:49 +01:00
|
|
|
stripTag = tag.replaceAll("#", "");
|
2022-04-27 15:20:42 +02:00
|
|
|
setSupportActionBar(binding.toolbar);
|
|
|
|
ActionBar actionBar = getSupportActionBar();
|
|
|
|
//Remove title
|
|
|
|
if (actionBar != null) {
|
|
|
|
actionBar.setDisplayShowTitleEnabled(false);
|
|
|
|
}
|
|
|
|
binding.title.setText(tag);
|
|
|
|
if (getSupportActionBar() != null) {
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
|
|
|
}
|
|
|
|
|
2022-11-15 10:51:46 +01:00
|
|
|
tagVM = new ViewModelProvider(HashTagActivity.this).get(TagVM.class);
|
2022-12-12 18:29:49 +01:00
|
|
|
tagVM.getTag(MainActivity.currentInstance, MainActivity.currentToken, stripTag).observe(this, returnedTag -> {
|
2022-11-15 10:51:46 +01:00
|
|
|
if (returnedTag != null) {
|
|
|
|
followedTag = returnedTag.following;
|
|
|
|
invalidateOptionsMenu();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
ReorderVM reorderVM = new ViewModelProvider(HashTagActivity.this).get(ReorderVM.class);
|
|
|
|
reorderVM.getAllPinned().observe(HashTagActivity.this, pinned -> {
|
2023-01-11 17:35:46 +01:00
|
|
|
if (pinned == null) {
|
|
|
|
pinned = new Pinned();
|
|
|
|
pinned.pinnedTimelines = new ArrayList<>();
|
|
|
|
}
|
2023-01-15 14:48:23 +01:00
|
|
|
this.pinned = pinned;
|
2023-01-11 17:35:46 +01:00
|
|
|
pinnedTag = false;
|
|
|
|
if (pinned.pinnedTimelines != null) {
|
|
|
|
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
|
|
|
|
if (pinnedTimeline.tagTimeline != null) {
|
|
|
|
if (pinnedTimeline.tagTimeline.name.equalsIgnoreCase(stripTag)) {
|
|
|
|
this.pinnedTimeline = pinnedTimeline;
|
|
|
|
pinnedTag = true;
|
|
|
|
break;
|
2022-11-15 10:51:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-11 17:35:46 +01:00
|
|
|
invalidateOptionsMenu();
|
2022-11-15 10:51:46 +01:00
|
|
|
}
|
|
|
|
});
|
2022-11-26 16:46:26 +01:00
|
|
|
if (MainActivity.filterFetched && MainActivity.mainFilters != null) {
|
2022-12-12 11:57:41 +01:00
|
|
|
mutedTag = false;
|
2022-11-26 16:46:26 +01:00
|
|
|
for (Filter filter : MainActivity.mainFilters) {
|
|
|
|
if (filter.title.equalsIgnoreCase(Helper.FEDILAB_MUTED_HASHTAGS)) {
|
|
|
|
fedilabFilter = filter;
|
|
|
|
String fetch = tag.startsWith("#") ? tag : "#" + tag;
|
|
|
|
for (Filter.KeywordsAttributes keywordsAttributes : filter.keywords) {
|
|
|
|
if (fetch.equalsIgnoreCase(keywordsAttributes.keyword)) {
|
|
|
|
mutedTag = true;
|
2022-12-12 11:57:41 +01:00
|
|
|
keyword = keywordsAttributes;
|
2022-11-26 16:46:26 +01:00
|
|
|
invalidateOptionsMenu();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-12-12 11:57:41 +01:00
|
|
|
invalidateOptionsMenu();
|
2022-11-26 16:46:26 +01:00
|
|
|
}
|
2022-11-15 10:51:46 +01:00
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
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);
|
|
|
|
binding.compose.setOnClickListener(v -> {
|
|
|
|
Intent intentToot = new Intent(HashTagActivity.this, ComposeActivity.class);
|
|
|
|
StatusDraft statusDraft = new StatusDraft();
|
|
|
|
Status status = new Status();
|
2022-12-12 18:29:49 +01:00
|
|
|
status.text = "#" + stripTag;
|
2022-04-27 15:20:42 +02:00
|
|
|
List<Status> statuses = new ArrayList<>();
|
|
|
|
statuses.add(status);
|
|
|
|
statusDraft.statusDraftList = statuses;
|
|
|
|
Bundle _b = new Bundle();
|
2022-12-12 18:29:49 +01:00
|
|
|
_b.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
|
2022-04-27 15:20:42 +02:00
|
|
|
intentToot.putExtras(_b);
|
|
|
|
startActivity(intentToot);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
if (item.getItemId() == android.R.id.home) {
|
|
|
|
finish();
|
|
|
|
return true;
|
|
|
|
} else if (item.getItemId() == R.id.action_add_timeline) {
|
2022-12-12 11:57:41 +01:00
|
|
|
|
|
|
|
if (pinnedTag) {
|
2023-01-30 18:15:12 +01:00
|
|
|
AlertDialog.Builder unpinConfirm = new MaterialAlertDialogBuilder(HashTagActivity.this);
|
2022-12-12 11:57:41 +01:00
|
|
|
unpinConfirm.setMessage(getString(R.string.unpin_timeline_description));
|
|
|
|
unpinConfirm.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
|
|
|
unpinConfirm.setPositiveButton(R.string.yes, (dialog, which) -> {
|
2023-01-15 14:48:23 +01:00
|
|
|
if (pinned == null || pinned.pinnedTimelines == null) {
|
|
|
|
return;
|
|
|
|
}
|
2022-12-12 11:57:41 +01:00
|
|
|
pinned.pinnedTimelines.remove(pinnedTimeline);
|
|
|
|
try {
|
2022-04-27 15:20:42 +02:00
|
|
|
new Pinned(HashTagActivity.this).updatePinned(pinned);
|
2022-12-12 11:57:41 +01:00
|
|
|
} catch (DBException e) {
|
|
|
|
e.printStackTrace();
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
2022-12-12 11:57:41 +01:00
|
|
|
pinnedTag = false;
|
|
|
|
invalidateOptionsMenu();
|
2022-04-27 15:20:42 +02:00
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
|
|
|
|
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
|
|
|
|
intentBD.putExtras(b);
|
2023-12-12 17:27:05 +01:00
|
|
|
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
|
|
|
sendBroadcast(intentBD);
|
2022-12-12 11:57:41 +01:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
unpinConfirm.show();
|
|
|
|
} else {
|
|
|
|
new Thread(() -> {
|
|
|
|
try {
|
|
|
|
Pinned pinned = new Pinned(HashTagActivity.this).getPinned(currentAccount);
|
|
|
|
boolean canBeAdded = true;
|
|
|
|
boolean update = true;
|
|
|
|
if (pinned == null) {
|
|
|
|
pinned = new Pinned();
|
|
|
|
pinned.pinnedTimelines = new ArrayList<>();
|
|
|
|
update = false;
|
|
|
|
} else {
|
|
|
|
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
|
|
|
|
if (pinnedTimeline.type == Timeline.TimeLineEnum.TAG) {
|
2022-12-12 18:29:49 +01:00
|
|
|
if (pinnedTimeline.tagTimeline.name.compareTo(stripTag.trim()) == 0) {
|
2022-12-12 11:57:41 +01:00
|
|
|
canBeAdded = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!canBeAdded) {
|
|
|
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
|
|
|
Runnable myRunnable = () -> Toasty.warning(HashTagActivity.this, getString(R.string.tags_already_stored), Toasty.LENGTH_SHORT).show();
|
|
|
|
mainHandler.post(myRunnable);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pinnedTimeline = new PinnedTimeline();
|
|
|
|
pinnedTimeline.type = Timeline.TimeLineEnum.TAG;
|
|
|
|
pinnedTimeline.position = pinned.pinnedTimelines.size();
|
|
|
|
pinnedTimeline.displayed = true;
|
|
|
|
TagTimeline tagTimeline = new TagTimeline();
|
2022-12-12 18:29:49 +01:00
|
|
|
tagTimeline.name = stripTag.trim();
|
2022-12-12 11:57:41 +01:00
|
|
|
tagTimeline.isNSFW = false;
|
|
|
|
tagTimeline.isART = false;
|
2023-01-04 11:53:51 +01:00
|
|
|
tagTimeline.any = new ArrayList<>();
|
|
|
|
tagTimeline.any.add(stripTag.trim());
|
2022-12-12 11:57:41 +01:00
|
|
|
pinnedTimeline.tagTimeline = tagTimeline;
|
|
|
|
pinned.pinnedTimelines.add(pinnedTimeline);
|
2023-02-03 17:23:33 +01:00
|
|
|
if (pinned.instance == null || pinned.user_id == null) {
|
|
|
|
pinned.instance = MainActivity.currentInstance;
|
|
|
|
pinned.user_id = MainActivity.currentUserID;
|
|
|
|
}
|
2022-12-12 11:57:41 +01:00
|
|
|
if (update) {
|
|
|
|
new Pinned(HashTagActivity.this).updatePinned(pinned);
|
|
|
|
} else {
|
|
|
|
new Pinned(HashTagActivity.this).insertPinned(pinned);
|
|
|
|
}
|
|
|
|
Bundle b = new Bundle();
|
|
|
|
b.putBoolean(Helper.RECEIVE_REDRAW_TOPBAR, true);
|
|
|
|
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
|
|
|
|
intentBD.putExtras(b);
|
2023-12-12 17:27:05 +01:00
|
|
|
intentBD.setPackage(BuildConfig.APPLICATION_ID);
|
|
|
|
sendBroadcast(intentBD);
|
2022-12-12 11:57:41 +01:00
|
|
|
pinnedTag = true;
|
|
|
|
invalidateOptionsMenu();
|
|
|
|
} catch (DBException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
}
|
2022-11-15 10:51:46 +01:00
|
|
|
} else if (item.getItemId() == R.id.action_follow_tag) {
|
2022-12-12 11:57:41 +01:00
|
|
|
if (!followedTag) {
|
2022-12-12 18:29:49 +01:00
|
|
|
tagVM.follow(MainActivity.currentInstance, MainActivity.currentToken, stripTag).observe(this, returnedTag -> {
|
2022-12-12 11:57:41 +01:00
|
|
|
if (returnedTag != null) {
|
|
|
|
followedTag = returnedTag.following;
|
|
|
|
invalidateOptionsMenu();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2022-12-12 18:29:49 +01:00
|
|
|
tagVM.unfollow(MainActivity.currentInstance, MainActivity.currentToken, stripTag).observe(this, returnedTag -> {
|
2022-12-12 11:57:41 +01:00
|
|
|
if (returnedTag != null) {
|
|
|
|
followedTag = returnedTag.following;
|
|
|
|
invalidateOptionsMenu();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-11-26 16:46:26 +01:00
|
|
|
} else if (item.getItemId() == R.id.action_mute) {
|
2022-11-26 18:28:00 +01:00
|
|
|
|
2022-12-12 11:57:41 +01:00
|
|
|
if (!mutedTag) {
|
|
|
|
if (MainActivity.mainFilters == null || fedilabFilter == null) {
|
|
|
|
MainActivity.mainFilters = new ArrayList<>();
|
|
|
|
Filter.FilterParams filterParams = new Filter.FilterParams();
|
|
|
|
filterParams.title = Helper.FEDILAB_MUTED_HASHTAGS;
|
|
|
|
filterParams.filter_action = "hide";
|
|
|
|
filterParams.context = new ArrayList<>();
|
|
|
|
filterParams.context.add("home");
|
|
|
|
filterParams.context.add("public");
|
|
|
|
filterParams.context.add("thread");
|
|
|
|
filterParams.context.add("account");
|
|
|
|
FiltersVM filtersVM = new ViewModelProvider(HashTagActivity.this).get(FiltersVM.class);
|
|
|
|
filtersVM.addFilter(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, filterParams)
|
|
|
|
.observe(HashTagActivity.this, filter -> {
|
|
|
|
if (filter != null) {
|
|
|
|
MainActivity.mainFilters.add(filter);
|
|
|
|
mutedTag = false;
|
|
|
|
fedilabFilter = filter;
|
|
|
|
muteTags();
|
|
|
|
invalidateOptionsMenu();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
muteTags();
|
|
|
|
}
|
2022-11-26 18:28:00 +01:00
|
|
|
} else {
|
2022-12-12 11:57:41 +01:00
|
|
|
unmuteTags();
|
2022-11-26 18:28:00 +01:00
|
|
|
}
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-12-12 11:57:41 +01:00
|
|
|
private void unmuteTags() {
|
|
|
|
String search = tag.startsWith("#") ? tag : "#" + tag;
|
|
|
|
for (Filter.KeywordsAttributes keywordsAttributes : fedilabFilter.keywords) {
|
|
|
|
if (search.equalsIgnoreCase(keywordsAttributes.keyword)) {
|
|
|
|
keyword = keywordsAttributes;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (keyword != null && keyword.id != null) {
|
|
|
|
FiltersVM filtersVM = new ViewModelProvider(HashTagActivity.this).get(FiltersVM.class);
|
|
|
|
filtersVM.removeKeyword(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, keyword.id);
|
|
|
|
fedilabFilter.keywords.remove(keyword);
|
|
|
|
mutedTag = false;
|
|
|
|
invalidateOptionsMenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-26 18:28:00 +01:00
|
|
|
private void muteTags() {
|
|
|
|
Filter.FilterParams filterParams = new Filter.FilterParams();
|
|
|
|
filterParams.id = fedilabFilter.id;
|
|
|
|
filterParams.keywords = new ArrayList<>();
|
|
|
|
Filter.KeywordsParams keywordsParams = new Filter.KeywordsParams();
|
|
|
|
keywordsParams.whole_word = true;
|
|
|
|
keywordsParams.keyword = tag.startsWith("#") ? tag : "#" + tag;
|
|
|
|
filterParams.keywords.add(keywordsParams);
|
|
|
|
filterParams.context = fedilabFilter.context;
|
|
|
|
FiltersVM filtersVM = new ViewModelProvider(HashTagActivity.this).get(FiltersVM.class);
|
|
|
|
filtersVM.editFilter(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, filterParams)
|
|
|
|
.observe(HashTagActivity.this, filter -> {
|
2022-12-12 11:57:41 +01:00
|
|
|
fedilabFilter = filter;
|
2022-11-26 18:28:00 +01:00
|
|
|
mutedTag = true;
|
|
|
|
invalidateOptionsMenu();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-04-27 15:20:42 +02:00
|
|
|
@Override
|
|
|
|
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
2022-11-15 10:51:46 +01:00
|
|
|
getMenuInflater().inflate(R.menu.menu_hashtag, menu);
|
|
|
|
MenuItem pin = menu.findItem(R.id.action_add_timeline);
|
|
|
|
MenuItem follow = menu.findItem(R.id.action_follow_tag);
|
2022-11-26 16:46:26 +01:00
|
|
|
MenuItem mute = menu.findItem(R.id.action_mute);
|
2022-12-12 11:57:41 +01:00
|
|
|
if (pinnedTag != null) {
|
|
|
|
pin.setVisible(true);
|
|
|
|
if (pinnedTag) {
|
|
|
|
pin.setIcon(R.drawable.tag_pin_off);
|
|
|
|
pin.setTitle(getString(R.string.unpin_tag));
|
|
|
|
} else {
|
2023-02-05 22:02:12 +01:00
|
|
|
pin.setTitle(getString(R.string.pin_tag));
|
2022-12-12 11:57:41 +01:00
|
|
|
pin.setIcon(R.drawable.tag_pin);
|
|
|
|
}
|
|
|
|
} else {
|
2022-11-15 10:51:46 +01:00
|
|
|
pin.setVisible(false);
|
|
|
|
}
|
2022-12-12 11:57:41 +01:00
|
|
|
if (followedTag != null) {
|
|
|
|
follow.setVisible(true);
|
|
|
|
if (followedTag) {
|
|
|
|
follow.setTitle(getString(R.string.unfollow_tag));
|
|
|
|
follow.setIcon(R.drawable.tag_unfollow);
|
|
|
|
} else {
|
|
|
|
follow.setTitle(getString(R.string.follow_tag));
|
|
|
|
follow.setIcon(R.drawable.tag_follow);
|
|
|
|
}
|
|
|
|
} else {
|
2022-11-15 10:51:46 +01:00
|
|
|
follow.setVisible(false);
|
|
|
|
}
|
2022-12-12 11:57:41 +01:00
|
|
|
if (mutedTag != null) {
|
|
|
|
mute.setVisible(true);
|
|
|
|
if (mutedTag) {
|
|
|
|
mute.setTitle(getString(R.string.unmute_tag_action));
|
|
|
|
mute.setIcon(R.drawable.tag_unmuted);
|
|
|
|
} else {
|
|
|
|
mute.setTitle(getString(R.string.mute_tag_action));
|
|
|
|
mute.setIcon(R.drawable.tag_muted);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mute.setVisible(false);
|
|
|
|
}
|
2022-04-27 15:20:42 +02:00
|
|
|
return super.onCreateOptionsMenu(menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|