mirror of
https://framagit.org/tom79/fedilab-tube
synced 2025-02-09 00:28:45 +01:00
Some fixes
This commit is contained in:
parent
087ac92f15
commit
f3f474ee13
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -205,8 +205,6 @@ public class VideoData {
|
||||
}
|
||||
|
||||
public List<File> 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();
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ interface MastodonService {
|
||||
@Field("website") String website);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("/oauth/token")
|
||||
@POST("oauth/token")
|
||||
Call<Token> createToken(
|
||||
@Field("grant_type") String grant_type,
|
||||
@Field("client_id") String client_id,
|
||||
|
@ -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<Token> 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<Status> postAction = null;
|
||||
if (status != null) {
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user