diff options
author | Thomas <tschneider.ac@gmail.com> | 2023-01-23 15:01:44 +0100 |
---|---|---|
committer | Thomas <tschneider.ac@gmail.com> | 2023-01-23 15:01:44 +0100 |
commit | 82a5bfebb42b0a1f82a38ddf3f2dda272a0c9611 (patch) | |
tree | ee550ea4b61d0f7b42032f785b3a1a7df4b4c3b0 | |
parent | 4c5232039a566aba74f0bc7d8f95d5f13567a3bd (diff) |
Some changes
25 files changed, 130 insertions, 346 deletions
diff --git a/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java b/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java index ff9f45499..d6eaf6692 100644 --- a/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java +++ b/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java @@ -29,7 +29,7 @@ import android.webkit.MimeTypeMap; import androidx.appcompat.app.AlertDialog; import androidx.localbroadcastmanager.content.LocalBroadcastManager; -import com.google.android.exoplayer2.SimpleExoPlayer; +import com.google.android.exoplayer2.ExoPlayer; import org.jetbrains.annotations.NotNull; @@ -50,7 +50,7 @@ public class BasePeertubeActivity extends BaseBarActivity { protected ActivityPeertubeBinding binding; protected VideoData.Video peertube; - protected SimpleExoPlayer player; + protected ExoPlayer player; protected String videoURL; protected String subtitlesStr; diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index 8d572ea89..9230ae23d 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -106,6 +106,7 @@ import java.util.regex.Pattern; import app.fedilab.android.activities.AboutActivity; import app.fedilab.android.activities.LoginActivity; import app.fedilab.android.activities.MainActivity; +import app.fedilab.android.activities.PeertubeBaseMainActivity; import app.fedilab.android.databinding.ActivityMainBinding; import app.fedilab.android.databinding.NavHeaderMainBinding; import app.fedilab.android.mastodon.activities.ActionActivity; @@ -334,6 +335,8 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt }); permissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS); } + + filteredAccounts = new ArrayList<>(); mamageNewIntent(getIntent()); filterFetched = false; @@ -598,6 +601,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null); } currentAccount = new Account(BaseMainActivity.this).getConnectedAccount(); + if (currentAccount.api == Account.API.PEERTUBE) { + startActivity(new Intent(this, PeertubeBaseMainActivity.class)); + finish(); + } } catch (DBException e) { e.printStackTrace(); } @@ -1006,7 +1013,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt Bundle extras = intent.getExtras(); String userIdIntent, instanceIntent, urlOfMessage; if (extras != null && extras.containsKey(Helper.INTENT_ACTION)) { - userIdIntent = extras.getString(Helper.PREF_KEY_ID); //Id of the account in the intent + userIdIntent = extras.getString(Helper.PREF_USER_ID); //Id of the account in the intent instanceIntent = extras.getString(Helper.PREF_INSTANCE); urlOfMessage = extras.getString(Helper.PREF_MESSAGE_URL); if (extras.getInt(Helper.INTENT_ACTION) == Helper.NOTIFICATION_INTENT) { diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java index 562c53072..f6387b263 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java +++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java @@ -266,7 +266,7 @@ public class Account extends BaseAccount implements Serializable { if (token.getAccess_token() != null) values.put(Sqlite.COL_TOKEN, token.getAccess_token()); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); - String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); + String userId = sharedpreferences.getString(Helper.PREF_USER_ID, null); String instance = HelperInstance.getLiveInstance(context); try { return db.update(Sqlite.TABLE_USER_ACCOUNT, diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java index 5dda503c0..aeacb46bb 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java @@ -177,8 +177,6 @@ public class Helper { public static final String INSTANCE_SOCIAL_KEY = "jGj9gW3z9ptyIpB8CMGhAlTlslcemMV6AgoiImfw3vPP98birAJTHOWiu5ZWfCkLvcaLsFZw9e3Pb7TIwkbIyrj3z6S7r2oE6uy6EFHvls3YtapP8QKNZ980p9RfzTb4"; public static final String WEBSITE_VALUE = "https://fedilab.app"; - public static final String OLD_DB_NAME = "mastodon_etalab_db"; - public static final String RECEIVE_TOAST_MESSAGE = "RECEIVE_TOAST_MESSAGE"; public static final String RECEIVE_TOAST_TYPE = "RECEIVE_TOAST_TYPE"; public static final String RECEIVE_TOAST_CONTENT = "RECEIVE_TOAST_CONTENT"; @@ -296,15 +294,16 @@ public class Helper { public static final String SCHEDULE_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ"; + public static final String PREF_USER_TOKEN = "PREF_USER_TOKEN"; public static final String PREF_USER_ID = "PREF_USER_ID"; public static final String PREF_USER_INSTANCE = "PREF_USER_INSTANCE"; public static final String PREF_IS_MODERATOR = "PREF_IS_MODERATOR"; public static final String PREF_IS_ADMINISTRATOR = "PREF_IS_ADMINISTRATOR"; - public static final String PREF_KEY_ID = "PREF_KEY_ID"; public static final String PREF_MESSAGE_URL = "PREF_MESSAGE_URL"; public static final String PREF_INSTANCE = "PREF_INSTANCE"; + public static final String SET_SECURITY_PROVIDER = "SET_SECURITY_PROVIDER"; public static final int NOTIFICATION_INTENT = 1; diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java index 06dd6b149..c7922f48b 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/NotificationsHelper.java @@ -369,7 +369,7 @@ public class NotificationsHelper { final Intent intent = new Intent(context, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Helper.INTENT_ACTION, Helper.NOTIFICATION_INTENT); - intent.putExtra(Helper.PREF_KEY_ID, account.user_id); + intent.putExtra(Helper.PREF_USER_ID, account.user_id); if (targeted_account != null) intent.putExtra(Helper.INTENT_TARGETED_ACCOUNT, targeted_account); intent.putExtra(Helper.PREF_INSTANCE, account.instance); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java index aa782a1be..ee6bc5da0 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java @@ -14,6 +14,7 @@ package app.fedilab.android.peertube.activities; * You should have received a copy of the GNU General Public License along with TubeLab; if not, * see <http://www.gnu.org/licenses>. */ +import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN; import static app.fedilab.android.peertube.activities.PeertubeMainActivity.badgeCount; import android.content.Intent; @@ -79,7 +80,7 @@ public class AccountActivity extends BaseBarActivity { SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); - String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); + String token = sharedpreferences.getString(PREF_USER_TOKEN, null); BaseAccount baseAccount = null; try { diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java index 640bdc5c3..05cbbf326 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java @@ -15,6 +15,7 @@ package app.fedilab.android.peertube.activities; * see <http://www.gnu.org/licenses>. */ import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO; +import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN; 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; @@ -38,7 +39,6 @@ import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.res.Configuration; -import android.database.sqlite.SQLiteDatabase; import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.drawable.Drawable; @@ -85,12 +85,12 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.github.vkay94.dtpv.youtube.YouTubeOverlay; import com.google.android.exoplayer2.C; -import com.google.android.exoplayer2.ExoPlaybackException; +import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.MediaItem; +import com.google.android.exoplayer2.PlaybackException; import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.Player; -import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector; import com.google.android.exoplayer2.source.MergingMediaSource; import com.google.android.exoplayer2.source.ProgressiveMediaSource; @@ -106,7 +106,7 @@ import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.Util; -import com.google.android.exoplayer2.video.VideoListener; +import com.google.android.exoplayer2.video.VideoSize; import com.google.android.material.snackbar.Snackbar; import org.jetbrains.annotations.NotNull; @@ -124,10 +124,13 @@ import java.util.regex.Pattern; import app.fedilab.android.R; import app.fedilab.android.activities.BasePeertubeActivity; import app.fedilab.android.databinding.ActivityPeertubeBinding; +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.peertube.client.APIResponse; import app.fedilab.android.peertube.client.MenuItemVideo; import app.fedilab.android.peertube.client.RetrofitPeertubeAPI; +import app.fedilab.android.peertube.client.data.AccountData; import app.fedilab.android.peertube.client.data.CaptionData.Caption; import app.fedilab.android.peertube.client.data.CommentData; import app.fedilab.android.peertube.client.data.CommentData.Comment; @@ -144,7 +147,6 @@ import app.fedilab.android.peertube.client.entities.UserSettings; import app.fedilab.android.peertube.drawer.CommentListAdapter; import app.fedilab.android.peertube.drawer.MenuAdapter; import app.fedilab.android.peertube.drawer.MenuItemAdapter; -import app.fedilab.android.peertube.helper.CacheDataSourceFactory; import app.fedilab.android.peertube.helper.Helper; import app.fedilab.android.peertube.helper.HelperInstance; import app.fedilab.android.peertube.viewmodel.CaptionsVM; @@ -153,15 +155,13 @@ import app.fedilab.android.peertube.viewmodel.PlaylistsVM; import app.fedilab.android.peertube.viewmodel.PostActionsVM; import app.fedilab.android.peertube.viewmodel.SearchVM; import app.fedilab.android.peertube.viewmodel.TimelineVM; -import app.fedilab.android.peertube.viewmodel.mastodon.MastodonPostActionsVM; import app.fedilab.android.peertube.webview.CustomWebview; import app.fedilab.android.peertube.webview.MastalabWebChromeClient; import app.fedilab.android.peertube.webview.MastalabWebViewClient; -import app.fedilab.android.sqlite.Sqlite; import es.dmoral.toasty.Toasty; -public class PeertubeActivity extends BasePeertubeActivity implements CommentListAdapter.AllCommentRemoved, Player.EventListener, VideoListener, MenuAdapter.ItemClicked, MenuItemAdapter.ItemAction { +public class PeertubeActivity extends BasePeertubeActivity implements CommentListAdapter.AllCommentRemoved, MenuAdapter.ItemClicked, MenuItemAdapter.ItemAction, Player.Listener { public static String video_id; public static List<String> playedVideos = new ArrayList<>(); @@ -198,18 +198,10 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis public static void hideKeyboard(Activity activity) { if (activity != null && activity.getWindow() != null) { activity.getWindow().getDecorView(); - InputMethodManager imm = activity.getSystemService(INPUT_METHOD_SERVICE); - assert imm != null; - imm.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0); - } - } - - @Override - public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) { - if (width < height) { - videoOrientationType = videoOrientation.PORTRAIT; - } else { - videoOrientationType = videoOrientation.LANDSCAPE; + InputMethodManager imm = (InputMethodManager) activity.getSystemService(INPUT_METHOD_SERVICE); + if (imm != null) { + imm.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0); + } } } @@ -219,17 +211,18 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis super.onCreate(savedInstanceState); videoOrientationType = videoOrientation.LANDSCAPE; max_id = "0"; - SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); - String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); + String token = sharedpreferences.getString(PREF_USER_TOKEN, null); if (Helper.canMakeAction(PeertubeActivity.this) && !sepiaSearch) { - Account account = null; + BaseAccount account = null; try { account = new app.fedilab.android.mastodon.client.entities.app.Account(PeertubeActivity.this).getAccountByToken(token); } catch (DBException e) { e.printStackTrace(); } - loadAvatar(PeertubeActivity.this, account, binding.myPp); + if (account != null) { + loadAvatar(PeertubeActivity.this, account.peertube_account, binding.myPp); + } } isRemote = false; @@ -278,9 +271,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis 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); } else { binding.peertubePlaylist.setVisibility(View.VISIBLE); } @@ -424,7 +414,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis return; } peertube = apiResponse.getPeertubes().get(0); - Matomo.sendScreen(PeertubeActivity.this, "VIDEO_REGARDEE", peertube.getUuid()); if (peertube.isNsfw()) { binding.videoSensitive.setVisibility(View.VISIBLE); } else { @@ -583,7 +572,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis private void playVideo() { if (player != null) { player.release(); - player = new SimpleExoPlayer.Builder(PeertubeActivity.this).build(); + player = new ExoPlayer.Builder(PeertubeActivity.this).build(); binding.mediaVideo.player(player); binding.doubleTapPlayerView.setPlayer(player); binding.loader.setVisibility(View.GONE); @@ -889,7 +878,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis binding.videoInformation.setOnClickListener(v -> { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PeertubeActivity.this); LayoutInflater inflater = getLayoutInflater(); - View dialogView = inflater.inflate(R.layout.popup_video_info, new LinearLayout(PeertubeActivity.this), false); + View dialogView = inflater.inflate(R.layout.popup_video_info_peertube, new LinearLayout(PeertubeActivity.this), false); TextView info_privacy = dialogView.findViewById(R.id.info_privacy); TextView info_published_at = dialogView.findViewById(R.id.info_published_at); TextView info_category = dialogView.findViewById(R.id.info_category); @@ -1046,8 +1035,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis if (mode != Helper.VIDEO_MODE_WEBVIEW) { - player = new SimpleExoPlayer.Builder(PeertubeActivity.this).build(); - player.addVideoListener(PeertubeActivity.this); + player = new ExoPlayer.Builder(PeertubeActivity.this).build(); player.addListener(this); binding.mediaVideo.player(player); binding.doubleTapPlayerView.setPlayer(player); @@ -1437,7 +1425,8 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis } @Override - public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) { + public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) { + super.onPictureInPictureModeChanged(isInPictureInPictureMode); if (!isInPictureInPictureMode) { if (onStopCalled) { isPlayInMinimized = false; @@ -1446,7 +1435,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis } } - private void toogleFullscreen(boolean fullscreen) { if (fullscreen) { @@ -1645,7 +1633,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis if (mode == Helper.VIDEO_MODE_NORMAL) { if (player != null) player.release(); - player = new SimpleExoPlayer.Builder(PeertubeActivity.this).build(); + player = new ExoPlayer.Builder(PeertubeActivity.this).build(); binding.mediaVideo.player(player); binding.doubleTapPlayerView.setPlayer(player); binding.loader.setVisibility(View.GONE); @@ -1688,7 +1676,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis player.release(); TrackSelector trackSelector = new DefaultTrackSelector(PeertubeActivity.this, new AdaptiveTrackSelection.Factory()); - player = new SimpleExoPlayer.Builder(PeertubeActivity.this).setTrackSelector(trackSelector).build(); + player = new ExoPlayer.Builder(PeertubeActivity.this).setTrackSelector(trackSelector).build(); binding.mediaVideo.player(player); binding.doubleTapPlayerView.setPlayer(player); captionLang = item.getStrId(); @@ -1788,10 +1776,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis if (Helper.isLoggedIn(PeertubeActivity.this)) { PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class); viewModelComment.comment(ADD_COMMENT, peertube.getId(), null, commentStr).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(ADD_COMMENT, 0, apiResponse1)); - } else {//Remote account is posting a message - String url = "https://" + peertube.getChannel().getHost() + "/videos/watch/" + peertube.getUuid(); - MastodonPostActionsVM viewModelCommentMastodon = new ViewModelProvider(PeertubeActivity.this).get(MastodonPostActionsVM.class); - viewModelCommentMastodon.comment(url, commentStr).observe(PeertubeActivity.this, status -> manageVIewPostActionsMastodon(ADD_COMMENT, position, status)); } binding.addCommentWrite.setText(""); } @@ -1801,9 +1785,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis if (Helper.isLoggedIn(PeertubeActivity.this)) { PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class); viewModelComment.comment(REPLY, peertube.getId(), comment.getId(), commentView).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(REPLY, position, apiResponse1)); - } else {//Remote account is posting a message - MastodonPostActionsVM viewModelCommentMastodon = new ViewModelProvider(PeertubeActivity.this).get(MastodonPostActionsVM.class); - viewModelCommentMastodon.comment(comment.getUrl(), commentView).observe(PeertubeActivity.this, status -> manageVIewPostActionsMastodon(REPLY, position, status)); } binding.addCommentWrite.setText(""); } @@ -1848,7 +1829,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis public void openPostComment(Comment comment, int position) { if (comment != null) { binding.replyContent.setVisibility(View.VISIBLE); - Account account = comment.getAccount(); + AccountData.PeertubeAccount account = comment.getAccount(); loadAvatar(PeertubeActivity.this, account, binding.commentAccountProfile); binding.commentAccountDisplayname.setText(account.getDisplayName()); binding.commentAccountUsername.setText(account.getAcct()); @@ -1934,33 +1915,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis } - public void manageVIewPostActionsMastodon(RetrofitPeertubeAPI.ActionType statusAction, int position, app.fedilab.android.peertube.client.mastodon.Status status) { - if (peertube.isCommentsEnabled() && statusAction == ADD_COMMENT) { - if (status != null) { - Comment comment = app.fedilab.android.peertube.client.mastodon.Status.convertStatusToComment(status); - comments.add(0, comment); - commentListAdapter.notifyItemInserted(0); - } - } else if (peertube.isCommentsEnabled() && statusAction == REPLY) { - if (status != null) { - Comment comment = app.fedilab.android.peertube.client.mastodon.Status.convertStatusToComment(status); - if (commentsThread == null) { - commentsThread = new ArrayList<>(); - } - commentsThread.add(position + 1, comment); - commentReplyListAdapter.notifyItemInserted(position + 1); - } - } - } - - public void retrieveRemoteStatus(app.fedilab.android.peertube.client.mastodon.Status status) { - this.status = status; - if (status != null) { - changeColorMastodon(); - binding.peertubeFavorite.setText(String.valueOf(status.getFavouriteCount())); - binding.peertubeReblog.setText(String.valueOf(status.getReblogsCount())); - } - } @SuppressWarnings({"unused", "RedundantSuppression"}) public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int position, APIResponse apiResponse) { @@ -2040,13 +1994,6 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis } - 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); - - } - private void changeColor() { Drawable thumbUp = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_baseline_thumb_up_alt_24); @@ -2063,13 +2010,13 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis } if (peertube.getMyRating() != null && peertube.getMyRating().compareTo("like") == 0) { if (thumbUp != null) { - thumbUp.setColorFilter(getResources().getColor(R.color.positive_thumbs), PorterDuff.Mode.SRC_ATOP); - DrawableCompat.setTint(thumbUp, getResources().getColor(R.color.positive_thumbs)); + thumbUp.setColorFilter(getAttColor(PeertubeActivity.this, R.attr.primaryColor), PorterDuff.Mode.SRC_ATOP); + DrawableCompat.setTint(thumbUp, getAttColor(PeertubeActivity.this, R.attr.primaryColor)); } } else if (peertube.getMyRating() != null && peertube.getMyRating().compareTo("dislike") == 0) { if (thumbDown != null) { - thumbDown.setColorFilter(getResources().getColor(R.color.negative_thumbs), PorterDuff.Mode.SRC_ATOP); - DrawableCompat.setTint(thumbDown, getResources().getColor(R.color.negative_thumbs)); + thumbDown.setColorFilter(getAttColor(PeertubeActivity.this, R.attr.colorError), PorterDuff.Mode.SRC_ATOP); + DrawableCompat.setTint(thumbDown, getAttColor(PeertubeActivity.this, R.attr.colorError)); } } binding.peertubeLikeCount.setCompoundDrawablesWithIntrinsicBounds(null, thumbUp, null, null); @@ -2228,11 +2175,21 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis } @Override - public void onPlayerError(ExoPlaybackException error) { - + public void onVideoSizeChanged(@NonNull VideoSize videoSize) { + Player.Listener.super.onVideoSizeChanged(videoSize); + if (videoSize.width < videoSize.height) { + videoOrientationType = videoOrientation.PORTRAIT; + } else { + videoOrientationType = videoOrientation.LANDSCAPE; + } } + @Override + public void onPlayerError(PlaybackException error) { + Player.Listener.super.onPlayerError(error); + } + enum videoOrientation { LANDSCAPE, PORTRAIT diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java index 5cbeb1902..27a97e8b0 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java @@ -14,6 +14,8 @@ package app.fedilab.android.peertube.activities; * You should have received a copy of the GNU General Public License along with TubeLab; if not, * see <http://www.gnu.org/licenses>. */ +import static app.fedilab.android.mastodon.helper.Helper.PREF_INSTANCE; +import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID; import static app.fedilab.android.peertube.helper.Helper.peertubeInformation; import android.annotation.SuppressLint; @@ -147,7 +149,7 @@ public abstract class PeertubeMainActivity extends PeertubeBaseMainActivity { WellKnownNodeinfo.NodeInfo instanceNodeInfo = new RetrofitPeertubeAPI(activity, newInstance, null).getNodeInfo(); if (instanceNodeInfo.getSoftware() != null && instanceNodeInfo.getSoftware().getName().trim().toLowerCase().compareTo("peertube") == 0) { SharedPreferences.Editor editor = sharedpreferences.edit(); - editor.putString(Helper.PREF_INSTANCE, newInstance); + editor.putString(PREF_INSTANCE, newInstance); editor.commit(); if (storeInDb) { newInstance = newInstance.trim().toLowerCase(); @@ -352,8 +354,8 @@ public abstract class PeertubeMainActivity extends PeertubeBaseMainActivity { String tokenStr = Helper.getToken(PeertubeMainActivity.this); String instance = HelperInstance.getLiveInstance(PeertubeMainActivity.this); SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); - String instanceShar = sharedpreferences.getString(Helper.PREF_INSTANCE, null); - String userIdShar = sharedpreferences.getString(Helper.PREF_KEY_ID, null); + String instanceShar = sharedpreferences.getString(PREF_INSTANCE, null); + String userIdShar = sharedpreferences.getString(PREF_USER_ID, null); BaseAccount account = null; try { account = new Account(PeertubeMainActivity.this).getAccountByToken(tokenStr); @@ -399,8 +401,7 @@ public abstract class PeertubeMainActivity extends PeertubeBaseMainActivity { e.printStackTrace(); } SharedPreferences.Editor editor = sharedpreferences.edit(); - editor.putString(Helper.PREF_KEY_ID, account.user_id); - editor.putString(Helper.PREF_KEY_NAME, account.peertube_account.getUsername()); + editor.putString(PREF_USER_ID, account.user_id); editor.putBoolean(getString(R.string.set_autoplay_choice), userMe.isAutoPlayVideo()); editor.putBoolean(getString(R.string.set_store_in_history), userMe.isVideosHistoryEnabled()); editor.putBoolean(getString(R.string.set_autoplay_next_video_choice), userMe.isAutoPlayNextVideo()); @@ -686,7 +687,7 @@ public abstract class PeertubeMainActivity extends P |