Add feature + hide boosts

This commit is contained in:
stom79 2018-09-04 19:27:26 +02:00
parent 4ec8376dd4
commit 930bcb393a
5 changed files with 92 additions and 1 deletions

View File

@ -42,6 +42,7 @@ import android.support.v7.widget.PopupMenu;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.style.UnderlineSpan;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -319,6 +320,8 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
popup.getMenu().findItem(R.id.action_mute).setVisible(false);
popup.getMenu().findItem(R.id.action_mention).setVisible(false);
popup.getMenu().findItem(R.id.action_follow_instance).setVisible(false);
popup.getMenu().findItem(R.id.action_hide_boost).setVisible(false);
popup.getMenu().findItem(R.id.action_endorse).setVisible(false);
stringArrayConf = getResources().getStringArray(R.array.more_action_owner_confirm);
}else {
popup.getMenu().findItem(R.id.action_block).setVisible(true);
@ -326,6 +329,23 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
popup.getMenu().findItem(R.id.action_mention).setVisible(true);
stringArrayConf = getResources().getStringArray(R.array.more_action_confirm);
}
if( relationship != null){
if( !relationship.isFollowing()) {
popup.getMenu().findItem(R.id.action_hide_boost).setVisible(false);
popup.getMenu().findItem(R.id.action_endorse).setVisible(false);
}
if(relationship.isEndorsed()){
popup.getMenu().findItem(R.id.action_endorse).setTitle(R.string.unendorse);
}else {
popup.getMenu().findItem(R.id.action_endorse).setTitle(R.string.endorse);
}
if(relationship.isShowing_reblogs()){
popup.getMenu().findItem(R.id.action_hide_boost).setTitle(getString(R.string.hide_boost, account.getUsername()));
}else {
popup.getMenu().findItem(R.id.action_hide_boost).setTitle(getString(R.string.show_boost, account.getUsername()));
}
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
AlertDialog.Builder builderInner;
@ -374,6 +394,22 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
}
}).start();
return true;
case R.id.action_endorse:
if( relationship != null)
if(relationship.isEndorsed()){
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.UNENDORSE, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}else {
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.ENDORSE, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
return true;
case R.id.action_hide_boost:
if( relationship != null)
if(relationship.isShowing_reblogs()){
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.HIDE_BOOST, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}else {
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.SHOW_BOOST, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
return true;
case R.id.action_show_pinned:
showPinned = !showPinned;
if( tabLayout.getTabAt(0) != null)
@ -889,6 +925,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
TextView account_followed_by = findViewById(R.id.account_followed_by);
account_followed_by.setVisibility(View.VISIBLE);
}
invalidateOptionsMenu();
}

View File

@ -84,7 +84,12 @@ public class API {
REPORT,
REMOTE_FOLLOW,
PIN,
UNPIN
UNPIN,
ENDORSE,
UNENDORSE,
SHOW_BOOST,
HIDE_BOOST
}
public enum accountPrivacy {
PUBLIC,
@ -964,6 +969,18 @@ public class API {
case UNPIN:
action = String.format("/statuses/%s/unpin", targetedId);
break;
case ENDORSE:
action = String.format("/accounts/%s/pin", targetedId);
break;
case UNENDORSE:
action = String.format("/accounts/%s/unpin", targetedId);
break;
case SHOW_BOOST:
action = String.format("/accounts/%s/follow", targetedId);
break;
case HIDE_BOOST:
action = String.format("/accounts/%s/follow", targetedId);
break;
case UNSTATUS:
action = String.format("/statuses/%s", targetedId);
break;

View File

@ -702,7 +702,16 @@ public class Helper {
message = context.getString(R.string.toast_report);
}else if(statusAction == API.StatusAction.UNSTATUS){
message = context.getString(R.string.toast_unstatus);
}else if(statusAction == API.StatusAction.UNENDORSE){
message = context.getString(R.string.toast_unendorse);
}else if(statusAction == API.StatusAction.ENDORSE){
message = context.getString(R.string.toast_endorse);
}else if(statusAction == API.StatusAction.SHOW_BOOST){
message = context.getString(R.string.toast_show_boost);
}else if(statusAction == API.StatusAction.HIDE_BOOST){
message = context.getString(R.string.toast_hide_boost);
}
}else {
message = context.getString(R.string.toast_error);
}

View File

@ -31,6 +31,21 @@
android:title="@string/more_action_7"
android:icon="@drawable/ic_chat_bubble_outline"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_hide_boost"
android:title="@string/hide_boost"
app:showAsAction="ifRoom" />
<!-- <item
android:id="@+id/action_block_domain"
android:title="@string/hide_everything"
app:showAsAction="ifRoom" /> -->
<item
android:id="@+id/action_endorse"
android:title="@string/endorse"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_follow_instance"
android:title="@string/follow_instance"

View File

@ -558,6 +558,19 @@
<string name="about_partnership" translatable="false"><b>Masto.host</b> is our Mastodon hosting partner.\n\nWith this partnership they provide me free hosting for <a href="https://ins.mastalab.app">Mastalab\'s instance</a> and in exchange I promote them in here.\n\nTo be clear, there is no money involved or tracking of users. I needed an instance for testing, we talked and agreed on this.\n\n<a href="https://masto.host">Go check them out</a> if you want to run your own Mastodon instance.</string>
<string name="action_partnership" >Partnerships</string>
<string name="neutral_menu_information">Information</string>
<string name="hide_boost">Hide boosts from %s</string>
<string name="endorse">Feature on profile</string>
<string name="hide_everything">Hide everything from %s</string>
<string name="show_boost">Show boosts from %s</string>
<string name="unendorse">Don\'t feature on profile</string>
<string name="show_everything">Show everything from %s</string>
<string name="toast_endorse">The account is now featured on profile</string>
<string name="toast_unendorse">The account is no longer featured on profile</string>
<string name="toast_show_boost">Boosts are now shown!</string>
<string name="toast_hide_boost">Boosts are now hidden!</string>
<string-array translatable="false" name="proxy_type_choice">
<item>HTTP</item>
<item>SOCKS</item>