Prepare backend 2 - TLs and menu
This commit is contained in:
parent
dfbe96e0e9
commit
f5db2a8ba5
|
@ -233,7 +233,14 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
finish();
|
||||
return;
|
||||
}
|
||||
social = (account.getSocial() == null || account.getSocial().equals("MASTODON")? UpdateAccountInfoAsyncTask.SOCIAL.MASTODON: UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE);
|
||||
|
||||
//Update the static variable which manages account type
|
||||
if( account.getSocial() == null || account.getSocial().equals("MASTODON") )
|
||||
social = UpdateAccountInfoAsyncTask.SOCIAL.MASTODON;
|
||||
else if( account.getSocial().equals("PEERTUBE"))
|
||||
social = UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE;
|
||||
else if( account.getSocial().equals("PIXELFED"))
|
||||
social = UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED;
|
||||
|
||||
countNewStatus = 0;
|
||||
countNewNotifications = 0;
|
||||
|
@ -278,12 +285,13 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
rateThisApp();
|
||||
|
||||
//Intialize Peertube information
|
||||
//This task will allow to instance a static PeertubeInformation class
|
||||
if( social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE){
|
||||
try{
|
||||
new RetrievePeertubeInformationAsyncTask(getApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}catch (Exception ignored){}
|
||||
}
|
||||
|
||||
//For old Mastodon releases that can't pin, this support could be removed
|
||||
Helper.canPin = false;
|
||||
Helper.fillMapEmoji(getApplicationContext());
|
||||
//Here, the user is authenticated
|
||||
|
@ -823,16 +831,140 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
viewPager.setVisibility(View.VISIBLE);
|
||||
delete_instance.setVisibility(View.GONE);
|
||||
Helper.switchLayout(BaseMainActivity.this);
|
||||
if( tab.getPosition() == 1 || (tabPosition.containsKey("art") && tab.getPosition() == tabPosition.get("art"))) {
|
||||
toot.hide();
|
||||
tootShow();
|
||||
if( !displayFollowInstance)
|
||||
federatedTimelines.hide();
|
||||
}else {
|
||||
tootShow();
|
||||
if( !displayFollowInstance)
|
||||
federatedTimelines.hide();
|
||||
else
|
||||
federatedTimelinesShow();
|
||||
else
|
||||
federatedTimelinesShow();
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
if( tab.getCustomView() != null) {
|
||||
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
||||
if( icon != null)
|
||||
if( theme == THEME_BLACK)
|
||||
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon), PorterDuff.Mode.SRC_IN);
|
||||
else
|
||||
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.mastodonC4), PorterDuff.Mode.SRC_IN);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
if( tab.getCustomView() != null) {
|
||||
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
||||
if( icon != null)
|
||||
if( theme == THEME_LIGHT)
|
||||
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon), PorterDuff.Mode.SRC_IN);
|
||||
else
|
||||
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
if( tab.getCustomView() != null) {
|
||||
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
|
||||
if( icon != null)
|
||||
if( theme == THEME_BLACK)
|
||||
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon), PorterDuff.Mode.SRC_IN);
|
||||
else
|
||||
icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.mastodonC4), PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Scroll to top when top bar is clicked for favourites/blocked/muted
|
||||
toolbarTitle.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, tabLayout.getSelectedTabPosition());
|
||||
DisplayStatusFragment displayStatusFragment = ((DisplayStatusFragment) fragment);
|
||||
displayStatusFragment.scrollToTop();
|
||||
}
|
||||
});
|
||||
}else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED){
|
||||
TabLayout.Tab pfTabHome = tabLayout.newTab();
|
||||
TabLayout.Tab pfTabLocal = tabLayout.newTab();
|
||||
TabLayout.Tab pfTabDiscover = tabLayout.newTab();
|
||||
|
||||
|
||||
|
||||
pfTabHome.setCustomView(R.layout.tab_badge);
|
||||
pfTabLocal.setCustomView(R.layout.tab_badge);
|
||||
pfTabDiscover.setCustomView(R.layout.tab_badge);
|
||||
|
||||
|
||||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||
ImageView iconHome = pfTabHome.getCustomView().findViewById(R.id.tab_icon);
|
||||
|
||||
iconHome.setImageResource(R.drawable.ic_home);
|
||||
|
||||
if (theme == THEME_BLACK)
|
||||
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon), PorterDuff.Mode.SRC_IN);
|
||||
else
|
||||
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.mastodonC4), PorterDuff.Mode.SRC_IN);
|
||||
|
||||
|
||||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||
ImageView iconLocal = pfTabLocal.getCustomView().findViewById(R.id.tab_icon);
|
||||
iconLocal.setImageResource(R.drawable.ic_people);
|
||||
|
||||
|
||||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||
ImageView iconDiscover = pfTabDiscover.getCustomView().findViewById(R.id.tab_icon);
|
||||
iconDiscover.setImageResource(R.drawable.ic_people);
|
||||
|
||||
|
||||
|
||||
iconHome.setContentDescription(getString(R.string.home_menu));
|
||||
iconDiscover.setContentDescription(getString(R.string.overview));
|
||||
iconLocal.setContentDescription(getString(R.string.local));
|
||||
|
||||
|
||||
if (theme == THEME_LIGHT) {
|
||||
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
||||
iconDiscover.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);
|
||||
} else {
|
||||
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||
iconDiscover.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);
|
||||
}
|
||||
|
||||
toot.setImageResource(R.drawable.ic_cloud_upload);
|
||||
|
||||
tabLayout.addTab(pfTabHome);
|
||||
tabLayout.addTab(pfTabLocal);
|
||||
tabLayout.addTab(pfTabDiscover);
|
||||
|
||||
|
||||
|
||||
main_app_container = findViewById(R.id.main_app_container);
|
||||
adapter = new PagerAdapter
|
||||
(getSupportFragmentManager(), tabLayout.getTabCount());
|
||||
viewPager.setAdapter(adapter);
|
||||
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
viewPager.setCurrentItem(tab.getPosition());
|
||||
if (stackBack.empty())
|
||||
stackBack.push(0);
|
||||
if (stackBack.contains(tab.getPosition())) {
|
||||
stackBack.remove(stackBack.indexOf(tab.getPosition()));
|
||||
stackBack.push(tab.getPosition());
|
||||
} else {
|
||||
stackBack.push(tab.getPosition());
|
||||
}
|
||||
main_app_container.setVisibility(View.GONE);
|
||||
viewPager.setVisibility(View.VISIBLE);
|
||||
delete_instance.setVisibility(View.GONE);
|
||||
Helper.switchLayout(BaseMainActivity.this);
|
||||
tootShow();
|
||||
if( !displayFollowInstance)
|
||||
federatedTimelines.hide();
|
||||
else
|
||||
federatedTimelinesShow();
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
if( tab.getCustomView() != null) {
|
||||
|
@ -1096,7 +1228,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
popup.getMenuInflater()
|
||||
.inflate(R.menu.main, popup.getMenu());
|
||||
|
||||
if( social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE){
|
||||
if( social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON){
|
||||
MenuItem action_about_instance = popup.getMenu().findItem(R.id.action_about_instance);
|
||||
if( action_about_instance != null)
|
||||
action_about_instance.setVisible(false);
|
||||
|
@ -1273,7 +1405,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
if( social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
|
||||
if( social != UpdateAccountInfoAsyncTask.SOCIAL.MASTODON)
|
||||
optionInfo.setVisibility(View.GONE);
|
||||
MenuFloating.tags = new ArrayList<>();
|
||||
updateHeaderAccountInfo(activity, account, headerLayout);
|
||||
|
@ -2312,6 +2444,26 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
bundle.putString("instanceType","PEERTUBE");
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED){
|
||||
//Remove the search bar
|
||||
if( !toolbar_search.isIconified() ) {
|
||||
toolbarTitle.setVisibility(View.VISIBLE);
|
||||
tabLayout.setVisibility(View.VISIBLE);
|
||||
toolbar_search.setIconified(true);
|
||||
}
|
||||
//Selection comes from another menu, no action to do
|
||||
Bundle bundle = new Bundle();
|
||||
DisplayStatusFragment fragment = new DisplayStatusFragment();
|
||||
if (position == 0) {
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_HOME);
|
||||
}else if( position == 1) {
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_LOCAL);
|
||||
}else if( position == 2) {
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_DISCOVER);
|
||||
}
|
||||
bundle.putString("instanceType","PIXELFED");
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,10 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
PMYVIDEOS,
|
||||
PLOCAL,
|
||||
CHANNEL,
|
||||
MYVIDEOS
|
||||
MYVIDEOS,
|
||||
PF_HOME,
|
||||
PF_LOCAL,
|
||||
PF_DISCOVER
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,7 +49,8 @@ public class UpdateAccountInfoAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
public enum SOCIAL{
|
||||
MASTODON,
|
||||
PEERTUBE
|
||||
PEERTUBE,
|
||||
PIXELFED
|
||||
}
|
||||
public UpdateAccountInfoAsyncTask(Context context, String token, String client_id, String client_secret, String refresh_token, String instance, SOCIAL social){
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
|
|
|
@ -1267,11 +1267,27 @@ public class Helper {
|
|||
MenuItem itemOpt = menu.findItem(R.id.nav_main_opt);
|
||||
if( itemOpt != null)
|
||||
itemOpt.setVisible(false);
|
||||
MenuItem itemPFCom = menu.findItem(R.id.nav_pixelfed_comm);
|
||||
if( itemPFCom != null)
|
||||
itemPFCom.setVisible(false);
|
||||
|
||||
}else if( BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED){
|
||||
MenuItem itemCom = menu.findItem(R.id.nav_main_com);
|
||||
if( itemCom != null)
|
||||
itemCom.setVisible(false);
|
||||
MenuItem itemOpt = menu.findItem(R.id.nav_main_opt);
|
||||
if( itemOpt != null)
|
||||
itemOpt.setVisible(false);
|
||||
MenuItem itemPCom = menu.findItem(R.id.nav_peertube_comm);
|
||||
if( itemPCom != null)
|
||||
itemPCom.setVisible(false);
|
||||
}else if( BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON){
|
||||
MenuItem itemCom = menu.findItem(R.id.nav_peertube_comm);
|
||||
if( itemCom != null)
|
||||
itemCom.setVisible(false);
|
||||
MenuItem itemPFCom = menu.findItem(R.id.nav_pixelfed_comm);
|
||||
if( itemPFCom != null)
|
||||
itemPFCom.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
|
||||
</vector>
|
|
@ -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="M2,6L0,6v5h0.01L0,20c0,1.1 0.9,2 2,2h18v-2L2,20L2,6zM22,4h-8l-2,-2L6,2c-1.1,0 -1.99,0.9 -1.99,2L4,16c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L24,6c0,-1.1 -0.9,-2 -2,-2zM7,15l4.5,-6 3.5,4.51 2.5,-3.01L21,15L7,15z"/>
|
||||
</vector>
|
|
@ -1,4 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2018 Thomas Schneider
|
||||
|
||||
This file is a part of Mastalab
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2019 Thomas Schneider
|
||||
|
||||
This file is a part of Mastalab
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
<android.support.v7.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/pf_pp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp" />
|
||||
<TextView
|
||||
android:id="@+id/pf_username"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:id="@+id/art_media"
|
||||
android:scaleType="fitCenter"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/pf_likes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:id="@+id/pf_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pf_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<group>
|
||||
<!-- MASTODON MENU -->
|
||||
<item
|
||||
android:title="@string/communication_menu_title"
|
||||
android:id="@+id/nav_main_com"
|
||||
|
@ -50,6 +51,7 @@
|
|||
</group>
|
||||
</menu>
|
||||
</item>
|
||||
<!-- PEERTUBE MENU -->
|
||||
<item
|
||||
android:title="@string/communication_menu_title"
|
||||
android:id="@+id/nav_peertube_comm"
|
||||
|
@ -76,6 +78,43 @@
|
|||
</group>
|
||||
</menu>
|
||||
</item>
|
||||
<!-- PIXELFED MENU -->
|
||||
<item
|
||||
android:title="@string/communication_menu_title"
|
||||
android:id="@+id/nav_pixelfed_comm"
|
||||
>
|
||||
<menu>
|
||||
<group android:checkableBehavior="single">
|
||||
<!--
|
||||
<item
|
||||
android:id="@+id/nav_peertube_fav"
|
||||
android:icon="@drawable/ic_favorite_peertube_full"
|
||||
android:title="@string/peertube_favorites" />
|
||||
-->
|
||||
<item
|
||||
android:id="@+id/nav_my_photo"
|
||||
android:icon="@drawable/ic_pixelfed_media"
|
||||
android:title="@string/my_videos" />
|
||||
<item
|
||||
android:id="@+id/nav_pixelfed_favorites"
|
||||
android:icon="@drawable/ic_pixelfed_favorite"
|
||||
android:title="@string/favorites_menu" />
|
||||
<item
|
||||
android:id="@+id/nav_pixelfed_blocked"
|
||||
android:icon="@drawable/ic_block"
|
||||
android:title="@string/blocked_menu" />
|
||||
<item
|
||||
android:id="@+id/nav_pixelfed_muted"
|
||||
android:icon="@drawable/ic_volume_mute"
|
||||
android:title="@string/muted_menu" />
|
||||
<item
|
||||
android:id="@+id/nav_pixelfed_settings"
|
||||
android:icon="@drawable/ic_settings"
|
||||
android:title="@string/settings" />
|
||||
|
||||
</group>
|
||||
</menu>
|
||||
</item>
|
||||
<item
|
||||
android:title="@string/neutral_menu_title"
|
||||
android:id="@+id/nav_main_opt">
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<api name="value"></api>
|
||||
</resources>
|
Loading…
Reference in New Issue