Add some elements

This commit is contained in:
Thomas 2023-03-14 18:00:47 +01:00
parent 20c797520e
commit e28b3fcf76
9 changed files with 327 additions and 15 deletions

View file

@ -1352,6 +1352,12 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
} else if (id == R.id.nav_cache) { } else if (id == R.id.nav_cache) {
Intent intent = new Intent(BaseMainActivity.this, CacheActivity.class); Intent intent = new Intent(BaseMainActivity.this, CacheActivity.class);
startActivity(intent); startActivity(intent);
} else if (id == R.id.nav_peertube) {
Intent intent = new Intent(BaseMainActivity.this, PeertubeMainActivity.class);
Bundle bundle = new Bundle();
bundle.putBoolean(Helper.ARG_PEERTUBE_NAV_REMOTE, true);
intent.putExtras(bundle);
startActivity(intent);
} else if (id == R.id.nav_about_instance) { } else if (id == R.id.nav_about_instance) {
(new InstanceActivity()).show(getSupportFragmentManager(), null); (new InstanceActivity()).show(getSupportFragmentManager(), null);
} }

View file

@ -203,6 +203,8 @@ public class Helper {
public static final String RECEIVE_REDRAW_PROFILE = "RECEIVE_REDRAW_PROFILE"; public static final String RECEIVE_REDRAW_PROFILE = "RECEIVE_REDRAW_PROFILE";
public static final String ARG_TIMELINE_TYPE = "ARG_TIMELINE_TYPE"; public static final String ARG_TIMELINE_TYPE = "ARG_TIMELINE_TYPE";
public static final String ARG_PEERTUBE_NAV_REMOTE = "ARG_PEERTUBE_NAV_REMOTE";
public static final String ARG_REMOTE_INSTANCE_STRING = "ARG_REMOTE_INSTANCE_STRING"; public static final String ARG_REMOTE_INSTANCE_STRING = "ARG_REMOTE_INSTANCE_STRING";
public static final String ARG_NOTIFICATION_TYPE = "ARG_NOTIFICATION_TYPE"; public static final String ARG_NOTIFICATION_TYPE = "ARG_NOTIFICATION_TYPE";

View file

@ -17,11 +17,13 @@ package app.fedilab.android.peertube.activities;
import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO; import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO;
import static app.fedilab.android.BaseMainActivity.currentAccount; import static app.fedilab.android.BaseMainActivity.currentAccount;
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN;
import static app.fedilab.android.peertube.activities.PeertubeMainActivity.typeOfConnection;
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.ADD_COMMENT; import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.ADD_COMMENT;
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.RATEVIDEO; import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.RATEVIDEO;
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.REPLY; import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.REPLY;
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT; import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT;
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.REPORT_VIDEO; import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.REPORT_VIDEO;
import static app.fedilab.android.peertube.helper.Helper.canMakeAction;
import static app.fedilab.android.peertube.helper.Helper.getAttColor; import static app.fedilab.android.peertube.helper.Helper.getAttColor;
import static app.fedilab.android.peertube.helper.Helper.isLoggedIn; import static app.fedilab.android.peertube.helper.Helper.isLoggedIn;
import static app.fedilab.android.peertube.helper.Helper.loadAvatar; import static app.fedilab.android.peertube.helper.Helper.loadAvatar;
@ -111,6 +113,7 @@ import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoSize; import com.google.android.exoplayer2.video.VideoSize;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.varunest.sparkbutton.SparkButton;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -124,13 +127,16 @@ import java.util.Objects;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R; import app.fedilab.android.R;
import app.fedilab.android.activities.BasePeertubeActivity; import app.fedilab.android.activities.BasePeertubeActivity;
import app.fedilab.android.databinding.ActivityPeertubeBinding; import app.fedilab.android.databinding.ActivityPeertubeBinding;
import app.fedilab.android.databinding.PopupVideoInfoPeertubeBinding; import app.fedilab.android.databinding.PopupVideoInfoPeertubeBinding;
import app.fedilab.android.mastodon.client.entities.api.Status;
import app.fedilab.android.mastodon.client.entities.app.BaseAccount; import app.fedilab.android.mastodon.client.entities.app.BaseAccount;
import app.fedilab.android.mastodon.exception.DBException; import app.fedilab.android.mastodon.exception.DBException;
import app.fedilab.android.mastodon.helper.CacheDataSourceFactory; import app.fedilab.android.mastodon.helper.CacheDataSourceFactory;
import app.fedilab.android.mastodon.viewmodel.mastodon.StatusesVM;
import app.fedilab.android.peertube.client.APIResponse; import app.fedilab.android.peertube.client.APIResponse;
import app.fedilab.android.peertube.client.MenuItemVideo; import app.fedilab.android.peertube.client.MenuItemVideo;
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI; import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
@ -198,6 +204,8 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
private boolean isRemote; private boolean isRemote;
private boolean willPlayFromIntent; private boolean willPlayFromIntent;
private Status status;
public static void hideKeyboard(Activity activity) { public static void hideKeyboard(Activity activity) {
if (activity != null && activity.getWindow() != null) { if (activity != null && activity.getWindow() != null) {
activity.getWindow().getDecorView(); activity.getWindow().getDecorView();
@ -218,24 +226,24 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
max_id = "0"; max_id = "0";
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this);
String token = sharedpreferences.getString(PREF_USER_TOKEN, null); String token = sharedpreferences.getString(PREF_USER_TOKEN, null);
if (Helper.isLoggedIn() && !sepiaSearch) { if (Helper.canMakeAction() && !sepiaSearch) {
BaseAccount account = null; BaseAccount account = null;
try { try {
account = new app.fedilab.android.mastodon.client.entities.app.Account(PeertubeActivity.this).getAccountByToken(token); account = new app.fedilab.android.mastodon.client.entities.app.Account(PeertubeActivity.this).getAccountByToken(token);
} catch (DBException e) { } catch (DBException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (account != null) { if (account != null && account.peertube_account != null) {
loadAvatar(PeertubeActivity.this, account.peertube_account, binding.myPp); loadAvatar(PeertubeActivity.this, account.peertube_account, binding.myPp);
} else if (account != null && account.mastodon_account != null) {
app.fedilab.android.mastodon.helper.Helper.loadPP(PeertubeActivity.this, binding.myPp, account);
} }
} }
isRemote = false; isRemote = false;
fullScreenMode = false; fullScreenMode = false;
initialOrientation = getResources().getConfiguration().orientation; initialOrientation = getResources().getConfiguration().orientation;
if (Helper.isTablet(PeertubeActivity.this)) { if (Helper.isTablet(PeertubeActivity.this)) {
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams( LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT,
0, 0,
@ -276,6 +284,13 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
if (Helper.isLoggedIn()) { if (Helper.isLoggedIn()) {
binding.peertubePlaylist.setVisibility(View.VISIBLE); binding.peertubePlaylist.setVisibility(View.VISIBLE);
} else if (typeOfConnection == PeertubeMainActivity.TypeOfConnection.REMOTE_ACCOUNT) {
binding.peertubeLikeCount.setVisibility(View.GONE);
binding.peertubeDislikeCount.setVisibility(View.GONE);
binding.peertubePlaylist.setVisibility(View.GONE);
binding.peertubeReblog.setVisibility(View.VISIBLE);
binding.peertubeFavorite.setVisibility(View.VISIBLE);
binding.peertubeBookmark.setVisibility(View.VISIBLE);
} }
binding.peertubeDescriptionMore.setOnClickListener(v -> { binding.peertubeDescriptionMore.setOnClickListener(v -> {
@ -289,7 +304,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
} }
} }
}); });
if (!Helper.isLoggedIn() || sepiaSearch) { if (!Helper.canMakeAction() || sepiaSearch) {
binding.writeCommentContainer.setVisibility(View.GONE); binding.writeCommentContainer.setVisibility(View.GONE);
} }
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true); playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
@ -397,7 +412,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
openFullscreenDialog(); openFullscreenDialog();
} }
binding.postCommentButton.setOnClickListener(v -> { binding.postCommentButton.setOnClickListener(v -> {
if (Helper.isLoggedIn() && !sepiaSearch) { if (canMakeAction() && !sepiaSearch) {
openPostComment(null, 0); openPostComment(null, 0);
} else { } else {
if (sepiaSearch) { if (sepiaSearch) {
@ -489,6 +504,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
return comments; return comments;
} }
@Override @Override
public void onNewIntent(Intent intent) { public void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
@ -573,6 +589,15 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
} }
private void playVideo() { private void playVideo() {
if (status == null && typeOfConnection == PeertubeMainActivity.TypeOfConnection.REMOTE_ACCOUNT) {
app.fedilab.android.mastodon.viewmodel.mastodon.SearchVM searchVM = new ViewModelProvider(PeertubeActivity.this).get(app.fedilab.android.mastodon.viewmodel.mastodon.SearchVM.class);
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, videoUuid, null, "statuses", false, true, false, 0, null, null, 1)
.observe(PeertubeActivity.this, results -> {
if (results != null && results.statuses != null && results.statuses.size() > 0) {
status = results.statuses.get(0);
}
});
}
if (player != null) { if (player != null) {
player.release(); player.release();
player = new ExoPlayer.Builder(PeertubeActivity.this).build(); player = new ExoPlayer.Builder(PeertubeActivity.this).build();
@ -862,7 +887,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
PlaylistsVM viewModel = new ViewModelProvider(this).get(PlaylistsVM.class); PlaylistsVM viewModel = new ViewModelProvider(this).get(PlaylistsVM.class);
viewModel.videoExists(videoIds).observe(this, this::manageVIewPlaylist); viewModel.videoExists(videoIds).observe(this, this::manageVIewPlaylist);
if (!Helper.isLoggedIn() || sepiaSearch) { if (!Helper.canMakeAction() || sepiaSearch) {
binding.writeCommentContainer.setVisibility(View.GONE); binding.writeCommentContainer.setVisibility(View.GONE);
} }
@ -1002,6 +1027,147 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
} }
} }
}); });
binding.peertubeReblog.setOnClickListener(v -> {
if (status != null) {
boolean confirmBoost = sharedpreferences.getBoolean(getString(R.string.SET_NOTIF_VALIDATION), true);
StatusesVM statusesVM = new ViewModelProvider(PeertubeActivity.this).get(StatusesVM.class);
if (confirmBoost) {
AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(this);
if (status.reblogged) {
alt_bld.setMessage(getString(R.string.reblog_remove));
} else {
alt_bld.setMessage(getString(R.string.reblog_add));
}
alt_bld.setPositiveButton(R.string.yes, (dialog, id) -> {
if (status.reblogged) {
statusesVM.unReblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.id)
.observe(PeertubeActivity.this, _status -> {
if (_status != null) {
status = _status;
}
manageVIewPostActionsMastodon(status);
});
} else {
((SparkButton) v).playAnimation();
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.id, null)
.observe(PeertubeActivity.this, _status -> {
if (_status != null) {
status = _status;
}
manageVIewPostActionsMastodon(status);
});
}
dialog.dismiss();
});
alt_bld.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
AlertDialog alert = alt_bld.create();
alert.show();
} else {
if (status.reblogged) {
statusesVM.unReblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.id)
.observe(PeertubeActivity.this, _status -> {
if (_status != null) {
status = _status;
}
manageVIewPostActionsMastodon(status);
});
} else {
((SparkButton) v).playAnimation();
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.id, null)
.observe(PeertubeActivity.this, _status -> {
if (_status != null) {
status = _status;
}
manageVIewPostActionsMastodon(status);
});
}
}
}
});
binding.peertubeFavorite.setOnClickListener(v -> {
if (status != null) {
boolean confirmFav = sharedpreferences.getBoolean(getString(R.string.SET_NOTIF_VALIDATION_FAV), false);
StatusesVM statusesVM = new ViewModelProvider(PeertubeActivity.this).get(StatusesVM.class);
if (confirmFav) {
AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(PeertubeActivity.this);
if (status.favourited) {
alt_bld.setMessage(getString(R.string.favourite_remove));
} else {
alt_bld.setMessage(getString(R.string.favourite_add));
}
alt_bld.setPositiveButton(R.string.yes, (dialog, id) -> {
if (status.favourited) {
statusesVM.unFavourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.id)
.observe(PeertubeActivity.this, _status -> {
if (_status != null) {
status = _status;
}
manageVIewPostActionsMastodon(status);
});
} else {
((SparkButton) v).playAnimation();
statusesVM.favourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.id)
.observe(PeertubeActivity.this, _status -> {
if (_status != null) {
status = _status;
}
manageVIewPostActionsMastodon(status);
});
}
dialog.dismiss();
});
alt_bld.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
AlertDialog alert = alt_bld.create();
alert.show();
} else {
if (status.favourited) {
statusesVM.unFavourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.id)
.observe(PeertubeActivity.this, _status -> {
if (_status != null) {
status = _status;
}
manageVIewPostActionsMastodon(status);
});
} else {
((SparkButton) v).playAnimation();
statusesVM.favourite(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.id)
.observe(PeertubeActivity.this, _status -> {
if (_status != null) {
status = _status;
}
manageVIewPostActionsMastodon(status);
});
}
}
}
});
binding.peertubeBookmark.setOnClickListener(v -> {
if (status != null) {
StatusesVM statusesVM = new ViewModelProvider(PeertubeActivity.this).get(StatusesVM.class);
if (status.bookmarked) {
statusesVM.unBookmark(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.id)
.observe(PeertubeActivity.this, _status -> {
if (_status != null) {
status = _status;
}
manageVIewPostActionsMastodon(status);
});
} else {
((SparkButton) v).playAnimation();
statusesVM.bookmark(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.id)
.observe(PeertubeActivity.this, _status -> {
if (_status != null) {
status = _status;
}
manageVIewPostActionsMastodon(status);
});
}
}
});
binding.peertubeDislikeCount.setOnClickListener(v -> { binding.peertubeDislikeCount.setOnClickListener(v -> {
if (isLoggedIn() && !sepiaSearch) { if (isLoggedIn() && !sepiaSearch) {
String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike"; String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike";
@ -1127,6 +1293,58 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
} }
public void manageVIewPostActionsMastodon(Status status) {
if (status != null) {
this.status = status;
changeColorMastodon();
binding.peertubeFavorite.setText(String.valueOf(status.favourites_count));
binding.peertubeReblog.setText(String.valueOf(status.reblogs_count));
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toasty.LENGTH_LONG).show();
}
}
private void changeColorMastodon() {
Drawable reblog = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_baseline_repeat_24);
Drawable favorite = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_baseline_star_24);
Drawable bookmark = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_baseline_bookmark_24);
int color = getAttColor(this, android.R.attr.colorControlNormal);
if (reblog != null) {
reblog.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
DrawableCompat.setTint(reblog, color);
}
if (favorite != null) {
favorite.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
DrawableCompat.setTint(favorite, color);
}
if (bookmark != null) {
bookmark.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
DrawableCompat.setTint(bookmark, color);
}
if (reblog != null && status.reblogged) {
reblog.setColorFilter(getResources().getColor(R.color.boost_icon), PorterDuff.Mode.SRC_ATOP);
DrawableCompat.setTint(reblog, getResources().getColor(R.color.boost_icon));
}
if (favorite != null && status.favourited) {
favorite.setColorFilter(getResources().getColor(R.color.marked_icon), PorterDuff.Mode.SRC_ATOP);
DrawableCompat.setTint(favorite, getResources().getColor(R.color.marked_icon));
}
if (bookmark != null && status.bookmarked) {
bookmark.setColorFilter(getResources().getColor(R.color.marked_icon), PorterDuff.Mode.SRC_ATOP);
DrawableCompat.setTint(bookmark, getResources().getColor(R.color.marked_icon));
}
binding.peertubeReblog.setCompoundDrawablesWithIntrinsicBounds(null, reblog, null, null);
binding.peertubeFavorite.setCompoundDrawablesWithIntrinsicBounds(null, favorite, null, null);
binding.peertubeBookmark.setCompoundDrawablesWithIntrinsicBounds(null, bookmark, null, null);
}
/** /**
* Manage video to play with different factors * Manage video to play with different factors
* *
@ -1203,14 +1421,14 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
private void fetchComments() { private void fetchComments() {
if (peertube.isCommentsEnabled()) { if (peertube.isCommentsEnabled()) {
if (Helper.isLoggedIn()) { if (Helper.canMakeAction()) {
binding.postCommentButton.setVisibility(View.VISIBLE); binding.postCommentButton.setVisibility(View.VISIBLE);
} else { } else {
binding.postCommentButton.setVisibility(View.GONE); binding.postCommentButton.setVisibility(View.GONE);
} }
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class); CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
commentViewModel.getThread(sepiaSearch ? peertubeInstance : null, videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment); commentViewModel.getThread(sepiaSearch ? peertubeInstance : null, videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
if (Helper.isLoggedIn() && !sepiaSearch) { if (Helper.canMakeAction() && !sepiaSearch) {
binding.writeCommentContainer.setVisibility(View.VISIBLE); binding.writeCommentContainer.setVisibility(View.VISIBLE);
} }
binding.peertubeComments.setVisibility(View.VISIBLE); binding.peertubeComments.setVisibility(View.VISIBLE);
@ -1765,7 +1983,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
private void sendComment(Comment comment, int position) { private void sendComment(Comment comment, int position) {
if (Helper.isLoggedIn() && !sepiaSearch) { if (Helper.canMakeAction() && !sepiaSearch) {
if (comment == null) { if (comment == null) {
String commentStr = binding.addCommentWrite.getText() != null ? binding.addCommentWrite.getText().toString() : ""; String commentStr = binding.addCommentWrite.getText() != null ? binding.addCommentWrite.getText().toString() : "";
if (commentStr.trim().length() > 0) { if (commentStr.trim().length() > 0) {
@ -1857,7 +2075,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
public void onAnimationEnd(Animation animation) { public void onAnimationEnd(Animation animation) {
binding.peertubeInformationContainer.setVisibility(View.GONE); binding.peertubeInformationContainer.setVisibility(View.GONE);
InputMethodManager inputMethodManager = InputMethodManager inputMethodManager =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow( inputMethodManager.toggleSoftInputFromWindow(
binding.addCommentWrite.getApplicationWindowToken(), binding.addCommentWrite.getApplicationWindowToken(),
InputMethodManager.SHOW_FORCED, 0); InputMethodManager.SHOW_FORCED, 0);

View file

@ -158,6 +158,17 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
binding = super.binding; binding = super.binding;
Intent intentActvity = getIntent();
if (intentActvity != null) {
Bundle extras = intentActvity.getExtras();
String userIdIntent, instanceIntent, urlOfMessage;
if (extras != null && extras.containsKey(app.fedilab.android.mastodon.helper.Helper.ARG_PEERTUBE_NAV_REMOTE)) {
if (extras.getBoolean(app.fedilab.android.mastodon.helper.Helper.ARG_PEERTUBE_NAV_REMOTE)) {
typeOfConnection = PeertubeMainActivity.TypeOfConnection.REMOTE_ACCOUNT;
}
}
}
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
@ -274,7 +285,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
if (typeOfConnection == TypeOfConnection.SURFING) { if (typeOfConnection == TypeOfConnection.SURFING) {
switchDialog(PeertubeMainActivity.this, false); switchDialog(PeertubeMainActivity.this, false);
} else { } else {
if (Helper.isLoggedIn()) { if (Helper.canMakeAction()) {
intent = new Intent(PeertubeMainActivity.this, AccountActivity.class); intent = new Intent(PeertubeMainActivity.this, AccountActivity.class);
startActivity(intent); startActivity(intent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up); overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
@ -571,6 +582,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
MenuItem incognitoItem = menu.findItem(R.id.action_incognito); MenuItem incognitoItem = menu.findItem(R.id.action_incognito);
switch (typeOfConnection) { switch (typeOfConnection) {
case REMOTE_ACCOUNT:
case NORMAL: case NORMAL:
if (Helper.isLoggedIn()) { if (Helper.isLoggedIn()) {
incognitoItem.setVisible(true); incognitoItem.setVisible(true);
@ -729,7 +741,8 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
public enum TypeOfConnection { public enum TypeOfConnection {
NORMAL, NORMAL,
SURFING SURFING,
REMOTE_ACCOUNT
} }
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter { private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {

View file

@ -297,7 +297,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
holder.binding.postReplyButton.setVisibility(View.GONE); holder.binding.postReplyButton.setVisibility(View.GONE);
} }
holder.binding.postReplyButton.setOnClickListener(v -> { holder.binding.postReplyButton.setOnClickListener(v -> {
if (Helper.isLoggedIn() && !sepiaSearch) { if (Helper.canMakeAction() && !sepiaSearch) {
((PeertubeActivity) context).openPostComment(comment, i); ((PeertubeActivity) context).openPostComment(comment, i);
} else { } else {
if (sepiaSearch) { if (sepiaSearch) {
@ -308,7 +308,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
} }
}); });
if (Helper.isLoggedIn() && !sepiaSearch) { if (Helper.canMakeAction() && !sepiaSearch) {
holder.binding.replyButton.setVisibility(View.VISIBLE); holder.binding.replyButton.setVisibility(View.VISIBLE);
} else { } else {
holder.binding.replyButton.setVisibility(View.GONE); holder.binding.replyButton.setVisibility(View.GONE);

View file

@ -656,6 +656,15 @@ public class Helper {
return typeOfConnection == PeertubeMainActivity.TypeOfConnection.NORMAL; return typeOfConnection == PeertubeMainActivity.TypeOfConnection.NORMAL;
} }
/**
* Some actions like following writing comment can be performed with remote accounts
*
* @return boolean
*/
public static boolean canMakeAction() {
return (isLoggedIn() || typeOfConnection == PeertubeMainActivity.TypeOfConnection.REMOTE_ACCOUNT);
}
public static String getToken(Context context) { public static String getToken(Context context) {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);

View file

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M21,3L3,3c-1.11,0 -2,0.89 -2,2v12c0,1.1 0.89,2 2,2h5v2h8v-2h5c1.1,0 1.99,-0.9 1.99,-2L23,5c0,-1.11 -0.9,-2 -2,-2zM21,17L3,17L3,5h18v12zM16,11l-7,4L9,7z" />
</vector>

View file

@ -229,6 +229,55 @@
app:drawableTopCompat="@drawable/ic_baseline_thumb_down_alt_24" app:drawableTopCompat="@drawable/ic_baseline_thumb_down_alt_24"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/peertube_reblog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:drawablePadding="5dp"
android:gravity="center_horizontal"
android:text="0"
android:visibility="gone"
app:drawableTopCompat="@drawable/ic_baseline_repeat_24"
tools:ignore="HardcodedText" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/peertube_favorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:drawablePadding="5dp"
android:gravity="center_horizontal"
android:text="0"
android:visibility="gone"
app:drawableTopCompat="@drawable/ic_baseline_star_24"
tools:ignore="HardcodedText" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/peertube_bookmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:drawablePadding="5dp"
android:gravity="center_horizontal"
android:text=""
android:visibility="gone"
app:drawableTopCompat="@drawable/ic_baseline_bookmark_24"
tools:ignore="HardcodedText" />
<ImageView <ImageView
android:id="@+id/peertube_playlist" android:id="@+id/peertube_playlist"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View file

@ -98,6 +98,11 @@
android:id="@+id/nav_cache" android:id="@+id/nav_cache"
android:icon="@drawable/ic_baseline_cached_24" android:icon="@drawable/ic_baseline_cached_24"
android:title="@string/action_cache" /> android:title="@string/action_cache" />
<item
android:id="@+id/nav_peertube"
android:icon="@drawable/baseline_ondemand_video_24"
android:title="Peertube"
tools:ignore="HardcodedText" />
<item <item
android:id="@+id/nav_about" android:id="@+id/nav_about"
android:icon="@drawable/ic_baseline_info_24" android:icon="@drawable/ic_baseline_info_24"