Change frontend
This commit is contained in:
parent
dd7695f1c1
commit
cf1dc7518c
|
@ -42,6 +42,7 @@ import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.support.v4.view.GravityCompat;
|
import android.support.v4.view.GravityCompat;
|
||||||
|
@ -109,6 +110,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.RemoteInstance;
|
import fr.gouv.etalab.mastodon.client.Entities.RemoteInstance;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
|
import fr.gouv.etalab.mastodon.client.Entities.TagTimeline;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Version;
|
import fr.gouv.etalab.mastodon.client.Entities.Version;
|
||||||
import fr.gouv.etalab.mastodon.client.HttpsConnection;
|
import fr.gouv.etalab.mastodon.client.HttpsConnection;
|
||||||
import fr.gouv.etalab.mastodon.fragments.DisplayAccountsFragment;
|
import fr.gouv.etalab.mastodon.fragments.DisplayAccountsFragment;
|
||||||
|
@ -181,7 +183,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
private RelativeLayout main_app_container;
|
private RelativeLayout main_app_container;
|
||||||
private Stack<Integer> stackBack = new Stack<>();
|
private Stack<Integer> stackBack = new Stack<>();
|
||||||
public static List<Filters> filters = new ArrayList<>();
|
public static List<Filters> filters = new ArrayList<>();
|
||||||
private DisplayStatusFragment homeFragment, federatedFragment, localFragment, artFragment;
|
private DisplayStatusFragment homeFragment, federatedFragment, localFragment;
|
||||||
private DisplayNotificationsFragment notificationsFragment;
|
private DisplayNotificationsFragment notificationsFragment;
|
||||||
private static final int ERROR_DIALOG_REQUEST_CODE = 97;
|
private static final int ERROR_DIALOG_REQUEST_CODE = 97;
|
||||||
private static BroadcastReceiver receive_data, receive_federated_data, receive_local_data;
|
private static BroadcastReceiver receive_data, receive_federated_data, receive_local_data;
|
||||||
|
@ -827,30 +829,6 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if( tabStrip.getChildCount() > 2 && !display_direct)
|
|
||||||
tabStrip.getChildAt(2).setOnLongClickListener(new View.OnLongClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(View v) {
|
|
||||||
return manageFilters(tabStrip, sharedpreferences);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
else if ( tabStrip.getChildCount() > 3 && display_direct)
|
|
||||||
tabStrip.getChildAt(3).setOnLongClickListener(new View.OnLongClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(View v) {
|
|
||||||
return manageFilters(tabStrip, sharedpreferences);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if( tabStrip.getChildCount() == 5)
|
|
||||||
tabStrip.getChildAt(4).setOnLongClickListener(new View.OnLongClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(View v) {
|
|
||||||
return manageFilters(tabStrip, sharedpreferences);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
countPage = 2;
|
countPage = 2;
|
||||||
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_DIRECT, true))
|
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_DIRECT, true))
|
||||||
countPage++;
|
countPage++;
|
||||||
|
@ -861,6 +839,21 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_ART, true))
|
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_ART, true))
|
||||||
countPage++;
|
countPage++;
|
||||||
|
|
||||||
|
if( tabPosition.containsKey("global"))
|
||||||
|
tabStrip.getChildAt(tabPosition.get("global")).setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
return manageFilters(tabStrip, sharedpreferences);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if( tabPosition.containsKey("local"))
|
||||||
|
tabStrip.getChildAt(tabPosition.get("local")).setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
return manageFilters(tabStrip, sharedpreferences);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
viewPager.setOffscreenPageLimit(countPage);
|
viewPager.setOffscreenPageLimit(countPage);
|
||||||
main_app_container = findViewById(R.id.main_app_container);
|
main_app_container = findViewById(R.id.main_app_container);
|
||||||
adapter = new PagerAdapter
|
adapter = new PagerAdapter
|
||||||
|
@ -997,10 +990,10 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if( countPage == 6) {
|
if( countPage == 6) {
|
||||||
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
|
||||||
displayStatusFragment.scrollToTop();
|
|
||||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.ART, 0);
|
updateTimeLine(RetrieveFeedsAsyncTask.Type.ART, 0);
|
||||||
}
|
}
|
||||||
|
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
||||||
|
displayStatusFragment.scrollToTop();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
|
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
|
||||||
|
@ -1580,12 +1573,9 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
if(homeFragment != null && homeFragment.getUserVisibleHint())
|
if(homeFragment != null && homeFragment.getUserVisibleHint())
|
||||||
popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(0));
|
popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(0));
|
||||||
else if(localFragment != null && localFragment.getUserVisibleHint())
|
else if(localFragment != null && localFragment.getUserVisibleHint())
|
||||||
popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(2));
|
popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(tabPosition.get("local")));
|
||||||
else if(federatedFragment != null && federatedFragment.getUserVisibleHint()){
|
else if(federatedFragment != null && federatedFragment.getUserVisibleHint()){
|
||||||
if( !display_local && display_global)
|
popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(tabPosition.get("global")));
|
||||||
popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(2));
|
|
||||||
else
|
|
||||||
popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(3));
|
|
||||||
}
|
}
|
||||||
if( popup == null)
|
if( popup == null)
|
||||||
return true;
|
return true;
|
||||||
|
@ -2338,7 +2328,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HashMap<String, DisplayStatusFragment> tagFragment = new HashMap<>();
|
||||||
/**
|
/**
|
||||||
* Page Adapter for settings
|
* Page Adapter for settings
|
||||||
*/
|
*/
|
||||||
|
@ -2383,10 +2373,12 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
return notificationsFragment;
|
return notificationsFragment;
|
||||||
}else {
|
}else {
|
||||||
statusFragment = new DisplayStatusFragment();
|
statusFragment = new DisplayStatusFragment();
|
||||||
bundle.putSerializable("type", Helper.timelineType(getApplicationContext(), position));
|
bundle.putSerializable("type", Helper.timelineType(getApplicationContext(), position, countPage));
|
||||||
if( Helper.timelineType(getApplicationContext(), position) == RetrieveFeedsAsyncTask.Type.TAG){
|
if( Helper.timelineType(getApplicationContext(), position, countPage) == RetrieveFeedsAsyncTask.Type.TAG){
|
||||||
if( tabLayout.getTabAt(position) != null && tabLayout.getTabAt(position).getText() != null)
|
if( tabLayout.getTabAt(position) != null && tabLayout.getTabAt(position).getText() != null) {
|
||||||
bundle.putString("tag", tabLayout.getTabAt(position).getText().toString());
|
bundle.putString("tag", tabLayout.getTabAt(position).getText().toString());
|
||||||
|
tagFragment.put(tabLayout.getTabAt(position).getText().toString(), statusFragment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
statusFragment.setArguments(bundle);
|
statusFragment.setArguments(bundle);
|
||||||
return statusFragment;
|
return statusFragment;
|
||||||
|
@ -2398,41 +2390,23 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
public Object instantiateItem(@NonNull ViewGroup container, int position) {
|
public Object instantiateItem(@NonNull ViewGroup container, int position) {
|
||||||
Fragment createdFragment = (Fragment) super.instantiateItem(container, position);
|
Fragment createdFragment = (Fragment) super.instantiateItem(container, position);
|
||||||
// save the appropriate reference depending on position
|
// save the appropriate reference depending on position
|
||||||
switch (position) {
|
if( position == 0){
|
||||||
case 0:
|
homeFragment = (DisplayStatusFragment) createdFragment;
|
||||||
homeFragment = (DisplayStatusFragment) createdFragment;
|
}else if( position == 1){
|
||||||
break;
|
notificationsFragment = (DisplayNotificationsFragment) createdFragment;
|
||||||
case 1:
|
}else if( position ==2 && countPage > 2){
|
||||||
notificationsFragment = (DisplayNotificationsFragment) createdFragment;
|
if( !display_direct && display_local)
|
||||||
break;
|
localFragment = (DisplayStatusFragment) createdFragment;
|
||||||
case 2:
|
else if (!display_local)
|
||||||
if( !display_direct && display_local)
|
federatedFragment = (DisplayStatusFragment) createdFragment;
|
||||||
localFragment = (DisplayStatusFragment) createdFragment;
|
}else if (position == 3 && countPage > 3){
|
||||||
else if ( !display_direct && display_global)
|
if( display_local)
|
||||||
federatedFragment = (DisplayStatusFragment) createdFragment;
|
localFragment = (DisplayStatusFragment) createdFragment;
|
||||||
else
|
else if (display_global)
|
||||||
artFragment = (DisplayStatusFragment) createdFragment;
|
federatedFragment = (DisplayStatusFragment) createdFragment;
|
||||||
case 3:
|
}else if( position == 4 && countPage > 4)
|
||||||
if( display_direct && display_local)
|
if( display_global)
|
||||||
localFragment = (DisplayStatusFragment) createdFragment;
|
federatedFragment = (DisplayStatusFragment) createdFragment;
|
||||||
else if( !display_direct && display_local && display_global)
|
|
||||||
federatedFragment = (DisplayStatusFragment) createdFragment;
|
|
||||||
else if( display_direct && display_global)
|
|
||||||
federatedFragment = (DisplayStatusFragment) createdFragment;
|
|
||||||
else
|
|
||||||
artFragment = (DisplayStatusFragment) createdFragment;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
if( display_direct && display_local && display_global)
|
|
||||||
federatedFragment = (DisplayStatusFragment) createdFragment;
|
|
||||||
else
|
|
||||||
artFragment = (DisplayStatusFragment) createdFragment;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
if( display_direct && display_local && display_global && display_art)
|
|
||||||
artFragment = (DisplayStatusFragment) createdFragment;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return createdFragment;
|
return createdFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2445,59 +2419,125 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
|
|
||||||
private void attacheDelete(int position){
|
private void attacheDelete(int position){
|
||||||
LinearLayout tabStrip = (LinearLayout) tabLayout.getChildAt(0);
|
LinearLayout tabStrip = (LinearLayout) tabLayout.getChildAt(0);
|
||||||
String title = tabLayout.getTabAt(position).getText().toString().trim();
|
|
||||||
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
|
||||||
tabStrip.getChildAt(position).setOnLongClickListener(new View.OnLongClickListener() {
|
tabStrip.getChildAt(position).setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BaseMainActivity.this, style);
|
String tag = tabLayout.getTabAt(position).getText().toString().trim();
|
||||||
dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
|
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
|
PopupMenu popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(position));
|
||||||
|
popup.getMenuInflater()
|
||||||
|
.inflate(R.menu.option_tag_timeline, popup.getMenu());
|
||||||
|
Menu menu = popup.getMenu();
|
||||||
|
final MenuItem itemMediaOnly = menu.findItem(R.id.action_show_media_only);
|
||||||
|
final MenuItem itemShowNSFW = menu.findItem(R.id.action_show_nsfw);
|
||||||
|
List<TagTimeline> tagTimelines = new SearchDAO(BaseMainActivity.this, db).getTimelineInfo(tag);
|
||||||
|
boolean mediaOnly = false;
|
||||||
|
boolean showNSFW = false;
|
||||||
|
if( tagTimelines != null && tagTimelines.size() > 0 ) {
|
||||||
|
mediaOnly = tagTimelines.get(0).isART();
|
||||||
|
showNSFW = tagTimelines.get(0).isNSFW();
|
||||||
|
}
|
||||||
|
itemMediaOnly.setChecked(mediaOnly);
|
||||||
|
itemShowNSFW.setChecked(showNSFW);
|
||||||
|
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onDismiss(PopupMenu menu) {
|
||||||
new SearchDAO(BaseMainActivity.this, db).remove(title);
|
FragmentTransaction fragTransaction = getSupportFragmentManager().beginTransaction();
|
||||||
String tag;
|
fragTransaction.detach(tagFragment.get(tag));
|
||||||
if( position > 0 && tabLayout.getTabAt(position - 1).getText() != null) {
|
fragTransaction.attach(tagFragment.get(tag));
|
||||||
tag = tabLayout.getTabAt(position - 1).getText().toString();
|
fragTransaction.commit();
|
||||||
}else if( tabLayout.getTabCount() > 1 && tabLayout.getTabAt(1).getText() != null) {
|
}
|
||||||
tag = tabLayout.getTabAt(1).getText().toString();
|
});
|
||||||
}else //Last element
|
boolean finalMediaOnly = mediaOnly;
|
||||||
tag = "";
|
boolean finalShowNSFW = showNSFW;
|
||||||
Helper.removeTab(tabLayout, adapter, position);
|
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||||
adapter = new BaseMainActivity.PagerAdapter
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
(getSupportFragmentManager(), tabLayout.getTabCount());
|
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||||
viewPager.setAdapter(adapter);
|
item.setActionView(new View(getApplicationContext()));
|
||||||
for(int i = 0; i < tabLayout.getTabCount() ; i++ ){
|
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||||
if( tabLayout.getTabAt(i).getText() != null && tabLayout.getTabAt(i).getText().equals(tag.trim())){
|
@Override
|
||||||
tabLayout.getTabAt(i).select();
|
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.action_show_media_only:
|
||||||
|
TagTimeline tagTimeline = new TagTimeline();
|
||||||
|
tagTimeline.setName(tag.trim());
|
||||||
|
tagTimeline.setART(!finalMediaOnly);
|
||||||
|
tagTimeline.setNSFW(finalShowNSFW);
|
||||||
|
itemMediaOnly.setChecked(!finalMediaOnly);
|
||||||
|
new SearchDAO(BaseMainActivity.this, db).updateSearch(tagTimeline);
|
||||||
|
break;
|
||||||
|
case R.id.action_show_nsfw:
|
||||||
|
tagTimeline = new TagTimeline();
|
||||||
|
tagTimeline.setName(tag.trim());
|
||||||
|
tagTimeline.setART(finalMediaOnly);
|
||||||
|
tagTimeline.setNSFW(!finalShowNSFW);
|
||||||
|
itemShowNSFW.setChecked(!finalShowNSFW);
|
||||||
|
new SearchDAO(BaseMainActivity.this, db).updateSearch(tagTimeline);
|
||||||
|
break;
|
||||||
|
case R.id.action_delete:
|
||||||
|
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BaseMainActivity.this, style);
|
||||||
|
dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
new SearchDAO(BaseMainActivity.this, db).remove(tag);
|
||||||
|
String tag;
|
||||||
|
if( position > 0 && tabLayout.getTabAt(position - 1).getText() != null) {
|
||||||
|
tag = tabLayout.getTabAt(position - 1).getText().toString();
|
||||||
|
}else if( tabLayout.getTabCount() > 1 && tabLayout.getTabAt(1).getText() != null) {
|
||||||
|
tag = tabLayout.getTabAt(1).getText().toString();
|
||||||
|
}else //Last element
|
||||||
|
tag = "";
|
||||||
|
Helper.removeTab(tabLayout, adapter, position);
|
||||||
|
adapter = new BaseMainActivity.PagerAdapter
|
||||||
|
(getSupportFragmentManager(), tabLayout.getTabCount());
|
||||||
|
viewPager.setAdapter(adapter);
|
||||||
|
for(int i = 0; i < tabLayout.getTabCount() ; i++ ){
|
||||||
|
if( tabLayout.getTabAt(i).getText() != null && tabLayout.getTabAt(i).getText().equals(tag.trim())){
|
||||||
|
tabLayout.getTabAt(i).select();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialogBuilder.setMessage(getString(R.string.delete) + ": " + tag);
|
||||||
|
AlertDialog alertDialog = dialogBuilder.create();
|
||||||
|
alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialogInterface) {
|
||||||
|
//Hide keyboard
|
||||||
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
assert imm != null;
|
||||||
|
imm.hideSoftInputFromWindow(viewPager.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if( alertDialog.getWindow() != null )
|
||||||
|
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||||
|
alertDialog.show();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
popup.show();
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialogBuilder.setMessage(getString(R.string.delete) + ": " + title);
|
|
||||||
AlertDialog alertDialog = dialogBuilder.create();
|
|
||||||
alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
||||||
@Override
|
|
||||||
public void onDismiss(DialogInterface dialogInterface) {
|
|
||||||
//Hide keyboard
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
assert imm != null;
|
|
||||||
imm.hideSoftInputFromWindow(viewPager.getWindowToken(), 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if( alertDialog.getWindow() != null )
|
|
||||||
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
|
||||||
alertDialog.show();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateHomeCounter(){
|
public void updateHomeCounter(){
|
||||||
|
|
|
@ -105,6 +105,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Card;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Emojis;
|
import fr.gouv.etalab.mastodon.client.Entities.Emojis;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
|
import fr.gouv.etalab.mastodon.client.Entities.TagTimeline;
|
||||||
import fr.gouv.etalab.mastodon.fragments.DisplayStatusFragment;
|
import fr.gouv.etalab.mastodon.fragments.DisplayStatusFragment;
|
||||||
import fr.gouv.etalab.mastodon.helper.CrossActions;
|
import fr.gouv.etalab.mastodon.helper.CrossActions;
|
||||||
import fr.gouv.etalab.mastodon.helper.CustomTextView;
|
import fr.gouv.etalab.mastodon.helper.CustomTextView;
|
||||||
|
@ -152,6 +153,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
private List<String> timedMute;
|
private List<String> timedMute;
|
||||||
private boolean redraft;
|
private boolean redraft;
|
||||||
private Status toot;
|
private Status toot;
|
||||||
|
private TagTimeline tagTimeline;
|
||||||
|
|
||||||
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, int behaviorWithAttachments, int translator, List<Status> statuses){
|
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, int behaviorWithAttachments, int translator, List<Status> statuses){
|
||||||
super();
|
super();
|
||||||
|
@ -167,6 +169,21 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
redraft = false;
|
redraft = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StatusListAdapter(Context context, TagTimeline tagTimeline, String targetedId, boolean isOnWifi, int behaviorWithAttachments, int translator, List<Status> statuses){
|
||||||
|
super();
|
||||||
|
this.context = context;
|
||||||
|
this.statuses = statuses;
|
||||||
|
this.isOnWifi = isOnWifi;
|
||||||
|
this.behaviorWithAttachments = behaviorWithAttachments;
|
||||||
|
layoutInflater = LayoutInflater.from(this.context);
|
||||||
|
statusListAdapter = this;
|
||||||
|
this.type = RetrieveFeedsAsyncTask.Type.TAG;
|
||||||
|
this.targetedId = targetedId;
|
||||||
|
this.translator = translator;
|
||||||
|
redraft = false;
|
||||||
|
this.tagTimeline = tagTimeline;
|
||||||
|
}
|
||||||
|
|
||||||
public StatusListAdapter(Context context, int position, String targetedId, boolean isOnWifi, int behaviorWithAttachments, int translator, List<Status> statuses){
|
public StatusListAdapter(Context context, int position, String targetedId, boolean isOnWifi, int behaviorWithAttachments, int translator, List<Status> statuses){
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.statuses = statuses;
|
this.statuses = statuses;
|
||||||
|
@ -221,7 +238,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
@Override
|
@Override
|
||||||
public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
|
public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
|
||||||
super.onViewAttachedToWindow(holder);
|
super.onViewAttachedToWindow(holder);
|
||||||
if( type != RetrieveFeedsAsyncTask.Type.ART && (holder.getItemViewType() == DISPLAYED_STATUS || holder.getItemViewType() == COMPACT_STATUS)) {
|
if( type != RetrieveFeedsAsyncTask.Type.ART && (tagTimeline == null || !tagTimeline.isART()) && (holder.getItemViewType() == DISPLAYED_STATUS || holder.getItemViewType() == COMPACT_STATUS)) {
|
||||||
final ViewHolder viewHolder = (ViewHolder) holder;
|
final ViewHolder viewHolder = (ViewHolder) holder;
|
||||||
// Bug workaround for losing text selection ability, see:
|
// Bug workaround for losing text selection ability, see:
|
||||||
// https://code.google.com/p/android/issues/detail?id=208169
|
// https://code.google.com/p/android/issues/detail?id=208169
|
||||||
|
@ -426,7 +443,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
if( type == RetrieveFeedsAsyncTask.Type.ART)
|
if( type == RetrieveFeedsAsyncTask.Type.ART || (tagTimeline != null && tagTimeline.isART()))
|
||||||
return new ViewHolderArt(layoutInflater.inflate(R.layout.drawer_art, parent, false));
|
return new ViewHolderArt(layoutInflater.inflate(R.layout.drawer_art, parent, false));
|
||||||
else if( viewType == DISPLAYED_STATUS)
|
else if( viewType == DISPLAYED_STATUS)
|
||||||
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_status, parent, false));
|
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_status, parent, false));
|
||||||
|
@ -445,7 +462,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
|
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
|
||||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
if( type == RetrieveFeedsAsyncTask.Type.ART) {
|
if( type == RetrieveFeedsAsyncTask.Type.ART || (tagTimeline != null && tagTimeline.isART())) {
|
||||||
final ViewHolderArt holder = (ViewHolderArt) viewHolder;
|
final ViewHolderArt holder = (ViewHolderArt) viewHolder;
|
||||||
final Status status = statuses.get(viewHolder.getAdapterPosition());
|
final Status status = statuses.get(viewHolder.getAdapterPosition());
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Conversation;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Peertube;
|
import fr.gouv.etalab.mastodon.client.Entities.Peertube;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.RemoteInstance;
|
import fr.gouv.etalab.mastodon.client.Entities.RemoteInstance;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
|
import fr.gouv.etalab.mastodon.client.Entities.TagTimeline;
|
||||||
import fr.gouv.etalab.mastodon.drawers.PeertubeAdapter;
|
import fr.gouv.etalab.mastodon.drawers.PeertubeAdapter;
|
||||||
import fr.gouv.etalab.mastodon.drawers.StatusListAdapter;
|
import fr.gouv.etalab.mastodon.drawers.StatusListAdapter;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
|
@ -61,6 +62,7 @@ import fr.gouv.etalab.mastodon.services.StreamingFederatedTimelineService;
|
||||||
import fr.gouv.etalab.mastodon.services.StreamingLocalTimelineService;
|
import fr.gouv.etalab.mastodon.services.StreamingLocalTimelineService;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.InstancesDAO;
|
import fr.gouv.etalab.mastodon.sqlite.InstancesDAO;
|
||||||
|
import fr.gouv.etalab.mastodon.sqlite.SearchDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.TempMuteDAO;
|
import fr.gouv.etalab.mastodon.sqlite.TempMuteDAO;
|
||||||
|
|
||||||
|
@ -100,6 +102,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
private String search_peertube, remote_channel_name;
|
private String search_peertube, remote_channel_name;
|
||||||
private String initialBookMark;
|
private String initialBookMark;
|
||||||
private boolean fetchMoreButtonDisplayed;
|
private boolean fetchMoreButtonDisplayed;
|
||||||
|
private TagTimeline tagTimeline;
|
||||||
|
|
||||||
public DisplayStatusFragment(){
|
public DisplayStatusFragment(){
|
||||||
}
|
}
|
||||||
|
@ -117,6 +120,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
fetchMoreButtonDisplayed = false;
|
fetchMoreButtonDisplayed = false;
|
||||||
showPinned = false;
|
showPinned = false;
|
||||||
showReply = false;
|
showReply = false;
|
||||||
|
tagTimeline = null;
|
||||||
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);
|
||||||
|
@ -156,7 +160,15 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
||||||
mutedAccount = new TempMuteDAO(context, db).getAllTimeMuted(account);
|
mutedAccount = new TempMuteDAO(context, db).getAllTimeMuted(account);
|
||||||
|
|
||||||
if( search_peertube == null && (instanceType == null || instanceType.equals("MASTODON"))) {
|
if( type == RetrieveFeedsAsyncTask.Type.TAG && tag != null) {
|
||||||
|
BaseMainActivity.displayPeertube = null;
|
||||||
|
List<TagTimeline> tagTimelines = new SearchDAO(context, db).getTimelineInfo(tag);
|
||||||
|
if( tagTimelines != null && tagTimelines.size() > 0) {
|
||||||
|
tagTimeline = tagTimelines.get(0);
|
||||||
|
statusListAdapter = new StatusListAdapter(context, tagTimeline, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, this.statuses);
|
||||||
|
lv_status.setAdapter(statusListAdapter);
|
||||||
|
}
|
||||||
|
}else if( search_peertube == null && (instanceType == null || instanceType.equals("MASTODON"))) {
|
||||||
BaseMainActivity.displayPeertube = null;
|
BaseMainActivity.displayPeertube = null;
|
||||||
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, this.statuses);
|
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, this.statuses);
|
||||||
lv_status.setAdapter(statusListAdapter);
|
lv_status.setAdapter(statusListAdapter);
|
||||||
|
@ -474,8 +486,18 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
}
|
}
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
this.statuses.addAll(statuses);
|
if( tagTimeline == null || !tagTimeline.isART() || (tagTimeline.isART() && tagTimeline.isNSFW())) {
|
||||||
statusListAdapter.notifyItemRangeInserted(previousPosition, statuses.size());
|
this.statuses.addAll(statuses);
|
||||||
|
statusListAdapter.notifyItemRangeInserted(previousPosition, statuses.size());
|
||||||
|
}else { //If it's an Art timeline not allowing NSFW
|
||||||
|
ArrayList<Status> safeStatuses = new ArrayList<>();
|
||||||
|
for(Status status: statuses){
|
||||||
|
if( !status.isSensitive())
|
||||||
|
safeStatuses.add(status);
|
||||||
|
}
|
||||||
|
this.statuses.addAll(safeStatuses);
|
||||||
|
statusListAdapter.notifyItemRangeInserted(previousPosition, safeStatuses.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( type == RetrieveFeedsAsyncTask.Type.HOME ) {
|
if( type == RetrieveFeedsAsyncTask.Type.HOME ) {
|
||||||
//Update the id of the last toot retrieved
|
//Update the id of the last toot retrieved
|
||||||
|
|
|
@ -2574,6 +2574,7 @@ public class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void refreshSearchTag(Context context, TabLayout tableLayout, BaseMainActivity.PagerAdapter pagerAdapter){
|
public static void refreshSearchTag(Context context, TabLayout tableLayout, BaseMainActivity.PagerAdapter pagerAdapter){
|
||||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
List<String> searches = new SearchDAO(context, db).getAllSearch();
|
List<String> searches = new SearchDAO(context, db).getAllSearch();
|
||||||
|
@ -2618,6 +2619,8 @@ public class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void removeSearchTag(String keyword, TabLayout tableLayout, BaseMainActivity.PagerAdapter pagerAdapter){
|
public static void removeSearchTag(String keyword, TabLayout tableLayout, BaseMainActivity.PagerAdapter pagerAdapter){
|
||||||
|
|
||||||
int selection = -1;
|
int selection = -1;
|
||||||
|
@ -3036,7 +3039,7 @@ public class Helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RetrieveFeedsAsyncTask.Type timelineType(Context context, int position){
|
public static RetrieveFeedsAsyncTask.Type timelineType(Context context, int position, int pageCount){
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||||
boolean display_direct = sharedpreferences.getBoolean(Helper.SET_DISPLAY_DIRECT, true);
|
boolean display_direct = sharedpreferences.getBoolean(Helper.SET_DISPLAY_DIRECT, true);
|
||||||
boolean display_local = sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true);
|
boolean display_local = sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true);
|
||||||
|
@ -3044,7 +3047,7 @@ public class Helper {
|
||||||
boolean display_art = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ART, true);
|
boolean display_art = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ART, true);
|
||||||
if (position == 0) {
|
if (position == 0) {
|
||||||
return RetrieveFeedsAsyncTask.Type.HOME;
|
return RetrieveFeedsAsyncTask.Type.HOME;
|
||||||
}else if(position == 2) {
|
}else if(position == 2 && pageCount > 2) {
|
||||||
if( display_direct) {
|
if( display_direct) {
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context));
|
||||||
|
@ -3071,19 +3074,19 @@ public class Helper {
|
||||||
return RetrieveFeedsAsyncTask.Type.PUBLIC;
|
return RetrieveFeedsAsyncTask.Type.PUBLIC;
|
||||||
if( display_art)
|
if( display_art)
|
||||||
return RetrieveFeedsAsyncTask.Type.ART;
|
return RetrieveFeedsAsyncTask.Type.ART;
|
||||||
}else if( position == 3){
|
}else if( position == 3 && pageCount > 3){
|
||||||
if( display_direct && display_local)
|
if( display_direct && display_local)
|
||||||
return RetrieveFeedsAsyncTask.Type.LOCAL;
|
return RetrieveFeedsAsyncTask.Type.LOCAL;
|
||||||
if( display_global)
|
if( display_global)
|
||||||
return RetrieveFeedsAsyncTask.Type.PUBLIC;
|
return RetrieveFeedsAsyncTask.Type.PUBLIC;
|
||||||
if( display_art)
|
if( display_art)
|
||||||
return RetrieveFeedsAsyncTask.Type.ART;
|
return RetrieveFeedsAsyncTask.Type.ART;
|
||||||
}else if (position == 4){
|
}else if (position == 4 && pageCount > 4){
|
||||||
if( display_direct && display_local && display_global)
|
if( display_direct && display_local && display_global)
|
||||||
return RetrieveFeedsAsyncTask.Type.PUBLIC;
|
return RetrieveFeedsAsyncTask.Type.PUBLIC;
|
||||||
if( display_art)
|
if( display_art)
|
||||||
return RetrieveFeedsAsyncTask.Type.ART;
|
return RetrieveFeedsAsyncTask.Type.ART;
|
||||||
}else if (position == 5){
|
}else if (position == 5 && pageCount > 5){
|
||||||
if( display_direct && display_local && display_global && display_art)
|
if( display_direct && display_local && display_global && display_art)
|
||||||
return RetrieveFeedsAsyncTask.Type.ART;
|
return RetrieveFeedsAsyncTask.Type.ART;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,23 @@ public class SearchDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------- UPDATES -------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update tag timeline info in database
|
||||||
|
* @param tagTimeline TagTimeline
|
||||||
|
*/
|
||||||
|
public void updateSearch(TagTimeline tagTimeline) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(Sqlite.COL_IS_ART, tagTimeline.isART()?1:0);
|
||||||
|
values.put(Sqlite.COL_IS_NSFW, tagTimeline.isNSFW()?1:0);
|
||||||
|
//Inserts search
|
||||||
|
try{
|
||||||
|
db.update(Sqlite.TABLE_SEARCH, values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_KEYWORDS + " = ?", new String[]{userId, tagTimeline.getName()});
|
||||||
|
}catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//------- REMOVE -------
|
//------- REMOVE -------
|
||||||
|
|
||||||
/***
|
/***
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?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_media_only"
|
||||||
|
android:checkable="true"
|
||||||
|
android:title="@string/show_media_only"
|
||||||
|
app:actionViewClass="android.widget.CheckBox"
|
||||||
|
app:showAsAction="always"
|
||||||
|
tools:ignore="AlwaysShowAction" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_show_nsfw"
|
||||||
|
android:checkable="true"
|
||||||
|
android:title="@string/show_media_nsfw"
|
||||||
|
app:actionViewClass="android.widget.CheckBox"
|
||||||
|
app:showAsAction="always" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_delete"
|
||||||
|
app:showAsAction="always"
|
||||||
|
android:title="@string/delete" />
|
||||||
|
</menu>
|
|
@ -760,6 +760,8 @@
|
||||||
<string name="serbian" translatable="false">Српски</string>
|
<string name="serbian" translatable="false">Српски</string>
|
||||||
<string name="ukrainian" translatable="false">Українська</string>
|
<string name="ukrainian" translatable="false">Українська</string>
|
||||||
<string name="russian" translatable="false">Русский</string>
|
<string name="russian" translatable="false">Русский</string>
|
||||||
|
<string name="show_media_only">Media only</string>
|
||||||
|
<string name="show_media_nsfw">Show NSFW</string>
|
||||||
<!-- end languages -->
|
<!-- end languages -->
|
||||||
|
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue