Adds feature to display toots only with media for accounts

This commit is contained in:
tom79 2017-08-03 14:38:47 +02:00
parent e472f7443f
commit 8df1890b73
23 changed files with 91 additions and 79 deletions

View File

@ -37,6 +37,7 @@ import android.support.v7.app.AppCompatActivity;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
@ -103,6 +104,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
private static int instanceValue = 0; private static int instanceValue = 0;
private Relationship relationship; private Relationship relationship;
private TextView account_un; private TextView account_un;
private boolean showMediaOnly;
public enum action{ public enum action{
FOLLOW, FOLLOW,
@ -139,6 +141,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
}else{ }else{
Toast.makeText(this,R.string.toast_error_loading_account,Toast.LENGTH_LONG).show(); Toast.makeText(this,R.string.toast_error_loading_account,Toast.LENGTH_LONG).show();
} }
showMediaOnly = false;
imageLoader = ImageLoader.getInstance(); imageLoader = ImageLoader.getInstance();
File cacheDir = new File(getCacheDir(), getString(R.string.app_name)); File cacheDir = new File(getCacheDir(), getString(R.string.app_name));
ImageLoaderConfiguration configImg = new ImageLoaderConfiguration.Builder(this) ImageLoaderConfiguration configImg = new ImageLoaderConfiguration.Builder(this)
@ -279,12 +282,29 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
new RetrieveRelationshipAsyncTask(getApplicationContext(), accountId,ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveRelationshipAsyncTask(getApplicationContext(), accountId,ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_showaccount, menu);
return true;
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
finish(); finish();
return true; return true;
case R.id.action_show_media:
showMediaOnly = !showMediaOnly;
if( showMediaOnly )
item.setIcon(R.drawable.ic_clear_all);
else
item.setIcon(R.drawable.ic_perm_media);
tabLayout.getTabAt(0).select();
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter);
return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -429,6 +449,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.USER); bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.USER);
bundle.putString("targetedId", accountId); bundle.putString("targetedId", accountId);
bundle.putBoolean("hideHeader",true); bundle.putBoolean("hideHeader",true);
bundle.putBoolean("showMediaOnly",showMediaOnly);
bundle.putString("hideHeaderValue",String.valueOf(instanceValue)); bundle.putString("hideHeaderValue",String.valueOf(instanceValue));
displayStatusFragment.setArguments(bundle); displayStatusFragment.setArguments(bundle);
return displayStatusFragment; return displayStatusFragment;

View File

@ -82,7 +82,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
isRefreshed = false; isRefreshed = false;
setTitle(R.string.conversation); setTitle(R.string.conversation);
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeContainer); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeContainer);
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, false, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if( theme == Helper.THEME_LIGHT) { if( theme == Helper.THEME_LIGHT) {
swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent, swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent,
@ -97,7 +97,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
@Override @Override
public void onRefresh() { public void onRefresh() {
isRefreshed = true; isRefreshed = true;
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, false, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
}); });
lv_status = (ListView) findViewById(R.id.lv_status); lv_status = (ListView) findViewById(R.id.lv_status);
@ -114,7 +114,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
@Override @Override
public void run() { public void run() {
isRefreshed = true; isRefreshed = true;
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, false, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
}, 1000); }, 1000);

View File

