diff --git a/app/src/main/java/app/fedilab/fedilabtube/LoginActivity.java b/app/src/main/java/app/fedilab/fedilabtube/LoginActivity.java index 310ea22..52ff1e7 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/LoginActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/LoginActivity.java @@ -175,7 +175,10 @@ public class LoginActivity extends AppCompatActivity { if (!hasFocus) { if (binding.loginInstance.getText() != null) { new Thread(() -> { - String testInstance = binding.loginInstance.getText().toString(); + String testInstance = binding.loginInstance.getText().toString().trim(); + if (testInstance.length() == 0) { + return; + } WellKnownNodeinfo.NodeInfo instanceNodeInfo = null; if (BuildConfig.allow_remote_connections) { instanceNodeInfo = new RetrofitPeertubeAPI(LoginActivity.this, testInstance, null).getNodeInfo(); diff --git a/app/src/main/java/app/fedilab/fedilabtube/MastodonWebviewConnectActivity.java b/app/src/main/java/app/fedilab/fedilabtube/MastodonWebviewConnectActivity.java index 017aeb9..0811d95 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/MastodonWebviewConnectActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/MastodonWebviewConnectActivity.java @@ -134,6 +134,9 @@ public class MastodonWebviewConnectActivity extends AppCompatActivity { return false; } String code = val[1]; + if (code.contains("&")) { + code = code.split("&")[0]; + } OauthParams oauthParams = new OauthParams(); oauthParams.setClient_id(clientId); oauthParams.setClient_secret(clientSecret); diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 6bde433..6cffd83 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -1069,6 +1069,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller); DefaultTimeBar exo_progress = controlView.findViewById(R.id.exo_progress); TextView exo_duration = controlView.findViewById(R.id.exo_duration); + TextView exo_position = controlView.findViewById(R.id.exo_position); TextView exo_live_badge = controlView.findViewById(R.id.exo_live_badge); if (peertube.isLive()) { exo_progress.setVisibility(View.INVISIBLE); @@ -1076,9 +1077,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd exo_live_badge.setVisibility(View.VISIBLE); exo_live_badge.setText(R.string.live); exo_live_badge.setBackgroundResource(R.drawable.rounded_live); + exo_position.setVisibility(View.GONE); } else { exo_progress.setVisibility(View.VISIBLE); exo_live_badge.setVisibility(View.GONE); + exo_position.setVisibility(View.VISIBLE); exo_duration.setBackground(null); } @@ -1137,6 +1140,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd if (peertube.isLive()) { info_duration.setText(R.string.live); info_duration.setBackgroundResource(R.drawable.rounded_live); + info_duration.setBackgroundResource(R.drawable.rounded_live); } else { info_duration.setText(Helper.secondsToString(peertube.getDuration())); } @@ -1442,7 +1446,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd e.printStackTrace(); } } - if (video_cache == 0 || dataSourceFactory != null) { + if (video_cache == 0 || dataSourceFactory != null || video.isLive()) { if (dataSourceFactory == null) { dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this, Util.getUserAgent(PeertubeActivity.this, null), null); @@ -2358,16 +2362,16 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd DrawableCompat.setTint(bookmark, color); } - if (status.isReblogged()) { + if (reblog != null && status.isReblogged()) { reblog.setColorFilter(getResources().getColor(R.color.positive_thumbs), PorterDuff.Mode.SRC_ATOP); DrawableCompat.setTint(reblog, getResources().getColor(R.color.positive_thumbs)); } - if (status.isFavourited()) { + if (favorite != null && status.isFavourited()) { favorite.setColorFilter(getResources().getColor(R.color.favorite), PorterDuff.Mode.SRC_ATOP); DrawableCompat.setTint(favorite, getResources().getColor(R.color.favorite)); } - if (status.isBookmarked()) { + if (bookmark != null && status.isBookmarked()) { bookmark.setColorFilter(getResources().getColor(R.color.bookmark), PorterDuff.Mode.SRC_ATOP); DrawableCompat.setTint(bookmark, getResources().getColor(R.color.bookmark)); } diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/data/VideoData.java b/app/src/main/java/app/fedilab/fedilabtube/client/data/VideoData.java index d9eadc0..fe7787c 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/data/VideoData.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/data/VideoData.java @@ -205,8 +205,6 @@ public class VideoData { } public List getAllFile(Context context) { - SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); - int mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL); if (files != null && files.size() > 0) { return files; } else if (streamingPlaylists != null) { @@ -232,9 +230,17 @@ public class VideoData { for (File file : files) { if (file.getResolutions().getLabel().compareTo(resolution) == 0) { if (mode == Helper.VIDEO_MODE_MAGNET) { - return file.getMagnetUri(); + if (file.getMagnetUri() != null) { + return file.getMagnetUri(); + } else { + return file.getFileUrl(); + } } else if (mode == Helper.VIDEO_MODE_TORRENT) { - return file.getTorrentUrl(); + if (file.getTorrentUrl() != null) { + return file.getTorrentUrl(); + } else { + return file.getFileUrl(); + } } else { return file.getFileUrl(); } @@ -244,9 +250,17 @@ public class VideoData { File file = Helper.defaultFile(context, files); if (file != null) { if (mode == Helper.VIDEO_MODE_MAGNET) { - return file.getMagnetUri(); + if (file.getMagnetUri() != null) { + return file.getMagnetUri(); + } else { + return file.getFileUrl(); + } } else if (mode == Helper.VIDEO_MODE_TORRENT) { - return file.getTorrentUrl(); + if (file.getTorrentUrl() != null) { + return file.getTorrentUrl(); + } else { + return file.getFileUrl(); + } } else { return file.getFileUrl(); } diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/mastodon/MastodonService.java b/app/src/main/java/app/fedilab/fedilabtube/client/mastodon/MastodonService.java index e67b715..a7385ea 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/mastodon/MastodonService.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/mastodon/MastodonService.java @@ -37,7 +37,7 @@ interface MastodonService { @Field("website") String website); @FormUrlEncoded - @POST("/oauth/token") + @POST("oauth/token") Call createToken( @Field("grant_type") String grant_type, @Field("client_id") String client_id, diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/mastodon/RetrofitMastodonAPI.java b/app/src/main/java/app/fedilab/fedilabtube/client/mastodon/RetrofitMastodonAPI.java index 01e7a83..45f54a3 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/mastodon/RetrofitMastodonAPI.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/mastodon/RetrofitMastodonAPI.java @@ -142,6 +142,19 @@ public class RetrofitMastodonAPI { }).start(); } + + private MastodonService init_no_api() { + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("https://" + instance) + .addConverterFactory(GsonConverterFactory.create()) + .build(); + SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + if (token == null) { + token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); + } + return retrofit.create(MastodonService.class); + } + private MastodonService init() { Retrofit retrofit = new Retrofit.Builder() .baseUrl(finalUrl) @@ -223,7 +236,7 @@ public class RetrofitMastodonAPI { * @return Account */ public Token manageToken(OauthParams oauthParams) throws Error { - MastodonService mastodonService = init(); + MastodonService mastodonService = init_no_api(); Call createToken = mastodonService.createToken( oauthParams.getGrant_type(), oauthParams.getClient_id(), @@ -274,7 +287,7 @@ public class RetrofitMastodonAPI { return null; } - public Status postAction(actionType type, Status status) throws Error { + public Status postAction(actionType type, Status status) { MastodonService mastodonService = init(); Call postAction = null; if (status != null) { diff --git a/app/src/main/java/app/fedilab/fedilabtube/viewmodel/mastodon/MastodonPostActionsVM.java b/app/src/main/java/app/fedilab/fedilabtube/viewmodel/mastodon/MastodonPostActionsVM.java index ae6fdbc..c2089b2 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/viewmodel/mastodon/MastodonPostActionsVM.java +++ b/app/src/main/java/app/fedilab/fedilabtube/viewmodel/mastodon/MastodonPostActionsVM.java @@ -107,7 +107,7 @@ public class MastodonPostActionsVM extends AndroidViewModel { Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> statusMutableLiveData.setValue(statusReply); mainHandler.post(myRunnable); - } catch (Exception | Error e) { + } catch (Exception e) { e.printStackTrace(); } }).start();