Add peertube column
This commit is contained in:
parent
2b4fc03db2
commit
28ef97d4cd
|
@ -55,6 +55,7 @@ import android.support.v7.widget.Toolbar;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.InputFilter;
|
import android.text.InputFilter;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
@ -93,6 +94,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -196,11 +198,11 @@ 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, artFragment, peertubeFragment;
|
||||||
private TabLayoutNotificationsFragment tabLayoutNotificationsFragment;
|
private TabLayoutNotificationsFragment tabLayoutNotificationsFragment;
|
||||||
private static final int ERROR_DIALOG_REQUEST_CODE = 97;
|
private static final int ERROR_DIALOG_REQUEST_CODE = 97;
|
||||||
|
|
||||||
private boolean display_direct, display_local, display_global, display_art;
|
private boolean display_direct, display_local, display_global, display_art, display_peertube;
|
||||||
public static int countNewStatus;
|
public static int countNewStatus;
|
||||||
public static int countNewNotifications;
|
public static int countNewNotifications;
|
||||||
public static String lastHomeId = null, lastNotificationId = null;
|
public static String lastHomeId = null, lastNotificationId = null;
|
||||||
|
@ -291,6 +293,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
display_local = sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true);
|
display_local = sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true);
|
||||||
display_global = sharedpreferences.getBoolean(Helper.SET_DISPLAY_GLOBAL, true);
|
display_global = sharedpreferences.getBoolean(Helper.SET_DISPLAY_GLOBAL, true);
|
||||||
display_art = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ART, true);
|
display_art = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ART, true);
|
||||||
|
display_peertube = sharedpreferences.getBoolean(Helper.SET_DISPLAY_PEERTUBE, true);
|
||||||
//Test if user is still log in
|
//Test if user is still log in
|
||||||
if( ! Helper.isLoggedIn(getApplicationContext())) {
|
if( ! Helper.isLoggedIn(getApplicationContext())) {
|
||||||
//It is not, the user is redirected to the login page
|
//It is not, the user is redirected to the login page
|
||||||
|
@ -355,6 +358,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
TabLayout.Tab tabLocal = tabLayout.newTab();
|
TabLayout.Tab tabLocal = tabLayout.newTab();
|
||||||
TabLayout.Tab tabPublic = tabLayout.newTab();
|
TabLayout.Tab tabPublic = tabLayout.newTab();
|
||||||
TabLayout.Tab tabArt = tabLayout.newTab();
|
TabLayout.Tab tabArt = tabLayout.newTab();
|
||||||
|
TabLayout.Tab tabPeertube = tabLayout.newTab();
|
||||||
|
|
||||||
tabHome.setCustomView(R.layout.tab_badge);
|
tabHome.setCustomView(R.layout.tab_badge);
|
||||||
tabNotif.setCustomView(R.layout.tab_badge);
|
tabNotif.setCustomView(R.layout.tab_badge);
|
||||||
|
@ -362,6 +366,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
tabLocal.setCustomView(R.layout.tab_badge);
|
tabLocal.setCustomView(R.layout.tab_badge);
|
||||||
tabPublic.setCustomView(R.layout.tab_badge);
|
tabPublic.setCustomView(R.layout.tab_badge);
|
||||||
tabArt.setCustomView(R.layout.tab_badge);
|
tabArt.setCustomView(R.layout.tab_badge);
|
||||||
|
tabPeertube.setCustomView(R.layout.tab_badge);
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||||
ImageView iconHome = tabHome.getCustomView().findViewById(R.id.tab_icon);
|
ImageView iconHome = tabHome.getCustomView().findViewById(R.id.tab_icon);
|
||||||
|
@ -396,12 +401,17 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
ImageView iconArt = tabArt.getCustomView().findViewById(R.id.tab_icon);
|
ImageView iconArt = tabArt.getCustomView().findViewById(R.id.tab_icon);
|
||||||
iconArt.setImageResource(R.drawable.ic_color_lens);
|
iconArt.setImageResource(R.drawable.ic_color_lens);
|
||||||
|
|
||||||
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||||
|
ImageView iconPeertube = tabPeertube.getCustomView().findViewById(R.id.tab_icon);
|
||||||
|
iconPeertube.setImageResource(R.drawable.ic_video_peertube);
|
||||||
|
|
||||||
iconHome.setContentDescription(getString(R.string.home_menu));
|
iconHome.setContentDescription(getString(R.string.home_menu));
|
||||||
iconNotif.setContentDescription(getString(R.string.notifications));
|
iconNotif.setContentDescription(getString(R.string.notifications));
|
||||||
iconDirect.setContentDescription(getString(R.string.direct_message));
|
iconDirect.setContentDescription(getString(R.string.direct_message));
|
||||||
iconLocal.setContentDescription(getString(R.string.local_menu));
|
iconLocal.setContentDescription(getString(R.string.local_menu));
|
||||||
iconGlobal.setContentDescription(getString(R.string.global_menu));
|
iconGlobal.setContentDescription(getString(R.string.global_menu));
|
||||||
iconArt.setContentDescription(getString(R.string.art_menu));
|
iconArt.setContentDescription(getString(R.string.art_menu));
|
||||||
|
iconPeertube.setContentDescription(getString(R.string.peertube_menu));
|
||||||
|
|
||||||
if (theme == THEME_LIGHT) {
|
if (theme == THEME_LIGHT) {
|
||||||
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
||||||
|
@ -410,6 +420,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
||||||
iconGlobal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
iconGlobal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
||||||
iconArt.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
iconArt.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
||||||
|
iconPeertube.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
||||||
} else {
|
} else {
|
||||||
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||||
iconNotif.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
iconNotif.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||||
|
@ -417,6 +428,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||||
iconGlobal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
iconGlobal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||||
iconArt.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
iconArt.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||||
|
iconPeertube.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -485,8 +497,15 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
tabLayout.addTab(tabArt);
|
tabLayout.addTab(tabArt);
|
||||||
tabPosition.put("art", i);
|
tabPosition.put("art", i);
|
||||||
typePosition.put(i, RetrieveFeedsAsyncTask.Type.ART);
|
typePosition.put(i, RetrieveFeedsAsyncTask.Type.ART);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
|
||||||
|
display_peertube = false;
|
||||||
|
if( display_peertube ) {
|
||||||
|
tabLayout.addTab(tabPeertube);
|
||||||
|
tabPosition.put("peertube", i);
|
||||||
|
typePosition.put(i, RetrieveFeedsAsyncTask.Type.PEERTUBE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE)
|
if( (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE)
|
||||||
tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
||||||
else if( i > 3 && !Helper.isTablet(getApplicationContext())){
|
else if( i > 3 && !Helper.isTablet(getApplicationContext())){
|
||||||
|
@ -596,6 +615,8 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
countPage++;
|
countPage++;
|
||||||
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_ART, true)&& social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
|
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_ART, true)&& social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
|
||||||
countPage++;
|
countPage++;
|
||||||
|
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_PEERTUBE, true)&& social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
|
||||||
|
countPage++;
|
||||||
|
|
||||||
if( tabPosition.containsKey("global"))
|
if( tabPosition.containsKey("global"))
|
||||||
tabStrip.getChildAt(tabPosition.get("global")).setOnLongClickListener(new View.OnLongClickListener() {
|
tabStrip.getChildAt(tabPosition.get("global")).setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@ -642,7 +663,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
viewPager.setVisibility(View.VISIBLE);
|
viewPager.setVisibility(View.VISIBLE);
|
||||||
delete_instance.setVisibility(View.GONE);
|
delete_instance.setVisibility(View.GONE);
|
||||||
Helper.switchLayout(BaseMainActivity.this);
|
Helper.switchLayout(BaseMainActivity.this);
|
||||||
if( tab.getPosition() == 1 || (tabPosition.containsKey("art") && tab.getPosition() == tabPosition.get("art"))) {
|
if( tab.getPosition() == 1 || (tabPosition.containsKey("art") && tab.getPosition() == tabPosition.get("art"))||(tabPosition.containsKey("peertube") && tab.getPosition() == tabPosition.get("peertube"))) {
|
||||||
toot.hide();
|
toot.hide();
|
||||||
federatedTimelines.hide();
|
federatedTimelines.hide();
|
||||||
}else {
|
}else {
|
||||||
|
@ -687,7 +708,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||||
drawer.closeDrawer(GravityCompat.START);
|
drawer.closeDrawer(GravityCompat.START);
|
||||||
}
|
}
|
||||||
if( tab.getPosition() == 1 || (tabPosition.containsKey("art") && tab.getPosition() == tabPosition.get("art"))) {
|
if( tab.getPosition() == 1 || (tabPosition.containsKey("art") && tab.getPosition() == tabPosition.get("art"))||(tabPosition.containsKey("peertube") && tab.getPosition() == tabPosition.get("peertube"))) {
|
||||||
toot.hide();
|
toot.hide();
|
||||||
federatedTimelines.hide();
|
federatedTimelines.hide();
|
||||||
}else {
|
}else {
|
||||||
|
@ -713,7 +734,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
updateNotifCounter();
|
updateNotifCounter();
|
||||||
}else if (tab.getPosition() > 1) {
|
}else if (tab.getPosition() > 1) {
|
||||||
if (typePosition.containsKey(tab.getPosition()))
|
if (typePosition.containsKey(tab.getPosition()))
|
||||||
updateTimeLine(typePosition.get(tab.getPosition()), 0);
|
manageTab(typePosition.get(tab.getPosition()), 0);
|
||||||
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
||||||
displayStatusFragment.scrollToTop();
|
displayStatusFragment.scrollToTop();
|
||||||
}
|
}
|
||||||
|
@ -1589,7 +1610,8 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
(homeFragment != null && homeFragment.getUserVisibleHint()) ||
|
(homeFragment != null && homeFragment.getUserVisibleHint()) ||
|
||||||
(federatedFragment != null && federatedFragment.getUserVisibleHint()) ||
|
(federatedFragment != null && federatedFragment.getUserVisibleHint()) ||
|
||||||
(localFragment != null && localFragment.getUserVisibleHint()) ||
|
(localFragment != null && localFragment.getUserVisibleHint()) ||
|
||||||
(artFragment != null && artFragment.getUserVisibleHint())
|
(artFragment != null && artFragment.getUserVisibleHint()) ||
|
||||||
|
(peertubeFragment != null && peertubeFragment.getUserVisibleHint())
|
||||||
){
|
){
|
||||||
PopupMenu popup = null;
|
PopupMenu popup = null;
|
||||||
if(homeFragment != null && homeFragment.getUserVisibleHint())
|
if(homeFragment != null && homeFragment.getUserVisibleHint())
|
||||||
|
@ -1663,7 +1685,10 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
});
|
});
|
||||||
popup.show();
|
popup.show();
|
||||||
return false;
|
return false;
|
||||||
|
}else if(peertubeFragment != null && peertubeFragment.getUserVisibleHint()){
|
||||||
|
//TODO: Peertube manage popup here
|
||||||
}
|
}
|
||||||
|
|
||||||
if( popup == null)
|
if( popup == null)
|
||||||
return true;
|
return true;
|
||||||
popup.getMenuInflater()
|
popup.getMenuInflater()
|
||||||
|
@ -1800,6 +1825,8 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
federatedFragment.refreshFilter();
|
federatedFragment.refreshFilter();
|
||||||
if(artFragment != null)
|
if(artFragment != null)
|
||||||
artFragment.refreshFilter();
|
artFragment.refreshFilter();
|
||||||
|
if(peertubeFragment != null)
|
||||||
|
peertubeFragment.refreshFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2509,6 +2536,12 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
if (typePosition.get(position) == RetrieveFeedsAsyncTask.Type.ART)
|
if (typePosition.get(position) == RetrieveFeedsAsyncTask.Type.ART)
|
||||||
bundle.putString("instanceType","ART");
|
bundle.putString("instanceType","ART");
|
||||||
|
if (typePosition.get(position) == RetrieveFeedsAsyncTask.Type.PEERTUBE) {
|
||||||
|
bundle.putString("instanceType", "PEERTUBE");
|
||||||
|
bundle.putString("remote_instance", "peertube.social");
|
||||||
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
|
||||||
|
|
||||||
|
}
|
||||||
statusFragment.setArguments(bundle);
|
statusFragment.setArguments(bundle);
|
||||||
return statusFragment;
|
return statusFragment;
|
||||||
}
|
}
|
||||||
|
@ -2592,6 +2625,8 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
federatedFragment = (DisplayStatusFragment) createdFragment;
|
federatedFragment = (DisplayStatusFragment) createdFragment;
|
||||||
else if (display_art && position == tabPosition.get("art"))
|
else if (display_art && position == tabPosition.get("art"))
|
||||||
artFragment = (DisplayStatusFragment) createdFragment;
|
artFragment = (DisplayStatusFragment) createdFragment;
|
||||||
|
else if (display_peertube && position == tabPosition.get("peertube"))
|
||||||
|
peertubeFragment = (DisplayStatusFragment) createdFragment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2894,132 +2929,44 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void manageTab( RetrieveFeedsAsyncTask.Type type, int value){
|
||||||
|
boolean searchedIsDisplayed;
|
||||||
|
//Search if the current timeline is displayed
|
||||||
|
searchedIsDisplayed = false;
|
||||||
|
int positionInTab;
|
||||||
|
switch (type){
|
||||||
|
case DIRECT:
|
||||||
|
searchedIsDisplayed = display_direct;
|
||||||
|
break;
|
||||||
|
case LOCAL:
|
||||||
|
searchedIsDisplayed = display_local;
|
||||||
|
break;
|
||||||
|
case PUBLIC:
|
||||||
|
searchedIsDisplayed = display_global;
|
||||||
|
break;
|
||||||
|
case ART:
|
||||||
|
searchedIsDisplayed = display_art;
|
||||||
|
break;
|
||||||
|
case PEERTUBE:
|
||||||
|
searchedIsDisplayed = display_peertube;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Log.v(Helper.TAG,"positionInTab " + Helper.getKeyByValue(typePosition, type));
|
||||||
|
if( searchedIsDisplayed){
|
||||||
|
//noinspection ConstantConditions
|
||||||
|
positionInTab = Helper.getKeyByValue(typePosition, type);
|
||||||
|
|
||||||
public void updateTimeLine(RetrieveFeedsAsyncTask.Type type, int value){
|
View tabCustom = tabLayout.getTabAt(positionInTab).getCustomView();
|
||||||
|
assert tabCustom != null;
|
||||||
if( type == RetrieveFeedsAsyncTask.Type.DIRECT || type == RetrieveFeedsAsyncTask.Type.CONVERSATION){
|
TextView tabCountertCustom = tabCustom.findViewById(R.id.tab_counter);
|
||||||
if (tabLayout.getTabAt(2) != null && display_direct) {
|
tabCountertCustom.setText(String.valueOf(value));
|
||||||
View tabDirect = tabLayout.getTabAt(2).getCustomView();
|
if( value > 0){
|
||||||
assert tabDirect != null;
|
tabCountertCustom.setVisibility(View.VISIBLE);
|
||||||
TextView tabCounterDirect = tabDirect.findViewById(R.id.tab_counter);
|
}else {
|
||||||
tabCounterDirect.setText(String.valueOf(value));
|
tabCountertCustom.setVisibility(View.GONE);
|
||||||
if (value > 0) {
|
|
||||||
tabCounterDirect.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
tabCounterDirect.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if( type == RetrieveFeedsAsyncTask.Type.LOCAL ){
|
|
||||||
if( display_local) {
|
|
||||||
if (tabLayout.getTabAt(2) != null && !display_direct) {
|
|
||||||
View tabLocal = tabLayout.getTabAt(2).getCustomView();
|
|
||||||
assert tabLocal != null;
|
|
||||||
TextView tabCounterLocal = tabLocal.findViewById(R.id.tab_counter);
|
|
||||||
tabCounterLocal.setText(String.valueOf(value));
|
|
||||||
if (value > 0) {
|
|
||||||
tabCounterLocal.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
tabCounterLocal.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
} else if (tabLayout.getTabAt(3) != null ) {
|
|
||||||
View tabLocal = tabLayout.getTabAt(3).getCustomView();
|
|
||||||
assert tabLocal != null;
|
|
||||||
TextView tabCounterLocal = tabLocal.findViewById(R.id.tab_counter);
|
|
||||||
tabCounterLocal.setText(String.valueOf(value));
|
|
||||||
if (value > 0) {
|
|
||||||
tabCounterLocal.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
tabCounterLocal.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if( type == RetrieveFeedsAsyncTask.Type.PUBLIC ){
|
|
||||||
if( display_global){
|
|
||||||
if( tabLayout.getTabAt(2) != null && !display_local && !display_direct){
|
|
||||||
View tabPublic = tabLayout.getTabAt(2).getCustomView();
|
|
||||||
assert tabPublic != null;
|
|
||||||
TextView tabCounterPublic = tabPublic.findViewById(R.id.tab_counter);
|
|
||||||
tabCounterPublic.setText(String.valueOf(value));
|
|
||||||
if( value > 0){
|
|
||||||
tabCounterPublic.setVisibility(View.VISIBLE);
|
|
||||||
}else {
|
|
||||||
tabCounterPublic.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}else if( tabLayout.getTabAt(3) != null && ((!display_local && display_direct) || (display_local && !display_direct) )){
|
|
||||||
View tabPublic = tabLayout.getTabAt(3).getCustomView();
|
|
||||||
assert tabPublic != null;
|
|
||||||
TextView tabCounterPublic = tabPublic.findViewById(R.id.tab_counter);
|
|
||||||
tabCounterPublic.setText(String.valueOf(value));
|
|
||||||
if( value > 0){
|
|
||||||
tabCounterPublic.setVisibility(View.VISIBLE);
|
|
||||||
}else {
|
|
||||||
tabCounterPublic.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}else if( tabLayout.getTabAt(4) != null && display_local && display_direct){
|
|
||||||
View tabPublic = tabLayout.getTabAt(4).getCustomView();
|
|
||||||
assert tabPublic != null;
|
|
||||||
TextView tabCounterPublic = tabPublic.findViewById(R.id.tab_counter);
|
|
||||||
tabCounterPublic.setText(String.valueOf(value));
|
|
||||||
if( value > 0){
|
|
||||||
tabCounterPublic.setVisibility(View.VISIBLE);
|
|
||||||
}else {
|
|
||||||
tabCounterPublic.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if( type == RetrieveFeedsAsyncTask.Type.ART ){
|
|
||||||
if( display_art){
|
|
||||||
if( tabLayout.getTabAt(2) != null && !display_local && !display_direct && !display_global){
|
|
||||||
View tabArt = tabLayout.getTabAt(2).getCustomView();
|
|
||||||
assert tabArt != null;
|
|
||||||
TextView tabCounterArt = tabArt.findViewById(R.id.tab_counter);
|
|
||||||
tabCounterArt.setText(String.valueOf(value));
|
|
||||||
if( value > 0){
|
|
||||||
tabCounterArt.setVisibility(View.VISIBLE);
|
|
||||||
}else {
|
|
||||||
tabCounterArt.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}else if( tabLayout.getTabAt(3) != null && (
|
|
||||||
(!display_local && !display_direct && display_global) ||
|
|
||||||
(!display_global && !display_direct && display_local) ||
|
|
||||||
(!display_global && !display_local && display_direct)
|
|
||||||
)){
|
|
||||||
View tabArt = tabLayout.getTabAt(3).getCustomView();
|
|
||||||
assert tabArt != null;
|
|
||||||
TextView tabCounterArt = tabArt.findViewById(R.id.tab_counter);
|
|
||||||
tabCounterArt.setText(String.valueOf(value));
|
|
||||||
if( value > 0){
|
|
||||||
tabCounterArt.setVisibility(View.VISIBLE);
|
|
||||||
}else {
|
|
||||||
tabCounterArt.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}else if( tabLayout.getTabAt(4) != null && (
|
|
||||||
(!display_direct && display_local && display_global) ||
|
|
||||||
(!display_local && display_direct && display_global) ||
|
|
||||||
(!display_global && display_local && display_direct)
|
|
||||||
)){
|
|
||||||
View tabArt = tabLayout.getTabAt(4).getCustomView();
|
|
||||||
assert tabArt != null;
|
|
||||||
TextView tabCounterArt = tabArt.findViewById(R.id.tab_counter);
|
|
||||||
tabCounterArt.setText(String.valueOf(value));
|
|
||||||
if( value > 0){
|
|
||||||
tabCounterArt.setVisibility(View.VISIBLE);
|
|
||||||
}else {
|
|
||||||
tabCounterArt.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}else if( tabLayout.getTabAt(5) != null && display_local && display_direct && display_global){
|
|
||||||
View tabArt = tabLayout.getTabAt(5).getCustomView();
|
|
||||||
assert tabArt != null;
|
|
||||||
TextView tabCounterArt = tabArt.findViewById(R.id.tab_counter);
|
|
||||||
tabCounterArt.setText(String.valueOf(value));
|
|
||||||
if( value > 0){
|
|
||||||
tabCounterArt.setVisibility(View.VISIBLE);
|
|
||||||
}else {
|
|
||||||
tabCounterArt.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateNotifCounter(){
|
public void updateNotifCounter(){
|
||||||
|
|
|
@ -75,6 +75,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
TAG,
|
TAG,
|
||||||
REMOTE_INSTANCE,
|
REMOTE_INSTANCE,
|
||||||
ART,
|
ART,
|
||||||
|
PEERTUBE,
|
||||||
NOTIFICATION,
|
NOTIFICATION,
|
||||||
SEARCH,
|
SEARCH,
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -157,6 +158,8 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
instanceType = bundle.getString("instanceType", "MASTODON");
|
instanceType = bundle.getString("instanceType", "MASTODON");
|
||||||
ischannel = bundle.getBoolean("ischannel",false);
|
ischannel = bundle.getBoolean("ischannel",false);
|
||||||
}
|
}
|
||||||
|
Log.v(Helper.TAG,"type! " + type);
|
||||||
|
Log.v(Helper.TAG,"instanceType! " + instanceType);
|
||||||
if( ischannel)
|
if( ischannel)
|
||||||
type = RetrieveFeedsAsyncTask.Type.CHANNEL;
|
type = RetrieveFeedsAsyncTask.Type.CHANNEL;
|
||||||
|
|
||||||
|
@ -914,9 +917,9 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
((MainActivity) context).updateHomeCounter();
|
((MainActivity) context).updateHomeCounter();
|
||||||
else {
|
else {
|
||||||
if( type != RetrieveFeedsAsyncTask.Type.CONVERSATION)
|
if( type != RetrieveFeedsAsyncTask.Type.CONVERSATION)
|
||||||
((MainActivity) context).updateTimeLine(type, inserted);
|
((MainActivity) context).manageTab(type, inserted);
|
||||||
else
|
else
|
||||||
((MainActivity) context).updateTimeLine(type, insertedConversation);
|
((MainActivity) context).manageTab(type, insertedConversation);
|
||||||
}
|
}
|
||||||
}catch (Exception ignored){}
|
}catch (Exception ignored){}
|
||||||
}
|
}
|
||||||
|
|
|
@ -878,6 +878,27 @@ public class SettingsFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
boolean display_peertube = sharedpreferences.getBoolean(Helper.SET_DISPLAY_PEERTUBE, true);
|
||||||
|
final CheckBox set_display_peertube = rootView.findViewById(R.id.set_display_peertube);
|
||||||
|
set_display_peertube.setChecked(display_peertube);
|
||||||
|
|
||||||
|
set_display_peertube.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
|
editor.putBoolean(Helper.SET_DISPLAY_PEERTUBE, set_display_peertube.isChecked());
|
||||||
|
editor.apply();
|
||||||
|
if( getActivity() != null)
|
||||||
|
getActivity().recreate();
|
||||||
|
Intent intent = new Intent(context, MainActivity.class);
|
||||||
|
intent.putExtra(INTENT_ACTION, BACK_TO_SETTINGS);
|
||||||
|
if(getActivity() != null)
|
||||||
|
getActivity().finish();
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
boolean disableGif = sharedpreferences.getBoolean(Helper.SET_DISABLE_GIF, false);
|
boolean disableGif = sharedpreferences.getBoolean(Helper.SET_DISABLE_GIF, false);
|
||||||
final CheckBox set_disable_gif = rootView.findViewById(R.id.set_disable_gif);
|
final CheckBox set_disable_gif = rootView.findViewById(R.id.set_disable_gif);
|
||||||
set_disable_gif.setChecked(disableGif);
|
set_disable_gif.setChecked(disableGif);
|
||||||
|
|
|
@ -145,13 +145,17 @@ import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import es.dmoral.toasty.Toasty;
|
import es.dmoral.toasty.Toasty;
|
||||||
import fr.gouv.etalab.mastodon.BuildConfig;
|
import fr.gouv.etalab.mastodon.BuildConfig;
|
||||||
|
@ -374,6 +378,7 @@ public class Helper {
|
||||||
public static final String SET_DISPLAY_LOCAL = "set_display_local";
|
public static final String SET_DISPLAY_LOCAL = "set_display_local";
|
||||||
public static final String SET_DISPLAY_GLOBAL = "set_display_global";
|
public static final String SET_DISPLAY_GLOBAL = "set_display_global";
|
||||||
public static final String SET_DISPLAY_ART = "set_display_art";
|
public static final String SET_DISPLAY_ART = "set_display_art";
|
||||||
|
public static final String SET_DISPLAY_PEERTUBE = "set_display_peertube";
|
||||||
public static final String SET_AUTOMATICALLY_SPLIT_TOOTS = "set_automatically_split_toots";
|
public static final String SET_AUTOMATICALLY_SPLIT_TOOTS = "set_automatically_split_toots";
|
||||||
public static final String SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE = "set_automatically_split_toots_size";
|
public static final String SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE = "set_automatically_split_toots_size";
|
||||||
public static final String SET_TRUNCATE_TOOTS_SIZE = "set_truncate_toots_size";
|
public static final String SET_TRUNCATE_TOOTS_SIZE = "set_truncate_toots_size";
|
||||||
|
@ -3803,4 +3808,14 @@ public class Helper {
|
||||||
return cleaned_content;
|
return cleaned_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static <T, E> T getKeyByValue(Map<T, E> map, E value) {
|
||||||
|
for (Map.Entry<T, E> entry : map.entrySet()) {
|
||||||
|
if (Objects.equals(value, entry.getValue())) {
|
||||||
|
return entry.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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="#FF000000"
|
||||||
|
android:pathData="M4,6L2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6zM20,2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM12,14.5v-9l6,4.5 -6,4.5z"/>
|
||||||
|
</vector>
|
|
@ -128,6 +128,13 @@
|
||||||
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
||||||
android:text="@string/set_display_art"
|
android:text="@string/set_display_art"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/set_display_peertube"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/settings_checkbox_margin"
|
||||||
|
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
||||||
|
android:text="@string/set_display_peertube"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/set_old_direct_timeline"
|
android:id="@+id/set_old_direct_timeline"
|
||||||
|
|
|
@ -130,6 +130,13 @@
|
||||||
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
||||||
android:text="@string/set_display_art"
|
android:text="@string/set_display_art"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/set_display_peertube"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/settings_checkbox_margin"
|
||||||
|
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
||||||
|
android:text="@string/set_display_peertube"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/set_old_direct_timeline"
|
android:id="@+id/set_old_direct_timeline"
|
||||||
|
|
|
@ -918,6 +918,8 @@
|
||||||
<string name="vote">Vote</string>
|
<string name="vote">Vote</string>
|
||||||
<string name="poll_not_private">A poll cannot be attached to a direct message!</string>
|
<string name="poll_not_private">A poll cannot be attached to a direct message!</string>
|
||||||
<string name="notif_poll">A poll you have voted in has ended</string>
|
<string name="notif_poll">A poll you have voted in has ended</string>
|
||||||
|
<string name="set_display_peertube">Display Peertube timeline</string>
|
||||||
|
<string name="peertube_menu">Peertube</string>
|
||||||
|
|
||||||
<plurals name="number_of_vote">
|
<plurals name="number_of_vote">
|
||||||
<item quantity="one">%d vote</item>
|
<item quantity="one">%d vote</item>
|
||||||
|
|
Loading…
Reference in New Issue