mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Add some elements
This commit is contained in:
parent
20c797520e
commit
e28b3fcf76
9 changed files with 327 additions and 15 deletions
|
@ -1352,6 +1352,12 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
} else if (id == R.id.nav_cache) {
|
||||
Intent intent = new Intent(BaseMainActivity.this, CacheActivity.class);
|
||||
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) {
|
||||
(new InstanceActivity()).show(getSupportFragmentManager(), null);
|
||||
}
|
||||
|
|
|
@ -203,6 +203,8 @@ public class Helper {
|
|||
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_PEERTUBE_NAV_REMOTE = "ARG_PEERTUBE_NAV_REMOTE";
|
||||
|
||||
public static final String ARG_REMOTE_INSTANCE_STRING = "ARG_REMOTE_INSTANCE_STRING";
|
||||
|
||||
public static final String ARG_NOTIFICATION_TYPE = "ARG_NOTIFICATION_TYPE";
|
||||
|
|
|
@ -17,11 +17,13 @@ package app.fedilab.android.peertube.activities;
|
|||
import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO;
|
||||
import static app.fedilab.android.BaseMainActivity.currentAccount;
|
||||
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.RATEVIDEO;
|
||||
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_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.isLoggedIn;
|
||||
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.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.varunest.sparkbutton.SparkButton;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -124,13 +127,16 @@ import java.util.Objects;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.BasePeertubeActivity;
|
||||
import app.fedilab.android.databinding.ActivityPeertubeBinding;
|
||||
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.exception.DBException;
|
||||
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.MenuItemVideo;
|
||||
import app.fedilab.android.peertube.client.RetrofitPeertubeAPI;
|
||||
|
@ -198,6 +204,8 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
private boolean isRemote;
|
||||
private boolean willPlayFromIntent;
|
||||
|
||||
private Status status;
|
||||
|
||||
public static void hideKeyboard(Activity activity) {
|
||||
if (activity != null && activity.getWindow() != null) {
|
||||
activity.getWindow().getDecorView();
|
||||
|
@ -218,24 +226,24 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
max_id = "0";
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this);
|
||||
String token = sharedpreferences.getString(PREF_USER_TOKEN, null);
|
||||
if (Helper.isLoggedIn() && !sepiaSearch) {
|
||||
if (Helper.canMakeAction() && !sepiaSearch) {
|
||||
BaseAccount account = null;
|
||||
try {
|
||||
account = new app.fedilab.android.mastodon.client.entities.app.Account(PeertubeActivity.this).getAccountByToken(token);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (account != null) {
|
||||
if (account != null && account.peertube_account != null) {
|
||||
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;
|
||||
|
||||
|
||||
fullScreenMode = false;
|
||||
initialOrientation = getResources().getConfiguration().orientation;
|
||||
if (Helper.isTablet(PeertubeActivity.this)) {
|
||||
|
||||
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
0,
|
||||
|
@ -276,6 +284,13 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
|
||||
if (Helper.isLoggedIn()) {
|
||||
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 -> {
|
||||
|
@ -289,7 +304,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
}
|
||||
}
|
||||
});
|
||||
if (!Helper.isLoggedIn() || sepiaSearch) {
|
||||
if (!Helper.canMakeAction() || sepiaSearch) {
|
||||
binding.writeCommentContainer.setVisibility(View.GONE);
|
||||
}
|
||||
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
||||
|
@ -397,7 +412,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
openFullscreenDialog();
|
||||
}
|
||||
binding.postCommentButton.setOnClickListener(v -> {
|
||||
if (Helper.isLoggedIn() && !sepiaSearch) {
|
||||
if (canMakeAction() && !sepiaSearch) {
|
||||
openPostComment(null, 0);
|
||||
} else {
|
||||
if (sepiaSearch) {
|
||||
|
@ -489,6 +504,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
return comments;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
@ -573,6 +589,15 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
}
|
||||
|
||||
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) {
|
||||
player.release();
|
||||
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);
|
||||
viewModel.videoExists(videoIds).observe(this, this::manageVIewPlaylist);
|
||||
|
||||
if (!Helper.isLoggedIn() || sepiaSearch) {
|
||||
if (!Helper.canMakeAction() || sepiaSearch) {
|
||||
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 -> {
|
||||
if (isLoggedIn() && !sepiaSearch) {
|
||||
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
|
||||
*
|
||||
|
@ -1203,14 +1421,14 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
|
||||
private void fetchComments() {
|
||||
if (peertube.isCommentsEnabled()) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
if (Helper.canMakeAction()) {
|
||||
binding.postCommentButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
binding.postCommentButton.setVisibility(View.GONE);
|
||||
}
|
||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||
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.peertubeComments.setVisibility(View.VISIBLE);
|
||||
|
@ -1765,7 +1983,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
|
||||
|
||||
private void sendComment(Comment comment, int position) {
|
||||
if (Helper.isLoggedIn() && !sepiaSearch) {
|
||||
if (Helper.canMakeAction() && !sepiaSearch) {
|
||||
if (comment == null) {
|
||||
String commentStr = binding.addCommentWrite.getText() != null ? binding.addCommentWrite.getText().toString() : "";
|
||||
if (commentStr.trim().length() > 0) {
|
||||
|
@ -1857,7 +2075,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
public void onAnimationEnd(Animation animation) {
|
||||
binding.peertubeInformationContainer.setVisibility(View.GONE);
|
||||
InputMethodManager inputMethodManager =
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
(InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
inputMethodManager.toggleSoftInputFromWindow(
|
||||
binding.addCommentWrite.getApplicationWindowToken(),
|
||||
InputMethodManager.SHOW_FORCED, 0);
|
||||
|
|
|
@ -158,6 +158,17 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
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);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
|
@ -274,7 +285,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
if (typeOfConnection == TypeOfConnection.SURFING) {
|
||||
switchDialog(PeertubeMainActivity.this, false);
|
||||
} else {
|
||||
if (Helper.isLoggedIn()) {
|
||||
if (Helper.canMakeAction()) {
|
||||
intent = new Intent(PeertubeMainActivity.this, AccountActivity.class);
|
||||
startActivity(intent);
|
||||
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);
|
||||
switch (typeOfConnection) {
|
||||
case REMOTE_ACCOUNT:
|
||||
case NORMAL:
|
||||
if (Helper.isLoggedIn()) {
|
||||
incognitoItem.setVisible(true);
|
||||
|
@ -729,7 +741,8 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
|
||||
public enum TypeOfConnection {
|
||||
NORMAL,
|
||||
SURFING
|
||||
SURFING,
|
||||
REMOTE_ACCOUNT
|
||||
}
|
||||
|
||||
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
|
|
@ -297,7 +297,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
holder.binding.postReplyButton.setVisibility(View.GONE);
|
||||
}
|
||||
holder.binding.postReplyButton.setOnClickListener(v -> {
|
||||
if (Helper.isLoggedIn() && !sepiaSearch) {
|
||||
if (Helper.canMakeAction() && !sepiaSearch) {
|
||||
((PeertubeActivity) context).openPostComment(comment, i);
|
||||
} else {
|
||||
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);
|
||||
} else {
|
||||
holder.binding.replyButton.setVisibility(View.GONE);
|
||||
|
|
|
@ -656,6 +656,15 @@ public class Helper {
|
|||
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) {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
|
|
@ -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>
|
|
@ -229,6 +229,55 @@
|
|||
app:drawableTopCompat="@drawable/ic_baseline_thumb_down_alt_24"
|
||||
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
|
||||
android:id="@+id/peertube_playlist"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -98,6 +98,11 @@
|
|||
android:id="@+id/nav_cache"
|
||||
android:icon="@drawable/ic_baseline_cached_24"
|
||||
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
|
||||
android:id="@+id/nav_about"
|
||||
android:icon="@drawable/ic_baseline_info_24"
|
||||
|
|
Loading…
Reference in a new issue