diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c83e503..601bfa8 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -58,6 +58,11 @@
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysHidden" />
+
. */
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.res.ColorStateList;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
@@ -26,8 +23,6 @@ import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -36,7 +31,6 @@ import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
@@ -48,45 +42,34 @@ import com.google.android.material.tabs.TabLayout;
import org.jetbrains.annotations.NotNull;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
import app.fedilab.fedilabtube.client.APIResponse;
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
-import app.fedilab.fedilabtube.client.data.ChannelData.Channel;
+import app.fedilab.fedilabtube.client.data.AccountData;
import app.fedilab.fedilabtube.fragment.DisplayAccountsFragment;
+import app.fedilab.fedilabtube.fragment.DisplayChannelsFragment;
import app.fedilab.fedilabtube.fragment.DisplayVideosFragment;
import app.fedilab.fedilabtube.helper.Helper;
-import app.fedilab.fedilabtube.viewmodel.ChannelsVM;
+import app.fedilab.fedilabtube.viewmodel.AccountsVM;
import app.fedilab.fedilabtube.viewmodel.PostActionsVM;
-import app.fedilab.fedilabtube.viewmodel.RelationshipVM;
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
import es.dmoral.toasty.Toasty;
import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY;
-import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.FOLLOW;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.MUTE;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT;
-import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.UNFOLLOW;
-import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.DataType.CHANNEL;
-import static app.fedilab.fedilabtube.helper.Helper.getLiveInstance;
-import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
public class ShowAccountActivity extends AppCompatActivity {
- private Button account_follow;
private ViewPager mPager;
private TabLayout tabLayout;
private TextView account_note, subscriber_count;
- private Map relationship;
private ImageView account_pp;
private TextView account_dn;
- private Channel channel;
- private action doAction;
- private String channelAcct;
+ private AccountData.Account account;
+ private String accountAcct;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -94,15 +77,13 @@ public class ShowAccountActivity extends AppCompatActivity {
setContentView(R.layout.activity_show_account);
setTitle("");
Bundle b = getIntent().getExtras();
- account_follow = findViewById(R.id.account_follow);
subscriber_count = findViewById(R.id.subscriber_count);
- account_follow.setEnabled(false);
account_pp = findViewById(R.id.account_pp);
account_dn = findViewById(R.id.account_dn);
account_pp.setBackgroundResource(R.drawable.account_pp_border);
if (b != null) {
- channel = b.getParcelable("channel");
- channelAcct = b.getString("channelId");
+ account = b.getParcelable("account");
+ accountAcct = b.getString("accountAcct");
} else {
Toasty.error(ShowAccountActivity.this, getString(R.string.toast_error_loading_account), Toast.LENGTH_LONG).show();
}
@@ -114,11 +95,9 @@ public class ShowAccountActivity extends AppCompatActivity {
tabLayout = findViewById(R.id.account_tabLayout);
account_note = findViewById(R.id.account_note);
-
- ChannelsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(ChannelsVM.class);
-
- manageChannel();
- viewModel.get(CHANNEL, channelAcct == null ? channel.getName() + "@" + channel.getHost() : channelAcct).observe(ShowAccountActivity.this, this::manageViewAccounts);
+ manageAccount();
+ AccountsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(AccountsVM.class);
+ viewModel.getAccount(accountAcct == null ? account.getUsername() + "@" + account.getHost() : accountAcct).observe(ShowAccountActivity.this, this::manageViewAccounts);
}
@Override
@@ -137,7 +116,7 @@ public class ShowAccountActivity extends AppCompatActivity {
return true;
} else if (item.getItemId() == R.id.action_mute) {
PostActionsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(PostActionsVM.class);
- viewModel.post(MUTE, channel.getOwnerAccount() != null ? channel.getOwnerAccount().getAcct() : channel.getAcct(), null).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(MUTE, apiResponse));
+ viewModel.post(MUTE, accountAcct == null ? account.getUsername() + "@" + account.getHost() : accountAcct, null).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(MUTE, apiResponse));
} else if (item.getItemId() == R.id.action_report) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ShowAccountActivity.this);
LayoutInflater inflater1 = getLayoutInflater();
@@ -150,7 +129,7 @@ public class ShowAccountActivity extends AppCompatActivity {
Toasty.info(ShowAccountActivity.this, getString(R.string.report_comment_size), Toasty.LENGTH_LONG).show();
} else {
PostActionsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(PostActionsVM.class);
- viewModel.post(REPORT_ACCOUNT, channel.getId(), report_content.getText().toString()).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(REPORT_ACCOUNT, apiResponse));
+ viewModel.post(REPORT_ACCOUNT, account.getId(), report_content.getText().toString()).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(REPORT_ACCOUNT, apiResponse));
dialog.dismiss();
}
});
@@ -160,30 +139,18 @@ public class ShowAccountActivity extends AppCompatActivity {
return super.onOptionsItemSelected(item);
}
- private void manageChannel() {
- SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
+ private void manageAccount() {
- String accountIdRelation = channel.getAcct();
- if (isLoggedIn(ShowAccountActivity.this)) {
- RelationshipVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(RelationshipVM.class);
- List uids = new ArrayList<>();
- uids.add(accountIdRelation);
- viewModel.get(uids).observe(ShowAccountActivity.this, this::manageVIewRelationship);
- }
-
- setTitle(channel.getAcct());
+ setTitle(account.getAcct());
mPager = findViewById(R.id.account_viewpager);
+ tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.channels)));
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.videos)));
- mPager.setOffscreenPageLimit(1);
-
+ mPager.setOffscreenPageLimit(2);
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter);
- ViewGroup.LayoutParams params = tabLayout.getLayoutParams();
- params.height = 0;
- tabLayout.setLayoutParams(params);
mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
@@ -222,111 +189,26 @@ public class ShowAccountActivity extends AppCompatActivity {
switch (tab.getPosition()) {
case 0:
if (fragment != null) {
- DisplayVideosFragment displayVideosFragment = ((DisplayVideosFragment) fragment);
- displayVideosFragment.scrollToTop();
+ DisplayChannelsFragment displayChannelsFragment = ((DisplayChannelsFragment) fragment);
+ displayChannelsFragment.scrollToTop();
}
break;
case 1:
if (fragment != null) {
- DisplayAccountsFragment displayAccountsFragment = ((DisplayAccountsFragment) fragment);
- displayAccountsFragment.scrollToTop();
+ DisplayVideosFragment displayVideosFragment = ((DisplayVideosFragment) fragment);
+ displayVideosFragment.scrollToTop();
}
break;
}
}
});
- account_dn.setText(channel.getDisplayName());
+ account_dn.setText(account.getDisplayName());
-
- manageNotes(channel);
- Helper.loadGiF(ShowAccountActivity.this, channel.getAvatar() != null ? channel.getAvatar().getPath() : null, account_pp);
- //Follow button
- String target = channel.getAcct();
-
- account_follow.setOnClickListener(v -> {
- if (doAction == action.NOTHING) {
- Toasty.info(ShowAccountActivity.this, getString(R.string.nothing_to_do), Toast.LENGTH_LONG).show();
- } else if (doAction == action.FOLLOW) {
- account_follow.setEnabled(false);
- PostActionsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(PostActionsVM.class);
- viewModel.post(FOLLOW, target, null).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(FOLLOW, apiResponse));
- } else if (doAction == action.UNFOLLOW) {
- boolean confirm_unfollow = sharedpreferences.getBoolean(Helper.SET_UNFOLLOW_VALIDATION, true);
- if (confirm_unfollow) {
- AlertDialog.Builder unfollowConfirm = new AlertDialog.Builder(ShowAccountActivity.this);
- unfollowConfirm.setTitle(getString(R.string.unfollow_confirm));
- unfollowConfirm.setMessage(channel.getAcct());
- unfollowConfirm.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
- unfollowConfirm.setPositiveButton(R.string.yes, (dialog, which) -> {
- account_follow.setEnabled(false);
- PostActionsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(PostActionsVM.class);
- viewModel.post(UNFOLLOW, target, null).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(UNFOLLOW, apiResponse));
- dialog.dismiss();
- });
- unfollowConfirm.show();
- } else {
- account_follow.setEnabled(false);
- PostActionsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(PostActionsVM.class);
- viewModel.post(UNFOLLOW, target, null).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(UNFOLLOW, apiResponse));
- }
-
- }
- });
+ manageNotes(account);
+ Helper.loadGiF(ShowAccountActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, account_pp);
}
-
- public void manageVIewRelationship(APIResponse apiResponse) {
-
- if (apiResponse.getError() != null) {
- Toasty.error(ShowAccountActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
- return;
- }
- this.relationship = apiResponse.getRelationships();
- manageButtonVisibility();
-
- invalidateOptionsMenu();
-
- }
-
- //Manages the visibility of the button
- private void manageButtonVisibility() {
- if (relationship == null)
- return;
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- int[][] states = new int[][]{
- new int[]{android.R.attr.state_enabled}, // enabled
- new int[]{-android.R.attr.state_enabled}, // disabled
- new int[]{-android.R.attr.state_checked}, // unchecked
- new int[]{android.R.attr.state_pressed} // pressed
- };
-
- int[] colors = new int[]{
- ContextCompat.getColor(ShowAccountActivity.this, Helper.getColorAccent()),
- ContextCompat.getColor(ShowAccountActivity.this, Helper.getColorAccent()),
- ContextCompat.getColor(ShowAccountActivity.this, Helper.getColorAccent()),
- ContextCompat.getColor(ShowAccountActivity.this, Helper.getColorAccent())
- };
- account_follow.setBackgroundTintList(new ColorStateList(states, colors));
- }
- account_follow.setEnabled(true);
-
- boolean isFollowing = relationship.get(channel.getAcct());
- if (isFollowing) {
- account_follow.setText(R.string.action_unfollow);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- account_follow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(ShowAccountActivity.this, R.color.red_1)));
- }
- doAction = action.UNFOLLOW;
- } else {
- account_follow.setText(R.string.action_follow);
- doAction = action.FOLLOW;
- }
- account_follow.setVisibility(View.VISIBLE);
- }
-
-
@Override
public void onDestroy() {
super.onDestroy();
@@ -344,47 +226,31 @@ public class ShowAccountActivity extends AppCompatActivity {
Toasty.error(ShowAccountActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
return;
}
- String target = channel.getAcct();
- //IF action is unfollow or mute, sends an intent to remove statuses
- if (statusAction == RetrofitPeertubeAPI.ActionType.UNFOLLOW) {
- Bundle b = new Bundle();
- b.putString("receive_action", apiResponse.getTargetedId());
- Intent intentBC = new Intent(Helper.RECEIVE_ACTION);
- intentBC.putExtras(b);
- }
- if (statusAction == RetrofitPeertubeAPI.ActionType.UNFOLLOW || statusAction == RetrofitPeertubeAPI.ActionType.FOLLOW) {
- RelationshipVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(RelationshipVM.class);
- List uris = new ArrayList<>();
- uris.add(target);
- viewModel.get(uris).observe(ShowAccountActivity.this, this::manageVIewRelationship);
- } else if (statusAction == RetrofitPeertubeAPI.ActionType.MUTE) {
+ if (statusAction == RetrofitPeertubeAPI.ActionType.MUTE) {
Toasty.info(ShowAccountActivity.this, getString(R.string.muted_done), Toast.LENGTH_LONG).show();
}
}
public void manageViewAccounts(APIResponse apiResponse) {
- if (apiResponse.getChannels() != null && apiResponse.getChannels().size() == 1) {
- Channel channel = apiResponse.getChannels().get(0);
- if (this.channel == null) {
- this.channel = channel;
- manageChannel();
+ if (apiResponse.getAccounts() != null && apiResponse.getAccounts().size() == 1) {
+ AccountData.Account account = apiResponse.getAccounts().get(0);
+ if (this.account == null) {
+ this.account = account;
+ manageAccount();
}
- if (channel.getOwnerAccount() != null) {
- this.channel.setOwnerAccount(channel.getOwnerAccount());
- }
- subscriber_count.setText(getString(R.string.followers_count, Helper.withSuffix(channel.getFollowersCount())));
+ subscriber_count.setText(getString(R.string.followers_count, Helper.withSuffix(account.getFollowersCount())));
subscriber_count.setVisibility(View.VISIBLE);
- manageNotes(channel);
+ manageNotes(account);
}
}
- private void manageNotes(Channel channel) {
- if (channel.getDescription() != null && channel.getDescription().compareTo("null") != 0 && channel.getDescription().trim().length() > 0) {
+ private void manageNotes(AccountData.Account account) {
+ if (account.getDescription() != null && account.getDescription().compareTo("null") != 0 && account.getDescription().trim().length() > 0) {
SpannableString spannableString;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- spannableString = new SpannableString(Html.fromHtml(channel.getDescription(), FROM_HTML_MODE_LEGACY));
+ spannableString = new SpannableString(Html.fromHtml(account.getDescription(), FROM_HTML_MODE_LEGACY));
else
- spannableString = new SpannableString(Html.fromHtml(channel.getDescription()));
+ spannableString = new SpannableString(Html.fromHtml(account.getDescription()));
account_note.setText(spannableString, TextView.BufferType.SPANNABLE);
account_note.setMovementMethod(LinkMovementMethod.getInstance());
@@ -394,11 +260,6 @@ public class ShowAccountActivity extends AppCompatActivity {
}
}
- public enum action {
- FOLLOW,
- UNFOLLOW,
- NOTHING
- }
/**
* Pager adapter for the 2 fragments
@@ -414,25 +275,24 @@ public class ShowAccountActivity extends AppCompatActivity {
public Fragment getItem(int position) {
Bundle bundle = new Bundle();
if (position == 0) {
- DisplayVideosFragment displayVideosFragment = new DisplayVideosFragment();
- bundle = new Bundle();
- bundle.putSerializable("type", TimelineVM.TimelineType.USER_VIDEOS);
- bundle.putString("channelId", channel.getAcct());
- displayVideosFragment.setArguments(bundle);
- return displayVideosFragment;
+ DisplayChannelsFragment displayChannelsFragment = new DisplayChannelsFragment();
+ bundle.putString("name", account.getAcct());
+ bundle.putBoolean("myChannels", false);
+ displayChannelsFragment.setArguments(bundle);
+ return displayChannelsFragment;
}
- DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment();
- bundle.putString("targetedid", channel.getId());
- bundle.putString("instance", getLiveInstance(ShowAccountActivity.this));
- bundle.putString("name", channel.getAcct());
- displayAccountsFragment.setArguments(bundle);
- return displayAccountsFragment;
+ DisplayVideosFragment displayVideosFragment = new DisplayVideosFragment();
+ bundle.putSerializable(Helper.TIMELINE_TYPE, TimelineVM.TimelineType.ACCOUNT_VIDEOS);
+ bundle.putString("channelId", account.getAcct());
+ bundle.putString("peertube_instance", account.getHost());
+ displayVideosFragment.setArguments(bundle);
+ return displayVideosFragment;
}
@Override
public int getCount() {
- return 1;
+ return 2;
}
}
diff --git a/app/src/main/java/app/fedilab/fedilabtube/ShowChannelActivity.java b/app/src/main/java/app/fedilab/fedilabtube/ShowChannelActivity.java
index ed9a0a7..7e19796 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/ShowChannelActivity.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/ShowChannelActivity.java
@@ -92,7 +92,7 @@ public class ShowChannelActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_show_account);
+ setContentView(R.layout.activity_show_channel);
setTitle("");
Bundle b = getIntent().getExtras();
account_follow = findViewById(R.id.account_follow);
@@ -417,7 +417,7 @@ public class ShowChannelActivity extends AppCompatActivity {
public Fragment getItem(int position) {
DisplayVideosFragment displayVideosFragment = new DisplayVideosFragment();
Bundle bundle = new Bundle();
- bundle.putSerializable(Helper.TIMELINE_TYPE, TimelineVM.TimelineType.USER_VIDEOS);
+ bundle.putSerializable(Helper.TIMELINE_TYPE, TimelineVM.TimelineType.CHANNEL_VIDEOS);
bundle.putString("channelId", channel.getAcct());
bundle.putString("peertube_instance", channel.getHost());
bundle.putBoolean("sepia_search", sepiaSearch);
diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeService.java b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeService.java
index 08d2c69..7b9a0eb 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeService.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeService.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
+import app.fedilab.fedilabtube.client.data.AccountData;
import app.fedilab.fedilabtube.client.data.BlockData;
import app.fedilab.fedilabtube.client.data.CaptionData;
import app.fedilab.fedilabtube.client.data.ChannelData;
@@ -165,7 +166,7 @@ public interface PeertubeService {
//Get my video
@GET("accounts/{name}/videos?sort=-publishedAt")
- Call getVideosForAccount(@Query("start") String maxId, @Query("count") String count);
+ Call getVideosForAccount(@Path("name") String name, @Query("start") String maxId, @Query("count") String count);
@Multipart
@PUT("videos/{id}")
@@ -228,6 +229,11 @@ public interface PeertubeService {
@GET("video-playlists")
Call getPlaylists();
+
+ //Get a single account
+ @GET("accounts/{accountHandle}")
+ Call getAccount(@Path("accountHandle") String accountHandle);
+
//Get/Post/Update/Delete playlist
@GET("accounts/{accountHandle}/video-playlists")
Call getPlaylistsForAccount(@Header("Authorization") String credentials, @Path("accountHandle") String accountHandle);
diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/RetrofitPeertubeAPI.java b/app/src/main/java/app/fedilab/fedilabtube/client/RetrofitPeertubeAPI.java
index 3a27223..2e66753 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/client/RetrofitPeertubeAPI.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/client/RetrofitPeertubeAPI.java
@@ -320,6 +320,9 @@ public class RetrofitPeertubeAPI {
case MY_VIDEOS:
videoCall = peertubeService.getMyVideos(getToken(), max_id, count);
break;
+ case ACCOUNT_VIDEOS:
+ videoCall = peertubeService.getVideosForAccount(forAccount, max_id, count);
+ break;
case SUBSCRIBTIONS:
if (forAccount == null) {
videoCall = peertubeService.getSubscriptionVideos(getToken(), max_id, count, filter);
@@ -844,6 +847,38 @@ public class RetrofitPeertubeAPI {
return apiResponse;
}
+
+ /**
+ * Get single account by its handle
+ *
+ * @param accountHandle String
+ * @return APIResponse
+ */
+ public APIResponse getAccount(String accountHandle) {
+ PeertubeService peertubeService = init();
+ Call accountDataCall = peertubeService.getAccount(accountHandle);
+ APIResponse apiResponse = new APIResponse();
+ if (accountDataCall != null) {
+ try {
+ Response response = accountDataCall.execute();
+ if (response.isSuccessful() && response.body() != null) {
+ List accountList = new ArrayList<>();
+ accountList.add(response.body());
+ apiResponse.setAccounts(accountList);
+ } else {
+ setError(apiResponse, response.code(), response.errorBody());
+ }
+ } catch (IOException e) {
+ Error error = new Error();
+ error.setError(_context.getString(R.string.toast_error));
+ apiResponse.setError(error);
+ e.printStackTrace();
+ }
+ }
+ return apiResponse;
+ }
+
+
/**
* Get muted accounts
*
diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/ChannelListAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/ChannelListAdapter.java
index ac658fd..6bd92e6 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/drawer/ChannelListAdapter.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/ChannelListAdapter.java
@@ -46,12 +46,14 @@ public class ChannelListAdapter extends RecyclerView.Adapter channels;
+ private final List channels;
private Context context;
+ private final boolean myChannel;
- public ChannelListAdapter(List channels) {
+ public ChannelListAdapter(List channels, boolean myChannel) {
this.channels = channels;
+ this.myChannel = myChannel;
}
@NonNull
@@ -75,7 +77,9 @@ public class ChannelListAdapter extends RecyclerView.Adapter {
PopupMenu popup = new PopupMenu(context, holder.more_actions);
popup.getMenuInflater()
@@ -84,35 +88,33 @@ public class ChannelListAdapter extends RecyclerView.Adapter {
- switch (item.getItemId()) {
- case R.id.action_delete:
- AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(context.getString(R.string.delete_channel) + ": " + channel.getName());
- builder.setMessage(context.getString(R.string.action_channel_confirm_delete));
- builder.setIcon(android.R.drawable.ic_dialog_alert)
- .setPositiveButton(R.string.yes, (dialog, which) -> {
- new Thread(() -> {
- new RetrofitPeertubeAPI(context).post(RetrofitPeertubeAPI.ActionType.DELETE_CHANNEL, channel.getName(), null);
- Handler mainHandler = new Handler(Looper.getMainLooper());
- Runnable myRunnable = () -> {
- channels.remove(channel);
- notifyDataSetChanged();
- if (channels.size() == 0) {
- allChannelRemoved.onAllChannelRemoved();
- }
- };
- mainHandler.post(myRunnable);
- }).start();
- dialog.dismiss();
- })
- .setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
- .show();
- break;
- case R.id.action_edit:
- if (context instanceof AccountActivity) {
- editAlertDialog.show(channel);
- }
- break;
+ int itemId = item.getItemId();
+ if (itemId == R.id.action_delete) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setTitle(context.getString(R.string.delete_channel) + ": " + channel.getName());
+ builder.setMessage(context.getString(R.string.action_channel_confirm_delete));
+ builder.setIcon(android.R.drawable.ic_dialog_alert)
+ .setPositiveButton(R.string.yes, (dialog, which) -> {
+ new Thread(() -> {
+ new RetrofitPeertubeAPI(context).post(RetrofitPeertubeAPI.ActionType.DELETE_CHANNEL, channel.getName(), null);
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () -> {
+ channels.remove(channel);
+ notifyDataSetChanged();
+ if (channels.size() == 0) {
+ allChannelRemoved.onAllChannelRemoved();
+ }
+ };
+ mainHandler.post(myRunnable);
+ }).start();
+ dialog.dismiss();
+ })
+ .setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
+ .show();
+ } else if (itemId == R.id.action_edit) {
+ if (context instanceof AccountActivity) {
+ editAlertDialog.show(channel);
+ }
}
return true;
});
diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeNotificationsListAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeNotificationsListAdapter.java
index 5899f0d..4484965 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeNotificationsListAdapter.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeNotificationsListAdapter.java
@@ -68,7 +68,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter {
- Intent intent = new Intent(context, ShowChannelActivity.class);
- Bundle b = new Bundle();
- b.putString("channelId", accountActionFollow.getName() + "@" + accountActionFollow.getHost());
- intent.putExtras(b);
- context.startActivity(intent);
- });
+ Actor actor = notification.getActorFollow().getFollower();
+ accountAction = new AccountData.Account();
+ accountAction.setAvatar(actor.getAvatar());
+ accountAction.setDisplayName(actor.getDisplayName());
+ accountAction.setHost(actor.getHost());
+ accountAction.setUsername(actor.getName());
} else if (notification.getComment() != null) { //Comment Notification
String profileUrl = notification.getComment().getAccount().getAvatar() != null ? notification.getComment().getAccount().getAvatar().getPath() : null;
Helper.loadGiF(context, profileUrl, holder.peertube_notif_pp);
@@ -117,10 +116,9 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter {
@@ -180,7 +179,8 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter();
+ myChannels = true;
if (bundle != null) {
name = bundle.getString("name", null);
+ myChannels = bundle.getBoolean("myChannels", true);
}
swiped = false;
@@ -86,8 +89,10 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
if (getActivity() != null) {
action_button = getActivity().findViewById(R.id.action_button);
- action_button.setVisibility(View.VISIBLE);
- action_button.setOnClickListener(view -> manageAlert(null));
+ if( action_button != null) {
+ action_button.setVisibility(View.VISIBLE);
+ action_button.setOnClickListener(view -> manageAlert(null));
+ }
}
lv_channels = rootView.findViewById(R.id.lv_elements);
@@ -97,7 +102,7 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
textviewNoAction = rootView.findViewById(R.id.no_action);
mainLoader.setVisibility(View.VISIBLE);
nextElementLoader.setVisibility(View.GONE);
- channelListAdapter = new ChannelListAdapter(this.channels);
+ channelListAdapter = new ChannelListAdapter(this.channels, myChannels);
channelListAdapter.allChannelRemoved = this;
channelListAdapter.editAlertDialog = this;
lv_channels.setAdapter(channelListAdapter);
@@ -170,7 +175,7 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
textviewNoAction.setVisibility(View.GONE);
if (swiped) {
- channelListAdapter = new ChannelListAdapter(this.channels);
+ channelListAdapter = new ChannelListAdapter(this.channels, myChannels);
channelListAdapter.allChannelRemoved = DisplayChannelsFragment.this;
channelListAdapter.editAlertDialog = DisplayChannelsFragment.this;
lv_channels.setAdapter(channelListAdapter);
@@ -267,12 +272,16 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
}
channelListAdapter.notifyItemChanged(position);
}
- action_button.setEnabled(true);
+ if( action_button != null) {
+ action_button.setEnabled(true);
+ }
};
mainHandler.post(myRunnable);
}).start();
alertDialog.dismiss();
- action_button.setEnabled(false);
+ if( action_button != null) {
+ action_button.setEnabled(false);
+ }
} else {
Toasty.error(context, context.getString(R.string.error_display_name_channel), Toast.LENGTH_LONG).show();
}
diff --git a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayVideosFragment.java b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayVideosFragment.java
index 4e38df9..a929d62 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayVideosFragment.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayVideosFragment.java
@@ -121,7 +121,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
playlistId = bundle.getString("playlistId", null);
}
max_id = "0";
- forAccount = null;
+ forAccount = type== TimelineVM.TimelineType.ACCOUNT_VIDEOS?channelId: null;
lv_status = rootView.findViewById(R.id.lv_status);
RecyclerView lv_accounts = rootView.findViewById(R.id.lv_accounts);
Button display_all = rootView.findViewById(R.id.display_all);
@@ -497,7 +497,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
*/
private void loadTimeline(String max_id) {
if (search_peertube == null) { //Not a Peertube search
- if (type == TimelineVM.TimelineType.USER_VIDEOS) {
+ if (type == TimelineVM.TimelineType.CHANNEL_VIDEOS) {
viewModelFeeds.getVideosInChannel(sepiaSearch?remoteInstance:null, channelId, max_id).observe(this.requireActivity(), this::manageVIewVideos);
} else if (type == TimelineVM.TimelineType.VIDEOS_IN_PLAYLIST) {
viewModelFeeds.loadVideosInPlaylist(playlistId, max_id).observe(this.requireActivity(), this::manageVIewVideos);
@@ -523,9 +523,9 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
static class GridSpacingItemDecoration extends RecyclerView.ItemDecoration {
- private int spanCount;
- private int spacing;
- private boolean includeEdge;
+ private final int spanCount;
+ private final int spacing;
+ private final boolean includeEdge;
public GridSpacingItemDecoration(int spanCount, int spacing, boolean includeEdge) {
this.spanCount = spanCount;
diff --git a/app/src/main/java/app/fedilab/fedilabtube/viewmodel/AccountsVM.java b/app/src/main/java/app/fedilab/fedilabtube/viewmodel/AccountsVM.java
index de2b372..e21120f 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/viewmodel/AccountsVM.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/viewmodel/AccountsVM.java
@@ -41,6 +41,12 @@ public class AccountsVM extends AndroidViewModel {
return apiResponseMutableLiveData;
}
+ public LiveData getAccount(String acct) {
+ apiResponseMutableLiveData = new MutableLiveData<>();
+ loadAccount(acct);
+ return apiResponseMutableLiveData;
+ }
+
private void loadAccounts(RetrofitPeertubeAPI.DataType dataType, String element) {
Context _mContext = getApplication().getApplicationContext();
new Thread(() -> {
@@ -62,4 +68,18 @@ public class AccountsVM extends AndroidViewModel {
}).start();
}
+ private void loadAccount(String acct) {
+ Context _mContext = getApplication().getApplicationContext();
+ new Thread(() -> {
+ try {
+ RetrofitPeertubeAPI retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
+ APIResponse apiResponse = retrofitPeertubeAPI.getAccount(acct);
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
+ mainHandler.post(myRunnable);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }).start();
+ }
}
diff --git a/app/src/main/java/app/fedilab/fedilabtube/viewmodel/TimelineVM.java b/app/src/main/java/app/fedilab/fedilabtube/viewmodel/TimelineVM.java
index 3ee0792..8037015 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/viewmodel/TimelineVM.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/viewmodel/TimelineVM.java
@@ -181,7 +181,8 @@ public class TimelineVM extends AndroidViewModel {
public enum TimelineType {
- USER_VIDEOS,
+ CHANNEL_VIDEOS,
+ ACCOUNT_VIDEOS,
SUBSCRIBTIONS,
MY_VIDEOS,
LOCAL,
diff --git a/app/src/main/res/layout/activity_show_account.xml b/app/src/main/res/layout/activity_show_account.xml
index 9e5defd..1daf4ff 100644
--- a/app/src/main/res/layout/activity_show_account.xml
+++ b/app/src/main/res/layout/activity_show_account.xml
@@ -83,34 +83,10 @@
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="@android:color/white"
android:visibility="invisible"
- app:layout_constraintBottom_toBottomOf="@id/account_follow"
+ app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/account_pp"
app:layout_constraintTop_toBottomOf="@id/account_dn" />
-
-
-
-
@@ -135,11 +111,8 @@
android:visibility="gone" />
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_show_channel.xml b/app/src/main/res/layout/activity_show_channel.xml
new file mode 100644
index 0000000..9e5defd
--- /dev/null
+++ b/app/src/main/res/layout/activity_show_channel.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file