Filters boosts & replies in home timeline
This commit is contained in:
parent
e09dbbe307
commit
2175c17ce6
|
@ -58,6 +58,7 @@ public class Status implements Parcelable {
|
|||
private boolean isTranslationShown = false;
|
||||
private boolean isNew = false;
|
||||
private boolean isTakingScreenShot = false;
|
||||
private boolean isVisible = true;
|
||||
|
||||
protected Status(Parcel in) {
|
||||
id = in.readString();
|
||||
|
@ -370,4 +371,12 @@ public class Status implements Parcelable {
|
|||
public void setTakingScreenShot(boolean takingScreenShot) {
|
||||
isTakingScreenShot = takingScreenShot;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return isVisible;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
isVisible = visible;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import android.support.v7.widget.PopupMenu;
|
|||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -118,7 +119,8 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
private String targetedId;
|
||||
private HashMap<String, String> urlConversion;
|
||||
private HashMap<String, String> tagConversion;
|
||||
|
||||
private final int HIDDEN_STATUS = 0;
|
||||
private final int DISPLAYED_STATUS = 1;
|
||||
private List<Status> pins;
|
||||
|
||||
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, int behaviorWithAttachments, int translator, List<Status> statuses){
|
||||
|
@ -131,10 +133,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
this.type = type;
|
||||
this.targetedId = targetedId;
|
||||
this.translator = translator;
|
||||
|
||||
pins = new ArrayList<>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,11 +153,30 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
Status status = statuses.get(position);
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
if(status.getReblog() != null && ! sharedpreferences.getBoolean(Helper.SET_SHOW_BOOSTS, true) )
|
||||
return HIDDEN_STATUS;
|
||||
else if((status.getIn_reply_to_account_id()!= null && !status.getIn_reply_to_account_id().equals("null")) || (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().equals("null") ) && ! sharedpreferences.getBoolean(Helper.SET_SHOW_REPLIES, true))
|
||||
return HIDDEN_STATUS;
|
||||
else
|
||||
return DISPLAYED_STATUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
|
||||
|
||||
if( getItemViewType(position) == HIDDEN_STATUS){
|
||||
return new View(context);
|
||||
}else {
|
||||
final Status status = statuses.get(position);
|
||||
imageLoader = ImageLoader.getInstance();
|
||||
File cacheDir = new File(context.getCacheDir(), context.getString(R.string.app_name));
|
||||
ImageLoaderConfiguration configImg = new ImageLoaderConfiguration.Builder(context)
|
||||
|
@ -173,8 +191,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
|
||||
final Status status = statuses.get(position);
|
||||
|
||||
if (convertView == null) {
|
||||
convertView = layoutInflater.inflate(R.layout.drawer_status, parent, false);
|
||||
holder = new ViewHolder();
|
||||
|
@ -232,7 +248,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
|
||||
|
||||
|
||||
//Display a preview for accounts that have replied *if enabled and only for home timeline*
|
||||
if( type == RetrieveFeedsAsyncTask.Type.HOME ) {
|
||||
boolean showPreview = sharedpreferences.getBoolean(Helper.SET_PREVIEW_REPLIES, false);
|
||||
|
@ -1049,10 +1064,11 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
}
|
||||
}
|
||||
});
|
||||
//Profile picture
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void loadAttachments(final Status status, ViewHolder holder){
|
||||
|
|
|
@ -370,6 +370,17 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh status in list
|
||||
*/
|
||||
public void refreshFilter(){
|
||||
int index = lv_status.getFirstVisiblePosition() + 1;
|
||||
View v = lv_status.getChildAt(0);
|
||||
int top = (v == null) ? 0 : v.getTop();
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
lv_status.setSelectionFromTop(index, top);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
|
|
|
@ -209,6 +209,9 @@ public class Helper {
|
|||
public static final String SET_PREVIEW_REPLIES_PP = "set_preview_replies_pp";
|
||||
public static final String SET_TRANSLATOR = "set_translator";
|
||||
public static final String SET_LED_COLOUR = "set_led_colour";
|
||||
public static final String SET_SHOW_BOOSTS = "set_show_boost";
|
||||
public static final String SET_SHOW_REPLIES = "set_show_replies";
|
||||
|
||||
|
||||
public static final int ATTACHMENT_ALWAYS = 1;
|
||||
public static final int ATTACHMENT_WIFI = 2;
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_show_boosts"
|
||||
android:checkable="true"
|
||||
android:title="@string/show_boosts"
|
||||
app:actionViewClass="android.widget.CheckBox"
|
||||
app:showAsAction="always"
|
||||
tools:ignore="AlwaysShowAction" />
|
||||
<item
|
||||
android:id="@+id/action_show_replies"
|
||||
android:checkable="true"
|
||||
android:title="@string/show_replies"
|
||||
app:actionViewClass="android.widget.CheckBox"
|
||||
app:showAsAction="always" />
|
||||
</menu>
|
|
@ -63,6 +63,9 @@
|
|||
<string name="follow">Neue Folgende</string>
|
||||
<string name="mention">Erwähnungen</string>
|
||||
<string name="reblog">Geteilte Beiträge</string>
|
||||
<string name="show_boosts">Geteilte Beiträge anzeigen</string>
|
||||
<string name="show_replies">Antworten anzeigen</string>
|
||||
|
||||
<!--- Menu -->
|
||||
<string name="home_menu">Home</string>
|
||||
<string name="local_menu">Lokale Zeitleiste</string>
|
||||
|
|
|
@ -64,7 +64,8 @@
|
|||
<string name="follow">Nouveaux⋅elles abonn⋅é⋅s</string>
|
||||
<string name="mention">Mentions</string>
|
||||
<string name="reblog">Partages</string>
|
||||
|
||||
<string name="show_boosts">Afficher les partages</string>
|
||||
<string name="show_replies">Afficher les réponses</string>
|
||||
<!--- Menu -->
|
||||
<string name="home_menu">Accueil</string>
|
||||
<string name="local_menu">Fil public local</string>
|
||||
|
|
|
@ -64,7 +64,8 @@
|
|||
<string name="follow">New followers</string>
|
||||
<string name="mention">Mentions</string>
|
||||
<string name="reblog">Boosts</string>
|
||||
|
||||
<string name="show_boosts">Show boosts</string>
|
||||
<string name="show_replies">Show replies</string>
|
||||
<!--- Menu -->
|
||||
<string name="home_menu">Home</string>
|
||||
<string name="local_menu">Local timeline</string>
|
||||
|
|
|
@ -144,7 +144,7 @@ public class MainActivity extends AppCompatActivity
|
|||
private String userIdService;
|
||||
private Intent streamingIntent;
|
||||
public static String lastHomeId = null, lastNotificationId = null;
|
||||
boolean notif_follow, notif_add, notif_mention, notif_share;
|
||||
boolean notif_follow, notif_add, notif_mention, notif_share, show_boosts, show_replies;
|
||||
|
||||
public MainActivity() {
|
||||
}
|
||||
|
@ -318,6 +318,70 @@ public class MainActivity extends AppCompatActivity
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
tabStrip.getChildAt(0).setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
//Only shown if the tab has focus
|
||||
if( homeFragment != null && homeFragment.getUserVisibleHint()){
|
||||
PopupMenu popup = new PopupMenu(MainActivity.this, tabStrip.getChildAt(0));
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.option_filter_toots, popup.getMenu());
|
||||
Menu menu = popup.getMenu();
|
||||
final MenuItem itemShowBoosts = menu.findItem(R.id.action_show_boosts);
|
||||
final MenuItem itemShowReplies = menu.findItem(R.id.action_show_replies);
|
||||
|
||||
show_boosts = sharedpreferences.getBoolean(Helper.SET_SHOW_BOOSTS, true);
|
||||
show_replies = sharedpreferences.getBoolean(Helper.SET_SHOW_REPLIES, true);
|
||||
itemShowBoosts.setChecked(show_boosts);
|
||||
itemShowReplies.setChecked(show_replies);
|
||||
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(PopupMenu menu) {
|
||||
if( homeFragment != null)
|
||||
homeFragment.refreshFilter();
|
||||
}
|
||||
});
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
item.setActionView(new View(getApplicationContext()));
|
||||
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_show_boosts:
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
show_boosts = !show_boosts;
|
||||
editor.putBoolean(Helper.SET_SHOW_BOOSTS, show_boosts);
|
||||
itemShowBoosts.setChecked(show_boosts);
|
||||
editor.apply();
|
||||
break;
|
||||
case R.id.action_show_replies:
|
||||
editor = sharedpreferences.edit();
|
||||
show_replies = !show_replies;
|
||||
editor.putBoolean(Helper.SET_SHOW_REPLIES, show_replies);
|
||||
itemShowReplies.setChecked(show_replies);
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
viewPager = (ViewPager) findViewById(R.id.viewpager);
|
||||
int countPage = 2;
|
||||
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true))
|
||||
|
|
Loading…
Reference in New Issue