From c843e268d006fb069c408cf00cc3a87384d66fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Sch=C3=BCller?= Date: Mon, 1 Jun 2020 20:15:50 +0200 Subject: [PATCH] update library and more (#160) (#161) * 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 Co-authored-by: jmgfr <13685004+jmgfr@users.noreply.github.com> --- app/build.gradle | 5 +- .../peertube/activity/AccountActivity.java | 2 +- .../peertube/adapter/ChannelAdapter.java | 4 +- .../peertube/adapter/VideoAdapter.java | 4 +- .../fragment/VideoMenuSpeedFragment.java | 10 ++++ .../fragment/VideoMetaDataFragment.java | 2 +- .../schueller/peertube/intents/Intents.java | 7 ++- ...ragment_video_options_speed_popup_menu.xml | 57 +++++++++++++++++++ app/src/main/res/values-ar/strings.xml | 2 + app/src/main/res/values-bn/strings.xml | 2 + app/src/main/res/values-fi/strings.xml | 2 + app/src/main/res/values-fr/strings.xml | 2 + app/src/main/res/values-nl/strings.xml | 2 + app/src/main/res/values-zh-rCN/strings.xml | 2 + app/src/main/res/values-zh-rTW/strings.xml | 2 + app/src/main/res/values/strings.xml | 2 + build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 18 files changed, 100 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1850d250..39d5a454 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -35,10 +35,10 @@ android { implementation 'com.squareup.retrofit2:retrofit:2.5.0' // image downloading and caching library - implementation 'com.squareup.picasso:picasso:2.5.2' + implementation 'com.squareup.picasso:picasso:2.71828' // 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' // Torrents and WebRTC @@ -79,5 +79,4 @@ android { dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta6' implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' } diff --git a/app/src/main/java/net/schueller/peertube/activity/AccountActivity.java b/app/src/main/java/net/schueller/peertube/activity/AccountActivity.java index 0c70e664..4c4b5cfa 100644 --- a/app/src/main/java/net/schueller/peertube/activity/AccountActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/AccountActivity.java @@ -200,7 +200,7 @@ public void onResponse(@NonNull Call call, @NonNull Response r Avatar avatar = account.getAvatar(); if (avatar != null) { String avatarPath = avatar.getPath(); - Picasso.with(AccountActivity.this) + Picasso.get() .load(APIUrlHelper.getUrl(AccountActivity.this) + avatarPath) .into(accountAvatar); } diff --git a/app/src/main/java/net/schueller/peertube/adapter/ChannelAdapter.java b/app/src/main/java/net/schueller/peertube/adapter/ChannelAdapter.java index 082256b7..ed4f2ead 100644 --- a/app/src/main/java/net/schueller/peertube/adapter/ChannelAdapter.java +++ b/app/src/main/java/net/schueller/peertube/adapter/ChannelAdapter.java @@ -70,7 +70,7 @@ public AccountViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewT @Override public void onBindViewHolder(@NonNull AccountViewHolder holder, int position) { - Picasso.with(this.context) + Picasso.get() .load(baseUrl + videoList.get(position).getPreviewPath()) .into(holder.thumb); @@ -78,7 +78,7 @@ public void onBindViewHolder(@NonNull AccountViewHolder holder, int position) { Avatar avatar = videoList.get(position).getAccount().getAvatar(); if (avatar != null) { String avatarPath = avatar.getPath(); - Picasso.with(this.context) + Picasso.get() .load(baseUrl + avatarPath) .into(holder.avatar); } diff --git a/app/src/main/java/net/schueller/peertube/adapter/VideoAdapter.java b/app/src/main/java/net/schueller/peertube/adapter/VideoAdapter.java index e55e40b4..7e1be5d3 100644 --- a/app/src/main/java/net/schueller/peertube/adapter/VideoAdapter.java +++ b/app/src/main/java/net/schueller/peertube/adapter/VideoAdapter.java @@ -73,7 +73,7 @@ public VideoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewTyp @Override public void onBindViewHolder(@NonNull VideoViewHolder holder, int position) { - Picasso.with(this.context) + Picasso.get() .load(baseUrl + videoList.get(position).getPreviewPath()) .into(holder.thumb); @@ -81,7 +81,7 @@ public void onBindViewHolder(@NonNull VideoViewHolder holder, int position) { Avatar avatar = videoList.get(position).getAccount().getAvatar(); if (avatar != null) { String avatarPath = avatar.getPath(); - Picasso.with(this.context) + Picasso.get() .load(baseUrl + avatarPath) .into(holder.avatar); } diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoMenuSpeedFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoMenuSpeedFragment.java index 52e93786..7cf8218a 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoMenuSpeedFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoMenuSpeedFragment.java @@ -37,7 +37,9 @@ public class VideoMenuSpeedFragment extends BottomSheetDialogFragment { public static final String TAG = "VideoMenuSpeed"; private TextView speed05Icon; + private TextView speed075Icon; private TextView speed10Icon; + private TextView speed125Icon; private TextView speed15Icon; private TextView speed20Icon; @@ -57,13 +59,17 @@ public View onCreateView(LayoutInflater inflater, // Icons speed05Icon = view.findViewById(R.id.video_speed05_icon); + speed075Icon = view.findViewById(R.id.video_speed075_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); speed20Icon = view.findViewById(R.id.video_speed20_icon); // Buttons 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 speed125 = view.findViewById(R.id.video_speed125); TextView speed15 = view.findViewById(R.id.video_speed15); TextView speed20 = view.findViewById(R.id.video_speed20); @@ -72,7 +78,9 @@ public View onCreateView(LayoutInflater inflater, // Attach the listener speed05.setOnClickListener(v -> setVideoSpeed(0.5f, speed05Icon)); + speed075.setOnClickListener(v -> setVideoSpeed(0.75f, speed075Icon)); speed10.setOnClickListener(v -> setVideoSpeed(1.0f, speed10Icon)); + speed125.setOnClickListener(v -> setVideoSpeed(1.25f, speed125Icon)); speed15.setOnClickListener(v -> setVideoSpeed(1.5f, speed15Icon)); speed20.setOnClickListener(v -> setVideoSpeed(2.0f, speed20Icon)); @@ -84,7 +92,9 @@ public View onCreateView(LayoutInflater inflater, private void setVideoSpeed(Float speed, TextView icon) { speed05Icon.setText(""); + speed075Icon.setText(""); speed10Icon.setText(""); + speed125Icon.setText(""); speed15Icon.setText(""); speed20Icon.setText(""); diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoMetaDataFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoMetaDataFragment.java index d58eab76..17558afa 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoMetaDataFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoMetaDataFragment.java @@ -165,7 +165,7 @@ public void onFailure(Call call, Throwable t) { ImageView avatarView = activity.findViewById(R.id.avatar); String baseUrl = APIUrlHelper.getUrl(context); String avatarPath = avatar.getPath(); - Picasso.with(context) + Picasso.get() .load(baseUrl + avatarPath) .into(avatarView); } diff --git a/app/src/main/java/net/schueller/peertube/intents/Intents.java b/app/src/main/java/net/schueller/peertube/intents/Intents.java index 29ea9c38..acbede12 100644 --- a/app/src/main/java/net/schueller/peertube/intents/Intents.java +++ b/app/src/main/java/net/schueller/peertube/intents/Intents.java @@ -25,10 +25,13 @@ import android.net.Uri; import android.os.Build; import android.os.Environment; +import android.webkit.MimeTypeMap; import android.webkit.URLUtil; + import com.github.se_bastiaan.torrentstream.TorrentOptions; +import net.schueller.peertube.R; import net.schueller.peertube.helper.APIUrlHelper; import net.schueller.peertube.model.Video; @@ -66,12 +69,14 @@ public static void Share(Context context, Video video) { public static void Download(Context context, Video video) { 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)); request.setDescription(video.getDescription()); request.setTitle(video.getName()); request.allowScanningByMediaScanner(); 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 DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); diff --git a/app/src/main/res/layout/fragment_video_options_speed_popup_menu.xml b/app/src/main/res/layout/fragment_video_options_speed_popup_menu.xml index ca15827a..7d0d3c77 100644 --- a/app/src/main/res/layout/fragment_video_options_speed_popup_menu.xml +++ b/app/src/main/res/layout/fragment_video_options_speed_popup_menu.xml @@ -35,6 +35,35 @@ + + + + + + + + + + + + + + + عنوان خادوم PeerTube حدد الخادوم الخادوم الحالي + 0.75x + 1.25x \ No newline at end of file diff --git a/app/src/main/res/values-bn/strings.xml b/app/src/main/res/values-bn/strings.xml index 9ee4ace0..366cf0cf 100644 --- a/app/src/main/res/values-bn/strings.xml +++ b/app/src/main/res/values-bn/strings.xml @@ -322,4 +322,6 @@ না পিয়ারটিউব সার্ভার URL সার্ভার নির্বাচন করুন + 0.75x + 1.25x \ No newline at end of file diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 14b911f8..34f6f80a 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -298,4 +298,6 @@ nauru kirgiisi turkmeeni + 1.25x + 0.75x \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index bace293e..fa70f15a 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -310,4 +310,6 @@ zhuang zoulou Serveur actuel + 0.75x + 1.25x \ No newline at end of file diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 9e7027d0..c34fd93e 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -300,4 +300,6 @@ PeerTube-server-url Server kiezen Huidige server + 0.75x + 1.25x \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index fbef971d..f390210b 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -99,4 +99,6 @@ 语言 + 0.75倍速 + 1.25倍速 \ No newline at end of file diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index df9a5a2e..d1c9a283 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -299,4 +299,6 @@ PeerTube 伺服器 URL 選取伺服器 目前的伺服器 + 1.25x + 0.75x \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6c975a4e..9cefc3cf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -332,5 +332,7 @@ dislike 1.0.0-alpha.7 Current Server + 0.75x + 1.25x \ No newline at end of file diff --git a/build.gradle b/build.gradle index bf2442ad..e4e9daa7 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } 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 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a2143274..8ff5dc2a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat May 16 15:51:28 CEST 2020 +#Mon Jun 01 12:58:36 CEST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME 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