mirror of
https://github.com/accelforce/Yuito
synced 2025-01-27 06:14:52 +01:00
parent
3756a1fd20
commit
30856a2f82
@ -174,13 +174,22 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
// This should only be called after setReblogged, in order to override the tint correctly.
|
||||
private void setRebloggingEnabled(boolean enabled, Status.Visibility visibility) {
|
||||
reblogButton.setEnabled(enabled);
|
||||
reblogButton.setEnabled(enabled && visibility != Status.Visibility.PRIVATE);
|
||||
|
||||
if (enabled) {
|
||||
int inactiveId = ThemeUtils.getDrawableId(reblogButton.getContext(),
|
||||
R.attr.status_reblog_inactive_drawable, R.drawable.reblog_inactive_dark);
|
||||
int inactiveId;
|
||||
int activeId;
|
||||
if (visibility == Status.Visibility.PRIVATE) {
|
||||
inactiveId = ThemeUtils.getDrawableId(reblogButton.getContext(),
|
||||
R.attr.status_reblog_disabled_drawable, R.drawable.reblog_private_dark);
|
||||
activeId = R.drawable.reblog_private_active;
|
||||
} else {
|
||||
inactiveId = ThemeUtils.getDrawableId(reblogButton.getContext(),
|
||||
R.attr.status_reblog_inactive_drawable, R.drawable.reblog_inactive_dark);
|
||||
activeId = R.drawable.reblog_active;
|
||||
}
|
||||
reblogButton.setInactiveImage(inactiveId);
|
||||
reblogButton.setActiveImage(R.drawable.reblog_active);
|
||||
reblogButton.setActiveImage(activeId);
|
||||
} else {
|
||||
int disabledId;
|
||||
if (visibility == Status.Visibility.DIRECT) {
|
||||
@ -188,7 +197,7 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||
R.attr.status_reblog_direct_drawable, R.drawable.reblog_direct_dark);
|
||||
} else {
|
||||
disabledId = ThemeUtils.getDrawableId(reblogButton.getContext(),
|
||||
R.attr.status_reblog_disabled_drawable, R.drawable.reblog_disabled_dark);
|
||||
R.attr.status_reblog_disabled_drawable, R.drawable.reblog_private_dark);
|
||||
}
|
||||
reblogButton.setInactiveImage(disabledId);
|
||||
reblogButton.setActiveImage(disabledId);
|
||||
|
@ -98,7 +98,7 @@ data class Status(
|
||||
}
|
||||
|
||||
fun rebloggingAllowed(): Boolean {
|
||||
return (visibility != Visibility.PRIVATE && visibility != Visibility.DIRECT && visibility != Visibility.UNKNOWN)
|
||||
return (visibility != Visibility.DIRECT && visibility != Visibility.UNKNOWN)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
@ -21,11 +21,11 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.BottomSheetBehavior;
|
||||
import android.support.v4.app.ActivityOptionsCompat;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.text.Spanned;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
|
||||
import com.keylesspalace.tusky.BottomSheetActivity;
|
||||
@ -66,6 +66,8 @@ public abstract class SFragment extends BaseFragment {
|
||||
protected abstract TimelineCases timelineCases();
|
||||
protected abstract void removeItem(int position);
|
||||
|
||||
protected abstract void onReblog(final boolean reblog, final int position);
|
||||
|
||||
private BottomSheetActivity bottomSheetActivity;
|
||||
|
||||
@Inject
|
||||
@ -150,6 +152,13 @@ public abstract class SFragment extends BaseFragment {
|
||||
popup.inflate(R.menu.status_more);
|
||||
} else {
|
||||
popup.inflate(R.menu.status_more_for_user);
|
||||
Menu menu = popup.getMenu();
|
||||
if (status.getVisibility() == Status.Visibility.PRIVATE) {
|
||||
boolean reblogged = status.getReblogged();
|
||||
if (status.getReblog() != null) reblogged = status.getReblog().getReblogged();
|
||||
menu.findItem(R.id.status_reblog_private).setVisible(!reblogged);
|
||||
menu.findItem(R.id.status_unreblog_private).setVisible(reblogged);
|
||||
}
|
||||
}
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
switch (item.getItemId()) {
|
||||
@ -193,6 +202,14 @@ public abstract class SFragment extends BaseFragment {
|
||||
openReportPage(accountId, accountUsename, id, content);
|
||||
return true;
|
||||
}
|
||||
case R.id.status_unreblog_private: {
|
||||
onReblog(false, position);
|
||||
return true;
|
||||
}
|
||||
case R.id.status_reblog_private: {
|
||||
onReblog(true, position);
|
||||
return true;
|
||||
}
|
||||
case R.id.status_delete: {
|
||||
timelineCases().delete(id);
|
||||
removeItem(position);
|
||||
|
9
app/src/main/res/drawable/reblog_private_active.xml
Normal file
9
app/src/main/res/drawable/reblog_private_active.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="@color/status_reblog_button_marked_dark"
|
||||
android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/>
|
||||
</vector>
|
@ -113,7 +113,7 @@
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@id/account_username"
|
||||
app:layout_constraintLeft_toRightOf="@id/account_username"
|
||||
app:srcCompat="@drawable/reblog_disabled_light"
|
||||
app:srcCompat="@drawable/reblog_private_light"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<android.support.text.emoji.widget.EmojiTextView
|
||||
|
@ -12,6 +12,8 @@
|
||||
android:title="@string/status_share_content"/>
|
||||
</menu>
|
||||
</item>
|
||||
<item android:visible="false" android:id="@+id/status_reblog_private" android:title="@string/reblog_private"/>
|
||||
<item android:visible="false" android:id="@+id/status_unreblog_private" android:title="@string/unreblog_private"/>
|
||||
<item android:title="@string/action_delete"
|
||||
android:id="@+id/status_delete" />
|
||||
</menu>
|
@ -28,7 +28,7 @@
|
||||
<item name="image_button_style">@style/AppTheme.ImageButton.Dark</item>
|
||||
<item name="status_reblog_small_drawable">@drawable/ic_reblog_dark_18dp</item>
|
||||
<item name="status_reblog_inactive_drawable">@drawable/reblog_inactive_dark</item>
|
||||
<item name="status_reblog_disabled_drawable">@drawable/reblog_disabled_dark</item>
|
||||
<item name="status_reblog_disabled_drawable">@drawable/reblog_private_dark</item>
|
||||
<item name="status_reblog_direct_drawable">@drawable/reblog_direct_dark</item>
|
||||
<item name="status_favourite_active_drawable">@drawable/favourite_active_dark</item>
|
||||
<item name="status_favourite_inactive_drawable">@drawable/favourite_inactive_dark</item>
|
||||
|
@ -332,5 +332,7 @@
|
||||
<string name="license_blobmoji">Blobmoji is licensed under the Apache license 2.0</string>
|
||||
<string name="license_twemoji">Twemoji is licensed as CC-BY 4.0 - https://creativecommons.org/licenses/by/4.0/</string>
|
||||
<string name="download_failed">Download failed</string>
|
||||
<string name="reblog_private">Boost to original audience</string>
|
||||
<string name="unreblog_private">Unboost</string>
|
||||
|
||||
</resources>
|
||||
|
@ -61,7 +61,7 @@
|
||||
<item name="image_button_style">@style/AppTheme.ImageButton.Light</item>
|
||||
<item name="status_reblog_small_drawable">@drawable/ic_reblog_light_18dp</item>
|
||||
<item name="status_reblog_inactive_drawable">@drawable/reblog_inactive_light</item>
|
||||
<item name="status_reblog_disabled_drawable">@drawable/reblog_disabled_light</item>
|
||||
<item name="status_reblog_disabled_drawable">@drawable/reblog_private_light</item>
|
||||
<item name="status_reblog_direct_drawable">@drawable/reblog_direct_light</item>
|
||||
<item name="status_favourite_active_drawable">@drawable/favourite_active_light</item>
|
||||
<item name="status_favourite_inactive_drawable">@drawable/favourite_inactive_light</item>
|
||||
|
Loading…
Reference in New Issue
Block a user