forked from mirrors/Fedilab
Automatically attach tag to message when composing from a tag timeline
This commit is contained in:
parent
c59b1e6f3f
commit
6fc8275aee
1 changed files with 10 additions and 8 deletions
|
@ -57,6 +57,7 @@ public class HashTagActivity extends BaseActivity {
|
||||||
|
|
||||||
public static int position;
|
public static int position;
|
||||||
private String tag;
|
private String tag;
|
||||||
|
private String stripTag;
|
||||||
private Boolean pinnedTag;
|
private Boolean pinnedTag;
|
||||||
private Boolean followedTag;
|
private Boolean followedTag;
|
||||||
private Boolean mutedTag;
|
private Boolean mutedTag;
|
||||||
|
@ -82,6 +83,7 @@ public class HashTagActivity extends BaseActivity {
|
||||||
pinnedTag = null;
|
pinnedTag = null;
|
||||||
followedTag = null;
|
followedTag = null;
|
||||||
mutedTag = null;
|
mutedTag = null;
|
||||||
|
stripTag = tag.replaceAll("#", "");
|
||||||
setSupportActionBar(binding.toolbar);
|
setSupportActionBar(binding.toolbar);
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
//Remove title
|
//Remove title
|
||||||
|
@ -95,7 +97,7 @@ public class HashTagActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
tagVM = new ViewModelProvider(HashTagActivity.this).get(TagVM.class);
|
tagVM = new ViewModelProvider(HashTagActivity.this).get(TagVM.class);
|
||||||
tagVM.getTag(MainActivity.currentInstance, MainActivity.currentToken, tag).observe(this, returnedTag -> {
|
tagVM.getTag(MainActivity.currentInstance, MainActivity.currentToken, stripTag).observe(this, returnedTag -> {
|
||||||
if (returnedTag != null) {
|
if (returnedTag != null) {
|
||||||
followedTag = returnedTag.following;
|
followedTag = returnedTag.following;
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
|
@ -109,7 +111,7 @@ public class HashTagActivity extends BaseActivity {
|
||||||
if (pinned.pinnedTimelines != null) {
|
if (pinned.pinnedTimelines != null) {
|
||||||
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
|
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
|
||||||
if (pinnedTimeline.tagTimeline != null) {
|
if (pinnedTimeline.tagTimeline != null) {
|
||||||
if (pinnedTimeline.tagTimeline.name.equalsIgnoreCase(tag)) {
|
if (pinnedTimeline.tagTimeline.name.equalsIgnoreCase(stripTag)) {
|
||||||
this.pinnedTimeline = pinnedTimeline;
|
this.pinnedTimeline = pinnedTimeline;
|
||||||
pinnedTag = true;
|
pinnedTag = true;
|
||||||
break;
|
break;
|
||||||
|
@ -147,12 +149,12 @@ public class HashTagActivity extends BaseActivity {
|
||||||
Intent intentToot = new Intent(HashTagActivity.this, ComposeActivity.class);
|
Intent intentToot = new Intent(HashTagActivity.this, ComposeActivity.class);
|
||||||
StatusDraft statusDraft = new StatusDraft();
|
StatusDraft statusDraft = new StatusDraft();
|
||||||
Status status = new Status();
|
Status status = new Status();
|
||||||
status.text = "#" + tag;
|
status.text = "#" + stripTag;
|
||||||
List<Status> statuses = new ArrayList<>();
|
List<Status> statuses = new ArrayList<>();
|
||||||
statuses.add(status);
|
statuses.add(status);
|
||||||
statusDraft.statusDraftList = statuses;
|
statusDraft.statusDraftList = statuses;
|
||||||
Bundle _b = new Bundle();
|
Bundle _b = new Bundle();
|
||||||
_b.putSerializable(Helper.ARG_TAG_TIMELINE, statusDraft);
|
_b.putSerializable(Helper.ARG_STATUS_DRAFT, statusDraft);
|
||||||
intentToot.putExtras(_b);
|
intentToot.putExtras(_b);
|
||||||
startActivity(intentToot);
|
startActivity(intentToot);
|
||||||
});
|
});
|
||||||
|
@ -199,7 +201,7 @@ public class HashTagActivity extends BaseActivity {
|
||||||
} else {
|
} else {
|
||||||
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
|
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
|
||||||
if (pinnedTimeline.type == Timeline.TimeLineEnum.TAG) {
|
if (pinnedTimeline.type == Timeline.TimeLineEnum.TAG) {
|
||||||
if (pinnedTimeline.tagTimeline.name.compareTo(tag.trim()) == 0) {
|
if (pinnedTimeline.tagTimeline.name.compareTo(stripTag.trim()) == 0) {
|
||||||
canBeAdded = false;
|
canBeAdded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +218,7 @@ public class HashTagActivity extends BaseActivity {
|
||||||
pinnedTimeline.position = pinned.pinnedTimelines.size();
|
pinnedTimeline.position = pinned.pinnedTimelines.size();
|
||||||
pinnedTimeline.displayed = true;
|
pinnedTimeline.displayed = true;
|
||||||
TagTimeline tagTimeline = new TagTimeline();
|
TagTimeline tagTimeline = new TagTimeline();
|
||||||
tagTimeline.name = tag.trim();
|
tagTimeline.name = stripTag.trim();
|
||||||
tagTimeline.isNSFW = false;
|
tagTimeline.isNSFW = false;
|
||||||
tagTimeline.isART = false;
|
tagTimeline.isART = false;
|
||||||
pinnedTimeline.tagTimeline = tagTimeline;
|
pinnedTimeline.tagTimeline = tagTimeline;
|
||||||
|
@ -240,14 +242,14 @@ public class HashTagActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
} else if (item.getItemId() == R.id.action_follow_tag) {
|
} else if (item.getItemId() == R.id.action_follow_tag) {
|
||||||
if (!followedTag) {
|
if (!followedTag) {
|
||||||
tagVM.follow(MainActivity.currentInstance, MainActivity.currentToken, tag).observe(this, returnedTag -> {
|
tagVM.follow(MainActivity.currentInstance, MainActivity.currentToken, stripTag).observe(this, returnedTag -> {
|
||||||
if (returnedTag != null) {
|
if (returnedTag != null) {
|
||||||
followedTag = returnedTag.following;
|
followedTag = returnedTag.following;
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
tagVM.unfollow(MainActivity.currentInstance, MainActivity.currentToken, tag).observe(this, returnedTag -> {
|
tagVM.unfollow(MainActivity.currentInstance, MainActivity.currentToken, stripTag).observe(this, returnedTag -> {
|
||||||
if (returnedTag != null) {
|
if (returnedTag != null) {
|
||||||
followedTag = returnedTag.following;
|
followedTag = returnedTag.following;
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
|
|
Loading…
Reference in a new issue