From 18c364f3b1c8d380218b6aa38a8da30e8e6e525c Mon Sep 17 00:00:00 2001 From: Olivier Humbert Date: Sat, 27 Jun 2020 22:24:12 +0000 Subject: [PATCH 001/198] Translated using Weblate (French) Currently translated at 99.7% (364 of 365 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/fr/ --- app/src/main/res/values-fr/strings.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 5567530..9482c9d 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -333,4 +333,21 @@ Langue de l\'application Mettre la lecture d\'arrière-plan en pause en appuyant sur la touche de retour pendant la lecture de la vidéo. Pause sur le bouton retour + Apparence + À propos + Lecture vidéo + Liste des vidéos + SettingsActivity2 + Compte + Sélectionner un serveur + Êtes-vous sûr de vouloir supprimer ce serveur du carnet d\'adresses \? + Supprimer le serveur + Bengalais (Bangladesh) + Comment une vidéo en cours de lecture réagit lorsqu\'elle passe en arrière-plan + La permission \"Image dans l\'image\" est désactivée pour cette application dans les paramètres Android + La version Android ne prend pas en charge la vidéo flottante + Configuration de la lecture en arrière-plan + Continuer la lecture de la vidéo dans une fenêtre flottante + Arrêter toutes les lectures + Continuer comme un flux audio d\'arrière plan \ No newline at end of file From cbda00aabbc34a196ce538a3a3005500209d7d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Sun, 28 Jun 2020 05:37:23 +0000 Subject: [PATCH 002/198] Translated using Weblate (Turkish) Currently translated at 99.7% (364 of 365 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/tr/ --- app/src/main/res/values-tr/strings.xml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 8312c87..81efe1a 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -281,7 +281,7 @@ {faw-share} {faw-download} {faw-save} - Arkaplanda Oynatma + Arka Planda Oynatma Etkinleştirilirse, arka planda izleti oynatmaya devam eder. Yerel Hesap @@ -351,4 +351,21 @@ Arama Geçmişini Temizle Uygulama arayüzü için dil seçin. Değişikliklerin etkili olması için uygulamayı yeniden başlatın. Uygulama Dili + Görünüm + Hakkında + Video Oynatma + Video Listesi + SettingsActivity2 + Hesap + Sunucu Seç + Bu sunucuyu adres defterinden kaldırmak istediğinizden emin misiniz\? + Sunucuyu Kaldır + Bengalce (Bangladeş) + Arka plana giderken oynatılan bir videonun nasıl yanıt vereceği + Android Ayarlarında bu uygulama için resim içinde resim izni devre dışı + Android sürümü kayan videoyu desteklemiyor + Kayan pencerede video oynatmaya devam et + Arka planda oynatma yapılandırması + Tüm oynatmaları durdur + Arka planda ses akışı olarak devam et \ No newline at end of file From fa8a14865843595cf0b9a12d066f31118af3dc8c Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Sun, 28 Jun 2020 03:34:52 +0000 Subject: [PATCH 003/198] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (365 of 365 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/zh_Hant/ --- app/src/main/res/values-zh-rTW/strings.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index ddce667..dca2312 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -323,4 +323,21 @@ 應用程式語言 當影片播放時按下後退鈕後暫停背景播放。 在後退鈕上暫停 + 外觀與感覺 + 關於 + 影片播放 + 影片清單 + SettingsActivity2 + 帳號 + 選取伺服器 + 您確定您想要從地址簿中移除此伺服器嗎? + 移除伺服器 + 孟加拉語(孟加拉) + 播放影片到背景時如何回應 + 在 Android 設定中已停用此應用程式的畫中畫權限 + Android 版本不支援懸浮影片 + 背景播放設定 + 繼續以懸浮視窗播放影片 + 停止所有播放 + 以背景音訊串流繼續 \ No newline at end of file From ab48efd8ff9cf5521493d5cc8dbc8f673de3c1f3 Mon Sep 17 00:00:00 2001 From: Heimen Stoffels Date: Sun, 28 Jun 2020 09:43:26 +0000 Subject: [PATCH 004/198] Translated using Weblate (Dutch) Currently translated at 100.0% (365 of 365 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/nl/ --- app/src/main/res/values-nl/strings.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 486a798..df609cc 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -323,4 +323,21 @@ App-taal Pauzeer het afspelen als er op de terugknop wordt gedrukt. Pauzeren na drukken op terugknop + Uiterlijk + Over + Video afspelen + Videolijst + SettingsActivity2 + Account + Server kiezen + Weet je zeker dat je deze server wilt verwijderen uit het adresboek\? + Server verwijderen + Bengaals (Bangladesh) + Hoe een video moet worden afgespeeld op de achtergrond + Picture-in-picturemachtiging is niet afgegeven voor deze app in de Android-instellingen + Deze Android-versie ondersteunt geen zwevende video\'s + Afspelen op achtergrond + Video afspelen in zwevend venster + Afspelen stoppen + Audio afspelen op achtergrond \ No newline at end of file From 9759e8372c6c324ee81984ad1f470bc7ad0b17e5 Mon Sep 17 00:00:00 2001 From: Digiwizkid Date: Tue, 30 Jun 2020 10:10:59 +0000 Subject: [PATCH 005/198] Translated using Weblate (Bengali) Currently translated at 99.4% (363 of 365 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/bn/ --- app/src/main/res/values-bn/strings.xml | 43 ++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values-bn/strings.xml b/app/src/main/res/values-bn/strings.xml index 7277160..e02802e 100644 --- a/app/src/main/res/values-bn/strings.xml +++ b/app/src/main/res/values-bn/strings.xml @@ -43,8 +43,8 @@ একটি টরেন্ট স্ট্রিমের মাধ্যমে ভিডিও প্লেব্যাক করুন। এর জন্য স্টোরেজ অনুমতির প্রয়োজন । (আলফা, স্থিতিশীল নয়!) অনুমতিপত্র -\nগাহ্নু অফেরও সাধারণ গণ অনুমতিপত্র সং.৩.০ -\n +\nগাহ্নু অফেরও সাধারণ গণ অনুমতিপত্র সং.৩.০ +\n \nএই শক্তিশালী কপিলেফট লাইসেন্সের অনুমতি এই চুক্তির উপর নির্ভরশীল যে অনুমতিপত্রের দ্বারা আবদ্ধ সকল কাজ ও পরিবর্তনের সোর্স কোড উপলব্ধ করার মাধ্যমে, যার আওতায় পড়ে অনুমতিপত্রের দ্বারা আবদ্ধ কাজের বৃহত্তর অংশ একই অনুমতিপত্রের আওতায় আনার মাধ্যমে। কপিরাইট এবং লাইসেন্স নোটিশ সংরক্ষণ করা আবশ্যক। অবদানকারীগণ তাদের পেটেন্টর অধিকার অবশ্যই দেয়, যখন একটি পরিমার্জিত সংস্করণ ব্যবহার করে একটি পরিসেবা একটি নেটওয়ার্ক দিয়ে দেয়া হয়, সম্পূর্ণ সোর্স কোড এর পরিমার্জিত সংস্করণ উপলব্ধ তৈরি করা আবশ্যক। সংস্করণ সার্চ পিয়ারটিউব @@ -157,7 +157,7 @@ লিনগালা লিথুনীয় লোজবান - + লুবা-কাতাঙ্গা লাক্সেমবোর্গীয় ম্যাসিডোনিয় মালাগাসি @@ -331,4 +331,41 @@ নিচের তালিকা থেকে একটি সার্ভার নিন অথবা সরাসরি একটি সার্ভার দিন। 0.75x 1.25x + ব্যাকগ্রউন্ড প্লে এর কনফিগারেশন + লুক এবং ফিল + লগইন আছে + পেছনে অডিও স্ট্রিম হিসেবে চালু রাখুন + সম্পর্কিত + ভিডিও প্লেব্যাক + ভিডিও এর লিস্ট + আকাউন্ট + সার্ভার পাছন্দ করুন + আপনি কি এই সার্ভার রিমুভ করতে চান সার্ভার বই থেকে\? + সার্ভার রিমুভ করুন + এড্রেস বই + যোগ + পাসওয়ার্ড + ইউজারনেম + সার্চ + সার্ভার ইউআরএল + লেবেল + সাহায্য ও মতামত + লগ আউট + সঠিক ইউ আর এল দরকার + সার্ভার লেবেল দরকার + সার্ভার বই খালি আছে + লগইন সফল হয় নি! + লগইন সফল হয়েছে + বাংলা (বাংলাদেশ) + আপনি কি পুরোপুরি সার্চ ইতিহাস মুছে ফেলতে চান\? + সার্চ ইতিহাস মুছে ফেলুন + চালু ভিডিও কি করবে যখন পেছনে যাবে + অ্যান্ড্রয়েড সেটিং এ পিকচার ইন পিকচার পারমিশন বন্ধ আছে এই আয়াপ এ + অ্যান্ড্রয়েড ভার্সন ভাসমান ভিডিও সাপোর্ট করে + ভাসমান উইন্ডো তে ভিডিও চালু রাখুন + সব প্লেব্যাক বন্ধ করুন + ভাষা পছন্দ করুন অ্যাপ্লিকেশান এর জন্য। রিস্টার্ট করুন পরিবর্তন দেখার জন্য। + অ্যাপ্লিকেশান এর ভাষা + ভিডিও চলার সময় ব্যাকগ্রাউন্ড প্লে পজ হবে ব্যাক বাটন প্রেস করলে। + ব্যাক বাটন এ পজ \ No newline at end of file From 15ce004b261c1f69b68baa44f596331b1e253069 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sat, 4 Jul 2020 17:01:49 +0200 Subject: [PATCH 006/198] Fixed https://github.com/sschueller/peertube-android/issues/194 with new Lib. --- app/build.gradle | 3 +++ .../peertube/helper/MetaDataHelper.java | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index dd038df..0a32a8e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -62,6 +62,9 @@ android { implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$libVersions.exoplayer" implementation "com.google.android.exoplayer:extension-mediasession:$libVersions.exoplayer" + // date formatter + implementation 'org.ocpsoft.prettytime:prettytime:4.0.4.Final' + // testing testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' diff --git a/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java b/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java index 84e9de9..fa7390f 100644 --- a/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java +++ b/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java @@ -18,17 +18,28 @@ package net.schueller.peertube.helper; import android.content.Context; + import android.text.format.DateUtils; + import net.schueller.peertube.R; -import java.time.Duration; -import java.time.Period; +import org.ocpsoft.prettytime.PrettyTime; + import java.util.Date; +import java.util.Locale; + public class MetaDataHelper { + public static String getMetaString(Date getCreatedAt, Integer viewCount, Context context) { - return (DateUtils.getRelativeTimeSpanString(context,getCreatedAt.getTime(),false).toString() + + + // Compatible with SDK 21+ + String currentLanguage = Locale.getDefault().getDisplayLanguage(); + PrettyTime p = new PrettyTime(currentLanguage); + String relativeTime = p.format(new Date(getCreatedAt.getTime())); + + return (relativeTime + context.getResources().getString(R.string.meta_data_seperator) + viewCount + context.getResources().getString(R.string.meta_data_views)); } From 4f1a6fd97ccc0c3b96acfdadb2f43e24255b0e3f Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 Jul 2020 17:26:01 +0200 Subject: [PATCH 007/198] Added appbar at the top of the SettingsActivity --- .../peertube/activity/SettingsActivity.java | 13 +++++++++++++ app/src/main/res/layout/activity_settings.xml | 17 ++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java b/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java index 52db457..38126d2 100644 --- a/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java @@ -38,12 +38,25 @@ public class SettingsActivity extends CommonActivity { .beginTransaction() .replace(R.id.settings, new SettingsFragment()) .commit(); + + // Attaching the layout to the toolbar object + Toolbar toolbar = findViewById(R.id.tool_bar_settings); + // Setting toolbar as the ActionBar with setSupportActionBar() call + setSupportActionBar(toolbar); + ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setHomeAsUpIndicator(R.drawable.ic_baseline_close_24); } } + @Override + public boolean onSupportNavigateUp() { + finish(); // close this activity as oppose to navigating up + return false; + } + public static class SettingsFragment extends PreferenceFragmentCompat { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index de6591a..4fb6dcc 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1,6 +1,21 @@ + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + Date: Sat, 4 Jul 2020 20:46:32 +0200 Subject: [PATCH 008/198] Added more fields to server list --- app/build.gradle | 3 + .../peertube/adapter/ChannelAdapter.java | 2 +- .../peertube/adapter/ServerAdapter.java | 58 ++++++++++++------ .../peertube/adapter/VideoAdapter.java | 2 +- .../fragment/VideoMetaDataFragment.java | 2 +- .../net/schueller/peertube/model/Server.java | 59 ++++++++++++++++++- .../ic_baseline_remove_red_eye_24.xml | 10 ++++ .../main/res/layout/fragment_video_meta.xml | 6 +- app/src/main/res/layout/row_account_about.xml | 6 +- .../main/res/layout/row_account_channels.xml | 6 +- app/src/main/res/layout/row_account_video.xml | 6 +- app/src/main/res/layout/row_server.xml | 48 ++++++++++++--- app/src/main/res/layout/row_video.xml | 6 +- app/src/main/res/values/strings.xml | 4 ++ 14 files changed, 172 insertions(+), 46 deletions(-) create mode 100644 app/src/main/res/drawable/ic_baseline_remove_red_eye_24.xml diff --git a/app/build.gradle b/app/build.gradle index 0a32a8e..e4b5736 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,6 +65,9 @@ android { // date formatter implementation 'org.ocpsoft.prettytime:prettytime:4.0.4.Final' + // Version comparison + implementation 'org.apache.maven:maven-artifact:3.0.3' + // testing testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' 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 ed4f2ea..4fbbe21 100644 --- a/app/src/main/java/net/schueller/peertube/adapter/ChannelAdapter.java +++ b/app/src/main/java/net/schueller/peertube/adapter/ChannelAdapter.java @@ -160,7 +160,7 @@ public class ChannelAdapter extends RecyclerView.Adapter= 0) { + // show NSFW Icon + if (serverList.get(position).getNSFW()) { + holder.isNSFW.setVisibility(View.VISIBLE); + } + } + + + // select server holder.itemView.setOnClickListener(v -> { -// SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(activity); -// SharedPreferences.Editor editor = sharedPref.edit(); - String serverUrl = APIUrlHelper.cleanServerUrl(serverList.get(position).getHost()); -// editor.putString("pref_api_base", serverUrl); -// editor.apply(); -// -// - Toast.makeText(activity, activity.getString(R.string.server_selection_set_server, serverUrl), Toast.LENGTH_LONG).show(); Intent intent = new Intent(); @@ -138,17 +156,19 @@ public class ServerAdapter extends RecyclerView.Adapter languages; + private Boolean autoBlacklistUserVideosEnabled; + private String defaultNSFWPolicy; + private Boolean isNSFW; private Integer totalUsers; private Integer totalVideos; private Integer totalLocalVideos; private Integer totalInstanceFollowers; private Integer totalInstanceFollowing; - private Boolean supportsIPv6; private String country; - private Integer health; + private Date createdAt; public Integer getId() { return id; @@ -93,6 +100,46 @@ public class Server { this.userVideoQuota = userVideoQuota; } + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public ArrayList getLanguages() { + return languages; + } + + public void setLanguages(ArrayList languages) { + this.languages = languages; + } + + public Boolean getAutoBlacklistUserVideosEnabled() { + return autoBlacklistUserVideosEnabled; + } + + public void setAutoBlacklistUserVideosEnabled(Boolean autoBlacklistUserVideosEnabled) { + this.autoBlacklistUserVideosEnabled = autoBlacklistUserVideosEnabled; + } + + public String getDefaultNSFWPolicy() { + return defaultNSFWPolicy; + } + + public void setDefaultNSFWPolicy(String defaultNSFWPolicy) { + this.defaultNSFWPolicy = defaultNSFWPolicy; + } + + public Boolean getNSFW() { + return isNSFW; + } + + public void setNSFW(Boolean NSFW) { + isNSFW = NSFW; + } + public Integer getTotalUsers() { return totalUsers; } @@ -156,4 +203,12 @@ public class Server { public void setHealth(Integer health) { this.health = health; } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_baseline_remove_red_eye_24.xml b/app/src/main/res/drawable/ic_baseline_remove_red_eye_24.xml new file mode 100644 index 0000000..a3e222a --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_remove_red_eye_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_video_meta.xml b/app/src/main/res/layout/fragment_video_meta.xml index 1db093d..f734fe4 100644 --- a/app/src/main/res/layout/fragment_video_meta.xml +++ b/app/src/main/res/layout/fragment_video_meta.xml @@ -16,7 +16,7 @@ android:paddingEnd="12dp" /> diff --git a/app/src/main/res/layout/row_account_about.xml b/app/src/main/res/layout/row_account_about.xml index a02de1c..cb86831 100644 --- a/app/src/main/res/layout/row_account_about.xml +++ b/app/src/main/res/layout/row_account_about.xml @@ -50,7 +50,7 @@ android:paddingEnd="12dp" /> + + - + android:orientation="vertical"> + + + + + + + + + + + + diff --git a/app/src/main/res/layout/row_video.xml b/app/src/main/res/layout/row_video.xml index 170c104..398db17 100644 --- a/app/src/main/res/layout/row_video.xml +++ b/app/src/main/res/layout/row_video.xml @@ -58,7 +58,7 @@ android:paddingEnd="12dp" /> About + PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular. + NSFW Instance + Videos: %s, Local Videos: %s + pref_token_access From 057c521a4af356a50eb9f4a30b6ad214a6302220 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sat, 4 Jul 2020 20:50:26 +0200 Subject: [PATCH 009/198] Fix merge --- app/src/main/res/values-fr/strings.xml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 09393f8..d1dab69 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -327,24 +327,9 @@ Mettre la lecture d\'arrière-plan en pause en appuyant sur la touche de retour pendant la lecture de la vidéo. Pause sur le bouton retour Apparence - À propos - Lecture vidéo - Liste des vidéos SettingsActivity2 - Compte - Sélectionner un serveur - Êtes-vous sûr de vouloir supprimer ce serveur du carnet d\'adresses \? - Supprimer le serveur Bengalais (Bangladesh) - Comment une vidéo en cours de lecture réagit lorsqu\'elle passe en arrière-plan - La permission \"Image dans l\'image\" est désactivée pour cette application dans les paramètres Android - La version Android ne prend pas en charge la vidéo flottante - Configuration de la lecture en arrière-plan - Continuer la lecture de la vidéo dans une fenêtre flottante - Arrêter toutes les lectures - Continuer comme un flux audio d\'arrière plan À propos - Apparence Compte Paramètres de lecture en fond Votre version Android ne supporte pas la lecture de vidéos dans une fenêtre flottante From 1d2035e4f805d434af3adebd173fb6207179a8ff Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sat, 4 Jul 2020 20:54:09 +0200 Subject: [PATCH 010/198] Version 1.0.42 --- CHANGELOG.md | 8 ++++++++ app/build.gradle | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f57e087..5e4f090 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +### Version 1.0.42 Tag: v1.0.42 (2020-07-04) + * Added appbar at the top of the SettingsActivity (@Poslovitch) + * Improved and added some French translations (@Poslovitch) + * Removed translations for untranslatable strings (@Poslovitch) + * Add stop button to expanded notification, and stop and switch to audio in video window (@dhk2) + * More data in Server search + * VideoList timestamp fix + ### Version 1.0.41 Tag: v1.0.41 (2020-06-28) * Floating window player controls fix (@dhk2) * Updated app icons diff --git a/app/build.gradle b/app/build.gradle index e4b5736..b3182c2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "net.schueller.peertube" minSdkVersion 21 targetSdkVersion 29 - versionCode 1041 - versionName "1.0.41" + versionCode 1042 + versionName "1.0.42" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ext { libVersions = [ From 9f892a506589d7124ceded83e7719515743abb7f Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sat, 4 Jul 2020 20:57:35 +0200 Subject: [PATCH 011/198] Lib version bump --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index b3182c2..701767c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -66,7 +66,7 @@ android { implementation 'org.ocpsoft.prettytime:prettytime:4.0.4.Final' // Version comparison - implementation 'org.apache.maven:maven-artifact:3.0.3' + implementation 'org.apache.maven:maven-artifact:3.5.0' // testing testImplementation 'junit:junit:4.12' From 58c338880a53b289298ea6e08235f2b7c155ab85 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 Jul 2020 21:38:29 +0200 Subject: [PATCH 012/198] Removed unused import in SettingsActivity.java --- .../java/net/schueller/peertube/activity/SettingsActivity.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java b/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java index 38126d2..6f559b2 100644 --- a/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java @@ -25,8 +25,6 @@ import androidx.preference.PreferenceFragmentCompat; import net.schueller.peertube.R; -import java.util.Objects; - public class SettingsActivity extends CommonActivity { @Override From 12e4c7fa35ef2b25549544168efae6c8d9ef7cd0 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 Jul 2020 21:41:24 +0200 Subject: [PATCH 013/198] Made the preferences not retain the margin reserved to icons in SettingsActivity Android reserves some space next to a preference to let developers put an icon there. As there aren't any icons, I added app:iconSpaceReserved="false" to all the preferences in order to "remove" this useless blank space. --- app/src/main/res/xml/root_preferences.xml | 38 ++++++++++++++--------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index e60c6cf..e4ece20 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -1,6 +1,6 @@ - + + app:title="@string/pref_language_app" + app:iconSpaceReserved="false"/> + app:title="@string/pref_title_app_theme" + app:iconSpaceReserved="false"/> + app:title="@string/pref_title_dark_mode" + app:iconSpaceReserved="false"/> - + + app:title="@string/pref_title_show_nsfw" + app:iconSpaceReserved="false"/> + app:title="@string/pref_language" + app:iconSpaceReserved="false"/> - + + app:title="@string/pref_title_back_pause" + app:iconSpaceReserved="false"/> + app:title="@string/pref_background_behavior" + app:iconSpaceReserved="false"/> + app:title="@string/pref_title_torrent_player" + app:iconSpaceReserved="false"/> - + + app:title="@string/pref_title_version" + app:iconSpaceReserved="false"/> + app:title="@string/pref_title_license" + app:iconSpaceReserved="false"/> From 8d7063ee78e46264d8294a7ffcd8c020b5a3ea7d Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 Jul 2020 22:30:00 +0200 Subject: [PATCH 014/198] Added VideoPlayerService#getPlayBackSpeed --- .../schueller/peertube/service/VideoPlayerService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java index d3aa9a8..b01ab4d 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -178,11 +178,18 @@ public class VideoPlayerService extends Service { //Playback speed control public void setPlayBackSpeed(float speed) { - Log.v(TAG, "setPlayBackSpeed..."); player.setPlaybackParameters(new PlaybackParameters(speed)); } + /** + * Returns the current playback speed of the player. + * @return the current playback speed of the player. + */ + public float getPlayBackSpeed() { + return player.getPlaybackParameters().speed; + } + public void playVideo() { Context context = this; From 70593c17ee201b6936f6aeb77d172d4b5b4eaeae Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 Jul 2020 22:30:58 +0200 Subject: [PATCH 015/198] Added preview of the current playback speed and video quality in the VideoOptionsFragment --- .../peertube/fragment/VideoOptionsFragment.java | 17 +++++++++++++++-- app/src/main/res/values-ar/strings.xml | 6 +++--- app/src/main/res/values-bn/strings.xml | 4 ++-- app/src/main/res/values-de/strings.xml | 4 ++-- app/src/main/res/values-es/strings.xml | 4 ++-- app/src/main/res/values-fi/strings.xml | 4 ++-- app/src/main/res/values-fr/strings.xml | 4 ++-- app/src/main/res/values-gd/strings.xml | 4 ++-- app/src/main/res/values-it/strings.xml | 4 ++-- app/src/main/res/values-ja/strings.xml | 4 ++-- app/src/main/res/values-nb-rNO/strings.xml | 4 ++-- app/src/main/res/values-nl/strings.xml | 4 ++-- app/src/main/res/values-pl/strings.xml | 4 ++-- app/src/main/res/values-ru/strings.xml | 4 ++-- app/src/main/res/values-sv/strings.xml | 4 ++-- app/src/main/res/values-tr/strings.xml | 4 ++-- app/src/main/res/values-zh-rCN/strings.xml | 4 ++-- app/src/main/res/values-zh-rTW/strings.xml | 4 ++-- app/src/main/res/values/strings.xml | 4 ++-- 19 files changed, 52 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java index 212c2d2..01da654 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java @@ -18,7 +18,9 @@ package net.schueller.peertube.fragment; import android.annotation.SuppressLint; +import android.content.SharedPreferences; import android.os.Bundle; +import android.preference.PreferenceManager; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -65,7 +67,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { LinearLayout menuRow = (LinearLayout) inflater.inflate(R.layout.row_popup_menu, null); TextView iconView = menuRow.findViewById(R.id.video_quality_icon); TextView textView = menuRow.findViewById(R.id.video_quality_text); - textView.setText(getString(R.string.menu_video_options_playback_speed)); + textView.setText(String.format(getString(R.string.menu_video_options_playback_speed), videoPlayerService.getPlayBackSpeed())); iconView.setText(R.string.video_option_speed_icon); new Iconics.IconicsBuilder().ctx(getContext()).on(iconView).build(); textView.setOnClickListener(view1 -> { @@ -80,7 +82,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { LinearLayout menuRow2 = (LinearLayout) inflater.inflate(R.layout.row_popup_menu, null); TextView iconView2 = menuRow2.findViewById(R.id.video_quality_icon); TextView textView2 = menuRow2.findViewById(R.id.video_quality_text); - textView2.setText(getString(R.string.menu_video_options_quality)); + textView2.setText(String.format(getString(R.string.menu_video_options_quality), getCurrentVideoQuality(files))); iconView2.setText(R.string.video_option_quality_icon); new Iconics.IconicsBuilder().ctx(getContext()).on(iconView2).build(); textView2.setOnClickListener(view1 -> { @@ -95,4 +97,15 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { } + private String getCurrentVideoQuality(ArrayList files) { + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext()); + Integer videoQuality = sharedPref.getInt("pref_quality", 0); + + for (File file : files) { + if (videoQuality.equals(file.getResolution().getId())) { + return file.getResolution().getLabel(); + } + } + return "Auto"; + } } \ No newline at end of file diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 571c662..fbb0413 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -143,9 +143,9 @@ الرخصة اللغة العلامات - سرعة التشغيل - الجودة - الفيديو + سرعة التشغيل + (%s) الجودة + الفيديو (s%) القنوات حول الحساب: diff --git a/app/src/main/res/values-bn/strings.xml b/app/src/main/res/values-bn/strings.xml index 0420e84..5fa6e20 100644 --- a/app/src/main/res/values-bn/strings.xml +++ b/app/src/main/res/values-bn/strings.xml @@ -285,8 +285,8 @@ গাঢ় বেগুনি অ্যাকাউন্ট সাম্প্রতিক - প্লেব্যাক এর গতি - কোয়ালিটি + প্লেব্যাক এর গতি (%s) + কোয়ালিটি (%s) ভিডিও চ্যানেলগুলি সম্পর্কিত diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index aae549c..8171a43 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -276,8 +276,8 @@ Lizenz Sprache Tags - Wiedergabegeschwindigkeit - Qualität + Wiedergabegeschwindigkeit (%s) + Qualität (%s) Videos Kanäle Über diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 8c61319..c34ccb4 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -96,8 +96,8 @@ Licencia Idioma Etiquetas - Velocidad de reproducción - Calidad + Velocidad de reproducción (%s) + Calidad (%s) Vídeos Canales Acerca de diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 78b7b91..8071156 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -103,7 +103,7 @@ maori oriya (makrokieli) bislama - Laatu + Laatu (%s) Jotain meni pieleen, yritä myöhemmin! bulgaria uzbekki @@ -204,7 +204,7 @@ navajo kanuri sunda - Toistonopeus + Toistonopeus (%s) sichuanin-yi Punainen Videon esikatselukuva diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index d1dab69..a39fbef 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -99,8 +99,8 @@ Licence Langue Étiquettes - Vitesse de lecture - Qualité + Vitesse de lecture (%s) + Qualité (%s) Vidéos Chaînes À propos diff --git a/app/src/main/res/values-gd/strings.xml b/app/src/main/res/values-gd/strings.xml index d338263..69b4a36 100644 --- a/app/src/main/res/values-gd/strings.xml +++ b/app/src/main/res/values-gd/strings.xml @@ -285,8 +285,8 @@ Ceadachas Cànan Tagaichean - Luaths na cluiche - Càileachd + Luaths na cluiche (%s) + Càileachd (%s) Videothan Seanailean Mu dhèidhinn diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 9f0d2e8..7c482cf 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -286,8 +286,8 @@ Licenza Lingua Parole chiave - Velocità di riproduzione - Qualità + Velocità di riproduzione (%s) + Qualità (%s) Video Canali A proposito diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index c9616a4..f993ef9 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -88,8 +88,8 @@ ラインセンス 言語 タグ - 再生速度 - クオリティ + 再生速度 (%s) + クオリティ(%s) ビデオ チャンネル 情報 diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index abfcf6f..8288fd7 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -51,8 +51,8 @@ Lisens Språk Etiketter - Avspillingshastighet - Kvalitet + Avspillingshastighet (%s) + Kvalitet (%s) Videoer Kanaler Om diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 591194e..97f079d 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -275,8 +275,8 @@ Licentie Taal Labels - Afspeelsnelheid - Kwaliteit + Afspeelsnelheid (%s) + Kwaliteit (%s) Video\'s Kanalen Over diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 9367e80..3cc2890 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -48,8 +48,8 @@ Konto: Kanały Filmy - Jakość - Prędkość odtwarzania + Jakość (%s) + Prędkość odtwarzania (%s) Znaczniki Język Licencja diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 2807285..719be8e 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -277,8 +277,8 @@ Лицензия Язык Теги - Скорость воспроизведения - Качество + Скорость воспроизведения (%s) + Качество (%s) Описание: Что-то пошло не так, пожалуйста, попробуйте позже! Выберите сервер diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 6a7f958..f3989a9 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -272,8 +272,8 @@ Licens Språk Taggar - Uppspelningshastighet - Kvalitet + Uppspelningshastighet (%s) + Kvalitet (%s) Videor Kanaler Om diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index dcb7795..77350d6 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -291,8 +291,8 @@ Lisans Dil Etiketler - Oynatma hızı - Kalite + Oynatma hızı (%s) + Kalite (%s) Hesap Yeniler diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 91e491e..e7835eb 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -112,8 +112,8 @@ 类别 许可 标签 - 播放速度 - 画质 + 播放速度 (%s) + 画质 (%s) 视频 频道 关于 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 039b46c..b8c74d4 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -279,8 +279,8 @@ 授權條款 語言 標籤 - 播放速度 - 畫質 + 播放速度 (%s) + 畫質 (%s) 影片 頻道 關於 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 543c2a3..4bee5e8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -324,8 +324,8 @@ License Language Tags - Playback speed - Quality + Playback speed (%s) + Quality (%s) Videos Channels About From 3a29bf5985278de6186d2f476879a55925d768bd Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sat, 4 Jul 2020 22:36:17 +0200 Subject: [PATCH 016/198] fix https://github.com/sschueller/peertube-android/issues/202 --- CHANGELOG.md | 3 +++ app/build.gradle | 4 ++-- .../schueller/peertube/activity/VideoPlayActivity.java | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e4f090..f6e2563 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### Version 1.0.43 Tag: v1.0.43 (2020-07-04) + * Fix back button issue + ### Version 1.0.42 Tag: v1.0.42 (2020-07-04) * Added appbar at the top of the SettingsActivity (@Poslovitch) * Improved and added some French translations (@Poslovitch) diff --git a/app/build.gradle b/app/build.gradle index 701767c..0751f3e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "net.schueller.peertube" minSdkVersion 21 targetSdkVersion 29 - versionCode 1042 - versionName "1.0.42" + versionCode 1043 + versionName "1.0.43" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ext { libVersions = [ diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index aa33eb1..f241d8b 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -415,6 +415,10 @@ public class VideoPlayActivity extends AppCompatActivity { } String backgroundBehavior = sharedPref.getString("pref_background_behavior","backgroundStop"); + + + // Log.v(TAG,"backgroundBehavior: " + backgroundBehavior); + switch (backgroundBehavior){ case "backgroundStop": Log.v(TAG,"stop the video"); @@ -440,6 +444,11 @@ public class VideoPlayActivity extends AppCompatActivity { super.onBackPressed(); } break; + default: + // Deal with bad entries from older version + Log.v(TAG,"No setting, fallback"); + super.onBackPressed(); + break; } Log.v(TAG, "onBackPressed()..."); } From fd3a7c87d1f9c2181876a88a5d35b540b4ef07b1 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 Jul 2020 22:46:52 +0200 Subject: [PATCH 017/198] Fixed typo in ar strings.xml --- app/src/main/res/values-ar/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index fbb0413..cf2e631 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -143,9 +143,9 @@ الرخصة اللغة العلامات - سرعة التشغيل + سرعة التشغيل (s%) (%s) الجودة - الفيديو (s%) + الفيديو القنوات حول الحساب: From d631193311d1d56befaf26555a2f4fea1eb6628d Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sun, 5 Jul 2020 09:38:03 +0200 Subject: [PATCH 018/198] Made the "Automated" video quality translatable --- .../peertube/fragment/VideoMenuQualityFragment.java | 5 +++-- .../schueller/peertube/fragment/VideoOptionsFragment.java | 5 +++-- app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoMenuQualityFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoMenuQualityFragment.java index 45420d9..da55956 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoMenuQualityFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoMenuQualityFragment.java @@ -17,6 +17,7 @@ */ package net.schueller.peertube.fragment; +import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; @@ -44,7 +45,7 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment { public static final String TAG = "VideoMenuQuality"; private static File autoQualityFile; - public static VideoMenuQualityFragment newInstance(ArrayList files) { + public static VideoMenuQualityFragment newInstance(Context context, ArrayList files) { mFiles = files; @@ -53,7 +54,7 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment { autoQualityFile = new File(); Resolution autoQualityResolution = new Resolution(); autoQualityResolution.setId(0); - autoQualityResolution.setLabel("Auto"); + autoQualityResolution.setLabel(context.getString(R.string.menu_video_options_quality_automated)); autoQualityFile.setId(0); autoQualityFile.setResolution(autoQualityResolution); } diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java index 01da654..f27080c 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java @@ -87,7 +87,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { new Iconics.IconicsBuilder().ctx(getContext()).on(iconView2).build(); textView2.setOnClickListener(view1 -> { VideoMenuQualityFragment videoMenuQualityFragment = - VideoMenuQualityFragment.newInstance(files); + VideoMenuQualityFragment.newInstance(getContext(), files); videoMenuQualityFragment.show(getActivity().getSupportFragmentManager(), videoMenuQualityFragment.TAG); }); @@ -106,6 +106,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { return file.getResolution().getLabel(); } } - return "Auto"; + // Returning Automated as a placeholder + return getString(R.string.menu_video_options_quality_automated); } } \ 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 a39fbef..52397c7 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -343,4 +343,5 @@ Sélectionner un serveur Retirer un serveur Voulez-vous vraiment retirer ce serveur de votre carnet d\'adresses ? + Automatique \ 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 4bee5e8..f000c8c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -384,6 +384,7 @@ pref_token_type pref_auth_username pref_auth_password + Automated \ No newline at end of file From 9a91c2140adb7bf3c6f3263675ebd9ddadccc9a9 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sun, 5 Jul 2020 11:07:35 +0200 Subject: [PATCH 019/198] Made use of existing strings for the video speed display --- .../peertube/fragment/VideoOptionsFragment.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java index f27080c..08c54c6 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java @@ -37,6 +37,7 @@ import net.schueller.peertube.service.VideoPlayerService; import java.util.ArrayList; import androidx.annotation.Nullable; +import androidx.annotation.StringRes; public class VideoOptionsFragment extends BottomSheetDialogFragment { @@ -67,7 +68,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { LinearLayout menuRow = (LinearLayout) inflater.inflate(R.layout.row_popup_menu, null); TextView iconView = menuRow.findViewById(R.id.video_quality_icon); TextView textView = menuRow.findViewById(R.id.video_quality_text); - textView.setText(String.format(getString(R.string.menu_video_options_playback_speed), videoPlayerService.getPlayBackSpeed())); + textView.setText(String.format(getString(R.string.menu_video_options_playback_speed), getCurrentVideoPlaybackSpeedString(videoPlayerService.getPlayBackSpeed()))); iconView.setText(R.string.video_option_speed_icon); new Iconics.IconicsBuilder().ctx(getContext()).on(iconView).build(); textView.setOnClickListener(view1 -> { @@ -109,4 +110,14 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { // Returning Automated as a placeholder return getString(R.string.menu_video_options_quality_automated); } + + private String getCurrentVideoPlaybackSpeedString(float playbackSpeed) { + String speed = String.valueOf(playbackSpeed); + // Remove all non-digit characters from the string + speed = speed.replaceAll("[^0-9]", ""); + + // Dynamically get the localized string corresponding to the speed + @StringRes int stringId = getResources().getIdentifier("video_speed_" + speed, "string", videoPlayerService.getPackageName()); + return getString(stringId); + } } \ No newline at end of file From b2a8cf857da14f92df726c37468b921af65feca1 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sun, 5 Jul 2020 11:07:57 +0200 Subject: [PATCH 020/198] Removed unusued imports in VideoOptionsFragment.java --- .../net/schueller/peertube/fragment/VideoOptionsFragment.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java index 08c54c6..2e9c3b4 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java @@ -17,11 +17,9 @@ */ package net.schueller.peertube.fragment; -import android.annotation.SuppressLint; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; From 9609447aaef02456f314c18bd7cd52d4d5d70764 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sun, 5 Jul 2020 11:52:40 +0200 Subject: [PATCH 021/198] Automated code cleanup in VideoPlayActivity Removed unused imports, redundancy, useless checks ; code formatting --- .../peertube/activity/VideoPlayActivity.java | 71 ++++++------------- 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index f241d8b..7df9ca5 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -56,9 +56,9 @@ import net.schueller.peertube.service.VideoPlayerService; import java.util.ArrayList; -import java.util.Objects; import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; //import static net.schueller.peertube.helper.Constants.BACKGROUND_PLAY_PREF_KEY; @@ -119,8 +119,8 @@ public class VideoPlayActivity extends AppCompatActivity { .setActions(actions) .build(); setPictureInPictureParams(params); - } + public void changedToPipMode() { FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); @@ -164,6 +164,7 @@ public class VideoPlayActivity extends AppCompatActivity { floatMode=true; videoPlayerFragment.showControls(false); } + public void changedToNormalMode(){ FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); @@ -175,6 +176,7 @@ public class VideoPlayActivity extends AppCompatActivity { Log.v(TAG,"switched to normal"); floatMode=false; } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -226,7 +228,6 @@ public class VideoPlayActivity extends AppCompatActivity { assert videoPlayerFragment != null; String videoUuid = intent.getStringExtra(VideoListActivity.EXTRA_VIDEOID); Log.v(TAG, "new intent click: " + videoUuid +" is trying to replace: "+videoPlayerFragment.getVideoUuid()); - assert videoPlayerFragment != null; String playingVideo = videoPlayerFragment.getVideoUuid(); if (TextUtils.isEmpty(playingVideo)){ @@ -245,12 +246,10 @@ public class VideoPlayActivity extends AppCompatActivity { if (orientation == Configuration.ORIENTATION_LANDSCAPE) { setOrientation(true); } - } @Override public void onConfigurationChanged(Configuration newConfig) { - Log.v(TAG, "onConfigurationChanged()..."); super.onConfigurationChanged(newConfig); @@ -263,58 +262,43 @@ public class VideoPlayActivity extends AppCompatActivity { } } - - private void setOrientation(Boolean isLandscape) { - FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); VideoMetaDataFragment videoMetaFragment = (VideoMetaDataFragment) fragmentManager.findFragmentById(R.id.video_meta_data_fragment); - if (isLandscape) { - assert videoPlayerFragment != null; - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) Objects.requireNonNull(videoPlayerFragment.getView()).getLayoutParams(); - params.width = FrameLayout.LayoutParams.MATCH_PARENT; - params.height = FrameLayout.LayoutParams.MATCH_PARENT; - videoPlayerFragment.getView().setLayoutParams(params); + assert videoPlayerFragment != null; + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) videoPlayerFragment.requireView().getLayoutParams(); + params.width = FrameLayout.LayoutParams.MATCH_PARENT; + params.height = isLandscape ? FrameLayout.LayoutParams.MATCH_PARENT : (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics()); + videoPlayerFragment.getView().setLayoutParams(params); - if (videoMetaFragment != null) { - fragmentManager.beginTransaction() - .setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out) - .hide(videoMetaFragment) - .commit(); + if (videoMetaFragment != null) { + FragmentTransaction transaction = fragmentManager.beginTransaction() + .setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); + + if (isLandscape) { + transaction.hide(videoMetaFragment); + } else { + transaction.show(videoMetaFragment); } - videoPlayerFragment.setIsFullscreen(true); - } else { - assert videoPlayerFragment != null; - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) Objects.requireNonNull(videoPlayerFragment.getView()).getLayoutParams(); - params.width = FrameLayout.LayoutParams.MATCH_PARENT; - params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics()); - videoPlayerFragment.getView().setLayoutParams(params); - - if (videoMetaFragment != null) { - fragmentManager.beginTransaction() - .setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out) - .show(videoMetaFragment) - .commit(); - } - videoPlayerFragment.setIsFullscreen(false); + transaction.commit(); } + videoPlayerFragment.setIsFullscreen(isLandscape); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } @Override protected void onDestroy() { - VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); assert videoPlayerFragment != null; videoPlayerFragment.destroyVideo(); - super.onDestroy(); Log.v(TAG, "onDestroy..."); } @@ -335,15 +319,6 @@ public class VideoPlayActivity extends AppCompatActivity { protected void onStop() { super.onStop(); -// SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); -// -// Log.v(TAG, "" + sharedPref.getBoolean(BACKGROUND_PLAY_PREF_KEY, false)); -// -// if (!sharedPref.getBoolean(BACKGROUND_PLAY_PREF_KEY, false)) { -// Log.v(TAG, "BACKGROUND_PLAY_PREF_KEY..."); -// stopService(new Intent(this, VideoPlayerService.class)); -// } - VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); @@ -366,7 +341,6 @@ public class VideoPlayActivity extends AppCompatActivity { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); - VideoMetaDataFragment videoMetaFragment = (VideoMetaDataFragment) fragmentManager.findFragmentById(R.id.video_meta_data_fragment); String backgroundBehavior = sharedPref.getString("pref_background_behavior","backgroundStop"); switch(backgroundBehavior){ @@ -397,7 +371,6 @@ public class VideoPlayActivity extends AppCompatActivity { // @RequiresApi(api = Build.VERSION_CODES.O) @SuppressLint("NewApi") public void onBackPressed() { - SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); @@ -410,7 +383,6 @@ public class VideoPlayActivity extends AppCompatActivity { } if (sharedPref.getBoolean("pref_back_pause", true)) { - assert videoPlayerFragment != null; videoPlayerFragment.pauseVideo(); } @@ -452,6 +424,7 @@ public class VideoPlayActivity extends AppCompatActivity { } Log.v(TAG, "onBackPressed()..."); } + public boolean canEnterPipMode(Context context) { Log.v(TAG,"api version "+Build.VERSION.SDK_INT); if (Build.VERSION.SDK_INT<28){ @@ -460,6 +433,7 @@ public class VideoPlayActivity extends AppCompatActivity { AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); return (AppOpsManager.MODE_ALLOWED== appOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, android.os.Process.myUid(), context.getPackageName())); } + @RequiresApi(api = Build.VERSION_CODES.O) public void enterPipMode() { Rational rational = new Rational(239, 100); @@ -472,6 +446,7 @@ public class VideoPlayActivity extends AppCompatActivity { enterPictureInPictureMode(mParams); } + @Override public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) { FragmentManager fragmentManager = getSupportFragmentManager(); From ded16379f12c2cf11884960192a57123f399feff Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 5 Jul 2020 13:16:50 +0200 Subject: [PATCH 022/198] Code Format --- .../peertube/activity/VideoPlayActivity.java | 90 +++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 7df9ca5..e705a45 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -61,7 +61,6 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; -//import static net.schueller.peertube.helper.Constants.BACKGROUND_PLAY_PREF_KEY; import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PAUSE; import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PLAY; import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_STOP; @@ -76,6 +75,7 @@ public class VideoPlayActivity extends AppCompatActivity { private static boolean floatMode = false; private static final int REQUEST_CODE = 101; private BroadcastReceiver receiver; + //This can only be called when in entering pip mode which can't happen if the device doesn't support pip mode. @SuppressLint("NewApi") public void makePipControls() { @@ -96,15 +96,15 @@ public class VideoPlayActivity extends AppCompatActivity { remoteAction = new RemoteAction(icon, "play", "stop the media", pendingIntent); actions.add(remoteAction); - if (videoPlayerFragment.isPaused()){ - Log.e(TAG,"setting actions with play button"); + if (videoPlayerFragment.isPaused()) { + Log.e(TAG, "setting actions with play button"); actionIntent = new Intent(ACTION_PLAY); pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); icon = Icon.createWithResource(getApplicationContext(), com.google.android.exoplayer2.ui.R.drawable.exo_notification_play); remoteAction = new RemoteAction(icon, "play", "play the media", pendingIntent); actions.add(remoteAction); } else { - Log.e(TAG,"setting actions with pause button"); + Log.e(TAG, "setting actions with pause button"); actionIntent = new Intent(ACTION_PAUSE); pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); icon = Icon.createWithResource(getApplicationContext(), com.google.android.exoplayer2.ui.R.drawable.exo_notification_pause); @@ -161,11 +161,11 @@ public class VideoPlayActivity extends AppCompatActivity { registerReceiver(receiver, filter); Log.v(TAG, "switched to pip "); - floatMode=true; + floatMode = true; videoPlayerFragment.showControls(false); } - public void changedToNormalMode(){ + public void changedToNormalMode() { FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); @@ -173,8 +173,8 @@ public class VideoPlayActivity extends AppCompatActivity { if (receiver != null) { unregisterReceiver(receiver); } - Log.v(TAG,"switched to normal"); - floatMode=false; + Log.v(TAG, "switched to normal"); + floatMode = false; } @Override @@ -199,17 +199,17 @@ public class VideoPlayActivity extends AppCompatActivity { assert videoPlayerFragment != null; String playingVideo = videoPlayerFragment.getVideoUuid(); - Log.v(TAG, "oncreate click: " + videoUuid +" is trying to replace: "+playingVideo); + Log.v(TAG, "oncreate click: " + videoUuid + " is trying to replace: " + playingVideo); - if (TextUtils.isEmpty(playingVideo)){ - Log.v(TAG,"oncreate no video currently playing"); + if (TextUtils.isEmpty(playingVideo)) { + Log.v(TAG, "oncreate no video currently playing"); videoPlayerFragment.start(videoUuid); - } else if(!playingVideo.equals(videoUuid)){ - Log.v(TAG,"oncreate different video playing currently"); + } else if (!playingVideo.equals(videoUuid)) { + Log.v(TAG, "oncreate different video playing currently"); videoPlayerFragment.stopVideo(); videoPlayerFragment.start(videoUuid); } else { - Log.v(TAG,"oncreate same video playing currently"); + Log.v(TAG, "oncreate same video playing currently"); } // if we are in landscape set the video to fullscreen @@ -227,18 +227,18 @@ public class VideoPlayActivity extends AppCompatActivity { getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); assert videoPlayerFragment != null; String videoUuid = intent.getStringExtra(VideoListActivity.EXTRA_VIDEOID); - Log.v(TAG, "new intent click: " + videoUuid +" is trying to replace: "+videoPlayerFragment.getVideoUuid()); + Log.v(TAG, "new intent click: " + videoUuid + " is trying to replace: " + videoPlayerFragment.getVideoUuid()); String playingVideo = videoPlayerFragment.getVideoUuid(); - if (TextUtils.isEmpty(playingVideo)){ - Log.v(TAG,"new intent no video currently playing"); + if (TextUtils.isEmpty(playingVideo)) { + Log.v(TAG, "new intent no video currently playing"); videoPlayerFragment.start(videoUuid); - } else if(!playingVideo.equals(videoUuid)){ - Log.v(TAG,"new intent different video playing currently"); + } else if (!playingVideo.equals(videoUuid)) { + Log.v(TAG, "new intent different video playing currently"); videoPlayerFragment.stopVideo(); videoPlayerFragment.start(videoUuid); } else { - Log.v(TAG,"new intent same video playing currently"); + Log.v(TAG, "new intent same video playing currently"); } // if we are in landscape set the video to fullscreen @@ -337,25 +337,25 @@ public class VideoPlayActivity extends AppCompatActivity { @SuppressLint("NewApi") @Override - public void onUserLeaveHint () { + public void onUserLeaveHint() { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); - String backgroundBehavior = sharedPref.getString("pref_background_behavior","backgroundStop"); + String backgroundBehavior = sharedPref.getString("pref_background_behavior", "backgroundStop"); - switch(backgroundBehavior){ + switch (backgroundBehavior) { case "backgroundStop": - Log.v(TAG,"stop the video"); + Log.v(TAG, "stop the video"); videoPlayerFragment.pauseVideo(); stopService(new Intent(this, VideoPlayerService.class)); super.onBackPressed(); break; case "backgroundAudio": - Log.v(TAG,"play the Audio"); + Log.v(TAG, "play the Audio"); super.onBackPressed(); break; case "backgroundFloat": - Log.v(TAG,"play in floating video"); + Log.v(TAG, "play in floating video"); //canEnterPIPMode makes sure API level is high enough if (canEnterPipMode(this)) { Log.v(TAG, "enabling pip"); @@ -368,7 +368,7 @@ public class VideoPlayActivity extends AppCompatActivity { Log.v(TAG, "onUserLeaveHint()..."); } - // @RequiresApi(api = Build.VERSION_CODES.O) + // @RequiresApi(api = Build.VERSION_CODES.O) @SuppressLint("NewApi") public void onBackPressed() { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); @@ -376,8 +376,8 @@ public class VideoPlayActivity extends AppCompatActivity { getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); //copying Youtube behavior to have back button exit full screen. - if (videoPlayerFragment.getIsFullscreen()){ - Log.v(TAG,"exiting full screen"); + if (videoPlayerFragment.getIsFullscreen()) { + Log.v(TAG, "exiting full screen"); videoPlayerFragment.fullScreenToggle(); return; } @@ -386,24 +386,24 @@ public class VideoPlayActivity extends AppCompatActivity { videoPlayerFragment.pauseVideo(); } - String backgroundBehavior = sharedPref.getString("pref_background_behavior","backgroundStop"); + String backgroundBehavior = sharedPref.getString("pref_background_behavior", "backgroundStop"); // Log.v(TAG,"backgroundBehavior: " + backgroundBehavior); - switch (backgroundBehavior){ + switch (backgroundBehavior) { case "backgroundStop": - Log.v(TAG,"stop the video"); + Log.v(TAG, "stop the video"); videoPlayerFragment.pauseVideo(); stopService(new Intent(this, VideoPlayerService.class)); super.onBackPressed(); break; case "backgroundAudio": - Log.v(TAG,"play the Audio"); - super.onBackPressed(); - break; + Log.v(TAG, "play the Audio"); + super.onBackPressed(); + break; case "backgroundFloat": - Log.v(TAG,"play in floating video"); + Log.v(TAG, "play in floating video"); //canEnterPIPMode makes sure API level is high enough if (canEnterPipMode(this)) { Log.v(TAG, "enabling pip"); @@ -412,13 +412,13 @@ public class VideoPlayActivity extends AppCompatActivity { Intent intentSettings = new Intent(this, VideoListActivity.class); this.startActivity(intentSettings); } else { - Log.v(TAG,"Unable to enter PIP mode"); + Log.v(TAG, "Unable to enter PIP mode"); super.onBackPressed(); } break; default: // Deal with bad entries from older version - Log.v(TAG,"No setting, fallback"); + Log.v(TAG, "No setting, fallback"); super.onBackPressed(); break; } @@ -426,18 +426,18 @@ public class VideoPlayActivity extends AppCompatActivity { } public boolean canEnterPipMode(Context context) { - Log.v(TAG,"api version "+Build.VERSION.SDK_INT); - if (Build.VERSION.SDK_INT<28){ + Log.v(TAG, "api version " + Build.VERSION.SDK_INT); + if (Build.VERSION.SDK_INT < 28) { return false; } AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); - return (AppOpsManager.MODE_ALLOWED== appOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, android.os.Process.myUid(), context.getPackageName())); + return (AppOpsManager.MODE_ALLOWED == appOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, android.os.Process.myUid(), context.getPackageName())); } @RequiresApi(api = Build.VERSION_CODES.O) public void enterPipMode() { Rational rational = new Rational(239, 100); - Log.v(TAG,rational.toString()); + Log.v(TAG, rational.toString()); PictureInPictureParams mParams = new PictureInPictureParams.Builder() .setAspectRatio(rational) @@ -448,17 +448,17 @@ public class VideoPlayActivity extends AppCompatActivity { } @Override - public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) { + public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) { FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); if (isInPictureInPictureMode) { changedToPipMode(); - Log.v(TAG,"switched to pip "); + Log.v(TAG, "switched to pip "); videoPlayerFragment.useController(false); } else { changedToNormalMode(); - Log.v(TAG,"switched to normal"); + Log.v(TAG, "switched to normal"); videoPlayerFragment.useController(true); } } From a56dc559212d5c29b7becfa7f01dc4e356bc468a Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 5 Jul 2020 13:56:17 +0200 Subject: [PATCH 023/198] Code cleanup --- .../peertube/activity/VideoPlayActivity.java | 175 ++++++++++-------- .../res/values/{array.xml => constants.xml} | 9 +- 2 files changed, 108 insertions(+), 76 deletions(-) rename app/src/main/res/values/{array.xml => constants.xml} (97%) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index e705a45..e76ba92 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -36,6 +36,7 @@ import android.os.Bundle; import android.preference.PreferenceManager; +import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; @@ -72,7 +73,8 @@ public class VideoPlayActivity extends AppCompatActivity { private static final String TAG = "VideoPlayActivity"; - private static boolean floatMode = false; + static boolean floatMode = false; + private static final int REQUEST_CODE = 101; private BroadcastReceiver receiver; @@ -96,21 +98,21 @@ public class VideoPlayActivity extends AppCompatActivity { remoteAction = new RemoteAction(icon, "play", "stop the media", pendingIntent); actions.add(remoteAction); + assert videoPlayerFragment != null; if (videoPlayerFragment.isPaused()) { Log.e(TAG, "setting actions with play button"); actionIntent = new Intent(ACTION_PLAY); pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); icon = Icon.createWithResource(getApplicationContext(), com.google.android.exoplayer2.ui.R.drawable.exo_notification_play); remoteAction = new RemoteAction(icon, "play", "play the media", pendingIntent); - actions.add(remoteAction); } else { Log.e(TAG, "setting actions with pause button"); actionIntent = new Intent(ACTION_PAUSE); pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); icon = Icon.createWithResource(getApplicationContext(), com.google.android.exoplayer2.ui.R.drawable.exo_notification_pause); remoteAction = new RemoteAction(icon, "pause", "pause the media", pendingIntent); - actions.add(remoteAction); } + actions.add(remoteAction); //add custom actions to pip window @@ -125,6 +127,7 @@ public class VideoPlayActivity extends AppCompatActivity { FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); + assert videoPlayerFragment != null; videoPlayerFragment.showControls(false); //create custom actions makePipControls(); @@ -139,6 +142,7 @@ public class VideoPlayActivity extends AppCompatActivity { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); + assert action != null; if (action.equals(ACTION_PAUSE)) { videoPlayerFragment.pauseVideo(); makePipControls(); @@ -169,6 +173,7 @@ public class VideoPlayActivity extends AppCompatActivity { FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); + assert videoPlayerFragment != null; videoPlayerFragment.showControls(true); if (receiver != null) { unregisterReceiver(receiver); @@ -249,7 +254,7 @@ public class VideoPlayActivity extends AppCompatActivity { } @Override - public void onConfigurationChanged(Configuration newConfig) { + public void onConfigurationChanged(@NonNull Configuration newConfig) { Log.v(TAG, "onConfigurationChanged()..."); super.onConfigurationChanged(newConfig); @@ -271,7 +276,8 @@ public class VideoPlayActivity extends AppCompatActivity { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) videoPlayerFragment.requireView().getLayoutParams(); params.width = FrameLayout.LayoutParams.MATCH_PARENT; params.height = isLandscape ? FrameLayout.LayoutParams.MATCH_PARENT : (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics()); - videoPlayerFragment.getView().setLayoutParams(params); + + videoPlayerFragment.requireView().setLayoutParams(params); if (videoMetaFragment != null) { FragmentTransaction transaction = fragmentManager.beginTransaction() @@ -338,100 +344,117 @@ public class VideoPlayActivity extends AppCompatActivity { @SuppressLint("NewApi") @Override public void onUserLeaveHint() { + + Log.v(TAG, "onUserLeaveHint()..."); + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); - String backgroundBehavior = sharedPref.getString("pref_background_behavior", "backgroundStop"); - switch (backgroundBehavior) { - case "backgroundStop": - Log.v(TAG, "stop the video"); - videoPlayerFragment.pauseVideo(); - stopService(new Intent(this, VideoPlayerService.class)); - super.onBackPressed(); - break; - case "backgroundAudio": - Log.v(TAG, "play the Audio"); - super.onBackPressed(); - break; - case "backgroundFloat": - Log.v(TAG, "play in floating video"); - //canEnterPIPMode makes sure API level is high enough - if (canEnterPipMode(this)) { - Log.v(TAG, "enabling pip"); - enterPipMode(); - } else { - Log.v(TAG, "unable to use pip"); - } - break; + String backgroundBehavior = sharedPref.getString("pref_background_behavior", getString(R.string.pref_background_stop_key)); + + assert videoPlayerFragment != null; + assert backgroundBehavior != null; + + if (backgroundBehavior.equals(getString(R.string.pref_background_stop_key))) { + Log.v(TAG, "stop the video"); + + videoPlayerFragment.pauseVideo(); + stopService(new Intent(this, VideoPlayerService.class)); + super.onBackPressed(); + + } else if (backgroundBehavior.equals(getString(R.string.pref_background_audio_key))) { + Log.v(TAG, "play the Audio"); + super.onBackPressed(); + + } else if (backgroundBehavior.equals(getString(R.string.pref_background_float_key))) { + Log.v(TAG, "play in floating video"); + //canEnterPIPMode makes sure API level is high enough + if (canEnterPipMode(this)) { + Log.v(TAG, "enabling pip"); + enterPipMode(); + } else { + Log.v(TAG, "unable to use pip"); + } + + } else { + // Deal with bad entries from older version + Log.v(TAG, "No setting, fallback"); + super.onBackPressed(); + } - Log.v(TAG, "onUserLeaveHint()..."); + + } // @RequiresApi(api = Build.VERSION_CODES.O) @SuppressLint("NewApi") public void onBackPressed() { + + Log.v(TAG, "onBackPressed()..."); + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); - //copying Youtube behavior to have back button exit full screen. + assert videoPlayerFragment != null; + + // copying Youtube behavior to have back button exit full screen. if (videoPlayerFragment.getIsFullscreen()) { Log.v(TAG, "exiting full screen"); videoPlayerFragment.fullScreenToggle(); return; } - + // pause video if pref is enabled if (sharedPref.getBoolean("pref_back_pause", true)) { videoPlayerFragment.pauseVideo(); } - String backgroundBehavior = sharedPref.getString("pref_background_behavior", "backgroundStop"); + String backgroundBehavior = sharedPref.getString("pref_background_behavior", getString(R.string.pref_background_stop_key)); + assert backgroundBehavior != null; - // Log.v(TAG,"backgroundBehavior: " + backgroundBehavior); + if (backgroundBehavior.equals(getString(R.string.pref_background_stop_key))) { + Log.v(TAG, "stop the video"); + videoPlayerFragment.pauseVideo(); + stopService(new Intent(this, VideoPlayerService.class)); + super.onBackPressed(); - switch (backgroundBehavior) { - case "backgroundStop": - Log.v(TAG, "stop the video"); - videoPlayerFragment.pauseVideo(); - stopService(new Intent(this, VideoPlayerService.class)); + } else if (backgroundBehavior.equals(getString(R.string.pref_background_audio_key))) { + Log.v(TAG, "play the Audio"); + super.onBackPressed(); + + } else if (backgroundBehavior.equals(getString(R.string.pref_background_float_key))) { + Log.v(TAG, "play in floating video"); + //canEnterPIPMode makes sure API level is high enough + if (canEnterPipMode(this)) { + Log.v(TAG, "enabling pip"); + enterPipMode(); + //fixes problem where back press doesn't bring up video list after returning from PIP mode + Intent intentSettings = new Intent(this, VideoListActivity.class); + this.startActivity(intentSettings); + } else { + Log.v(TAG, "Unable to enter PIP mode"); super.onBackPressed(); - break; - case "backgroundAudio": - Log.v(TAG, "play the Audio"); - super.onBackPressed(); - break; - case "backgroundFloat": - Log.v(TAG, "play in floating video"); - //canEnterPIPMode makes sure API level is high enough - if (canEnterPipMode(this)) { - Log.v(TAG, "enabling pip"); - enterPipMode(); - //fixes problem where back press doesn't bring up video list after returning from PIP mode - Intent intentSettings = new Intent(this, VideoListActivity.class); - this.startActivity(intentSettings); - } else { - Log.v(TAG, "Unable to enter PIP mode"); - super.onBackPressed(); - } - break; - default: - // Deal with bad entries from older version - Log.v(TAG, "No setting, fallback"); - super.onBackPressed(); - break; + } + + } else { + // Deal with bad entries from older version + Log.v(TAG, "No setting, fallback"); + super.onBackPressed(); + } - Log.v(TAG, "onBackPressed()..."); + + } public boolean canEnterPipMode(Context context) { Log.v(TAG, "api version " + Build.VERSION.SDK_INT); - if (Build.VERSION.SDK_INT < 28) { - return false; + if (Build.VERSION.SDK_INT > 27) { + AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); + return (AppOpsManager.MODE_ALLOWED == appOpsManager.checkOp(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, android.os.Process.myUid(), context.getPackageName())); } - AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); - return (AppOpsManager.MODE_ALLOWED == appOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, android.os.Process.myUid(), context.getPackageName())); + return false; } @RequiresApi(api = Build.VERSION_CODES.O) @@ -452,14 +475,20 @@ public class VideoPlayActivity extends AppCompatActivity { FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); - if (isInPictureInPictureMode) { - changedToPipMode(); - Log.v(TAG, "switched to pip "); - videoPlayerFragment.useController(false); + if (videoPlayerFragment != null) { + + if (isInPictureInPictureMode) { + changedToPipMode(); + Log.v(TAG, "switched to pip "); + videoPlayerFragment.useController(false); + } else { + changedToNormalMode(); + Log.v(TAG, "switched to normal"); + videoPlayerFragment.useController(true); + } + } else { - changedToNormalMode(); - Log.v(TAG, "switched to normal"); - videoPlayerFragment.useController(true); + Log.e(TAG, "videoPlayerFragment is NULL"); } } diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/constants.xml similarity index 97% rename from app/src/main/res/values/array.xml rename to app/src/main/res/values/constants.xml index a74e65b..ce3bf6e 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/constants.xml @@ -1,6 +1,9 @@ + backgroundAudio + backgroundStop + backgroundFloat @string/pref_background_audio @@ -9,9 +12,9 @@ - backgroundAudio - backgroundStop - backgroundFloat + @string/pref_background_audio_key + @string/pref_background_stop_key + @string/pref_background_float_key From db560bb3405ea54f295030fa9991e2df8b70dcdf Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 5 Jul 2020 14:15:48 +0200 Subject: [PATCH 024/198] Code cleanup --- .../activity/AppCompatPreferenceActivity.java | 145 ------------------ .../peertube/activity/CommonActivity.java | 20 ++- .../activity/SelectServerActivity.java | 12 -- .../peertube/activity/VideoPlayActivity.java | 14 +- .../schueller/peertube/helper/Constants.java | 25 --- app/src/main/res/values/constants.xml | 45 +++++- app/src/main/res/values/strings.xml | 34 +--- 7 files changed, 65 insertions(+), 230 deletions(-) delete mode 100644 app/src/main/java/net/schueller/peertube/activity/AppCompatPreferenceActivity.java delete mode 100644 app/src/main/java/net/schueller/peertube/helper/Constants.java diff --git a/app/src/main/java/net/schueller/peertube/activity/AppCompatPreferenceActivity.java b/app/src/main/java/net/schueller/peertube/activity/AppCompatPreferenceActivity.java deleted file mode 100644 index 36d5fe0..0000000 --- a/app/src/main/java/net/schueller/peertube/activity/AppCompatPreferenceActivity.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2018 Stefan Schüller - * - * License: GPL-3.0+ - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.schueller.peertube.activity; - -import android.content.SharedPreferences; -import android.content.res.Configuration; -import android.os.Bundle; -import android.preference.PreferenceActivity; -import androidx.annotation.LayoutRes; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AppCompatDelegate; - -import android.preference.PreferenceManager; -import android.view.MenuInflater; -import android.view.View; -import android.view.ViewGroup; - -import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; -import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; - -/** - * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls - * to be used with AppCompat. - */ -public abstract class AppCompatPreferenceActivity extends PreferenceActivity { - - private AppCompatDelegate mDelegate; - - @Override - protected void onCreate(Bundle savedInstanceState) { - getDelegate().installViewFactory(); - getDelegate().onCreate(savedInstanceState); - super.onCreate(savedInstanceState); - - // TODO: cleanup this duplication - - // Set Night Mode - SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); - AppCompatDelegate.setDefaultNightMode(sharedPref.getBoolean("pref_dark_mode", false) ? - AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO); - - // Set theme - setTheme(getResources().getIdentifier( - sharedPref.getString(THEME_PREF_KEY, DEFAULT_THEME), - "style", - getPackageName()) - ); - } - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - super.onPostCreate(savedInstanceState); - getDelegate().onPostCreate(savedInstanceState); - } - - public ActionBar getSupportActionBar() { - return getDelegate().getSupportActionBar(); - } - -// public void setSupportActionBar(@Nullable Toolbar toolbar) { -// getDelegate().setSupportActionBar(toolbar); -// } - - @Override - public MenuInflater getMenuInflater() { - return getDelegate().getMenuInflater(); - } - - @Override - public void setContentView(@LayoutRes int layoutResID) { - getDelegate().setContentView(layoutResID); - } - - @Override - public void setContentView(View view) { - getDelegate().setContentView(view); - } - - @Override - public void setContentView(View view, ViewGroup.LayoutParams params) { - getDelegate().setContentView(view, params); - } - - @Override - public void addContentView(View view, ViewGroup.LayoutParams params) { - getDelegate().addContentView(view, params); - } - - @Override - protected void onPostResume() { - super.onPostResume(); - getDelegate().onPostResume(); - } - - @Override - protected void onTitleChanged(CharSequence title, int color) { - super.onTitleChanged(title, color); - getDelegate().setTitle(title); - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - getDelegate().onConfigurationChanged(newConfig); - } - - @Override - protected void onStop() { - super.onStop(); - getDelegate().onStop(); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - getDelegate().onDestroy(); - } - - public void invalidateOptionsMenu() { - getDelegate().invalidateOptionsMenu(); - } - - private AppCompatDelegate getDelegate() { - if (mDelegate == null) { - mDelegate = AppCompatDelegate.create(this, null); - } - return mDelegate; - } -} diff --git a/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java b/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java index a733fca..9f7ada0 100644 --- a/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java @@ -26,10 +26,9 @@ import android.preference.PreferenceManager; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; -import java.util.Locale; +import net.schueller.peertube.R; -import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; -import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; +import java.util.Locale; public class CommonActivity extends AppCompatActivity { @@ -44,18 +43,23 @@ public class CommonActivity extends AppCompatActivity { // Set theme setTheme(getResources().getIdentifier( - sharedPref.getString(THEME_PREF_KEY, DEFAULT_THEME), + sharedPref.getString( + getString(R.string.pref_theme_key), + getString(R.string.app_default_theme) + ), "style", getPackageName()) ); // Set language - String countryCode=sharedPref.getString("pref_language_app","en"); - Locale locale=new Locale(countryCode);; + String countryCode = sharedPref.getString("pref_language_app", "en"); + assert countryCode != null; + Locale locale = new Locale(countryCode); + //Neither Chinese language choice was working, found this fix on stack overflow - if(countryCode.equals("zh-rCN")) + if (countryCode.equals("zh-rCN")) locale = Locale.SIMPLIFIED_CHINESE; - if(countryCode.equals("zh-rTW")) + if (countryCode.equals("zh-rTW")) locale = Locale.TRADITIONAL_CHINESE; Locale.setDefault(locale); diff --git a/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java b/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java index a4c6186..1706108 100644 --- a/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java @@ -18,7 +18,6 @@ package net.schueller.peertube.activity; import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -27,33 +26,22 @@ import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; -import android.content.Intent; -import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceManager; import android.util.Log; -import android.util.Patterns; import android.view.View; -import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import net.schueller.peertube.R; import net.schueller.peertube.adapter.ServerAdapter; -import net.schueller.peertube.adapter.VideoAdapter; import net.schueller.peertube.helper.APIUrlHelper; import net.schueller.peertube.model.ServerList; -import net.schueller.peertube.model.VideoList; import net.schueller.peertube.network.GetServerListDataService; -import net.schueller.peertube.network.GetVideoDataService; import net.schueller.peertube.network.RetrofitInstance; import java.util.ArrayList; import java.util.Objects; -import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; -import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; - public class SelectServerActivity extends CommonActivity { private ServerAdapter serverAdapter; diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index e76ba92..9460e74 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -65,9 +65,6 @@ import androidx.fragment.app.FragmentTransaction; import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PAUSE; import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PLAY; import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_STOP; -import static net.schueller.peertube.helper.Constants.BACKGROUND_AUDIO; -import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; -import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; public class VideoPlayActivity extends AppCompatActivity { @@ -86,7 +83,7 @@ public class VideoPlayActivity extends AppCompatActivity { ArrayList actions = new ArrayList<>(); - Intent actionIntent = new Intent(BACKGROUND_AUDIO); + Intent actionIntent = new Intent(getString(R.string.app_background_audio)); PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); @SuppressLint({"NewApi", "LocalSuppress"}) Icon icon = Icon.createWithResource(getApplicationContext(), android.R.drawable.stat_sys_speakerphone); @SuppressLint({"NewApi", "LocalSuppress"}) RemoteAction remoteAction = new RemoteAction(icon, "close pip", "from pip window custom command", pendingIntent); @@ -137,7 +134,7 @@ public class VideoPlayActivity extends AppCompatActivity { filter.addAction(ACTION_STOP); filter.addAction(ACTION_PAUSE); filter.addAction(ACTION_PLAY); - filter.addAction((BACKGROUND_AUDIO)); + filter.addAction((getString(R.string.app_background_audio))); receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -152,7 +149,7 @@ public class VideoPlayActivity extends AppCompatActivity { makePipControls(); } - if (action.equals(BACKGROUND_AUDIO)) { + if (action.equals(getString(R.string.app_background_audio))) { unregisterReceiver(receiver); finish(); } @@ -189,7 +186,10 @@ public class VideoPlayActivity extends AppCompatActivity { // Set theme SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); setTheme(getResources().getIdentifier( - sharedPref.getString(THEME_PREF_KEY, DEFAULT_THEME), + sharedPref.getString( + getString(R.string.pref_theme_key), + getString(R.string.app_default_theme) + ), "style", getPackageName()) ); diff --git a/app/src/main/java/net/schueller/peertube/helper/Constants.java b/app/src/main/java/net/schueller/peertube/helper/Constants.java deleted file mode 100644 index 0e87a3f..0000000 --- a/app/src/main/java/net/schueller/peertube/helper/Constants.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2018 Stefan Schüller - * - * License: GPL-3.0+ - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package net.schueller.peertube.helper; - -public class Constants { - public static final String THEME_PREF_KEY = "pref_theme"; - public static final String DEFAULT_THEME = "AppTheme.BLUE"; - public static final String BACKGROUND_PLAY_PREF_KEY = "pref_background_play"; - public static final String BACKGROUND_AUDIO = "BACKGROUND_AUDIO"; -} diff --git a/app/src/main/res/values/constants.xml b/app/src/main/res/values/constants.xml index ce3bf6e..0cfa51f 100644 --- a/app/src/main/res/values/constants.xml +++ b/app/src/main/res/values/constants.xml @@ -1,9 +1,50 @@ + Thorium + + pref_token_access + pref_token_refresh + pref_token_expiration + pref_token_type + pref_auth_username + pref_auth_password backgroundAudio backgroundStop backgroundFloat + https://troll.tv + pref_theme + + 1.0.0-alpha.7 + + AppTheme.BLUE + BACKGROUND_AUDIO + + none + like + dislike + + {faw-play-circle} + {faw-cog} + {faw-check} + {faw-check} + {faw-expand} + {faw-compress} + {faw-ellipsis-v} + {faw-thumbs-up} + {faw-thumbs-down} + {faw-share} + {faw-download} + {faw-save} + + \@ + \u0020-\u0020 + + VideoPlayActivity + + PeerTube + + PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular. @string/pref_background_audio @@ -478,7 +519,7 @@ zh-rTW - + @string/ar @string/bn @string/bn_rBD @@ -505,7 +546,7 @@ - + Low diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f000c8c..d66a185 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,7 +1,6 @@ - Thorium - VideoPlayActivity + Settings Sign in @@ -29,9 +28,7 @@ Account - \u0020-\u0020 \u0020Views - \@ Video Thumbnail Account Avatar UrlVideoPlayActivity @@ -40,7 +37,6 @@ No Results More Share - PeerTube Invalid URL. Dark Mode @@ -56,7 +52,6 @@ Show NSFW content Language filter Select a video language, instead of showing all videos in all languages. - https://troll.tv PeerTube Server Background Playback If enabled, continues to play video in background. @@ -292,18 +287,7 @@ Normal 1.5x 2x - {faw-play-circle} - {faw-cog} - {faw-check} - {faw-check} - {faw-expand} - {faw-compress} - {faw-ellipsis-v} - {faw-thumbs-up} - {faw-thumbs-down} - {faw-share} - {faw-download} - {faw-save} + Select Server Signup Allowed: %s Yes @@ -352,10 +336,7 @@ Password Add Has Login - none - like - dislike - 1.0.0-alpha.7 + Current Server Address Book 0.75x @@ -372,18 +353,9 @@ About - PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular. NSFW Instance Videos: %s, Local Videos: %s - - - pref_token_access - pref_token_refresh - pref_token_expiration - pref_token_type - pref_auth_username - pref_auth_password Automated From 3ac28ef4d97d1bf76a6201b4777d9027a3be3d6a Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sun, 5 Jul 2020 02:17:31 +0000 Subject: [PATCH 025/198] Translated using Weblate (French) Currently translated at 100.0% (368 of 368 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/fr/ --- app/src/main/res/values-fr/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index d1dab69..97b7520 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -343,4 +343,7 @@ Sélectionner un serveur Retirer un serveur Voulez-vous vraiment retirer ce serveur de votre carnet d\'adresses ? + Instance avec du contenu adulte + Bonjour ! Fragment vide + Vidéos : %s, Vidéos locales : %s \ No newline at end of file From a41049e8dd0de2b480a4f76bca724ed227be3fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Sat, 4 Jul 2020 18:54:20 +0000 Subject: [PATCH 026/198] Translated using Weblate (Turkish) Currently translated at 99.7% (367 of 368 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/tr/ --- app/src/main/res/values-tr/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index dcb7795..b768928 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -353,4 +353,6 @@ Arka planda oynatma yapılandırması Tüm oynatmaları durdur Arka planda ses akışı olarak devam et + İş Yeri İçin Uygun Olmayan (NSFW) Örnek + Video: %s, Yerel Video: %s \ No newline at end of file From 0c3d508a53cbcd74f4a741e14d1a8292cf964d78 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Sun, 5 Jul 2020 03:53:05 +0000 Subject: [PATCH 027/198] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (368 of 368 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/zh_Hant/ --- app/src/main/res/values-zh-rTW/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 039b46c..773aa99 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -339,4 +339,6 @@ 繼續以懸浮視窗播放影片 停止所有播放 以背景音訊串流繼續 + 影片:%s,本地影片:%s + NSFW 站臺 \ No newline at end of file From ed8c46a79a18d944c50f747bc3480ae7560da65f Mon Sep 17 00:00:00 2001 From: "J. Lavoie" Date: Sun, 5 Jul 2020 02:21:06 +0000 Subject: [PATCH 028/198] Translated using Weblate (German) Currently translated at 93.7% (345 of 368 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/de/ --- app/src/main/res/values-de/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index aae549c..31b1694 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -314,4 +314,8 @@ Suchverlauf löschen Wählen Sie die Sprache für die Anwendungsschnittstelle aus. Starten Sie die Anwendung neu, damit die Änderung wirksam wird. Sprache der Anwendung + Über + Videowiedergabe + Videoliste + Videos: %s, Lokale Videos: %s \ No newline at end of file From b01807d2a9b31348f6af2ab2cfea7f589aa8b246 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 5 Jul 2020 14:25:28 +0200 Subject: [PATCH 029/198] Code cleanup, renamed serverlist to search server --- app/src/main/AndroidManifest.xml | 2 +- ...erActivity.java => SearchServerActivity.java} | 16 ++++++++-------- .../peertube/adapter/ServerListAdapter.java | 8 -------- ...rverAdapter.java => ServerSearchAdapter.java} | 8 ++++---- .../peertube/fragment/AddServerFragment.java | 4 ++-- ..._selection.xml => activity_search_server.xml} | 2 +- app/src/main/res/values/strings.xml | 2 +- 7 files changed, 17 insertions(+), 25 deletions(-) rename app/src/main/java/net/schueller/peertube/activity/{SelectServerActivity.java => SearchServerActivity.java} (92%) rename app/src/main/java/net/schueller/peertube/adapter/{ServerAdapter.java => ServerSearchAdapter.java} (95%) rename app/src/main/res/layout/{activity_server_selection.xml => activity_search_server.xml} (97%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ee09a9b..3091705 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -49,7 +49,7 @@ android:label="@string/title_activity_settings" android:theme="@style/AppTheme.NoActionBar" /> (), this); + serverAdapter = new ServerSearchAdapter(new ArrayList<>(), this); recyclerView.setAdapter(serverAdapter); loadServers(currentStart, count); @@ -132,7 +132,7 @@ public class SelectServerActivity extends CommonActivity { isLoading = true; GetServerListDataService service = RetrofitInstance.getRetrofitInstance( - APIUrlHelper.getServerIndexUrl(SelectServerActivity.this) + APIUrlHelper.getServerIndexUrl(SearchServerActivity.this) ).create(GetServerListDataService.class); @@ -171,7 +171,7 @@ public class SelectServerActivity extends CommonActivity { @Override public void onFailure(@NonNull Call call, @NonNull Throwable t) { Log.wtf("err", t.fillInStackTrace()); - Toast.makeText(SelectServerActivity.this, getString(R.string.api_error), Toast.LENGTH_SHORT).show(); + Toast.makeText(SearchServerActivity.this, getString(R.string.api_error), Toast.LENGTH_SHORT).show(); isLoading = false; swipeRefreshLayout.setRefreshing(false); } diff --git a/app/src/main/java/net/schueller/peertube/adapter/ServerListAdapter.java b/app/src/main/java/net/schueller/peertube/adapter/ServerListAdapter.java index f7225df..b5a575a 100644 --- a/app/src/main/java/net/schueller/peertube/adapter/ServerListAdapter.java +++ b/app/src/main/java/net/schueller/peertube/adapter/ServerListAdapter.java @@ -18,15 +18,11 @@ package net.schueller.peertube.adapter; import android.app.Activity; -import android.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; -import android.provider.SearchRecentSuggestions; import android.text.TextUtils; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -39,12 +35,8 @@ import androidx.recyclerview.widget.RecyclerView; import net.schueller.peertube.R; -import net.schueller.peertube.activity.SelectServerActivity; -import net.schueller.peertube.activity.ServerAddressBookActivity; -import net.schueller.peertube.activity.VideoListActivity; import net.schueller.peertube.database.Server; import net.schueller.peertube.helper.APIUrlHelper; -import net.schueller.peertube.provider.SearchSuggestionsProvider; import net.schueller.peertube.service.LoginService; diff --git a/app/src/main/java/net/schueller/peertube/adapter/ServerAdapter.java b/app/src/main/java/net/schueller/peertube/adapter/ServerSearchAdapter.java similarity index 95% rename from app/src/main/java/net/schueller/peertube/adapter/ServerAdapter.java rename to app/src/main/java/net/schueller/peertube/adapter/ServerSearchAdapter.java index 4798032..f605cf8 100644 --- a/app/src/main/java/net/schueller/peertube/adapter/ServerAdapter.java +++ b/app/src/main/java/net/schueller/peertube/adapter/ServerSearchAdapter.java @@ -27,7 +27,7 @@ import android.widget.Toast; import net.schueller.peertube.R; -import net.schueller.peertube.activity.SelectServerActivity; +import net.schueller.peertube.activity.SearchServerActivity; import net.schueller.peertube.helper.APIUrlHelper; import net.schueller.peertube.model.Server; @@ -41,14 +41,14 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import static android.app.Activity.RESULT_OK; -public class ServerAdapter extends RecyclerView.Adapter { +public class ServerSearchAdapter extends RecyclerView.Adapter { private ArrayList serverList; - private SelectServerActivity activity; + private SearchServerActivity activity; private String baseUrl; - public ServerAdapter(ArrayList serverList, SelectServerActivity activity) { + public ServerSearchAdapter(ArrayList serverList, SearchServerActivity activity) { this.serverList = serverList; this.activity = activity; } diff --git a/app/src/main/java/net/schueller/peertube/fragment/AddServerFragment.java b/app/src/main/java/net/schueller/peertube/fragment/AddServerFragment.java index 6e15a2b..4c90721 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/AddServerFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/AddServerFragment.java @@ -38,7 +38,7 @@ import android.widget.EditText; import android.widget.Toast; import net.schueller.peertube.R; -import net.schueller.peertube.activity.SelectServerActivity; +import net.schueller.peertube.activity.SearchServerActivity; import net.schueller.peertube.activity.ServerAddressBookActivity; import net.schueller.peertube.helper.APIUrlHelper; @@ -128,7 +128,7 @@ public class AddServerFragment extends Fragment { Button pickServerUrl = mView.findViewById(R.id.pickServerUrl); pickServerUrl.setOnClickListener(view -> { - Intent intentServer = new Intent(getActivity(), SelectServerActivity.class); + Intent intentServer = new Intent(getActivity(), SearchServerActivity.class); this.startActivityForResult(intentServer, PICK_SERVER); }); diff --git a/app/src/main/res/layout/activity_server_selection.xml b/app/src/main/res/layout/activity_search_server.xml similarity index 97% rename from app/src/main/res/layout/activity_server_selection.xml rename to app/src/main/res/layout/activity_search_server.xml index 9a91455..1860129 100644 --- a/app/src/main/res/layout/activity_server_selection.xml +++ b/app/src/main/res/layout/activity_search_server.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".activity.SelectServerActivity"> + tools:context=".activity.SearchServerActivity"> Remove Server Are you sure you want to remove this server from the address book? - Select Server + Search Server Account SettingsActivity2 From 6cbf35972bb62303248fbae924007678c63adc1d Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 5 Jul 2020 14:31:19 +0200 Subject: [PATCH 030/198] Code cleanup --- .../java/net/schueller/peertube/adapter/ServerListAdapter.java | 2 +- .../net/schueller/peertube/adapter/ServerSearchAdapter.java | 2 +- .../main/java/net/schueller/peertube/adapter/VideoAdapter.java | 2 +- app/src/main/res/layout/content_server_address_book.xml | 2 +- .../main/res/layout/{row_server.xml => row_search_server.xml} | 0 .../layout/{row_serverbook.xml => row_server_address_book.xml} | 0 app/src/main/res/layout/{row_video.xml => row_video_list.xml} | 0 7 files changed, 4 insertions(+), 4 deletions(-) rename app/src/main/res/layout/{row_server.xml => row_search_server.xml} (100%) rename app/src/main/res/layout/{row_serverbook.xml => row_server_address_book.xml} (100%) rename app/src/main/res/layout/{row_video.xml => row_video_list.xml} (100%) diff --git a/app/src/main/java/net/schueller/peertube/adapter/ServerListAdapter.java b/app/src/main/java/net/schueller/peertube/adapter/ServerListAdapter.java index b5a575a..cbefba9 100644 --- a/app/src/main/java/net/schueller/peertube/adapter/ServerListAdapter.java +++ b/app/src/main/java/net/schueller/peertube/adapter/ServerListAdapter.java @@ -57,7 +57,7 @@ public class ServerListAdapter extends RecyclerView.Adapter + tools:listitem="@layout/row_server_address_book" /> diff --git a/app/src/main/res/layout/row_server.xml b/app/src/main/res/layout/row_search_server.xml similarity index 100% rename from app/src/main/res/layout/row_server.xml rename to app/src/main/res/layout/row_search_server.xml diff --git a/app/src/main/res/layout/row_serverbook.xml b/app/src/main/res/layout/row_server_address_book.xml similarity index 100% rename from app/src/main/res/layout/row_serverbook.xml rename to app/src/main/res/layout/row_server_address_book.xml diff --git a/app/src/main/res/layout/row_video.xml b/app/src/main/res/layout/row_video_list.xml similarity index 100% rename from app/src/main/res/layout/row_video.xml rename to app/src/main/res/layout/row_video_list.xml From 52c593b9f1420b8c2a607c4b41855a24422f967e Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sun, 5 Jul 2020 14:39:50 +0200 Subject: [PATCH 031/198] Completed implementation of Likes & Dislikes * Added the ability to change the rating from Like to Dislike and vice versa without having to "undo" the rating beforehand. * Fixed Likes/Dislikes counters not being incremented/decremented (it previously required to go back and then re-open the video page to see the change). * Improved overall code performance and readability by removing redundant calls. * Fixed some typos in comments * Removed "video_rating_none", "video_rating_like" and "video_rating_dislike" from strings.xml as they were not translatable and only used in the code without ever being displayed to the user. --- .../fragment/VideoMetaDataFragment.java | 141 ++++++++++-------- app/src/main/res/values/strings.xml | 3 - 2 files changed, 78 insertions(+), 66 deletions(-) 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 0785eeb..1d370e0 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoMetaDataFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoMetaDataFragment.java @@ -65,6 +65,10 @@ public class VideoMetaDataFragment extends Fragment { private static final String TAG = "VideoMetaDataFragment"; + private static final String RATING_NONE = "none"; + private static final String RATING_LIKE = "like"; + private static final String RATING_DISLIKE = "dislike"; + private Rating videoRating; private ColorStateList defaultTextColor; @@ -72,13 +76,11 @@ public class VideoMetaDataFragment extends Fragment { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_video_meta, container, false); } public void updateVideoMeta(Video video, VideoPlayerService mService) { - Context context = getContext(); Activity activity = getActivity(); @@ -91,26 +93,23 @@ public class VideoMetaDataFragment extends Fragment { thumbsUpButton.setText(R.string.video_thumbs_up_icon); new Iconics.IconicsBuilder().ctx(context).on(thumbsUpButton).build(); thumbsUpButton.setOnClickListener(v -> { - rateVideo(true, video.getId()); + rateVideo(true, video); }); - TextView thumbsUpButtonTotal = activity.findViewById(R.id.video_thumbs_up_total); - thumbsUpButtonTotal.setText(video.getLikes().toString()); - // Thumbs Down Button thumbsDownButton = activity.findViewById(R.id.video_thumbs_down); thumbsDownButton.setText(R.string.video_thumbs_down_icon); new Iconics.IconicsBuilder().ctx(context).on(thumbsDownButton).build(); thumbsDownButton.setOnClickListener(v -> { - rateVideo(false, video.getId()); + rateVideo(false, video); }); - // video rating videoRating = new Rating(); - videoRating.setRating("none"); // default - updateVideoRating(); + videoRating.setRating(RATING_NONE); // default + updateVideoRating(video); + // Retrieve which rating the user gave to this video if (Session.getInstance().isLoggedIn()) { Call call = videoDataService.getVideoRating(video.getId()); call.enqueue(new Callback() { @@ -118,20 +117,16 @@ public class VideoMetaDataFragment extends Fragment { @Override public void onResponse(Call call, Response response) { videoRating = response.body(); - updateVideoRating(); + updateVideoRating(video); } @Override public void onFailure(Call call, Throwable t) { -// Toast.makeText(context, "Rating Failed", Toast.LENGTH_SHORT).show(); + // Do nothing. } }); } - - TextView thumbsDownButtonTotal = activity.findViewById(R.id.video_thumbs_down_total); - thumbsDownButtonTotal.setText(video.getDislikes().toString()); - // Share Button videoShareButton = activity.findViewById(R.id.video_share); videoShareButton.setText(R.string.video_share_icon); @@ -156,7 +151,6 @@ public class VideoMetaDataFragment extends Fragment { } }); - Account account = video.getAccount(); // owner / creator Avatar @@ -198,7 +192,6 @@ public class VideoMetaDataFragment extends Fragment { TextView videoDescription = activity.findViewById(R.id.description); videoDescription.setText(video.getDescription()); - // video privacy TextView videoPrivacy = activity.findViewById(R.id.video_privacy); videoPrivacy.setText(video.getPrivacy().getLabel()); @@ -211,7 +204,7 @@ public class VideoMetaDataFragment extends Fragment { TextView videoLicense = activity.findViewById(R.id.video_license); videoLicense.setText(video.getLicence().getLabel()); - // video langauge + // video language TextView videoLanguage = activity.findViewById(R.id.video_language); videoLanguage.setText(video.getLanguage().getLabel()); @@ -219,7 +212,6 @@ public class VideoMetaDataFragment extends Fragment { TextView videoTags = activity.findViewById(R.id.video_tags); videoTags.setText(android.text.TextUtils.join(", ", video.getTags())); - // more button TextView moreButton = activity.findViewById(R.id.moreButton); moreButton.setText(R.string.video_more_icon); @@ -259,8 +251,7 @@ public class VideoMetaDataFragment extends Fragment { } - - void updateVideoRating() { + void updateVideoRating(Video video) { Button thumbsUpButton = getActivity().findViewById(R.id.video_thumbs_up); Button thumbsDownButton = getActivity().findViewById(R.id.video_thumbs_down); @@ -269,44 +260,46 @@ public class VideoMetaDataFragment extends Fragment { TypedArray a = getContext().obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorPrimary}); int accentColor = a.getColor(0, 0); - if (videoRating.getRating().equals(getString(R.string.video_rating_none))) { - thumbsUpButton.setTextColor(defaultTextColor); - thumbsDownButton.setTextColor(defaultTextColor); - //Log.v(TAG, getString(R.string.video_rating_none)); - - } else if (videoRating.getRating().equals(getString(R.string.video_rating_like))) { - thumbsUpButton.setTextColor(accentColor); - thumbsDownButton.setTextColor(defaultTextColor); - //Log.v(TAG, getString(R.string.video_rating_like)); - - } else if (videoRating.getRating().equals(getString(R.string.video_rating_dislike))) { - thumbsUpButton.setTextColor(defaultTextColor); - thumbsDownButton.setTextColor(accentColor); - //Log.v(TAG, getString(R.string.video_rating_dislike)); - + // Change the color of the thumbs + switch (videoRating.getRating()) { + case RATING_NONE: + thumbsUpButton.setTextColor(defaultTextColor); + thumbsDownButton.setTextColor(defaultTextColor); + break; + case RATING_LIKE: + thumbsUpButton.setTextColor(accentColor); + thumbsDownButton.setTextColor(defaultTextColor); + break; + case RATING_DISLIKE: + thumbsUpButton.setTextColor(defaultTextColor); + thumbsDownButton.setTextColor(accentColor); + break; } + // Update the texts + TextView thumbsDownTotal = getActivity().findViewById(R.id.video_thumbs_down_total); + TextView thumbsUpTotal = getActivity().findViewById(R.id.video_thumbs_up_total); + thumbsUpTotal.setText(String.valueOf(video.getLikes())); + thumbsDownTotal.setText(String.valueOf(video.getDislikes())); + a.recycle(); } - void rateVideo(Boolean rate, Integer videoId) { - - // TODO cleanup - + void rateVideo(Boolean like, Video video) { if (Session.getInstance().isLoggedIn()) { + final String ratePayload; - String ratePayload = getString(R.string.video_rating_none); - - if (rate) { - // thumbsup - if (videoRating.getRating().equals(getString(R.string.video_rating_none))) { - ratePayload = getString(R.string.video_rating_like); - } - } else { - // thumbsdown - if (videoRating.getRating().equals(getString(R.string.video_rating_none))) { - ratePayload = getString(R.string.video_rating_dislike); - } + switch (videoRating.getRating()) { + case RATING_LIKE: + ratePayload = like ? RATING_NONE : RATING_DISLIKE; + break; + case RATING_DISLIKE: + ratePayload = like ? RATING_LIKE : RATING_NONE; + break; + case RATING_NONE: + default: + ratePayload = like ? RATING_LIKE : RATING_DISLIKE; + break; } RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json"), "{\"rating\":\"" + ratePayload + "\"}"); @@ -314,23 +307,47 @@ public class VideoMetaDataFragment extends Fragment { String apiBaseURL = APIUrlHelper.getUrlWithVersion(getContext()); GetVideoDataService videoDataService = RetrofitInstance.getRetrofitInstance(apiBaseURL).create(GetVideoDataService.class); - Call call = videoDataService.rateVideo(videoId, body); - - final String newRating = ratePayload; + Call call = videoDataService.rateVideo(video.getId(), body); call.enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { - //Log.v(TAG, response.toString()); - // if 20x update likes + // if 20x, update likes/dislikes if (response.isSuccessful()) { - videoRating.setRating(newRating); - updateVideoRating(); + String previousRating = videoRating.getRating(); - // TODO: update count under thumb + // Update the likes/dislikes count of the video, if needed. + // This is only a visual trick, as the actual like/dislike count has + // already been modified on the PeerTube instance. + if (!previousRating.equals(ratePayload)) { + switch (previousRating) { + case RATING_NONE: + if (ratePayload.equals(RATING_LIKE)) { + video.setLikes(video.getLikes() + 1); + } else { + video.setDislikes(video.getDislikes() + 1); + } + break; + case RATING_LIKE: + video.setLikes(video.getLikes() - 1); + if (ratePayload.equals(RATING_DISLIKE)) { + video.setDislikes(video.getDislikes() + 1); + } + break; + case RATING_DISLIKE: + video.setDislikes(video.getDislikes() - 1); + if (ratePayload.equals(RATING_LIKE)) { + video.setLikes(video.getLikes() + 1); + } + break; + } + } + + videoRating.setRating(ratePayload); + updateVideoRating(video); } } @@ -341,9 +358,7 @@ public class VideoMetaDataFragment extends Fragment { }); } else { Toast.makeText(getContext(), getString(R.string.video_login_required_for_service), Toast.LENGTH_SHORT).show(); - } - } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 543c2a3..20da13c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -352,9 +352,6 @@ Password Add Has Login - none - like - dislike 1.0.0-alpha.7 Current Server Address Book From cee233db3920d1071206df6d6782d603e1df820c Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 5 Jul 2020 15:07:50 +0200 Subject: [PATCH 032/198] Code cleanup --- .../peertube/activity/VideoPlayActivity.java | 14 +- .../peertube/fragment/AddServerFragment.java | 7 +- .../fragment/VideoOptionsFragment.java | 18 ++- .../fragment/VideoPlayerFragment.java | 135 +++++++++--------- .../peertube/helper/VideoHelper.java | 40 ++++++ app/src/main/res/values-ar/strings.xml | 4 +- app/src/main/res/values-bn/strings.xml | 4 +- app/src/main/res/values-de/strings.xml | 4 +- app/src/main/res/values-es/strings.xml | 4 +- app/src/main/res/values-fi/strings.xml | 2 +- app/src/main/res/values-fr/strings.xml | 4 +- app/src/main/res/values-gd/strings.xml | 4 +- app/src/main/res/values-it/strings.xml | 4 +- app/src/main/res/values-ja/strings.xml | 4 +- app/src/main/res/values-nb-rNO/strings.xml | 4 +- app/src/main/res/values-nl/strings.xml | 4 +- app/src/main/res/values-pl/strings.xml | 4 +- app/src/main/res/values-ru/strings.xml | 4 +- app/src/main/res/values-sv/strings.xml | 4 +- app/src/main/res/values-tr/strings.xml | 4 +- app/src/main/res/values-zh-rCN/strings.xml | 4 +- app/src/main/res/values-zh-rTW/strings.xml | 4 +- app/src/main/res/values/constants.xml | 1 + app/src/main/res/values/strings.xml | 4 +- app/src/main/res/xml/root_preferences.xml | 2 +- 25 files changed, 166 insertions(+), 121 deletions(-) create mode 100644 app/src/main/java/net/schueller/peertube/helper/VideoHelper.java diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 9460e74..159b942 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -65,6 +65,7 @@ import androidx.fragment.app.FragmentTransaction; import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PAUSE; import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PLAY; import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_STOP; +import static net.schueller.peertube.helper.VideoHelper.canEnterPipMode; public class VideoPlayActivity extends AppCompatActivity { @@ -351,7 +352,7 @@ public class VideoPlayActivity extends AppCompatActivity { FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); - String backgroundBehavior = sharedPref.getString("pref_background_behavior", getString(R.string.pref_background_stop_key)); + String backgroundBehavior = sharedPref.getString(getString(R.string.pref_background_behavior_key), getString(R.string.pref_background_stop_key)); assert videoPlayerFragment != null; assert backgroundBehavior != null; @@ -410,7 +411,7 @@ public class VideoPlayActivity extends AppCompatActivity { videoPlayerFragment.pauseVideo(); } - String backgroundBehavior = sharedPref.getString("pref_background_behavior", getString(R.string.pref_background_stop_key)); + String backgroundBehavior = sharedPref.getString(getString(R.string.pref_background_behavior_key), getString(R.string.pref_background_stop_key)); assert backgroundBehavior != null; @@ -448,15 +449,6 @@ public class VideoPlayActivity extends AppCompatActivity { } - public boolean canEnterPipMode(Context context) { - Log.v(TAG, "api version " + Build.VERSION.SDK_INT); - if (Build.VERSION.SDK_INT > 27) { - AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); - return (AppOpsManager.MODE_ALLOWED == appOpsManager.checkOp(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, android.os.Process.myUid(), context.getPackageName())); - } - return false; - } - @RequiresApi(api = Build.VERSION_CODES.O) public void enterPipMode() { Rational rational = new Rational(239, 100); diff --git a/app/src/main/java/net/schueller/peertube/fragment/AddServerFragment.java b/app/src/main/java/net/schueller/peertube/fragment/AddServerFragment.java index 4c90721..9f761a8 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/AddServerFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/AddServerFragment.java @@ -42,6 +42,8 @@ import net.schueller.peertube.activity.SearchServerActivity; import net.schueller.peertube.activity.ServerAddressBookActivity; import net.schueller.peertube.helper.APIUrlHelper; +import java.util.Objects; + import static android.app.Activity.RESULT_OK; @@ -78,14 +80,15 @@ public class AddServerFragment extends Fragment { Activity act = getActivity(); - Boolean formValid = true; + boolean formValid = true; // close keyboard try { + assert act != null; InputMethodManager inputManager = (InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE); - inputManager.hideSoftInputFromWindow(act.getCurrentFocus().getWindowToken(), + inputManager.hideSoftInputFromWindow(Objects.requireNonNull(act.getCurrentFocus()).getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception e) { diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java index 2e9c3b4..ada3fdf 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java @@ -28,6 +28,7 @@ import android.widget.TextView; import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import com.mikepenz.iconics.Iconics; + import net.schueller.peertube.R; import net.schueller.peertube.model.File; import net.schueller.peertube.service.VideoPlayerService; @@ -66,13 +67,22 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { LinearLayout menuRow = (LinearLayout) inflater.inflate(R.layout.row_popup_menu, null); TextView iconView = menuRow.findViewById(R.id.video_quality_icon); TextView textView = menuRow.findViewById(R.id.video_quality_text); - textView.setText(String.format(getString(R.string.menu_video_options_playback_speed), getCurrentVideoPlaybackSpeedString(videoPlayerService.getPlayBackSpeed()))); + + textView.setText( + getString( + R.string.menu_video_options_playback_speed, + getCurrentVideoPlaybackSpeedString(videoPlayerService.getPlayBackSpeed() + ) + ) + ); + + iconView.setText(R.string.video_option_speed_icon); new Iconics.IconicsBuilder().ctx(getContext()).on(iconView).build(); textView.setOnClickListener(view1 -> { VideoMenuSpeedFragment videoMenuSpeedFragment = VideoMenuSpeedFragment.newInstance(videoPlayerService); - videoMenuSpeedFragment.show(getActivity().getSupportFragmentManager(), + videoMenuSpeedFragment.show(requireActivity().getSupportFragmentManager(), VideoMenuSpeedFragment.TAG); }); menuHolder.addView(menuRow); @@ -87,8 +97,8 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { textView2.setOnClickListener(view1 -> { VideoMenuQualityFragment videoMenuQualityFragment = VideoMenuQualityFragment.newInstance(getContext(), files); - videoMenuQualityFragment.show(getActivity().getSupportFragmentManager(), - videoMenuQualityFragment.TAG); + videoMenuQualityFragment.show(requireActivity().getSupportFragmentManager(), + VideoMenuQualityFragment.TAG); }); menuHolder.addView(menuRow2); diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java index 9fad3b3..16c75cf 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java @@ -18,7 +18,6 @@ package net.schueller.peertube.fragment; import android.app.Activity; -import android.app.AppOpsManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -66,15 +65,16 @@ import net.schueller.peertube.network.GetVideoDataService; import net.schueller.peertube.network.RetrofitInstance; import net.schueller.peertube.service.VideoPlayerService; -import java.util.Objects; - import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.fragment.app.Fragment; + import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; +import static net.schueller.peertube.helper.VideoHelper.canEnterPipMode; + public class VideoPlayerFragment extends Fragment implements VideoRendererEventListener { private String mVideoUuid; @@ -134,6 +134,7 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL progressBar = activity.findViewById(R.id.torrent_progress); progressBar.setMax(100); + assert context != null; simpleExoPlayerView = new PlayerView(context); simpleExoPlayerView = activity.findViewById(R.id.video_view); @@ -195,23 +196,24 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL @Override public void onFailure(@NonNull Call