update library and more (#160)

* download files with friendly name (not video ID)

* Update Picasso library
FIX : add extension in downloaded filename.
download files with friendly name (not video ID)

* Update Gradle
Add 0.75x and 1.25x to play speed
This commit is contained in:
jmgfr 2020-06-01 19:44:35 +02:00 committed by GitHub
parent e27e75a4ae
commit aa5e37c5f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 100 additions and 13 deletions

View File

@ -35,10 +35,10 @@ android {
implementation 'com.squareup.retrofit2:retrofit:2.5.0' implementation 'com.squareup.retrofit2:retrofit:2.5.0'
// image downloading and caching library // image downloading and caching library
implementation 'com.squareup.picasso:picasso:2.5.2' implementation 'com.squareup.picasso:picasso:2.71828'
// json decoder/encoder // json decoder/encoder
implementation 'com.google.code.gson:gson:2.8.5' implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0' implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
// Torrents and WebRTC // Torrents and WebRTC
@ -79,5 +79,4 @@ android {
dependencies { dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta6' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta6'
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
} }

View File

@ -200,7 +200,7 @@ public class AccountActivity extends CommonActivity {
Avatar avatar = account.getAvatar(); Avatar avatar = account.getAvatar();
if (avatar != null) { if (avatar != null) {
String avatarPath = avatar.getPath(); String avatarPath = avatar.getPath();
Picasso.with(AccountActivity.this) Picasso.get()
.load(APIUrlHelper.getUrl(AccountActivity.this) + avatarPath) .load(APIUrlHelper.getUrl(AccountActivity.this) + avatarPath)
.into(accountAvatar); .into(accountAvatar);
} }

View File

@ -70,7 +70,7 @@ public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.AccountV
@Override @Override
public void onBindViewHolder(@NonNull AccountViewHolder holder, int position) { public void onBindViewHolder(@NonNull AccountViewHolder holder, int position) {
Picasso.with(this.context) Picasso.get()
.load(baseUrl + videoList.get(position).getPreviewPath()) .load(baseUrl + videoList.get(position).getPreviewPath())
.into(holder.thumb); .into(holder.thumb);
@ -78,7 +78,7 @@ public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.AccountV
Avatar avatar = videoList.get(position).getAccount().getAvatar(); Avatar avatar = videoList.get(position).getAccount().getAvatar();
if (avatar != null) { if (avatar != null) {
String avatarPath = avatar.getPath(); String avatarPath = avatar.getPath();
Picasso.with(this.context) Picasso.get()
.load(baseUrl + avatarPath) .load(baseUrl + avatarPath)
.into(holder.avatar); .into(holder.avatar);
} }

View File

@ -73,7 +73,7 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
@Override @Override
public void onBindViewHolder(@NonNull VideoViewHolder holder, int position) { public void onBindViewHolder(@NonNull VideoViewHolder holder, int position) {
Picasso.with(this.context) Picasso.get()
.load(baseUrl + videoList.get(position).getPreviewPath()) .load(baseUrl + videoList.get(position).getPreviewPath())
.into(holder.thumb); .into(holder.thumb);
@ -81,7 +81,7 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
Avatar avatar = videoList.get(position).getAccount().getAvatar(); Avatar avatar = videoList.get(position).getAccount().getAvatar();
if (avatar != null) { if (avatar != null) {
String avatarPath = avatar.getPath(); String avatarPath = avatar.getPath();
Picasso.with(this.context) Picasso.get()
.load(baseUrl + avatarPath) .load(baseUrl + avatarPath)
.into(holder.avatar); .into(holder.avatar);
} }

View File

@ -37,7 +37,9 @@ public class VideoMenuSpeedFragment extends BottomSheetDialogFragment {
public static final String TAG = "VideoMenuSpeed"; public static final String TAG = "VideoMenuSpeed";
private TextView speed05Icon; private TextView speed05Icon;
private TextView speed075Icon;
private TextView speed10Icon; private TextView speed10Icon;
private TextView speed125Icon;
private TextView speed15Icon; private TextView speed15Icon;
private TextView speed20Icon; private TextView speed20Icon;
@ -57,13 +59,17 @@ public class VideoMenuSpeedFragment extends BottomSheetDialogFragment {
// Icons // Icons
speed05Icon = view.findViewById(R.id.video_speed05_icon); speed05Icon = view.findViewById(R.id.video_speed05_icon);
speed075Icon = view.findViewById(R.id.video_speed075_icon);
speed10Icon = view.findViewById(R.id.video_speed10_icon); speed10Icon = view.findViewById(R.id.video_speed10_icon);
speed125Icon = view.findViewById(R.id.video_speed125_icon);
speed15Icon = view.findViewById(R.id.video_speed15_icon); speed15Icon = view.findViewById(R.id.video_speed15_icon);
speed20Icon = view.findViewById(R.id.video_speed20_icon); speed20Icon = view.findViewById(R.id.video_speed20_icon);
// Buttons // Buttons
TextView speed05 = view.findViewById(R.id.video_speed05); TextView speed05 = view.findViewById(R.id.video_speed05);
TextView speed075 = view.findViewById(R.id.video_speed075);
TextView speed10 = view.findViewById(R.id.video_speed10); TextView speed10 = view.findViewById(R.id.video_speed10);
TextView speed125 = view.findViewById(R.id.video_speed125);
TextView speed15 = view.findViewById(R.id.video_speed15); TextView speed15 = view.findViewById(R.id.video_speed15);
TextView speed20 = view.findViewById(R.id.video_speed20); TextView speed20 = view.findViewById(R.id.video_speed20);
@ -72,7 +78,9 @@ public class VideoMenuSpeedFragment extends BottomSheetDialogFragment {
// Attach the listener // Attach the listener
speed05.setOnClickListener(v -> setVideoSpeed(0.5f, speed05Icon)); speed05.setOnClickListener(v -> setVideoSpeed(0.5f, speed05Icon));
speed075.setOnClickListener(v -> setVideoSpeed(0.75f, speed075Icon));
speed10.setOnClickListener(v -> setVideoSpeed(1.0f, speed10Icon)); speed10.setOnClickListener(v -> setVideoSpeed(1.0f, speed10Icon));
speed125.setOnClickListener(v -> setVideoSpeed(1.25f, speed125Icon));
speed15.setOnClickListener(v -> setVideoSpeed(1.5f, speed15Icon)); speed15.setOnClickListener(v -> setVideoSpeed(1.5f, speed15Icon));
speed20.setOnClickListener(v -> setVideoSpeed(2.0f, speed20Icon)); speed20.setOnClickListener(v -> setVideoSpeed(2.0f, speed20Icon));
@ -84,7 +92,9 @@ public class VideoMenuSpeedFragment extends BottomSheetDialogFragment {
private void setVideoSpeed(Float speed, TextView icon) { private void setVideoSpeed(Float speed, TextView icon) {
speed05Icon.setText(""); speed05Icon.setText("");
speed075Icon.setText("");
speed10Icon.setText(""); speed10Icon.setText("");
speed125Icon.setText("");
speed15Icon.setText(""); speed15Icon.setText("");
speed20Icon.setText(""); speed20Icon.setText("");

View File

@ -165,7 +165,7 @@ public class VideoMetaDataFragment extends Fragment {
ImageView avatarView = activity.findViewById(R.id.avatar); ImageView avatarView = activity.findViewById(R.id.avatar);
String baseUrl = APIUrlHelper.getUrl(context); String baseUrl = APIUrlHelper.getUrl(context);
String avatarPath = avatar.getPath(); String avatarPath = avatar.getPath();
Picasso.with(context) Picasso.get()
.load(baseUrl + avatarPath) .load(baseUrl + avatarPath)
.into(avatarView); .into(avatarView);
} }

View File

@ -25,10 +25,13 @@ import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Environment; import android.os.Environment;
import android.webkit.MimeTypeMap;
import android.webkit.URLUtil; import android.webkit.URLUtil;
import com.github.se_bastiaan.torrentstream.TorrentOptions; import com.github.se_bastiaan.torrentstream.TorrentOptions;
import net.schueller.peertube.R;
import net.schueller.peertube.helper.APIUrlHelper; import net.schueller.peertube.helper.APIUrlHelper;
import net.schueller.peertube.model.Video; import net.schueller.peertube.model.Video;
@ -66,12 +69,14 @@ public class Intents {
public static void Download(Context context, Video video) { public static void Download(Context context, Video video) {
String url = video.getFiles().get(0).getFileDownloadUrl(); String url = video.getFiles().get(0).getFileDownloadUrl();
String destFilename = video.getName() + "." + MimeTypeMap.getFileExtensionFromUrl(URLUtil.guessFileName(url,null,null));
//Toast.makeText(context, destFilename, Toast.LENGTH_LONG).show();
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setDescription(video.getDescription()); request.setDescription(video.getDescription());
request.setTitle(video.getName()); request.setTitle(video.getName());
request.allowScanningByMediaScanner(); request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(url, null, null)); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, destFilename);
// get download service and enqueue file // get download service and enqueue file
DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);

View File

@ -35,6 +35,35 @@
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/video_speed075_icon"
android:layout_width="32dp"
android:layout_height="56dp"
android:layout_marginStart="16dp"
android:gravity="center|start"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="12sp" />
<TextView
android:id="@+id/video_speed075"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:gravity="center|start"
android:text="@string/video_speed_075"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -65,6 +94,34 @@
android:textSize="16sp" /> android:textSize="16sp" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/video_speed125_icon"
android:layout_width="32dp"
android:layout_height="56dp"
android:layout_marginStart="16dp"
android:gravity="center|start"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="12sp" />
<TextView
android:id="@+id/video_speed125"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:gravity="center|start"
android:text="@string/video_speed_125"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -310,4 +310,6 @@
<string name="server_selection_peertube_server_url">عنوان خادوم PeerTube</string> <string name="server_selection_peertube_server_url">عنوان خادوم PeerTube</string>
<string name="action_bar_title_server_selection">حدد الخادوم</string> <string name="action_bar_title_server_selection">حدد الخادوم</string>
<string name="login_current_server_hint">الخادوم الحالي</string> <string name="login_current_server_hint">الخادوم الحالي</string>
<string name="video_speed_075">0.75x</string>
<string name="video_speed_125">1.25x</string>
</resources> </resources>

View File

@ -322,4 +322,6 @@
<string name="server_selection_signup_allowed_no">না</string> <string name="server_selection_signup_allowed_no">না</string>
<string name="server_selection_peertube_server_url">পিয়ারটিউব সার্ভার URL</string> <string name="server_selection_peertube_server_url">পিয়ারটিউব সার্ভার URL</string>
<string name="action_bar_title_server_selection">সার্ভার নির্বাচন করুন</string> <string name="action_bar_title_server_selection">সার্ভার নির্বাচন করুন</string>
<string name="video_speed_075">0.75x</string>
<string name="video_speed_125">1.25x</string>
</resources> </resources>

View File

@ -298,4 +298,6 @@
<string name="na">nauru</string> <string name="na">nauru</string>
<string name="ky">kirgiisi</string> <string name="ky">kirgiisi</string>
<string name="tk">turkmeeni</string> <string name="tk">turkmeeni</string>
<string name="video_speed_125">1.25x</string>
<string name="video_speed_075">0.75x</string>
</resources> </resources>

View File

@ -310,4 +310,6 @@
<string name="za">zhuang</string> <string name="za">zhuang</string>
<string name="zu">zoulou</string> <string name="zu">zoulou</string>
<string name="login_current_server_hint">Serveur actuel</string> <string name="login_current_server_hint">Serveur actuel</string>
<string name="video_speed_075">0.75x</string>
<string name="video_speed_125">1.25x</string>
</resources> </resources>

View File

@ -300,4 +300,6 @@
<string name="server_selection_peertube_server_url">PeerTube-server-url</string> <string name="server_selection_peertube_server_url">PeerTube-server-url</string>
<string name="action_bar_title_server_selection">Server kiezen</string> <string name="action_bar_title_server_selection">Server kiezen</string>
<string name="login_current_server_hint">Huidige server</string> <string name="login_current_server_hint">Huidige server</string>
<string name="video_speed_075">0.75x</string>
<string name="video_speed_125">1.25x</string>
</resources> </resources>

View File

@ -99,4 +99,6 @@
<string name="video_meta_button_language">语言</string> <string name="video_meta_button_language">语言</string>
<string name="server_selection_signup_allowed_yes"></string> <string name="server_selection_signup_allowed_yes"></string>
<string name="server_selection_signup_allowed_no"></string> <string name="server_selection_signup_allowed_no"></string>
<string name="video_speed_075">0.75倍速</string>
<string name="video_speed_125">1.25倍速</string>
</resources> </resources>

View File

@ -299,4 +299,6 @@
<string name="server_selection_peertube_server_url">PeerTube 伺服器 URL</string> <string name="server_selection_peertube_server_url">PeerTube 伺服器 URL</string>
<string name="action_bar_title_server_selection">選取伺服器</string> <string name="action_bar_title_server_selection">選取伺服器</string>
<string name="login_current_server_hint">目前的伺服器</string> <string name="login_current_server_hint">目前的伺服器</string>
<string name="video_speed_125">1.25x</string>
<string name="video_speed_075">0.75x</string>
</resources> </resources>

View File

@ -332,5 +332,7 @@
<string name="video_rating_dislike" translatable="false">dislike</string> <string name="video_rating_dislike" translatable="false">dislike</string>
<string name="peertube_required_server_version" translatable="false">1.0.0-alpha.7</string> <string name="peertube_required_server_version" translatable="false">1.0.0-alpha.7</string>
<string name="login_current_server_hint">Current Server</string> <string name="login_current_server_hint">Current Server</string>
<string name="video_speed_075">0.75x</string>
<string name="video_speed_125">1.25x</string>
</resources> </resources>

View File

@ -7,7 +7,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.6.3' classpath 'com.android.tools.build:gradle:4.0.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong

View File

@ -1,6 +1,6 @@
#Sat May 16 15:51:28 CEST 2020 #Mon Jun 01 12:58:36 CEST 2020
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip