Enable boosting of own private toots, closes #664 (#666)

main
Paul 7 years ago committed by Konrad Pozniak
parent 0375193029
commit dcb96597c4
  1. 17
      app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java
  2. 2
      app/src/main/java/com/keylesspalace/tusky/entity/Status.kt
  3. 19
      app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java
  4. 9
      app/src/main/res/drawable/reblog_private_active.xml
  5. 0
      app/src/main/res/drawable/reblog_private_dark.xml
  6. 0
      app/src/main/res/drawable/reblog_private_light.xml
  7. 2
      app/src/main/res/layout/activity_account.xml
  8. 2
      app/src/main/res/menu/status_more_for_user.xml
  9. 2
      app/src/main/res/values-night/styles.xml
  10. 2
      app/src/main/res/values/strings.xml
  11. 2
      app/src/main/res/values/styles.xml

@ -174,13 +174,22 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
// This should only be called after setReblogged, in order to override the tint correctly. // This should only be called after setReblogged, in order to override the tint correctly.
private void setRebloggingEnabled(boolean enabled, Status.Visibility visibility) { private void setRebloggingEnabled(boolean enabled, Status.Visibility visibility) {
reblogButton.setEnabled(enabled); reblogButton.setEnabled(enabled && visibility != Status.Visibility.PRIVATE);
if (enabled) { if (enabled) {
int inactiveId = ThemeUtils.getDrawableId(reblogButton.getContext(), 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); R.attr.status_reblog_inactive_drawable, R.drawable.reblog_inactive_dark);
activeId = R.drawable.reblog_active;
}
reblogButton.setInactiveImage(inactiveId); reblogButton.setInactiveImage(inactiveId);
reblogButton.setActiveImage(R.drawable.reblog_active); reblogButton.setActiveImage(activeId);
} else { } else {
int disabledId; int disabledId;
if (visibility == Status.Visibility.DIRECT) { 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); R.attr.status_reblog_direct_drawable, R.drawable.reblog_direct_dark);
} else { } else {
disabledId = ThemeUtils.getDrawableId(reblogButton.getContext(), 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.setInactiveImage(disabledId);
reblogButton.setActiveImage(disabledId); reblogButton.setActiveImage(disabledId);

@ -98,7 +98,7 @@ data class Status(
} }
fun rebloggingAllowed(): Boolean { 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 { override fun equals(other: Any?): Boolean {

@ -21,11 +21,11 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetBehavior;
import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
import android.text.Spanned; import android.text.Spanned;
import android.view.Menu;
import android.view.View; import android.view.View;
import com.keylesspalace.tusky.BottomSheetActivity; import com.keylesspalace.tusky.BottomSheetActivity;
@ -66,6 +66,8 @@ public abstract class SFragment extends BaseFragment {
protected abstract TimelineCases timelineCases(); protected abstract TimelineCases timelineCases();
protected abstract void removeItem(int position); protected abstract void removeItem(int position);
protected abstract void onReblog(final boolean reblog, final int position);
private BottomSheetActivity bottomSheetActivity; private BottomSheetActivity bottomSheetActivity;
@Inject @Inject
@ -150,6 +152,13 @@ public abstract class SFragment extends BaseFragment {
popup.inflate(R.menu.status_more); popup.inflate(R.menu.status_more);
} else { } else {
popup.inflate(R.menu.status_more_for_user); 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 -> { popup.setOnMenuItemClickListener(item -> {
switch (item.getItemId()) { switch (item.getItemId()) {
@ -193,6 +202,14 @@ public abstract class SFragment extends BaseFragment {
openReportPage(accountId, accountUsename, id, content); openReportPage(accountId, accountUsename, id, content);
return true; 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: { case R.id.status_delete: {
timelineCases().delete(id); timelineCases().delete(id);
removeItem(position); removeItem(position);

@ -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" android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/account_username" app:layout_constraintBottom_toBottomOf="@id/account_username"
app:layout_constraintLeft_toRightOf="@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" /> tools:visibility="visible" />
<android.support.text.emoji.widget.EmojiTextView <android.support.text.emoji.widget.EmojiTextView

@ -12,6 +12,8 @@
android:title="@string/status_share_content"/> android:title="@string/status_share_content"/>
</menu> </menu>
</item> </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" <item android:title="@string/action_delete"
android:id="@+id/status_delete" /> android:id="@+id/status_delete" />
</menu> </menu>

@ -28,7 +28,7 @@
<item name="image_button_style">@style/AppTheme.ImageButton.Dark</item> <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_small_drawable">@drawable/ic_reblog_dark_18dp</item>
<item name="status_reblog_inactive_drawable">@drawable/reblog_inactive_dark</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_reblog_direct_drawable">@drawable/reblog_direct_dark</item>
<item name="status_favourite_active_drawable">@drawable/favourite_active_dark</item> <item name="status_favourite_active_drawable">@drawable/favourite_active_dark</item>
<item name="status_favourite_inactive_drawable">@drawable/favourite_inactive_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_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="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="download_failed">Download failed</string>
<string name="reblog_private">Boost to original audience</string>
<string name="unreblog_private">Unboost</string>
</resources> </resources>

@ -61,7 +61,7 @@
<item name="image_button_style">@style/AppTheme.ImageButton.Light</item> <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_small_drawable">@drawable/ic_reblog_light_18dp</item>
<item name="status_reblog_inactive_drawable">@drawable/reblog_inactive_light</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_reblog_direct_drawable">@drawable/reblog_direct_light</item>
<item name="status_favourite_active_drawable">@drawable/favourite_active_light</item> <item name="status_favourite_active_drawable">@drawable/favourite_active_light</item>
<item name="status_favourite_inactive_drawable">@drawable/favourite_inactive_light</item> <item name="status_favourite_inactive_drawable">@drawable/favourite_inactive_light</item>

Loading…
Cancel
Save