@ -1045,34 +1045,6 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
} }
/*private void manageShowUsers(searchAction action, boolean click){
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean show_reply = sharedpreferences.getBoolean(Helper.SET_SHOW_REPLY, false);
Log.v(Helper.TAG,"action: " + action);
if(action == searchAction.CLOSE){
toot_show_accounts.setVisibility(View.GONE);
search_small_container.setVisibility(View.GONE);
bottom_container.setVisibility(View.VISIBLE);
if( show_reply && tootReply != null){
toot_reply_content_container.setVisibility(View.VISIBLE);
}else {
toot_reply_content_container.setVisibility(View.GONE);
}
toot_content.requestFocus();
if( !click) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(toot_content.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
}
}else if(action == searchAction.OPEN){
toot_show_accounts.setVisibility(View.VISIBLE);
search_small_container.setVisibility(View.VISIBLE);
bottom_container.setVisibility(View.GONE);
toot_reply_content_container.setVisibility(View.GONE);
}
}*/
private void tootReply(){ private void tootReply(){
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
if( title != null) if( title != null)

View File

@ -35,6 +35,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
private OnRetrieveFeedsInterface listener; private OnRetrieveFeedsInterface listener;
private String targetedID; private String targetedID;
private String tag; private String tag;
private boolean showMediaOnly = false;
public enum Type{ public enum Type{
HOME, HOME,
@ -55,12 +56,13 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
this.listener = onRetrieveFeedsInterface; this.listener = onRetrieveFeedsInterface;
} }
public RetrieveFeedsAsyncTask(Context context, Type action, String targetedID, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface){ public RetrieveFeedsAsyncTask(Context context, Type action, String targetedID, String max_id, boolean showMediaOnly, OnRetrieveFeedsInterface onRetrieveFeedsInterface){
this.context = context; this.context = context;
this.action = action; this.action = action;
this.max_id = max_id; this.max_id = max_id;
this.listener = onRetrieveFeedsInterface; this.listener = onRetrieveFeedsInterface;
this.targetedID = targetedID; this.targetedID = targetedID;
this.showMediaOnly = showMediaOnly;
} }
public RetrieveFeedsAsyncTask(Context context, Type action, String tag, String targetedID, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface){ public RetrieveFeedsAsyncTask(Context context, Type action, String tag, String targetedID, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface){
this.context = context; this.context = context;
@ -88,7 +90,10 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
apiResponse = api.getFavourites(max_id); apiResponse = api.getFavourites(max_id);
break; break;
case USER: case USER:
apiResponse = api.getStatus(targetedID, max_id); if( !showMediaOnly)
apiResponse = api.getStatus(targetedID, max_id);
else
apiResponse = api.getStatusWithMedia(targetedID, max_id);
break; break;
case ONESTATUS: case ONESTATUS:
apiResponse = api.getStatusbyId(targetedID); apiResponse = api.getStatusbyId(targetedID);

View File

@ -287,6 +287,17 @@ public class API {
return getStatus(accountId, false, false, max_id, null, tootPerPage); return getStatus(accountId, false, false, max_id, null, tootPerPage);
} }
/**
* Retrieves status with media for the account *synchronously*
*
* @param accountId String Id of the account
* @param max_id String id max
* @return APIResponse
*/
public APIResponse getStatusWithMedia(String accountId, String max_id) {
return getStatus(accountId, true, false, max_id, null, tootPerPage);
}
/** /**
* Retrieves status for the account *synchronously* * Retrieves status for the account *synchronously*

View File

@ -133,11 +133,8 @@ public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filt
if (constraint != null) { if (constraint != null) {
suggestions.clear(); suggestions.clear();
for (Account account : tempAccounts) { for (Account account : tempAccounts) {
if (account.getAcct().toLowerCase().startsWith(constraint.toString().toLowerCase())) { suggestions.add(account);
suggestions.add(account);
}
} }
FilterResults filterResults = new FilterResults(); FilterResults filterResults = new FilterResults();
filterResults.values = suggestions; filterResults.values = suggestions;
filterResults.count = suggestions.size(); filterResults.count = suggestions.size();

View File

@ -70,6 +70,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
private boolean isOnWifi; private boolean isOnWifi;
private int behaviorWithAttachments; private int behaviorWithAttachments;
private String instanceValue; private String instanceValue;
private boolean showMediaOnly;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -80,11 +81,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
Bundle bundle = this.getArguments(); Bundle bundle = this.getArguments();
boolean comesFromSearch = false; boolean comesFromSearch = false;
boolean hideHeader = false; boolean hideHeader = false;
showMediaOnly = false;
if (bundle != null) { if (bundle != null) {
type = (RetrieveFeedsAsyncTask.Type) bundle.get("type"); type = (RetrieveFeedsAsyncTask.Type) bundle.get("type");
targetedId = bundle.getString("targetedId", null); targetedId = bundle.getString("targetedId", null);
tag = bundle.getString("tag", null); tag = bundle.getString("tag", null);
hideHeader = bundle.getBoolean("hideHeader", false); hideHeader = bundle.getBoolean("hideHeader", false);
showMediaOnly = bundle.getBoolean("showMediaOnly",false);
instanceValue = bundle.getString("hideHeaderValue", null); instanceValue = bundle.getString("hideHeaderValue", null);
if( bundle.containsKey("statuses")){ if( bundle.containsKey("statuses")){
ArrayList<Parcelable> statusesReceived = bundle.getParcelableArrayList("statuses"); ArrayList<Parcelable> statusesReceived = bundle.getParcelableArrayList("statuses");
@ -150,7 +153,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
if(!flag_loading ) { if(!flag_loading ) {
flag_loading = true; flag_loading = true;
if( type == RetrieveFeedsAsyncTask.Type.USER) if( type == RetrieveFeedsAsyncTask.Type.USER)
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else if( type == RetrieveFeedsAsyncTask.Type.TAG) else if( type == RetrieveFeedsAsyncTask.Type.TAG)
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else else
@ -174,7 +177,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
if(!flag_loading ) { if(!flag_loading ) {
flag_loading = true; flag_loading = true;
if( type == RetrieveFeedsAsyncTask.Type.USER) if( type == RetrieveFeedsAsyncTask.Type.USER)
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else if( type == RetrieveFeedsAsyncTask.Type.TAG) else if( type == RetrieveFeedsAsyncTask.Type.TAG)
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else else
@ -198,7 +201,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
flag_loading = true; flag_loading = true;
swiped = true; swiped = true;
if( type == RetrieveFeedsAsyncTask.Type.USER) if( type == RetrieveFeedsAsyncTask.Type.USER)
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else if( type == RetrieveFeedsAsyncTask.Type.TAG) else if( type == RetrieveFeedsAsyncTask.Type.TAG)
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else else
@ -218,7 +221,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
if( type == RetrieveFeedsAsyncTask.Type.USER) if( type == RetrieveFeedsAsyncTask.Type.USER)
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else if( type == RetrieveFeedsAsyncTask.Type.TAG) else if( type == RetrieveFeedsAsyncTask.Type.TAG)
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else else

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

View File

@ -15,43 +15,35 @@
You should have received a copy of the GNU General Public License along with Thomas Schneider; if not, You should have received a copy of the GNU General Public License along with Thomas Schneider; if not,
see <http://www.gnu.org/licenses>. see <http://www.gnu.org/licenses>.
--> -->
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto" android:padding="2dp"
xmlns:card_view="http://schemas.android.com/tools" android:id="@+id/account_container"
style="?attr/cardStyle" android:orientation="horizontal">
card_view:cardPreventCornerOverlap="true" <ImageView
app:cardUseCompatPadding="true"> android:layout_margin="5dp"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_gravity="center"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/account_pp"
android:layout_width="match_parent" android:layout_width="30dp"
android:layout_height="wrap_content" android:layout_height="30dp"
android:id="@+id/account_container" tools:ignore="ContentDescription" />
android:orientation="horizontal"> <TextView
<ImageView android:layout_marginStart="10dp"
android:layout_margin="5dp" android:layout_marginLeft="10dp"
android:layout_gravity="center" android:maxLines="1"
android:id="@+id/account_pp" android:id="@+id/account_un"
android:layout_width="30dp" android:layout_gravity="center_vertical"
android:layout_height="30dp" android:layout_width="wrap_content"
tools:ignore="ContentDescription" /> android:layout_height="wrap_content" />
<TextView <TextView
android:layout_marginStart="10dp" android:id="@+id/account_dn"
android:layout_marginLeft="10dp" android:layout_marginStart="10dp"
android:maxLines="1" android:layout_marginLeft="10dp"
android:id="@+id/account_un" android:maxLines="1"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<TextView </LinearLayout>
android:id="@+id/account_dn"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:maxLines="1"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.CardView>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_show_media"
android:title="@string/media"
android:icon="@drawable/ic_perm_media"
app:showAsAction="always" />
</menu>

View File

@ -49,6 +49,7 @@
<string name="previous">Précédent</string> <string name="previous">Précédent</string>
<string name="open_with">Ouvrir avec</string> <string name="open_with">Ouvrir avec</string>
<string name="validate">Valider</string> <string name="validate">Valider</string>
<string name="media">Médias</string>
<!--- Menu --> <!--- Menu -->
<string name="home_menu">Accueil</string> <string name="home_menu">Accueil</string>
<string name="local_menu">Fil public local</string> <string name="local_menu">Fil public local</string>

View File

@ -52,6 +52,7 @@
<string name="previous">Previous</string> <string name="previous">Previous</string>
<string name="open_with">Open with</string> <string name="open_with">Open with</string>
<string name="validate">Validate</string> <string name="validate">Validate</string>
<string name="media">Media</string>
<!--- Menu --> <!--- Menu -->
<string name="home_menu">Home</string> <string name="home_menu">Home</string>
<string name="local_menu">Local timeline</string> <string name="local_menu">Local timeline</string>