mirror of
https://framagit.org/tom79/fedilab-tube
synced 2025-02-26 16:57:42 +01:00
some fixes
This commit is contained in:
parent
92a0af8b36
commit
d62ff6d18f
@ -171,6 +171,7 @@
|
||||
<string name="peertube_video_from_subscription"><![CDATA[<b>%1$s</b> a publié une nouvelle vidéo : <b>%2$s</b>]]></string>
|
||||
<string name="peertube_video_blacklist"><![CDATA[Votre vidéo <b>%1$s</b> a été blacklisté]]></string>
|
||||
<string name="peertube_video_unblacklist"><![CDATA[Votre vidéo <b>%1$s</b> n’est plus blacklisté]]></string>
|
||||
<string name="peertube_video_abuse"><![CDATA[Nouvelle modération sur la vidéo : <b>%1$s</b>]]></string>
|
||||
<string name="toast_code_error">Une erreur s’est produite ! L’instance n’a retourné aucun code d\autorisation !</string>
|
||||
<string name="subscriptions">Abonnements</string>
|
||||
<string name="report">Signaler</string>
|
||||
@ -196,6 +197,16 @@
|
||||
<string name="set_video_mode_choice" translatable="false">set_video_mode_choice</string>
|
||||
<string name="set_video_minimize_choice" translatable="false">set_video_minimize_choice</string>
|
||||
<string name="set_video_language_choice" translatable="false">set_video_language_choice</string>
|
||||
<string name="set_video_quality_choice" translatable="false">set_video_quality_choice</string>
|
||||
|
||||
<string-array name="settings_video_quality">
|
||||
<item>Elevé</item>
|
||||
<item>Moyen</item>
|
||||
<item>Faible</item>
|
||||
</string-array>
|
||||
|
||||
<string name="set_video_quality_description">Permet de définir la qualité de la vidéo par défaut</string>
|
||||
<string name="set_quality_mode">Résolution pour les vidéos</string>
|
||||
|
||||
<string name="set_video_mode_description">Permet de changer le mode de lecture pour les vidéos (normal, streaming ou via un navigateur).</string>
|
||||
<string name="register_account">Créer un compte</string>
|
||||
|
@ -138,7 +138,10 @@
|
||||
<string name="set_video_mode_choice" translatable="false">set_video_mode_choice</string>
|
||||
<string name="set_video_minimize_choice" translatable="false">set_video_minimize_choice</string>
|
||||
<string name="set_video_language_choice" translatable="false">set_video_language_choice</string>
|
||||
<string name="set_video_quality_choice" translatable="false">set_video_quality_choice</string>
|
||||
|
||||
<string name="set_video_quality_description">Define a default quality for videos</string>
|
||||
<string name="set_quality_mode">Resolution for videos</string>
|
||||
|
||||
<string name="captions">Captions</string>
|
||||
<string name="pickup_captions">Pick captions</string>
|
||||
@ -160,6 +163,7 @@
|
||||
<string name="peertube_video_from_subscription"><![CDATA[<b>%1$s</b> published a new video: <b>%2$s</b>]]></string>
|
||||
<string name="peertube_video_blacklist"><![CDATA[Your video <b>%1$s</b> has been blacklisted]]></string>
|
||||
<string name="peertube_video_unblacklist"><![CDATA[Your video <b>%1$s</b> has been unblacklisted]]></string>
|
||||
<string name="peertube_video_abuse"><![CDATA[New abuse report for video: <b>%1$s</b>]]></string>
|
||||
<string name="add_public_comment">Add a public comment</string>
|
||||
<string name="send_comment">Send comment</string>
|
||||
<string name="all">All</string>
|
||||
@ -199,6 +203,11 @@
|
||||
<item>Direct stream</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="settings_video_quality">
|
||||
<item>High</item>
|
||||
<item>Medium</item>
|
||||
<item>Low</item>
|
||||
</string-array>
|
||||
|
||||
<string name="unfollow_confirm">Do you want to unfollow this account?</string>
|
||||
|
||||
|
@ -52,13 +52,6 @@ import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.updateCredentia
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
//Peertube notification type
|
||||
public static int NEW_VIDEO_FROM_SUBSCRIPTION = 1;
|
||||
public static int BLACKLIST_ON_MY_VIDEO = 4;
|
||||
public static int UNBLACKLIST_ON_MY_VIDEO = 5;
|
||||
public static int MY_VIDEO_PUBLISHED = 6;
|
||||
public static int MY_VIDEO_IMPORT_SUCCESS = 7;
|
||||
public static int MY_VIDEO_IMPORT_ERROR = 8;
|
||||
private static String client_id;
|
||||
private static String client_secret;
|
||||
private EditText login_uid;
|
||||
|
@ -50,6 +50,7 @@ import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@ -58,7 +59,6 @@ import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@ -100,11 +100,13 @@ import app.fedilab.fedilabtube.client.entities.File;
|
||||
import app.fedilab.fedilabtube.client.entities.ItemStr;
|
||||
import app.fedilab.fedilabtube.client.entities.Report;
|
||||
import app.fedilab.fedilabtube.drawer.CommentListAdapter;
|
||||
import app.fedilab.fedilabtube.fragment.DisplayAccountsFragment;
|
||||
import app.fedilab.fedilabtube.helper.CacheDataSourceFactory;
|
||||
import app.fedilab.fedilabtube.helper.FullScreenMediaController;
|
||||
import app.fedilab.fedilabtube.helper.Helper;
|
||||
import app.fedilab.fedilabtube.sqlite.AccountDAO;
|
||||
import app.fedilab.fedilabtube.sqlite.Sqlite;
|
||||
import app.fedilab.fedilabtube.viewmodel.AccountsVM;
|
||||
import app.fedilab.fedilabtube.viewmodel.CaptionsVM;
|
||||
import app.fedilab.fedilabtube.viewmodel.CommentVM;
|
||||
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
||||
@ -153,6 +155,12 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||
private boolean onStopCalled;
|
||||
private List<Caption> captions;
|
||||
private TextView no_action_text;
|
||||
private String max_id;
|
||||
private RecyclerView lv_comments;
|
||||
private boolean flag_loading;
|
||||
|
||||
private List<Comment> comments;
|
||||
private CommentListAdapter commentListAdapter;
|
||||
|
||||
public static void hideKeyboard(Activity activity) {
|
||||
if (activity != null && activity.getWindow() != null) {
|
||||
@ -185,6 +193,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||
playerView = findViewById(R.id.media_video);
|
||||
write_comment_container = findViewById(R.id.write_comment_container);
|
||||
|
||||
max_id = "0";
|
||||
loader = findViewById(R.id.loader);
|
||||
ImageView my_pp = findViewById(R.id.my_pp);
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
@ -249,7 +258,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
|
||||
peertube_information_container.setVisibility(View.GONE);
|
||||
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
} else {
|
||||
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
||||
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
@ -258,7 +266,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
videoLayout.setVisibility(View.GONE);
|
||||
peertube_information_container.setVisibility(View.VISIBLE);
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
|
||||
}
|
||||
});
|
||||
webview_video.getSettings().setAllowFileAccess(true);
|
||||
@ -280,9 +287,57 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||
initFullscreenDialog();
|
||||
initFullscreenButton();
|
||||
}
|
||||
flag_loading = true;
|
||||
comments = new ArrayList<>();
|
||||
lv_comments = findViewById(R.id.peertube_comments);
|
||||
commentListAdapter = new CommentListAdapter(comments);
|
||||
commentListAdapter.allCommentRemoved = PeertubeActivity.this;
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this);
|
||||
lv_comments.setLayoutManager(mLayoutManager);
|
||||
lv_comments.setNestedScrollingEnabled(false);
|
||||
lv_comments.setAdapter(commentListAdapter);
|
||||
lv_comments.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
if (dy > 0) {
|
||||
int visibleItemCount = mLayoutManager.getChildCount();
|
||||
int totalItemCount = mLayoutManager.getItemCount();
|
||||
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
|
||||
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
||||
if (!flag_loading) {
|
||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||
commentViewModel.getThread(videoId, max_id).observe(PeertubeActivity.this, apiresponse ->manageVIewComment(apiresponse));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
playVideo();
|
||||
}
|
||||
|
||||
|
||||
public void manageVIewComment(APIResponse apiResponse) {
|
||||
flag_loading = false;
|
||||
if (apiResponse == null || (apiResponse.getError() != null)) {
|
||||
if (apiResponse == null)
|
||||
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Toasty.error(PeertubeActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
int oldSize = comments.size();
|
||||
int newComments = 0;
|
||||
for (Comment comment : apiResponse.getComments()) {
|
||||
if (comment.getText() != null && comment.getText().trim().length() > 0) {
|
||||
comments.add(comment);
|
||||
newComments++;
|
||||
}
|
||||
}
|
||||
if (comments.size() > 0) {
|
||||
lv_comments.setVisibility(View.VISIBLE);
|
||||
commentListAdapter.notifyItemRangeInserted(oldSize, newComments);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
@ -323,13 +378,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
Objects.requireNonNull(getSupportActionBar()).hide();
|
||||
peertube_information_container.setVisibility(View.GONE);
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
|
||||
} else {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
|
||||
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
|
||||
Objects.requireNonNull(getSupportActionBar()).show();
|
||||
peertube_information_container.setVisibility(View.VISIBLE);
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -549,7 +602,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||
|
||||
if (peertube.isCommentsEnabled()) {
|
||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||
commentViewModel.getThread(videoId).observe(PeertubeActivity.this, this::manageVIewComment);
|
||||
commentViewModel.getThread(videoId, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
||||
write_comment_container.setVisibility(View.VISIBLE);
|
||||
|
||||
} else {
|
||||
@ -796,33 +849,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||
}
|
||||
|
||||
|
||||
public void manageVIewComment(APIResponse apiResponse) {
|
||||
if (apiResponse == null || (apiResponse.getError() != null)) {
|
||||
if (apiResponse == null)
|
||||
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Toasty.error(PeertubeActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
List<Comment> comments = new ArrayList<>();
|
||||
|
||||
for (Comment comment : apiResponse.getComments()) {
|
||||
if (comment.getText() != null && comment.getText().trim().length() > 0) {
|
||||
comments.add(comment);
|
||||
}
|
||||
}
|
||||
RecyclerView lv_comments = findViewById(R.id.peertube_comments);
|
||||
if (comments.size() > 0) {
|
||||
lv_comments.setVisibility(View.VISIBLE);
|
||||
CommentListAdapter commentListAdapter = new CommentListAdapter(comments);
|
||||
commentListAdapter.allCommentRemoved = PeertubeActivity.this;
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this);
|
||||
lv_comments.setLayoutManager(mLayoutManager);
|
||||
lv_comments.setNestedScrollingEnabled(false);
|
||||
lv_comments.setAdapter(commentListAdapter);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
@ -956,7 +982,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||
|
||||
if (peertube.isCommentsEnabled() && statusAction == ADD_COMMENT) {
|
||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||
commentViewModel.getThread(videoId).observe(PeertubeActivity.this, this::manageVIewComment);
|
||||
commentViewModel.getThread(videoId, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
||||
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT) {
|
||||
Toasty.success(PeertubeActivity.this, getString(R.string.successful_report), Toasty.LENGTH_LONG).show();
|
||||
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_VIDEO) {
|
||||
|
@ -326,7 +326,7 @@ public interface PeertubeService {
|
||||
|
||||
//Comment
|
||||
@GET("videos/{id}/comment-threads")
|
||||
Call<CommentData> getComments(@Path("id") String id);
|
||||
Call<CommentData> getComments(@Path("id") String id, @Query("start") String maxId);
|
||||
|
||||
@GET("videos/{id}/comment-threads/{threadId}")
|
||||
Call<CommentData> getReplies(@Path("id") String id, @Path("threadId") String threadId);
|
||||
|
@ -1146,13 +1146,13 @@ public class RetrofitPeertubeAPI {
|
||||
apiResponse.setError(error);
|
||||
}
|
||||
|
||||
public APIResponse getComments(CommentVM.action type, String videoId, String forCommentId) {
|
||||
public APIResponse getComments(CommentVM.action type, String videoId, String forCommentId, String max_id) {
|
||||
PeertubeService peertubeService = init();
|
||||
|
||||
APIResponse apiResponse = new APIResponse();
|
||||
try {
|
||||
if (type == CommentVM.action.GET_THREAD) {
|
||||
Call<CommentData> commentsCall = peertubeService.getComments(videoId);
|
||||
Call<CommentData> commentsCall = peertubeService.getComments(videoId, max_id);
|
||||
Response<CommentData> response = commentsCall.execute();
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
apiResponse.setComments(response.body().data);
|
||||
|
@ -180,11 +180,11 @@ public class VideoData {
|
||||
}
|
||||
|
||||
public String getFileUrl(String resolution, Context context) {
|
||||
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean streamService = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL) == Helper.VIDEO_MODE_STREAMING;
|
||||
if (resolution != null) {
|
||||
for (File file : files) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean streamService = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL) == Helper.VIDEO_MODE_STREAMING;
|
||||
|
||||
if (file.getResolutions().getLabel().compareTo(resolution) == 0) {
|
||||
if (streamService) {
|
||||
return file.getMagnetUri();
|
||||
@ -195,16 +195,21 @@ public class VideoData {
|
||||
}
|
||||
}
|
||||
}
|
||||
return files.get(0).getFileUrl();
|
||||
if (streamService) {
|
||||
return Helper.defaultFile(context, files).getMagnetUri();
|
||||
} else {
|
||||
return Helper.defaultFile(context, files).getFileUrl();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public String getTorrentUrl(String resolution) {
|
||||
public String getTorrentUrl(String resolution, Context context) {
|
||||
for (File file : files) {
|
||||
if (file.getResolutions().getLabel().compareTo(resolution) == 0) {
|
||||
return file.getTorrentUrl();
|
||||
}
|
||||
}
|
||||
return files.get(0).getTorrentUrl();
|
||||
return Helper.defaultFile(context, files).getTorrentUrl();
|
||||
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.fedilabtube.LoginActivity;
|
||||
import app.fedilab.fedilabtube.PeertubeActivity;
|
||||
import app.fedilab.fedilabtube.R;
|
||||
import app.fedilab.fedilabtube.ShowAccountActivity;
|
||||
@ -40,6 +39,7 @@ import app.fedilab.fedilabtube.client.data.AccountData;
|
||||
import app.fedilab.fedilabtube.client.data.ChannelData;
|
||||
import app.fedilab.fedilabtube.client.data.NotificationData.Notification;
|
||||
import app.fedilab.fedilabtube.client.entities.Actor;
|
||||
import app.fedilab.fedilabtube.fragment.DisplayNotificationsFragment;
|
||||
import app.fedilab.fedilabtube.helper.Helper;
|
||||
|
||||
|
||||
@ -120,18 +120,18 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
||||
String message = "";
|
||||
if (notification.getVideo() != null) {
|
||||
|
||||
if (notification.getType() == LoginActivity.MY_VIDEO_PUBLISHED) {
|
||||
if (notification.getType() == DisplayNotificationsFragment.MY_VIDEO_PUBLISHED) {
|
||||
message = context.getString(R.string.peertube_video_published, notification.getVideo().getName());
|
||||
} else if (notification.getType() == LoginActivity.MY_VIDEO_IMPORT_ERROR) {
|
||||
} else if (notification.getType() == DisplayNotificationsFragment.MY_VIDEO_IMPORT_ERROR) {
|
||||
message = context.getString(R.string.peertube_video_import_error, notification.getVideo().getName());
|
||||
} else if (notification.getType() == LoginActivity.MY_VIDEO_IMPORT_SUCCESS) {
|
||||
} else if (notification.getType() == DisplayNotificationsFragment.MY_VIDEO_IMPORT_SUCCESS) {
|
||||
message = context.getString(R.string.peertube_video_import_success, notification.getVideo().getName());
|
||||
} else if (notification.getType() == LoginActivity.NEW_VIDEO_FROM_SUBSCRIPTION) {
|
||||
} else if (notification.getType() == DisplayNotificationsFragment.NEW_VIDEO_FROM_SUBSCRIPTION) {
|
||||
channelAction = notification.getVideo().getChannel();
|
||||
message = context.getString(R.string.peertube_video_from_subscription, channelAction.getDisplayName(), notification.getVideo().getName());
|
||||
} else if (notification.getType() == LoginActivity.BLACKLIST_ON_MY_VIDEO) {
|
||||
} else if (notification.getType() == DisplayNotificationsFragment.BLACKLIST_ON_MY_VIDEO) {
|
||||
message = context.getString(R.string.peertube_video_blacklist, notification.getVideo().getName());
|
||||
} else if (notification.getType() == LoginActivity.UNBLACKLIST_ON_MY_VIDEO) {
|
||||
} else if (notification.getType() == DisplayNotificationsFragment.UNBLACKLIST_ON_MY_VIDEO) {
|
||||
message = context.getString(R.string.peertube_video_unblacklist, notification.getVideo().getName());
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
@ -146,6 +146,12 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}else if (notification.getVideoAbuse() != null && notification.getVideoAbuse().getVideo() != null) {
|
||||
message = context.getString(R.string.peertube_video_abuse, notification.getVideoAbuse().getVideo().getName());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
holder.peertube_notif_message.setText(Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
holder.peertube_notif_message.setText(Html.fromHtml(message));
|
||||
}
|
||||
}
|
||||
holder.peertube_notif_date.setText(Helper.dateDiff(context, notification.getCreatedAt()));
|
||||
|
@ -56,6 +56,16 @@ public class DisplayNotificationsFragment extends Fragment {
|
||||
private RecyclerView lv_notifications;
|
||||
private View rootView;
|
||||
|
||||
//Peertube notification type
|
||||
public static int NEW_VIDEO_FROM_SUBSCRIPTION = 1;
|
||||
public static int NEW_REPORT = 3;
|
||||
public static int BLACKLIST_ON_MY_VIDEO = 4;
|
||||
public static int UNBLACKLIST_ON_MY_VIDEO = 5;
|
||||
public static int MY_VIDEO_PUBLISHED = 6;
|
||||
public static int MY_VIDEO_IMPORT_SUCCESS = 7;
|
||||
public static int MY_VIDEO_IMPORT_ERROR = 8;
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
|
@ -88,6 +88,22 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
||||
|
||||
}
|
||||
}
|
||||
if (key.compareTo(getString(R.string.set_video_quality_choice)) == 0) {
|
||||
ListPreference set_video_quality_choice = findPreference(getString(R.string.set_video_quality_choice));
|
||||
if (set_video_quality_choice != null) {
|
||||
switch (set_video_quality_choice.getValue()) {
|
||||
case "0":
|
||||
editor.putInt(Helper.SET_QUALITY_MODE, Helper.QUALITY_HIGH);
|
||||
break;
|
||||
case "1":
|
||||
editor.putInt(Helper.SET_QUALITY_MODE, Helper.QUALITY_MEDIUM);
|
||||
break;
|
||||
case "2":
|
||||
editor.putInt(Helper.SET_QUALITY_MODE, Helper.QUALITY_LOW);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (key.compareTo(getString(R.string.set_video_minimize_choice)) == 0) {
|
||||
SwitchPreference set_video_minimize_choice = findPreference(getString(R.string.set_video_minimize_choice));
|
||||
assert set_video_minimize_choice != null;
|
||||
@ -129,6 +145,21 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
||||
set_video_mode_choice.setValueIndex(video_mode);
|
||||
}
|
||||
|
||||
//****** Video quality *******
|
||||
ListPreference set_video_quality_choice = findPreference(getString(R.string.set_video_quality_choice));
|
||||
List<String> arrayQuality = Arrays.asList(getResources().getStringArray(R.array.settings_video_quality));
|
||||
CharSequence[] entriesQuality = arrayQuality.toArray(new CharSequence[0]);
|
||||
CharSequence[] entryValuesQuality = new CharSequence[3];
|
||||
int video_quality = sharedpref.getInt(Helper.SET_QUALITY_MODE, Helper.QUALITY_HIGH);
|
||||
entryValuesQuality[0] = String.valueOf(Helper.QUALITY_HIGH);
|
||||
entryValuesQuality[1] = String.valueOf(Helper.QUALITY_MEDIUM);
|
||||
entryValuesQuality[2] = String.valueOf(Helper.QUALITY_LOW);
|
||||
if (set_video_quality_choice != null) {
|
||||
set_video_quality_choice.setEntries(entriesQuality);
|
||||
set_video_quality_choice.setEntryValues(entryValuesQuality);
|
||||
set_video_quality_choice.setValueIndex(video_quality);
|
||||
}
|
||||
|
||||
boolean minimized = sharedpref.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
||||
SwitchPreference set_video_minimize_choice = findPreference(getString(R.string.set_video_minimize_choice));
|
||||
assert set_video_minimize_choice != null;
|
||||
|
@ -52,6 +52,7 @@ import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.util.regex.Pattern;
|
||||
@ -61,6 +62,7 @@ import app.fedilab.fedilabtube.MainActivity;
|
||||
import app.fedilab.fedilabtube.R;
|
||||
import app.fedilab.fedilabtube.WebviewActivity;
|
||||
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
||||
import app.fedilab.fedilabtube.client.entities.File;
|
||||
import app.fedilab.fedilabtube.sqlite.AccountDAO;
|
||||
import app.fedilab.fedilabtube.sqlite.Sqlite;
|
||||
import app.fedilab.fedilabtube.webview.CustomWebview;
|
||||
@ -73,9 +75,13 @@ public class Helper {
|
||||
|
||||
public static final int RELOAD_MYVIDEOS = 10;
|
||||
public static final String SET_VIDEO_MODE = "set_video_mode";
|
||||
public static final String SET_QUALITY_MODE = "set_quality_mode";
|
||||
public static final int VIDEO_MODE_NORMAL = 0;
|
||||
public static final int VIDEO_MODE_STREAMING = 1;
|
||||
public static final int VIDEO_MODE_WEBVIEW = 2;
|
||||
public static final int QUALITY_HIGH = 0;
|
||||
public static final int QUALITY_MEDIUM = 1;
|
||||
public static final int QUALITY_LOW = 2;
|
||||
public static final int VIDEO_MODE_TORRENT = 3;
|
||||
public static final int ADD_USER_INTENT = 5;
|
||||
public static final int VIDEO_UPLOADED_INTENT = 6;
|
||||
@ -682,4 +688,27 @@ public class Helper {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Return a File depending of the requested quality
|
||||
* @param context Context
|
||||
* @param files List<File>
|
||||
* @return File
|
||||
*/
|
||||
public static File defaultFile(Context context, List<File> files){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
int video_quality = sharedpreferences.getInt(Helper.SET_QUALITY_MODE, Helper.QUALITY_HIGH);
|
||||
if( video_quality == QUALITY_HIGH) {
|
||||
return files.get(0);
|
||||
}else if( video_quality == QUALITY_LOW) {
|
||||
return files.get(files.size() -1);
|
||||
}else{
|
||||
if( files.size() < 3) {
|
||||
return files.get(files.size() -1);
|
||||
}else{
|
||||
int middle = files.size()/2;
|
||||
return files.get(middle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ public class CommentVM extends AndroidViewModel {
|
||||
super(application);
|
||||
}
|
||||
|
||||
public LiveData<APIResponse> getThread(String videoId) {
|
||||
public LiveData<APIResponse> getThread(String videoId, String max_Id) {
|
||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||
getThreadComments(videoId);
|
||||
getThreadComments(videoId, max_Id);
|
||||
return apiResponseMutableLiveData;
|
||||
}
|
||||
|
||||
@ -48,12 +48,12 @@ public class CommentVM extends AndroidViewModel {
|
||||
}
|
||||
|
||||
|
||||
private void getThreadComments(String videoId) {
|
||||
private void getThreadComments(String videoId, String max_id) {
|
||||
Context _mContext = getApplication().getApplicationContext();
|
||||
new Thread(() -> {
|
||||
try {
|
||||
RetrofitPeertubeAPI api = new RetrofitPeertubeAPI(_mContext);
|
||||
APIResponse apiResponse = api.getComments(CommentVM.action.GET_THREAD, videoId, null);
|
||||
APIResponse apiResponse = api.getComments(CommentVM.action.GET_THREAD, videoId, null, max_id);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
||||
mainHandler.post(myRunnable);
|
||||
@ -69,7 +69,7 @@ public class CommentVM extends AndroidViewModel {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
RetrofitPeertubeAPI api = new RetrofitPeertubeAPI(_mContext);
|
||||
APIResponse apiResponse = api.getComments(action.GET_REPLIES, videoId, null);
|
||||
APIResponse apiResponse = api.getComments(action.GET_REPLIES, videoId, null, null);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
||||
mainHandler.post(myRunnable);
|
||||
|
10
app/src/main/res/drawable/ic_baseline_high_quality_24.xml
Normal file
10
app/src/main/res/drawable/ic_baseline_high_quality_24.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M19,4L5,4c-1.11,0 -2,0.9 -2,2v12c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.9,-2 -2,-2zM11,15L9.5,15v-2h-2v2L6,15L6,9h1.5v2.5h2L9.5,9L11,9v6zM18,14c0,0.55 -0.45,1 -1,1h-0.75v1.5h-1.5L14.75,15L14,15c-0.55,0 -1,-0.45 -1,-1v-4c0,-0.55 0.45,-1 1,-1h3c0.55,0 1,0.45 1,1v4zM14.5,13.5h2v-3h-2v3z"/>
|
||||
</vector>
|
@ -21,4 +21,9 @@
|
||||
android:summary="@string/set_video_language_description"
|
||||
android:title="@string/set_video_language" />
|
||||
|
||||
<androidx.preference.ListPreference
|
||||
android:icon="@drawable/ic_baseline_high_quality_24"
|
||||
android:key="@string/set_video_quality_choice"
|
||||
android:summary="@string/set_video_quality_description"
|
||||
android:title="@string/set_quality_mode" />
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user