Solve issue - #692

This commit is contained in:
stom79 2019-01-04 17:09:53 +01:00
parent 13785b0db3
commit 944f114d5f
6 changed files with 32 additions and 50 deletions

View File

@ -844,48 +844,6 @@ public abstract class BaseMainActivity extends BaseActivity
@Override
public void onTabReselected(TabLayout.Tab tab) {
if( viewPager.getVisibility() == View.GONE){
viewPager.setVisibility(View.VISIBLE);
delete_instance.setVisibility(View.GONE);
Helper.switchLayout(BaseMainActivity.this);
main_app_container.setVisibility(View.GONE);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
}
if( tab.getPosition() == 1 || (tabPosition.containsKey("art") && tab.getPosition() == tabPosition.get("art"))) {
toot.hide();
federatedTimelines.hide();
}else {
toot.show();
if( !displayFollowInstance)
federatedTimelines.hide();
else
federatedTimelines.show();
}
if( viewPager.getAdapter() != null) {
Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, tab.getPosition());
DisplayStatusFragment displayStatusFragment;
if (tab.getPosition() == 0) {
displayStatusFragment = ((DisplayStatusFragment) fragment);
countNewStatus = 0;
updateHomeCounter();
displayStatusFragment.scrollToTop();
displayStatusFragment.updateLastReadToot();
} else if( tab.getPosition() == 1) {
DisplayNotificationsFragment notificationsFragment = ((DisplayNotificationsFragment) fragment);
countNewNotifications = 0;
updateNotifCounter();
notificationsFragment.scrollToTop();
}else if (tab.getPosition() > 1) {
if (typePosition.containsKey(tab.getPosition()))
updateTimeLine(typePosition.get(tab.getPosition()), 0);
displayStatusFragment = ((DisplayStatusFragment) fragment);
displayStatusFragment.scrollToTop();
}
}
if( tab.getCustomView() != null) {
ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon);
if( icon != null)
@ -2097,6 +2055,12 @@ public abstract class BaseMainActivity extends BaseActivity
fragmentManager.beginTransaction()
.replace(R.id.main_app_container, displayFavoritesPeertubeFragment, fragmentTag).commit();
toot.hide();
}else if (id == R.id.nav_peertube_fav) {
DisplayFavoritesPeertubeFragment displayFavoritesPeertubeFragment = new DisplayFavoritesPeertubeFragment();
fragmentTag = "BOOKMARKS_PEERTUBE";
fragmentManager.beginTransaction()
.replace(R.id.main_app_container, displayFavoritesPeertubeFragment, fragmentTag).commit();
toot.hide();
}else if( id == R.id.nav_follow_request){
toot.hide();
DisplayFollowRequestSentFragment followRequestSentFragment = new DisplayFollowRequestSentFragment();

View File

@ -819,7 +819,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
if( relationship == null)
return;
account_follow.setEnabled(true);
if( account.getId() != null && account.getId().equals(userId)){
if( account.getId() != null && account.getId().equals(userId) && MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON){
account_follow.hide();
header_edit_profile.show();
header_edit_profile.bringToFront();

View File

@ -19,9 +19,12 @@ import android.os.AsyncTask;
import java.lang.ref.WeakReference;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountInterface;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.client.Entities.Error;
import fr.gouv.etalab.mastodon.client.PeertubeAPI;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountInterface;
/**
@ -35,7 +38,7 @@ public class RetrieveAccountAsyncTask extends AsyncTask<Void, Void, Void> {
private String targetedId;
private Account account;
private OnRetrieveAccountInterface listener;
private API api;
private Error error;
private WeakReference<Context> contextReference;
public RetrieveAccountAsyncTask(Context context, String targetedId, OnRetrieveAccountInterface onRetrieveAccountInterface){
@ -46,14 +49,21 @@ public class RetrieveAccountAsyncTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
api = new API(this.contextReference.get());
account = api.getAccount(targetedId);
if(MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
API api = new API(this.contextReference.get());
account = api.getAccount(targetedId);
error = api.getError();
}else if(MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
PeertubeAPI peertubeAPI = new PeertubeAPI(this.contextReference.get());
account = peertubeAPI.getAccount(targetedId);
error = peertubeAPI.getError();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
listener.onRetrieveAccount(account, api.getError());
listener.onRetrieveAccount(account, error);
}
}

View File

@ -237,7 +237,7 @@ public class PeertubeAPI {
account = new Account();
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/accounts/%s",accountId)), 60, null, prefKeyOauthTokenT);
account = parseAccountResponse(context, new JSONObject(response));
account = parseAccountResponsePeertube(context, new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
} catch (NoSuchAlgorithmException e) {

View File

@ -1749,7 +1749,11 @@ public class Helper {
if (account != null) {
Intent intent = new Intent(activity, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", account.getId());
if(MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
b.putBoolean("peertubeaccount", true);
b.putString("accountId", account.getAcct());
}else
b.putString("accountId", account.getId());
intent.putExtras(b);
activity.startActivity(intent);
}

View File

@ -56,6 +56,10 @@
>
<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_upload"
android:icon="@drawable/ic_cloud_upload"