From 134d5754905c2e330c122be8f177949aa8787520 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Thu, 26 May 2022 14:31:17 +0000
Subject: [PATCH 001/202] Bump gradle from 7.2.0 to 7.2.1
Bumps gradle from 7.2.0 to 7.2.1.
---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
---
build.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build.gradle b/build.gradle
index facc3448f..738ae3345 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.2.0'
+ classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
// NOTE: Do not place your application dependencies here; they belong
From 7eb68c83e637d3349789ab1713dc13ac3c92a1ca Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 13 Jun 2022 14:42:30 +0000
Subject: [PATCH 002/202] Bump actions/setup-python from 3 to 4
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3...v4)
---
updated-dependencies:
- dependency-name: actions/setup-python
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot]
---
.github/workflows/tg-bot.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/tg-bot.yml b/.github/workflows/tg-bot.yml
index 7ca78bb81..ac605cb01 100644
--- a/.github/workflows/tg-bot.yml
+++ b/.github/workflows/tg-bot.yml
@@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- - uses: actions/setup-python@v3
+ - uses: actions/setup-python@v4
with:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
From 155de893b75e904d74936fc0a9321cc44fa1cd91 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D5=B1=D5=BC=D6=85=D5=BC=E1=83=A7=5F=D5=BD=D5=BC=C4=B8?=
=?UTF-8?q?=D5=BC=D6=85=D5=A1=D5=BC?=
<87353286+TheAnonyUnknown@users.noreply.github.com>
Date: Fri, 24 Jun 2022 09:44:23 +0530
Subject: [PATCH 003/202] Revert "Bump actions/setup-python from 3 to 4"
---
.github/workflows/tg-bot.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/tg-bot.yml b/.github/workflows/tg-bot.yml
index 961d4d403..17659ca55 100644
--- a/.github/workflows/tg-bot.yml
+++ b/.github/workflows/tg-bot.yml
@@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- - uses: actions/setup-python@v4
+ - uses: actions/setup-python@v3
with:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
From b184157b2a4af0a98824bce4cd63094d835c6a90 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Fri, 24 Jun 2022 14:50:17 +0000
Subject: [PATCH 004/202] Bump actions/setup-python from 3 to 4
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3...v4)
---
updated-dependencies:
- dependency-name: actions/setup-python
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot]
---
.github/workflows/tg-bot.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/tg-bot.yml b/.github/workflows/tg-bot.yml
index 17659ca55..961d4d403 100644
--- a/.github/workflows/tg-bot.yml
+++ b/.github/workflows/tg-bot.yml
@@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- - uses: actions/setup-python@v3
+ - uses: actions/setup-python@v4
with:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
From 5b7c35bfbbdeab3e75cff24a173e39e6877482ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D5=B1=D5=BC=D6=85=D5=BC=E1=83=A7=5F=D5=BD=D5=BC=C4=B8?=
=?UTF-8?q?=D5=BC=D6=85=D5=A1=D5=BC?=
<87353286+TheAnonyUnknown@users.noreply.github.com>
Date: Sun, 26 Jun 2022 16:02:16 +0530
Subject: [PATCH 005/202] Update README.md
---
README.md | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/README.md b/README.md
index b5c6894f0..277902dcc 100644
--- a/README.md
+++ b/README.md
@@ -7,25 +7,25 @@
[![Twitter](https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube)
[![Reddit](https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/)
-[ ](https://f-droid.org/en/packages/com.github.libretube/)
-[ ](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
-[ ](https://github.com/libre-tube/LibreTube/releases/latest)
-[ ](https://t.me/LibreTube)
+[ ](https://f-droid.org/en/packages/com.github.libretube/)
+[ ](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
+[ ](https://github.com/libre-tube/LibreTube/releases/latest)
+[ ](https://t.me/LibreTube)
-## Screenshots
+## 📱 Screenshots
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
+[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
+[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
+[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
+[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
+[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
+[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
+[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
+[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
+[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
-## Features
+## ⭐ Features
| Feature ||
| - | - |
@@ -39,21 +39,21 @@
| Comments | ✅ |
-## Contributing
+## 😇 Contributing
Whether you have ideas, translations, design changes, code cleaning, or real heavy code changes, help is always welcome.The more is done the better it gets!
If creating a pull request, please make sure to format your code (preferred ktlint) before.
If opening an issue without following the issue template, we will ignore the issue and force close it.
-WARNING: THIS IS A BETA VERSION, THEREFORE YOU MAY ENCOUNTER BUGS. IF YOU DO, OPEN AN ISSUE VIA OUR GITHUB REPOSITORY.
+>**⚠️ WARNING: This is a beta version, therefore you may encounter bugs. If you do, open an issue via our github repository.**
-### Translation
+### 📝 Translation
-### Donate
+### 💰 Donate
[![Support us on Patreon](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Dlibretubeteam%26type%3Dpatrons&style=for-the-badge)](https://patreon.com/libretubeteam)
**BTC:** `bc1q0hk2smc74ej8fxupfrp05wk867e54e2zztnxfc`
From c36519294b0592ea155238f3ec0b8fe6a340d610 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D5=B1=D5=BC=D6=85=D5=BC=E1=83=A7=5F=D5=BD=D5=BC=C4=B8?=
=?UTF-8?q?=D5=BC=D6=85=D5=A1=D5=BC?=
<87353286+TheAnonyUnknown@users.noreply.github.com>
Date: Mon, 27 Jun 2022 18:42:51 +0530
Subject: [PATCH 006/202] Fixed layout for mobile screen
---
README.md | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index 277902dcc..348273de3 100644
--- a/README.md
+++ b/README.md
@@ -7,23 +7,27 @@
[![Twitter](https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube)
[![Reddit](https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/)
-[ ](https://f-droid.org/en/packages/com.github.libretube/)
-[ ](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
-[ ](https://github.com/libre-tube/LibreTube/releases/latest)
-[ ](https://t.me/LibreTube)
+[ ](https://f-droid.org/en/packages/com.github.libretube/)
+[ ](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
+[ ](https://github.com/libre-tube/LibreTube/releases/latest)
+[ ](https://t.me/LibreTube)
## 📱 Screenshots
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
-[ ](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
+
+
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
+
+
## ⭐ Features
From f9984f9ec324b29118e568896dde5e7754944b11 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D5=B1=D5=BC=D6=85=D5=BC=E1=83=A7=5F=D5=BD=D5=BC=C4=B8?=
=?UTF-8?q?=D5=BC=D6=85=D5=A1=D5=BC?=
<87353286+TheAnonyUnknown@users.noreply.github.com>
Date: Mon, 27 Jun 2022 18:54:13 +0530
Subject: [PATCH 007/202] Try to fix pc layout
---
README.md | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index 348273de3..f0195ad4d 100644
--- a/README.md
+++ b/README.md
@@ -7,25 +7,15 @@
[![Twitter](https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube)
[![Reddit](https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/)
-[ ](https://f-droid.org/en/packages/com.github.libretube/)
-[ ](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
-[ ](https://github.com/libre-tube/LibreTube/releases/latest)
-[ ](https://t.me/LibreTube)
+[ ](https://f-droid.org/en/packages/com.github.libretube/) [ ](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube) [ ](https://github.com/libre-tube/LibreTube/releases/latest) [ ](https://t.me/LibreTube)
+
## 📱 Screenshots
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
From fe13ec8048e55e58709edcdf3e39d9974a314bf0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D5=B1=D5=BC=D6=85=D5=BC=E1=83=A7=5F=D5=BD=D5=BC=C4=B8?=
=?UTF-8?q?=D5=BC=D6=85=D5=A1=D5=BC?=
<87353286+TheAnonyUnknown@users.noreply.github.com>
Date: Wed, 29 Jun 2022 16:40:59 +0530
Subject: [PATCH 008/202] Reworked layout and line wrapping
---
README.md | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index f0195ad4d..825f66780 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,10 @@
[![Twitter](https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube)
[![Reddit](https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/)
-[ ](https://f-droid.org/en/packages/com.github.libretube/) [ ](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube) [ ](https://github.com/libre-tube/LibreTube/releases/latest) [ ](https://t.me/LibreTube)
+[ ](https://f-droid.org/en/packages/com.github.libretube/)
+[ ](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
+[ ](https://github.com/libre-tube/LibreTube/releases/latest)
+[ ](https://t.me/LibreTube)
@@ -15,7 +18,15 @@
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png) [
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
@@ -54,6 +65,6 @@ If opening an issue without following the issue template, we will ignore the iss
**XMR:** `44txdmy4E5bDzMYQJh1ZSoHbrp1sWfpGa2FYg26L2ya8EaRejPsh42yVrYhepW9P4YWvrqmTZvms35z5FDgqy1xcVewk18d`
-## Mirrors (read-only)
+## 🪞 Mirrors (read-only)
GitLab
NotABug
From 47c6bdcb23d12c51a7290dcfe7d944b0dea95895 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D5=B1=D5=BC=D6=85=D5=BC=E1=83=A7=5F=D5=BD=D5=BC=C4=B8?=
=?UTF-8?q?=D5=BC=D6=85=D5=A1=D5=BC?=
<87353286+TheAnonyUnknown@users.noreply.github.com>
Date: Wed, 29 Jun 2022 17:00:55 +0530
Subject: [PATCH 009/202] Refactored sizing
---
README.md | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index 825f66780..b2ccd8980 100644
--- a/README.md
+++ b/README.md
@@ -7,10 +7,10 @@
[![Twitter](https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube)
[![Reddit](https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/)
-[ ](https://f-droid.org/en/packages/com.github.libretube/)
-[ ](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
-[ ](https://github.com/libre-tube/LibreTube/releases/latest)
-[ ](https://t.me/LibreTube)
+[ ](https://f-droid.org/en/packages/com.github.libretube/)
+[ ](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
+[ ](https://github.com/libre-tube/LibreTube/releases/latest)
+[ ](https://t.me/LibreTube)
@@ -18,15 +18,15 @@
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
@@ -45,6 +45,7 @@
## 😇 Contributing
+
Whether you have ideas, translations, design changes, code cleaning, or real heavy code changes, help is always welcome.The more is done the better it gets!
If creating a pull request, please make sure to format your code (preferred ktlint) before.
@@ -54,11 +55,13 @@ If opening an issue without following the issue template, we will ignore the iss
>**⚠️ WARNING: This is a beta version, therefore you may encounter bugs. If you do, open an issue via our github repository.**
### 📝 Translation
+
### 💰 Donate
+
[![Support us on Patreon](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Dlibretubeteam%26type%3Dpatrons&style=for-the-badge)](https://patreon.com/libretubeteam)
**BTC:** `bc1q0hk2smc74ej8fxupfrp05wk867e54e2zztnxfc`
From c098b3265eabd4696014b16adb6a3b748729f319 Mon Sep 17 00:00:00 2001
From: "restyled-io[bot]" <32688539+restyled-io[bot]@users.noreply.github.com>
Date: Wed, 29 Jun 2022 17:03:07 +0530
Subject: [PATCH 010/202] Code Enhancements
---
README.md | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index b2ccd8980..1480a5b52 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
[![Telegram](https://libre-tube.github.io/assets/tg-widget.svg)](https://t.me/libretube)
[![Twitter](https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube)
[![Reddit](https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/)
-
+
[ ](https://f-droid.org/en/packages/com.github.libretube/)
[ ](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
[ ](https://github.com/libre-tube/LibreTube/releases/latest)
@@ -32,17 +32,16 @@
## ⭐ Features
-| Feature ||
-| - | - |
-| User Accounts | ✅ |
-| Subscriptions | ✅ |
-| User Playlists | ✅ |
-| Channel Playlists | ✅ |
-| Search Filters | ✅ |
-| SponsorBlock | ✅ |
-| Subtitles | ✅ |
-| Comments | ✅ |
-
+| Feature | |
+| ----------------- | --- |
+| User Accounts | ✅ |
+| Subscriptions | ✅ |
+| User Playlists | ✅ |
+| Channel Playlists | ✅ |
+| Search Filters | ✅ |
+| SponsorBlock | ✅ |
+| Subtitles | ✅ |
+| Comments | ✅ |
## 😇 Contributing
@@ -52,7 +51,7 @@ If creating a pull request, please make sure to format your code (preferred ktli
If opening an issue without following the issue template, we will ignore the issue and force close it.
->**⚠️ WARNING: This is a beta version, therefore you may encounter bugs. If you do, open an issue via our github repository.**
+> **⚠️ WARNING: This is a beta version, therefore you may encounter bugs. If you do, open an issue via our github repository.**
### 📝 Translation
@@ -69,5 +68,6 @@ If opening an issue without following the issue template, we will ignore the iss
**XMR:** `44txdmy4E5bDzMYQJh1ZSoHbrp1sWfpGa2FYg26L2ya8EaRejPsh42yVrYhepW9P4YWvrqmTZvms35z5FDgqy1xcVewk18d`
## 🪞 Mirrors (read-only)
+
GitLab
NotABug
From 9259778e0302986209698fe882bce8f3ed990005 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D5=B1=D5=BC=D6=85=D5=BC=E1=83=A7=5F=D5=BD=D5=BC=C4=B8?=
=?UTF-8?q?=D5=BC=D6=85=D5=A1=D5=BC?=
<87353286+TheAnonyUnknown@users.noreply.github.com>
Date: Wed, 29 Jun 2022 17:32:34 +0530
Subject: [PATCH 011/202] Try to fix pc layout again
---
README.md | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/README.md b/README.md
index 1480a5b52..de10ad348 100644
--- a/README.md
+++ b/README.md
@@ -1,32 +1,32 @@
-[![GPL-v3](https://libre-tube.github.io/assets/license-widget.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
-[![Matrix](https://libre-tube.github.io/assets/mat-widget.svg)](https://matrix.to/#/#LibreTube:matrix.org)
-[![Telegram](https://libre-tube.github.io/assets/tg-widget.svg)](https://t.me/libretube)
-[![Twitter](https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube)
-[![Reddit](https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/)
+ [![GPL-v3](https://libre-tube.github.io/assets/license-widget.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
+ [![Matrix](https://libre-tube.github.io/assets/mat-widget.svg)](https://matrix.to/#/#LibreTube:matrix.org)
+ [![Telegram](https://libre-tube.github.io/assets/tg-widget.svg)](https://t.me/libretube)
+ [![Twitter](https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube)
+ [![Reddit](https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/)
-[
](https://f-droid.org/en/packages/com.github.libretube/)
-[
](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
-[
](https://github.com/libre-tube/LibreTube/releases/latest)
-[
](https://t.me/LibreTube)
+ [
](https://f-droid.org/en/packages/com.github.libretube/)
+ [
](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
+ [
](https://github.com/libre-tube/LibreTube/releases/latest)
+ [
](https://t.me/LibreTube)
## 📱 Screenshots
-
+
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
From b521bcd3bb3de22c8db0e802bcc786371a64f126 Mon Sep 17 00:00:00 2001
From: "restyled-io[bot]" <32688539+restyled-io[bot]@users.noreply.github.com>
Date: Wed, 29 Jun 2022 17:34:30 +0530
Subject: [PATCH 012/202] Removed extra spaces
---
README.md | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index de10ad348..d15adf310 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,16 @@
- [![GPL-v3](https://libre-tube.github.io/assets/license-widget.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
- [![Matrix](https://libre-tube.github.io/assets/mat-widget.svg)](https://matrix.to/#/#LibreTube:matrix.org)
- [![Telegram](https://libre-tube.github.io/assets/tg-widget.svg)](https://t.me/libretube)
- [![Twitter](https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube)
- [![Reddit](https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/)
+[![GPL-v3](https://libre-tube.github.io/assets/license-widget.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
+[![Matrix](https://libre-tube.github.io/assets/mat-widget.svg)](https://matrix.to/#/#LibreTube:matrix.org)
+[![Telegram](https://libre-tube.github.io/assets/tg-widget.svg)](https://t.me/libretube)
+[![Twitter](https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube)
+[![Reddit](https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/)
- [
](https://f-droid.org/en/packages/com.github.libretube/)
- [
](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
- [
](https://github.com/libre-tube/LibreTube/releases/latest)
- [
](https://t.me/LibreTube)
+[
](https://f-droid.org/en/packages/com.github.libretube/)
+[
](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
+[
](https://github.com/libre-tube/LibreTube/releases/latest)
+[
](https://t.me/LibreTube)
From 94fd3087143d772cd0f77c01acecf3411906d576 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D5=B1=D5=BC=D6=85=D5=BC=E1=83=A7=5F=D5=BD=D5=BC=C4=B8?=
=?UTF-8?q?=D5=BC=D6=85=D5=A1=D5=BC?=
<87353286+TheAnonyUnknown@users.noreply.github.com>
Date: Thu, 30 Jun 2022 09:07:49 +0530
Subject: [PATCH 013/202] Update README.md
---
README.md | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index d15adf310..87aa1ecfe 100644
--- a/README.md
+++ b/README.md
@@ -7,16 +7,18 @@
[![Twitter](https://libre-tube.github.io/assets/tw-widget.svg)](https://twitter.com/libretube)
[![Reddit](https://libre-tube.github.io/assets/rd-widget.svg)](https://www.reddit.com/r/Libretube/)
-[
](https://f-droid.org/en/packages/com.github.libretube/)
-[
](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
-[
](https://github.com/libre-tube/LibreTube/releases/latest)
-[
](https://t.me/LibreTube)
+
+
+[
](https://f-droid.org/en/packages/com.github.libretube/)
+[
](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
+[
](https://github.com/libre-tube/LibreTube/releases/latest)
+[
](https://t.me/LibreTube)
## 📱 Screenshots
-
+
[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
From 946ff5108aff304641197d97e428a5857d41a73f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D5=B1=D5=BC=D6=85=D5=BC=E1=83=A7=5F=D5=BD=D5=BC=C4=B8?=
=?UTF-8?q?=D5=BC=D6=85=D5=A1=D5=BC?=
<87353286+TheAnonyUnknown@users.noreply.github.com>
Date: Thu, 30 Jun 2022 09:29:09 +0530
Subject: [PATCH 014/202] =?UTF-8?q?3=C3=973=20layout?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index 87aa1ecfe..9cb63c092 100644
--- a/README.md
+++ b/README.md
@@ -9,10 +9,10 @@
-[
](https://f-droid.org/en/packages/com.github.libretube/)
-[
](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
-[
](https://github.com/libre-tube/LibreTube/releases/latest)
-[
](https://t.me/LibreTube)
+[
](https://f-droid.org/en/packages/com.github.libretube/)
+[
](https://apt.izzysoft.de/fdroid/index/apk/com.github.libretube)
+[
](https://github.com/libre-tube/LibreTube/releases/latest)
+[
](https://t.me/LibreTube)
@@ -20,15 +20,15 @@
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
-[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_1.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_2.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_3.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_4.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_5.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_6.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_7.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_8.png)
+[
](fastlane/metadata/android/en-US/images/phoneScreenshots/shot_9.png)
From c81f1e064285d86c2aa1182cdf43532aca85c0b9 Mon Sep 17 00:00:00 2001
From: Bnyro <82752168+Bnyro@users.noreply.github.com>
Date: Thu, 30 Jun 2022 07:57:48 +0200
Subject: [PATCH 015/202] Update tg-bot.yml
---
.github/workflows/tg-bot.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/tg-bot.yml b/.github/workflows/tg-bot.yml
index 961d4d403..17659ca55 100644
--- a/.github/workflows/tg-bot.yml
+++ b/.github/workflows/tg-bot.yml
@@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- - uses: actions/setup-python@v4
+ - uses: actions/setup-python@v3
with:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
From 2801f5d1659bfb0c4f6148fdc2bbe3c51d398783 Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Thu, 30 Jun 2022 13:38:21 +0200
Subject: [PATCH 016/202] reduce preload buffer
---
.../main/java/com/github/libretube/fragments/PlayerFragment.kt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
index 05d306338..779203258 100644
--- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
@@ -969,7 +969,7 @@ class PlayerFragment : Fragment() {
// cache the last three minutes
.setBackBuffer(1000 * 60 * 3, true)
.setBufferDurationsMs(
- DefaultLoadControl.DEFAULT_MIN_BUFFER_MS,
+ 1000 * 10, // exo default is 50s
bufferingGoal,
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS,
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS
From 6d50edb6a539e579dd793a236a3fae8fb9932509 Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Thu, 30 Jun 2022 14:19:54 +0200
Subject: [PATCH 017/202] chapters animation
---
.../util/CustomOnScaleGestureListener.kt | 34 +++++++++++++++++++
app/src/main/res/layout/chapter_column.xml | 3 +-
2 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 app/src/main/java/com/github/libretube/util/CustomOnScaleGestureListener.kt
diff --git a/app/src/main/java/com/github/libretube/util/CustomOnScaleGestureListener.kt b/app/src/main/java/com/github/libretube/util/CustomOnScaleGestureListener.kt
new file mode 100644
index 000000000..7d166c68d
--- /dev/null
+++ b/app/src/main/java/com/github/libretube/util/CustomOnScaleGestureListener.kt
@@ -0,0 +1,34 @@
+package com.github.libretube.util
+
+import android.util.Log
+import android.view.ScaleGestureDetector
+import com.google.android.exoplayer2.ui.AspectRatioFrameLayout
+import com.google.android.exoplayer2.ui.StyledPlayerView
+
+class CustomOnScaleGestureListener(
+ private val player: StyledPlayerView
+) : ScaleGestureDetector.SimpleOnScaleGestureListener() {
+ private var scaleFactor = 0f
+
+ override fun onScale(
+ detector: ScaleGestureDetector
+ ): Boolean {
+ scaleFactor = detector.scaleFactor
+ return true
+ }
+
+ override fun onScaleBegin(
+ detector: ScaleGestureDetector
+ ): Boolean {
+ return true
+ }
+
+ override fun onScaleEnd(detector: ScaleGestureDetector) {
+ Log.e("scale", "scale")
+ if (scaleFactor > 1) {
+ player.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
+ } else {
+ player.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT
+ }
+ }
+}
diff --git a/app/src/main/res/layout/chapter_column.xml b/app/src/main/res/layout/chapter_column.xml
index f323807ab..b44de7e06 100644
--- a/app/src/main/res/layout/chapter_column.xml
+++ b/app/src/main/res/layout/chapter_column.xml
@@ -3,7 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="100dp"
android:layout_height="wrap_content"
- android:layout_marginHorizontal="5dp"
+ android:paddingHorizontal="5dp"
+ android:background="?attr/selectableItemBackground"
android:orientation="vertical">
Date: Thu, 30 Jun 2022 14:20:22 +0200
Subject: [PATCH 018/202] .
---
.../util/CustomOnScaleGestureListener.kt | 34 -------------------
1 file changed, 34 deletions(-)
delete mode 100644 app/src/main/java/com/github/libretube/util/CustomOnScaleGestureListener.kt
diff --git a/app/src/main/java/com/github/libretube/util/CustomOnScaleGestureListener.kt b/app/src/main/java/com/github/libretube/util/CustomOnScaleGestureListener.kt
deleted file mode 100644
index 7d166c68d..000000000
--- a/app/src/main/java/com/github/libretube/util/CustomOnScaleGestureListener.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.github.libretube.util
-
-import android.util.Log
-import android.view.ScaleGestureDetector
-import com.google.android.exoplayer2.ui.AspectRatioFrameLayout
-import com.google.android.exoplayer2.ui.StyledPlayerView
-
-class CustomOnScaleGestureListener(
- private val player: StyledPlayerView
-) : ScaleGestureDetector.SimpleOnScaleGestureListener() {
- private var scaleFactor = 0f
-
- override fun onScale(
- detector: ScaleGestureDetector
- ): Boolean {
- scaleFactor = detector.scaleFactor
- return true
- }
-
- override fun onScaleBegin(
- detector: ScaleGestureDetector
- ): Boolean {
- return true
- }
-
- override fun onScaleEnd(detector: ScaleGestureDetector) {
- Log.e("scale", "scale")
- if (scaleFactor > 1) {
- player.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
- } else {
- player.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT
- }
- }
-}
From 87f7fcb3232273e0a79c69146d5e500772ea414d Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Thu, 30 Jun 2022 14:30:23 +0200
Subject: [PATCH 019/202] add support for android 13 monochrome icons
---
.../res/drawable/ic_launcher_monochrome.xml | 17 +++++++++++++++++
.../main/res/mipmap-anydpi-v26/ic_launcher.xml | 1 +
.../res/mipmap-anydpi-v26/ic_launcher_round.xml | 1 +
3 files changed, 19 insertions(+)
create mode 100644 app/src/main/res/drawable/ic_launcher_monochrome.xml
diff --git a/app/src/main/res/drawable/ic_launcher_monochrome.xml b/app/src/main/res/drawable/ic_launcher_monochrome.xml
new file mode 100644
index 000000000..7ea164ea6
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launcher_monochrome.xml
@@ -0,0 +1,17 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
index c9ad5f98f..6c7bd4e4a 100644
--- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -2,4 +2,5 @@
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
index c9ad5f98f..6c7bd4e4a 100644
--- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -2,4 +2,5 @@
+
\ No newline at end of file
From 37bba6ea953f7844a20ad3553068b3a394c62d32 Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Thu, 30 Jun 2022 14:39:37 +0200
Subject: [PATCH 020/202] fix icon size
---
.../res/drawable/ic_launcher_monochrome.xml | 22 +++++++++----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/app/src/main/res/drawable/ic_launcher_monochrome.xml b/app/src/main/res/drawable/ic_launcher_monochrome.xml
index 7ea164ea6..6cc55ad92 100644
--- a/app/src/main/res/drawable/ic_launcher_monochrome.xml
+++ b/app/src/main/res/drawable/ic_launcher_monochrome.xml
@@ -4,14 +4,14 @@
android:height="1280dp"
android:viewportWidth="1280"
android:viewportHeight="1280">
-
-
-
\ No newline at end of file
+
+
+
From 8f758566f128009fd82d4d881742ad1626b80116 Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Thu, 30 Jun 2022 16:02:55 +0200
Subject: [PATCH 021/202] autoplay in background mode
---
.../com/github/libretube/BackgroundMode.kt | 53 +++++++++++++++++--
.../libretube/dialogs/VideoOptionsDialog.kt | 2 +-
.../libretube/fragments/PlayerFragment.kt | 2 +-
.../libretube/util/DescriptionAdapter.kt | 4 +-
4 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/app/src/main/java/com/github/libretube/BackgroundMode.kt b/app/src/main/java/com/github/libretube/BackgroundMode.kt
index 79ff8a319..a95a8801d 100644
--- a/app/src/main/java/com/github/libretube/BackgroundMode.kt
+++ b/app/src/main/java/com/github/libretube/BackgroundMode.kt
@@ -1,13 +1,16 @@
package com.github.libretube
+import android.app.NotificationManager
import android.content.Context
import android.support.v4.media.session.MediaSessionCompat
import com.github.libretube.obj.Streams
import com.github.libretube.util.DescriptionAdapter
+import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
import com.google.android.exoplayer2.C
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.MediaItem
+import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.audio.AudioAttributes
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector
import com.google.android.exoplayer2.ui.PlayerNotificationManager
@@ -42,7 +45,7 @@ class BackgroundMode {
/**
* The [PlayerNotificationManager] to load the [mediaSession] content on it.
*/
- private lateinit var playerNotification: PlayerNotificationManager
+ private var playerNotification: PlayerNotificationManager? = null
/**
* The [AudioAttributes] handle the audio focus of the [player]
@@ -63,9 +66,45 @@ class BackgroundMode {
.setAudioAttributes(audioAttributes, true)
.build()
}
+
+ /**
+ * Listens for changed playbackStates (e.g. pause, end)
+ * Plays the next video when the current one ended
+ */
+ player!!.addListener(object : Player.Listener {
+ override fun onPlaybackStateChanged(@Player.State state: Int) {
+ val autoplay = PreferenceHelper.getBoolean(c, "autoplay", false)
+ if (state == Player.STATE_ENDED) {
+ if (autoplay) playNextVideo(c)
+ }
+ }
+ })
setMediaItem(c)
}
+ /**
+ * Plays the first related video to the current (used when the playback of the current video ended)
+ */
+ private fun playNextVideo(c: Context) {
+ if (response!!.relatedStreams!!.isNotEmpty()) {
+ val videoId = response!!
+ .relatedStreams!![0].url!!
+ .replace("/watch?v=", "")
+
+ // destroy old player and its notification
+ playerNotification = null
+ player = null
+
+ // kill old notification
+ val notificationManager = c.getSystemService(Context.NOTIFICATION_SERVICE)
+ as NotificationManager
+ notificationManager.cancel(1)
+
+ // play new video on background
+ playOnBackgroundMode(c, videoId)
+ }
+ }
+
/**
* Initializes the [playerNotification] attached to the [player] and shows it.
*/
@@ -82,10 +121,12 @@ class BackgroundMode {
)
)
.build()
- playerNotification.apply {
+ playerNotification?.apply {
setPlayer(player)
- setUsePreviousAction(false)
setUseNextAction(false)
+ setUsePreviousAction(false)
+ setUseStopAction(true)
+ setColorized(true)
setMediaSessionToken(mediaSession.sessionToken)
}
}
@@ -110,7 +151,11 @@ class BackgroundMode {
/**
* Gets the video data and prepares the [player].
*/
- fun playOnBackgroundMode(c: Context, videoId: String, seekToPosition: Long) {
+ fun playOnBackgroundMode(
+ c: Context,
+ videoId: String,
+ seekToPosition: Long = 0
+ ) {
runBlocking {
val job = launch {
response = RetrofitInstance.api.getStreams(videoId)
diff --git a/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt
index 9271af500..da87f5551 100644
--- a/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt
+++ b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt
@@ -47,7 +47,7 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog
// This for example will be the "Background mode" option
0 -> {
BackgroundMode.getInstance()
- .playOnBackgroundMode(requireContext(), videoId, 0)
+ .playOnBackgroundMode(requireContext(), videoId)
}
// Add Video to Playlist Dialog
1 -> {
diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
index 779203258..55b6cbd3b 100644
--- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
@@ -1006,8 +1006,8 @@ class PlayerFragment : Fragment() {
playerNotification.apply {
setPlayer(exoPlayer)
- setUseNextAction(false)
setUsePreviousAction(false)
+ setUseStopAction(true)
setMediaSessionToken(mediaSession.sessionToken)
}
}
diff --git a/app/src/main/java/com/github/libretube/util/DescriptionAdapter.kt b/app/src/main/java/com/github/libretube/util/DescriptionAdapter.kt
index 8f81b6fad..a7c9c1ec9 100644
--- a/app/src/main/java/com/github/libretube/util/DescriptionAdapter.kt
+++ b/app/src/main/java/com/github/libretube/util/DescriptionAdapter.kt
@@ -83,8 +83,8 @@ class DescriptionAdapter(
return try {
val resizedBitmap = Bitmap.createScaledBitmap(
bitmap,
- 1080,
- 1080,
+ bitmap.width,
+ bitmap.width,
false
)
resizedBitmap
From 6806f4fe6ec5b3d9c29c870e9e92ea4677213239 Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Thu, 30 Jun 2022 21:05:31 +0200
Subject: [PATCH 022/202] introduce viewbinding
---
app/build.gradle | 4 ++
.../java/com/github/libretube/MainActivity.kt | 22 +++----
.../libretube/fragments/PlayerFragment.kt | 57 +++++++++----------
3 files changed, 44 insertions(+), 39 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index 90f219fa8..043de6114 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -17,6 +17,10 @@ android {
resValue "string", "app_name", "LibreTube"
}
+ buildFeatures {
+ viewBinding true
+ }
+
buildTypes {
release {
minifyEnabled true
diff --git a/app/src/main/java/com/github/libretube/MainActivity.kt b/app/src/main/java/com/github/libretube/MainActivity.kt
index 5c694a275..459bb8d4a 100644
--- a/app/src/main/java/com/github/libretube/MainActivity.kt
+++ b/app/src/main/java/com/github/libretube/MainActivity.kt
@@ -32,6 +32,7 @@ import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.findNavController
import androidx.navigation.ui.setupWithNavController
+import com.github.libretube.databinding.ActivityMainBinding
import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.fragments.isFullScreen
import com.github.libretube.services.ClosingService
@@ -46,7 +47,9 @@ import com.google.android.material.color.DynamicColors
class MainActivity : AppCompatActivity() {
val TAG = "MainActivity"
- lateinit var bottomNavigationView: BottomNavigationView
+ lateinit var binding: ActivityMainBinding
+
+ private lateinit var bottomNavigationView: BottomNavigationView
private lateinit var toolbar: Toolbar
lateinit var navController: NavController
@@ -76,12 +79,12 @@ class MainActivity : AppCompatActivity() {
startActivity(intent)
}
} else {
- setContentView(R.layout.activity_main)
+ binding = ActivityMainBinding.inflate(layoutInflater)
+ setContentView(binding.root)
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
- bottomNavigationView = findViewById(R.id.bottomNav)
navController = findNavController(R.id.fragment)
- bottomNavigationView.setupWithNavController(navController)
+ binding.bottomNav.setupWithNavController(navController)
// hide the trending page if enabled
val hideTrendingPage = PreferenceHelper.getBoolean(this, "hide_trending_page", false)
@@ -94,7 +97,7 @@ class MainActivity : AppCompatActivity() {
"library" -> navController.navigate(R.id.library)
}
- bottomNavigationView.setOnItemSelectedListener {
+ binding.bottomNav.setOnItemSelectedListener {
when (it.itemId) {
R.id.home2 -> {
navController.backQueue.clear()
@@ -112,7 +115,6 @@ class MainActivity : AppCompatActivity() {
false
}
- toolbar = findViewById(R.id.toolbar)
val typedValue = TypedValue()
this.theme.resolveAttribute(R.attr.colorPrimary, typedValue, true)
val hexColor = String.format("#%06X", (0xFFFFFF and typedValue.data))
@@ -120,15 +122,15 @@ class MainActivity : AppCompatActivity() {
"LibreTube ",
HtmlCompat.FROM_HTML_MODE_COMPACT
)
- toolbar.title = appName
+ binding.toolbar.title = appName
- toolbar.setNavigationOnClickListener {
+ binding.toolbar.setNavigationOnClickListener {
// settings activity stuff
val intent = Intent(this, SettingsActivity::class.java)
startActivity(intent)
}
- toolbar.setOnMenuItemClickListener {
+ binding.toolbar.setOnMenuItemClickListener {
when (it.itemId) {
R.id.action_search -> {
navController.navigate(R.id.searchFragment)
@@ -267,7 +269,7 @@ class MainActivity : AppCompatActivity() {
override fun onBackPressed() {
try {
- val mainMotionLayout = findViewById(R.id.mainMotionLayout)
+ val mainMotionLayout = binding.mainMotionLayout
if (mainMotionLayout.progress == 0.toFloat()) {
mainMotionLayout.transitionToEnd()
findViewById(R.id.main_container).isClickable = false
diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
index 55b6cbd3b..a6762f05d 100644
--- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
@@ -43,6 +43,7 @@ import com.github.libretube.R
import com.github.libretube.adapters.ChaptersAdapter
import com.github.libretube.adapters.CommentsAdapter
import com.github.libretube.adapters.TrendingAdapter
+import com.github.libretube.databinding.FragmentPlayerBinding
import com.github.libretube.dialogs.AddtoPlaylistDialog
import com.github.libretube.dialogs.DownloadDialog
import com.github.libretube.dialogs.ShareDialog
@@ -102,6 +103,8 @@ var isMiniPlayerVisible = false
class PlayerFragment : Fragment() {
private val TAG = "PlayerFragment"
+ private lateinit var binding: FragmentPlayerBinding
+
private var videoId: String? = null
private var playlistId: String? = null
private var sId: Int = 0
@@ -157,8 +160,9 @@ class PlayerFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
+ binding = FragmentPlayerBinding.inflate(layoutInflater, container, false)
// Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_player, container, false)
+ return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -172,17 +176,16 @@ class PlayerFragment : Fragment() {
}
private fun initializeTransitionLayout(view: View) {
- val playerDescription = view.findViewById(R.id.player_description)
videoId = videoId!!.replace("/watch?v=", "")
- relDownloadVideo = view.findViewById(R.id.relPlayer_download)
+
val mainActivity = activity as MainActivity
- mainActivity.findViewById(R.id.container).visibility = View.VISIBLE
- val playerMotionLayout = view.findViewById(R.id.playerMotionLayout)
- motionLayout = playerMotionLayout
- exoPlayerView = view.findViewById(R.id.player)
+ mainActivity.binding.container.visibility = View.VISIBLE
+
+ motionLayout = binding.playerMotionLayout
+ exoPlayerView = binding.player
view.findViewById(R.id.player_description).text = videoId
- playerMotionLayout.addTransitionListener(object : MotionLayout.TransitionListener {
+ motionLayout.addTransitionListener(object : MotionLayout.TransitionListener {
override fun onTransitionStarted(
motionLayout: MotionLayout?,
startId: Int,
@@ -198,7 +201,7 @@ class PlayerFragment : Fragment() {
) {
val mainActivity = activity as MainActivity
val mainMotionLayout =
- mainActivity.findViewById(R.id.mainMotionLayout)
+ mainActivity.binding.mainMotionLayout
mainMotionLayout.progress = abs(progress)
exoPlayerView.hideController()
eId = endId
@@ -209,7 +212,7 @@ class PlayerFragment : Fragment() {
println(currentId)
val mainActivity = activity as MainActivity
val mainMotionLayout =
- mainActivity.findViewById(R.id.mainMotionLayout)
+ mainActivity.binding.mainMotionLayout
if (currentId == eId) {
isMiniPlayerVisible = true
exoPlayerView.useController = false
@@ -230,10 +233,10 @@ class PlayerFragment : Fragment() {
}
})
- playerMotionLayout.progress = 1.toFloat()
- playerMotionLayout.transitionToStart()
+ motionLayout.progress = 1.toFloat()
+ motionLayout.transitionToStart()
- view.findViewById(R.id.close_imageView).setOnClickListener {
+ binding.closeImageView.setOnClickListener {
isMiniPlayerVisible = false
motionLayout.transitionToEnd()
val mainActivity = activity as MainActivity
@@ -251,25 +254,23 @@ class PlayerFragment : Fragment() {
.remove(this)
.commit()
}
- val playImageView = view.findViewById(R.id.play_imageView)
- playImageView.setOnClickListener {
+ binding.playImageView.setOnClickListener {
paused = if (paused) {
- playImageView.setImageResource(R.drawable.ic_pause)
+ binding.playImageView.setImageResource(R.drawable.ic_pause)
exoPlayer.play()
false
} else {
- playImageView.setImageResource(R.drawable.ic_play)
+ binding.playImageView.setImageResource(R.drawable.ic_play)
exoPlayer.pause()
true
}
}
// video description and chapters toggle
- val descLinLayout = view.findViewById(R.id.desc_linLayout)
- view.findViewById(R.id.player_title_layout).setOnClickListener {
- val arrowImageView = view.findViewById(R.id.player_description_arrow)
- arrowImageView.animate().rotationBy(180F).setDuration(250).start()
- descLinLayout.visibility = if (descLinLayout.isVisible) View.GONE else View.VISIBLE
+ binding.playerTitleLayout.setOnClickListener {
+ binding.playerDescriptionArrow.animate().rotationBy(180F).setDuration(250).start()
+ binding.descLinLayout.visibility =
+ if (binding.descLinLayout.isVisible) View.GONE else View.VISIBLE
}
view.findViewById(R.id.comments_toggle)
@@ -279,8 +280,6 @@ class PlayerFragment : Fragment() {
val fullScreenButton = view.findViewById(R.id.fullscreen)
val exoTitle = view.findViewById(R.id.exo_title)
- val mainContainer = view.findViewById(R.id.main_container)
- val linLayout = view.findViewById(R.id.linLayout)
// FullScreen button trigger
fullScreenButton.setOnClickListener {
@@ -291,8 +290,8 @@ class PlayerFragment : Fragment() {
enableTransition(R.id.yt_transition, false)
}
- mainContainer.isClickable = true
- linLayout.visibility = View.GONE
+ binding.mainContainer.isClickable = true
+ binding.linLayout.visibility = View.GONE
fullScreenButton.setImageResource(R.drawable.ic_fullscreen_exit)
exoTitle.visibility = View.VISIBLE
@@ -304,8 +303,8 @@ class PlayerFragment : Fragment() {
enableTransition(R.id.yt_transition, true)
}
- mainContainer.isClickable = false
- linLayout.visibility = View.VISIBLE
+ binding.mainContainer.isClickable = false
+ binding.linLayout.visibility = View.VISIBLE
fullScreenButton.setImageResource(R.drawable.ic_fullscreen)
exoTitle.visibility = View.INVISIBLE
@@ -714,7 +713,7 @@ class PlayerFragment : Fragment() {
// check if livestream
if (response.duration!! > 0) {
// download clicked
- relDownloadVideo.setOnClickListener {
+ binding.relPlayerDownload.setOnClickListener {
if (!IS_DOWNLOAD_RUNNING) {
val newFragment = DownloadDialog()
val bundle = Bundle()
From 0498e52f5d8376e40eba0332c85353335bfdf0c4 Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Thu, 30 Jun 2022 21:25:40 +0200
Subject: [PATCH 023/202] viewbind playerfragment
---
.../libretube/fragments/PlayerFragment.kt | 128 +++++++-----------
.../layout/exo_styled_player_control_view.xml | 2 +-
app/src/main/res/layout/fragment_player.xml | 2 +-
3 files changed, 54 insertions(+), 78 deletions(-)
diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
index a6762f05d..a928122dc 100644
--- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
@@ -22,14 +22,10 @@ import android.view.ViewGroup
import android.widget.Button
import android.widget.FrameLayout
import android.widget.ImageButton
-import android.widget.ImageView
import android.widget.LinearLayout
-import android.widget.RelativeLayout
-import android.widget.ScrollView
import android.widget.TextView
import android.widget.Toast
import androidx.constraintlayout.motion.widget.MotionLayout
-import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.net.toUri
import androidx.core.os.bundleOf
import androidx.core.view.isVisible
@@ -37,7 +33,6 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R
import com.github.libretube.adapters.ChaptersAdapter
@@ -117,14 +112,11 @@ class PlayerFragment : Fragment() {
private var isSubscribed: Boolean = false
- private lateinit var relatedRecView: RecyclerView
- private lateinit var commentsRecView: RecyclerView
private var commentsAdapter: CommentsAdapter? = null
private var commentsLoaded: Boolean? = false
private var nextPage: String? = null
private var isLoading = true
private lateinit var exoPlayerView: StyledPlayerView
- private lateinit var motionLayout: MotionLayout
private lateinit var exoPlayer: ExoPlayer
private lateinit var segmentData: Segments
private var relatedStreamsEnabled = true
@@ -136,8 +128,6 @@ class PlayerFragment : Fragment() {
private var isPlayerLocked: Boolean = false
- private lateinit var relDownloadVideo: LinearLayout
-
private lateinit var mediaSession: MediaSessionCompat
private lateinit var mediaSessionConnector: MediaSessionConnector
private lateinit var playerNotification: PlayerNotificationManager
@@ -159,7 +149,7 @@ class PlayerFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
- ): View? {
+ ): View {
binding = FragmentPlayerBinding.inflate(layoutInflater, container, false)
// Inflate the layout for this fragment
return binding.root
@@ -181,11 +171,9 @@ class PlayerFragment : Fragment() {
val mainActivity = activity as MainActivity
mainActivity.binding.container.visibility = View.VISIBLE
- motionLayout = binding.playerMotionLayout
exoPlayerView = binding.player
-
- view.findViewById(R.id.player_description).text = videoId
- motionLayout.addTransitionListener(object : MotionLayout.TransitionListener {
+
+ binding.playerMotionLayout.addTransitionListener(object : MotionLayout.TransitionListener {
override fun onTransitionStarted(
motionLayout: MotionLayout?,
startId: Int,
@@ -225,7 +213,7 @@ class PlayerFragment : Fragment() {
}
override fun onTransitionTrigger(
- motionLayout: MotionLayout?,
+ MotionLayout: MotionLayout?,
triggerId: Int,
positive: Boolean,
progress: Float
@@ -233,12 +221,12 @@ class PlayerFragment : Fragment() {
}
})
- motionLayout.progress = 1.toFloat()
- motionLayout.transitionToStart()
+ binding.playerMotionLayout.progress = 1.toFloat()
+ binding.playerMotionLayout.transitionToStart()
binding.closeImageView.setOnClickListener {
isMiniPlayerVisible = false
- motionLayout.transitionToEnd()
+ binding.playerMotionLayout.transitionToEnd()
val mainActivity = activity as MainActivity
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
mainActivity.supportFragmentManager.beginTransaction()
@@ -247,7 +235,7 @@ class PlayerFragment : Fragment() {
}
view.findViewById(R.id.close_imageButton).setOnClickListener {
isMiniPlayerVisible = false
- motionLayout.transitionToEnd()
+ binding.playerMotionLayout.transitionToEnd()
val mainActivity = activity as MainActivity
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
mainActivity.supportFragmentManager.beginTransaction()
@@ -285,7 +273,7 @@ class PlayerFragment : Fragment() {
fullScreenButton.setOnClickListener {
exoPlayerView.hideController()
if (!isFullScreen) {
- with(motionLayout) {
+ with(binding.playerMotionLayout) {
getConstraintSet(R.id.start).constrainHeight(R.id.player, -1)
enableTransition(R.id.yt_transition, false)
}
@@ -298,7 +286,7 @@ class PlayerFragment : Fragment() {
val mainActivity = activity as MainActivity
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
} else {
- with(motionLayout) {
+ with(binding.playerMotionLayout) {
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
enableTransition(R.id.yt_transition, true)
}
@@ -342,32 +330,28 @@ class PlayerFragment : Fragment() {
isPlayerLocked = !isPlayerLocked
}
- val scrollView = view.findViewById(R.id.player_scrollView)
- scrollView.viewTreeObserver
+ binding.playerScrollView.viewTreeObserver
.addOnScrollChangedListener {
- if (scrollView.getChildAt(0).bottom
- == (scrollView.height + scrollView.scrollY) &&
+ if (binding.playerScrollView.getChildAt(0).bottom
+ == (binding.playerScrollView.height + binding.playerScrollView.scrollY) &&
nextPage != null
) {
fetchNextComments()
}
}
- commentsRecView = view.findViewById(R.id.comments_recView)
- commentsRecView.layoutManager = LinearLayoutManager(view.context)
+ binding.commentsRecView.layoutManager = LinearLayoutManager(view.context)
+ binding.commentsRecView.setItemViewCacheSize(20)
- commentsRecView.setItemViewCacheSize(20)
-
- relatedRecView = view.findViewById(R.id.player_recView)
- relatedRecView.layoutManager =
+ binding.relatedRecView.layoutManager =
GridLayoutManager(view.context, resources.getInteger(R.integer.grid_items))
}
private fun toggleComments() {
- commentsRecView.visibility =
- if (commentsRecView.isVisible) View.GONE else View.VISIBLE
- relatedRecView.visibility =
- if (relatedRecView.isVisible) View.GONE else View.VISIBLE
+ binding.commentsRecView.visibility =
+ if (binding.commentsRecView.isVisible) View.GONE else View.VISIBLE
+ binding.relatedRecView.visibility =
+ if (binding.relatedRecView.isVisible) View.GONE else View.VISIBLE
if (!commentsLoaded!!) fetchComments()
}
@@ -637,18 +621,17 @@ class PlayerFragment : Fragment() {
}
private fun initializePlayerView(view: View, response: Streams) {
- view.findViewById(R.id.player_views_info).text =
+ binding.playerViewsInfo.text =
context?.getString(R.string.views, response.views.formatShort()) +
" • " + response.uploadDate
- view.findViewById(R.id.textLike).text = response.likes.formatShort()
- view.findViewById(R.id.textDislike).text = response.dislikes.formatShort()
- val channelImage = view.findViewById(R.id.player_channelImage)
- Picasso.get().load(response.uploaderAvatar).into(channelImage)
- view.findViewById(R.id.player_channelName).text = response.uploader
+ binding.textLike.text = response.likes.formatShort()
+ binding.textDislike.text = response.dislikes.formatShort()
+ Picasso.get().load(response.uploaderAvatar).into(binding.playerChannelImage)
+ binding.playerChannelName.text = response.uploader
- view.findViewById(R.id.title_textView).text = response.title
- view.findViewById(R.id.player_title).text = response.title
- view.findViewById(R.id.player_description).text = response.description
+ binding.titleTextView.text = response.title
+ binding.playerTitle.text = response.title
+ binding.playerDescription.text = response.description
view.findViewById(R.id.exo_title).text = response.title
@@ -689,24 +672,21 @@ class PlayerFragment : Fragment() {
if (playWhenReady && playbackState == Player.STATE_READY) {
// media actually playing
transitioning = false
- view.findViewById(R.id.play_imageView)
- .setImageResource(R.drawable.ic_pause)
+ binding.playImageView.setImageResource(R.drawable.ic_pause)
} else if (playWhenReady) {
// might be idle (plays after prepare()),
// buffering (plays when data available)
// or ended (plays when seek away from end)
- view.findViewById(R.id.play_imageView)
- .setImageResource(R.drawable.ic_play)
+ binding.playImageView.setImageResource(R.drawable.ic_play)
} else {
// player paused in any state
- view.findViewById(R.id.play_imageView)
- .setImageResource(R.drawable.ic_play)
+ binding.playImageView.setImageResource(R.drawable.ic_play)
}
}
})
// share button
- view.findViewById(R.id.relPlayer_share).setOnClickListener {
+ binding.relPlayerShare.setOnClickListener {
val shareDialog = ShareDialog(videoId!!, false)
shareDialog.show(childFragmentManager, "ShareDialog")
}
@@ -731,7 +711,7 @@ class PlayerFragment : Fragment() {
}
if (response.hls != null) {
- view.findViewById(R.id.relPlayer_vlc).setOnClickListener {
+ binding.relPlayerVlc.setOnClickListener {
// start an intent with video as mimetype using the hls stream
val uri: Uri = Uri.parse(response.hls)
val intent = Intent()
@@ -748,14 +728,14 @@ class PlayerFragment : Fragment() {
}
if (relatedStreamsEnabled) {
// only show related streams if enabled
- relatedRecView.adapter = TrendingAdapter(
+ binding.relatedRecView.adapter = TrendingAdapter(
response.relatedStreams!!,
childFragmentManager
)
}
// set video description
val description = response.description!!
- view.findViewById(R.id.player_description).text =
+ binding.playerDescription.text =
// detect whether the description is html formatted
if (description.contains("<") && description.contains(">")) {
if (SDK_INT >= Build.VERSION_CODES.N) {
@@ -768,19 +748,18 @@ class PlayerFragment : Fragment() {
description
}
- view.findViewById(R.id.player_channel).setOnClickListener {
+ binding.playerChannel.setOnClickListener {
val activity = view.context as MainActivity
val bundle = bundleOf("channel_id" to response.uploaderUrl)
activity.navController.navigate(R.id.channel, bundle)
- activity.findViewById(R.id.mainMotionLayout).transitionToEnd()
- view.findViewById(R.id.playerMotionLayout).transitionToEnd()
+ activity.binding.mainMotionLayout.transitionToEnd()
+ binding.playerMotionLayout.transitionToEnd()
}
val token = PreferenceHelper.getToken(requireContext())
if (token != "") {
val channelId = response.uploaderUrl?.replace("/channel/", "")
- val subButton = view.findViewById(R.id.player_subscribe)
- isSubscribed(subButton, channelId!!)
- view.findViewById(R.id.save).setOnClickListener {
+ isSubscribed(binding.playerSubscribe, channelId!!)
+ binding.save.setOnClickListener {
val newFragment = AddtoPlaylistDialog()
val bundle = Bundle()
bundle.putString("videoId", videoId)
@@ -791,13 +770,11 @@ class PlayerFragment : Fragment() {
}
private fun initializeChapters(chapters: List) {
- val chaptersRecView = view?.findViewById(R.id.chapters_recView)
-
if (chapters.isNotEmpty()) {
- chaptersRecView?.layoutManager =
+ binding.chaptersRecView.layoutManager =
LinearLayoutManager(this.context, LinearLayoutManager.HORIZONTAL, false)
- chaptersRecView?.adapter = ChaptersAdapter(chapters, exoPlayer)
- chaptersRecView?.visibility = View.VISIBLE
+ binding.chaptersRecView.adapter = ChaptersAdapter(chapters, exoPlayer)
+ binding.chaptersRecView.visibility = View.VISIBLE
}
}
@@ -1142,7 +1119,7 @@ class PlayerFragment : Fragment() {
return@launchWhenCreated
}
commentsAdapter = CommentsAdapter(videoId!!, commentsResponse.comments)
- commentsRecView.adapter = commentsAdapter
+ binding.commentsRecView.adapter = commentsAdapter
nextPage = commentsResponse.nextpage
commentsLoaded = true
isLoading = false
@@ -1175,35 +1152,34 @@ class PlayerFragment : Fragment() {
if (isInPictureInPictureMode) {
exoPlayerView.hideController()
exoPlayerView.useController = false
- with(motionLayout) {
+ with(binding.playerMotionLayout) {
getConstraintSet(R.id.start).constrainHeight(R.id.player, -1)
enableTransition(R.id.yt_transition, false)
}
- view?.findViewById(R.id.main_container)?.isClickable = true
- view?.findViewById(R.id.top_bar)?.visibility = View.GONE
+ binding.mainContainer.isClickable = true
+ view?.findViewById(R.id.exo_top_bar)?.visibility = View.GONE
val mainActivity = activity as MainActivity
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
isFullScreen = false
} else {
- with(motionLayout) {
+ with(binding.playerMotionLayout) {
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
enableTransition(R.id.yt_transition, true)
}
exoPlayerView.showController()
exoPlayerView.useController = true
- view?.findViewById(R.id.main_container)?.isClickable = false
- view?.findViewById(R.id.top_bar)?.visibility = View.VISIBLE
+ binding.mainContainer.isClickable = false
+ view?.findViewById(R.id.exo_top_bar)?.visibility = View.VISIBLE
}
}
fun onUserLeaveHint() {
val bounds = Rect()
- val scrollView = view?.findViewById(R.id.player_scrollView)
- scrollView?.getHitRect(bounds)
+ binding.playerScrollView.getHitRect(bounds)
if (SDK_INT >= Build.VERSION_CODES.O &&
exoPlayer.isPlaying && (
- scrollView?.getLocalVisibleRect(bounds) == true ||
+ binding.playerScrollView.getLocalVisibleRect(bounds) == true ||
isFullScreen
)
) {
diff --git a/app/src/main/res/layout/exo_styled_player_control_view.xml b/app/src/main/res/layout/exo_styled_player_control_view.xml
index 02d9d5655..d0f2f93f2 100644
--- a/app/src/main/res/layout/exo_styled_player_control_view.xml
+++ b/app/src/main/res/layout/exo_styled_player_control_view.xml
@@ -28,7 +28,7 @@
android:background="@color/exo_black_opacity_60" />
Date: Thu, 30 Jun 2022 21:26:16 +0200
Subject: [PATCH 024/202] ktlint
---
.../main/java/com/github/libretube/fragments/PlayerFragment.kt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
index a928122dc..263352f56 100644
--- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
@@ -172,7 +172,7 @@ class PlayerFragment : Fragment() {
mainActivity.binding.container.visibility = View.VISIBLE
exoPlayerView = binding.player
-
+
binding.playerMotionLayout.addTransitionListener(object : MotionLayout.TransitionListener {
override fun onTransitionStarted(
motionLayout: MotionLayout?,
From 9ebd3d5f7e517fc4939f2d1274dd53fc5065ae9d Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Fri, 1 Jul 2022 10:19:00 +0200
Subject: [PATCH 025/202] convert all dialogs to viewbinding
---
.../libretube/dialogs/AddtoPlaylistDialog.kt | 34 +++++-----
.../libretube/dialogs/CreatePlaylistDialog.kt | 24 +++----
.../libretube/dialogs/CustomInstanceDialog.kt | 30 +++------
.../libretube/dialogs/DeleteAccountDialog.kt | 24 +++----
.../libretube/dialogs/DownloadDialog.kt | 30 ++++-----
.../github/libretube/dialogs/LoginDialog.kt | 66 ++++++++-----------
.../github/libretube/dialogs/LogoutDialog.kt | 46 +++++++++++++
.../libretube/preferences/InstanceSettings.kt | 13 +++-
app/src/main/res/layout/dialog_logout.xml | 1 +
9 files changed, 140 insertions(+), 128 deletions(-)
create mode 100644 app/src/main/java/com/github/libretube/dialogs/LogoutDialog.kt
diff --git a/app/src/main/java/com/github/libretube/dialogs/AddtoPlaylistDialog.kt b/app/src/main/java/com/github/libretube/dialogs/AddtoPlaylistDialog.kt
index cabc0826b..0cc9119ad 100644
--- a/app/src/main/java/com/github/libretube/dialogs/AddtoPlaylistDialog.kt
+++ b/app/src/main/java/com/github/libretube/dialogs/AddtoPlaylistDialog.kt
@@ -4,17 +4,14 @@ import android.app.Dialog
import android.os.Bundle
import android.util.Log
import android.util.TypedValue
-import android.view.View
import android.widget.ArrayAdapter
-import android.widget.Button
-import android.widget.Spinner
-import android.widget.TextView
import android.widget.Toast
import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.github.libretube.R
+import com.github.libretube.databinding.DialogAddtoplaylistBinding
import com.github.libretube.obj.PlaylistId
import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
@@ -24,23 +21,22 @@ import java.io.IOException
class AddtoPlaylistDialog : DialogFragment() {
private val TAG = "AddToPlaylistDialog"
+ private lateinit var binding: DialogAddtoplaylistBinding
+
private lateinit var videoId: String
private lateinit var token: String
- private lateinit var spinner: Spinner
- private lateinit var button: Button
+
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return activity?.let {
videoId = arguments?.getString("videoId")!!
val builder = MaterialAlertDialogBuilder(it)
// Get the layout inflater
- val inflater = requireActivity().layoutInflater
+ binding = DialogAddtoplaylistBinding.inflate(layoutInflater)
+
token = PreferenceHelper.getToken(requireContext())
- var view: View = inflater.inflate(R.layout.dialog_addtoplaylist, null)
- spinner = view.findViewById(R.id.playlists_spinner)
- button = view.findViewById(R.id.addToPlaylist)
- if (token != "") {
- fetchPlaylists()
- }
+
+ if (token != "") fetchPlaylists()
+
val typedValue = TypedValue()
this.requireActivity().theme.resolveAttribute(R.attr.colorPrimaryDark, typedValue, true)
val hexColor = String.format("#%06X", (0xFFFFFF and typedValue.data))
@@ -48,9 +44,9 @@ class AddtoPlaylistDialog : DialogFragment() {
"LibreTube ",
HtmlCompat.FROM_HTML_MODE_COMPACT
)
- view.findViewById(R.id.title).text = appName
+ binding.title.text = appName
- builder.setView(view)
+ builder.setView(binding.root)
builder.create()
} ?: throw IllegalStateException("Activity cannot be null")
}
@@ -80,10 +76,12 @@ class AddtoPlaylistDialog : DialogFragment() {
arrayAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item
)
- spinner.adapter = arrayAdapter
+ binding.playlistsSpinner.adapter = arrayAdapter
runOnUiThread {
- button.setOnClickListener {
- addToPlaylist(response[spinner.selectedItemPosition].id!!)
+ binding.addToPlaylist.setOnClickListener {
+ addToPlaylist(
+ response[binding.playlistsSpinner.selectedItemPosition].id!!
+ )
}
}
} else {
diff --git a/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt b/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt
index d08256704..c08a9096a 100644
--- a/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt
+++ b/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt
@@ -4,32 +4,29 @@ import android.app.Dialog
import android.os.Bundle
import android.util.Log
import android.util.TypedValue
-import android.view.View
-import android.widget.Button
-import android.widget.TextView
import android.widget.Toast
import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.github.libretube.R
+import com.github.libretube.databinding.DialogCreatePlaylistBinding
import com.github.libretube.fragments.Library
import com.github.libretube.obj.Playlists
import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
import com.google.android.material.dialog.MaterialAlertDialogBuilder
-import com.google.android.material.textfield.TextInputEditText
import retrofit2.HttpException
import java.io.IOException
class CreatePlaylistDialog : DialogFragment() {
val TAG = "CreatePlaylistDialog"
private var token: String = ""
+ private lateinit var binding: DialogCreatePlaylistBinding
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return activity?.let {
val builder = MaterialAlertDialogBuilder(it)
- val inflater = requireActivity().layoutInflater
- val view: View = inflater.inflate(R.layout.dialog_create_playlist, null)
+ binding = DialogCreatePlaylistBinding.inflate(layoutInflater)
val typedValue = TypedValue()
this.requireActivity().theme.resolveAttribute(R.attr.colorPrimaryDark, typedValue, true)
@@ -38,21 +35,18 @@ class CreatePlaylistDialog : DialogFragment() {
"LibreTube ",
HtmlCompat.FROM_HTML_MODE_COMPACT
)
- view.findViewById(R.id.title).text = appName
+ binding.title.text = appName
- val cancelBtn = view.findViewById(R.id.cancel_button)
- cancelBtn.setOnClickListener {
+ binding.cancelButton.setOnClickListener {
dismiss()
}
token = PreferenceHelper.getToken(requireContext())
- val playlistName = view.findViewById(R.id.playlist_name)
- val createPlaylistBtn = view.findViewById(R.id.create_new_playlist)
- createPlaylistBtn.setOnClickListener {
+ binding.createNewPlaylist.setOnClickListener {
// avoid creating the same playlist multiple times by spamming the button
- createPlaylistBtn.setOnClickListener(null)
- val listName = playlistName.text.toString()
+ binding.createNewPlaylist.setOnClickListener(null)
+ val listName = binding.playlistName.text.toString()
if (listName != "") {
createPlaylist(listName)
} else {
@@ -60,7 +54,7 @@ class CreatePlaylistDialog : DialogFragment() {
}
}
- builder.setView(view)
+ builder.setView(binding.root)
builder.create()
} ?: throw IllegalStateException("Activity cannot be null")
}
diff --git a/app/src/main/java/com/github/libretube/dialogs/CustomInstanceDialog.kt b/app/src/main/java/com/github/libretube/dialogs/CustomInstanceDialog.kt
index 94df2f77d..9cd1769fe 100644
--- a/app/src/main/java/com/github/libretube/dialogs/CustomInstanceDialog.kt
+++ b/app/src/main/java/com/github/libretube/dialogs/CustomInstanceDialog.kt
@@ -3,44 +3,34 @@ package com.github.libretube.dialogs
import android.app.Dialog
import android.os.Bundle
import android.util.TypedValue
-import android.view.View
-import android.widget.Button
-import android.widget.TextView
import android.widget.Toast
import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment
import com.github.libretube.R
+import com.github.libretube.databinding.DialogCustomInstanceBinding
import com.github.libretube.obj.CustomInstance
import com.github.libretube.util.PreferenceHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder
-import com.google.android.material.textfield.TextInputEditText
import java.net.URL
class CustomInstanceDialog : DialogFragment() {
val TAG = "CustomInstanceDialog"
+ private lateinit var binding: DialogCustomInstanceBinding
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return activity?.let {
val builder = MaterialAlertDialogBuilder(it)
- val inflater = requireActivity().layoutInflater
- val view: View = inflater.inflate(R.layout.dialog_custom_instance, null)
+ binding = DialogCustomInstanceBinding.inflate(layoutInflater)
- val instanceNameEditText = view.findViewById(R.id.instanceName)
- val instanceApiUrlEditText = view.findViewById(R.id.instanceApiUrl)
- val instanceFrontendUrlEditText = view
- .findViewById(R.id.instanceFrontendUrl)
-
- val addInstanceButton = view.findViewById(R.id.addInstance)
- val cancelButton = view.findViewById(R.id.cancel)
- cancelButton.setOnClickListener {
+ binding.cancel.setOnClickListener {
dismiss()
}
- addInstanceButton.setOnClickListener {
+ binding.addInstance.setOnClickListener {
val customInstance = CustomInstance()
- customInstance.name = instanceNameEditText.text.toString()
- customInstance.apiUrl = instanceApiUrlEditText.text.toString()
- customInstance.frontendUrl = instanceFrontendUrlEditText.text.toString()
+ customInstance.name = binding.instanceName.text.toString()
+ customInstance.apiUrl = binding.instanceApiUrl.text.toString()
+ customInstance.frontendUrl = binding.instanceFrontendUrl.text.toString()
if (
customInstance.name != "" &&
@@ -80,9 +70,9 @@ class CustomInstanceDialog : DialogFragment() {
"LibreTube ",
HtmlCompat.FROM_HTML_MODE_COMPACT
)
- view.findViewById(R.id.title).text = appName
+ binding.title.text = appName
- builder.setView(view)
+ builder.setView(binding.root)
builder.create()
} ?: throw IllegalStateException("Activity cannot be null")
}
diff --git a/app/src/main/java/com/github/libretube/dialogs/DeleteAccountDialog.kt b/app/src/main/java/com/github/libretube/dialogs/DeleteAccountDialog.kt
index a9e0da91d..d815c490d 100644
--- a/app/src/main/java/com/github/libretube/dialogs/DeleteAccountDialog.kt
+++ b/app/src/main/java/com/github/libretube/dialogs/DeleteAccountDialog.kt
@@ -4,14 +4,12 @@ import android.app.Dialog
import android.os.Bundle
import android.util.Log
import android.util.TypedValue
-import android.widget.Button
-import android.widget.EditText
-import android.widget.TextView
import android.widget.Toast
import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.github.libretube.R
+import com.github.libretube.databinding.DialogDeleteAccountBinding
import com.github.libretube.obj.DeleteUserRequest
import com.github.libretube.requireMainActivityRestart
import com.github.libretube.util.PreferenceHelper
@@ -20,22 +18,20 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
class DeleteAccountDialog : DialogFragment() {
private val TAG = "DeleteAccountDialog"
- lateinit var username: EditText
- lateinit var password: EditText
+ private lateinit var binding: DialogDeleteAccountBinding
+
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return activity?.let {
val builder = MaterialAlertDialogBuilder(it)
- val inflater = requireActivity().layoutInflater
- val view = inflater.inflate(R.layout.dialog_delete_account, null)
+ binding = DialogDeleteAccountBinding.inflate(layoutInflater)
- view.findViewById(R.id.cancel_button).setOnClickListener {
+ binding.cancelButton.setOnClickListener {
dialog?.dismiss()
}
- password = view.findViewById(R.id.delete_password)
- view.findViewById(R.id.delete_account_confirm).setOnClickListener {
- if (password.text.toString() != "") {
- deleteAccount(password.text.toString())
+ binding.deleteAccountConfirm.setOnClickListener {
+ if (binding.deletePassword.text.toString() != "") {
+ deleteAccount(binding.deletePassword.text.toString())
} else {
Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
}
@@ -48,9 +44,9 @@ class DeleteAccountDialog : DialogFragment() {
"LibreTube ",
HtmlCompat.FROM_HTML_MODE_COMPACT
)
- view.findViewById(R.id.title).text = appName
+ binding.title.text = appName
- builder.setView(view)
+ builder.setView(binding.root)
builder.create()
} ?: throw IllegalStateException("Activity cannot be null")
}
diff --git a/app/src/main/java/com/github/libretube/dialogs/DownloadDialog.kt b/app/src/main/java/com/github/libretube/dialogs/DownloadDialog.kt
index cc467c313..3c5cc2677 100644
--- a/app/src/main/java/com/github/libretube/dialogs/DownloadDialog.kt
+++ b/app/src/main/java/com/github/libretube/dialogs/DownloadDialog.kt
@@ -9,22 +9,20 @@ import android.os.Bundle
import android.os.Environment
import android.util.Log
import android.util.TypedValue
-import android.view.View
import android.widget.ArrayAdapter
-import android.widget.Button
-import android.widget.Spinner
-import android.widget.TextView
import androidx.core.app.ActivityCompat
import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment
import com.github.libretube.MainActivity
import com.github.libretube.R
+import com.github.libretube.databinding.DialogDownloadBinding
import com.github.libretube.obj.Streams
import com.github.libretube.services.DownloadService
import com.google.android.material.dialog.MaterialAlertDialogBuilder
class DownloadDialog : DialogFragment() {
private val TAG = "DownloadDialog"
+ private lateinit var binding: DialogDownloadBinding
private lateinit var streams: Streams
private lateinit var videoId: String
@@ -37,9 +35,7 @@ class DownloadDialog : DialogFragment() {
val mainActivity = activity as MainActivity
val builder = MaterialAlertDialogBuilder(it)
- // Get the layout inflater
- val inflater = requireActivity().layoutInflater
- var view: View = inflater.inflate(R.layout.dialog_download, null)
+ binding = DialogDownloadBinding.inflate(layoutInflater)
// request storage permissions if not granted yet
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
@@ -103,29 +99,27 @@ class DownloadDialog : DialogFragment() {
audioUrl.add(audio.url!!)
}
- val videoSpinner = view.findViewById(R.id.video_spinner)
val videoArrayAdapter = ArrayAdapter(
requireContext(),
android.R.layout.simple_spinner_item,
vidName
)
videoArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
- videoSpinner.adapter = videoArrayAdapter
- videoSpinner.setSelection(1)
+ binding.videoSpinner.adapter = videoArrayAdapter
+ binding.videoSpinner.setSelection(1)
- val audioSpinner = view.findViewById(R.id.audio_spinner)
val audioArrayAdapter = ArrayAdapter(
requireContext(),
android.R.layout.simple_spinner_item,
audioName
)
audioArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
- audioSpinner.adapter = audioArrayAdapter
- audioSpinner.setSelection(1)
+ binding.audioSpinner.adapter = audioArrayAdapter
+ binding.audioSpinner.setSelection(1)
- view.findViewById(R.id.download).setOnClickListener {
- val selectedAudioUrl = audioUrl[audioSpinner.selectedItemPosition]
- val selectedVideoUrl = vidUrl[videoSpinner.selectedItemPosition]
+ binding.download.setOnClickListener {
+ val selectedAudioUrl = audioUrl[binding.audioSpinner.selectedItemPosition]
+ val selectedVideoUrl = vidUrl[binding.videoSpinner.selectedItemPosition]
val intent = Intent(context, DownloadService::class.java)
intent.putExtra("videoId", videoId)
@@ -143,9 +137,9 @@ class DownloadDialog : DialogFragment() {
"LibreTube ",
HtmlCompat.FROM_HTML_MODE_COMPACT
)
- view.findViewById(R.id.title).text = appName
+ binding.title.text = appName
- builder.setView(view)
+ builder.setView(binding.root)
builder.create()
} ?: throw IllegalStateException("Activity cannot be null")
}
diff --git a/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt b/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt
index 466249620..70a6cd2ea 100644
--- a/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt
+++ b/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt
@@ -4,15 +4,12 @@ import android.app.Dialog
import android.os.Bundle
import android.util.Log
import android.util.TypedValue
-import android.view.View
-import android.widget.Button
-import android.widget.EditText
-import android.widget.TextView
import android.widget.Toast
import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.github.libretube.R
+import com.github.libretube.databinding.DialogLoginBinding
import com.github.libretube.obj.Login
import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
@@ -22,45 +19,34 @@ import java.io.IOException
class LoginDialog : DialogFragment() {
private val TAG = "LoginDialog"
- lateinit var username: EditText
- lateinit var password: EditText
+ private lateinit var binding: DialogLoginBinding
+
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return activity?.let {
val builder = MaterialAlertDialogBuilder(it)
// Get the layout inflater
- val inflater = requireActivity().layoutInflater
- val token = PreferenceHelper.getToken(requireContext())
- var view: View
- Log.e("dafaq", token!!)
- if (token != "") {
- val user = PreferenceHelper.getUsername(requireContext())
- view = inflater.inflate(R.layout.dialog_logout, null)
- view.findViewById(R.id.user).text =
- view.findViewById(R.id.user).text.toString() + " (" + user + ")"
- view.findViewById(R.id.logout).setOnClickListener {
- Toast.makeText(context, R.string.loggedout, Toast.LENGTH_SHORT).show()
- PreferenceHelper.setToken(requireContext(), "")
- dialog?.dismiss()
+ binding = DialogLoginBinding.inflate(layoutInflater)
+
+ binding.login.setOnClickListener {
+ if (binding.username.text.toString() != "" && binding.password.text.toString() != "") {
+ val login = Login(binding.username.text.toString(), binding.password.text.toString())
+ login(login)
+ } else {
+ Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
}
- } else {
- view = inflater.inflate(R.layout.dialog_login, null)
- username = view.findViewById(R.id.username)
- password = view.findViewById(R.id.password)
- view.findViewById(R.id.login).setOnClickListener {
- if (username.text.toString() != "" && password.text.toString() != "") {
- val login = Login(username.text.toString(), password.text.toString())
- login(login)
- } else {
- Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
- }
- }
- view.findViewById(R.id.register).setOnClickListener {
- if (username.text.toString() != "" && password.text.toString() != "") {
- val login = Login(username.text.toString(), password.text.toString())
- register(login)
- } else {
- Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
- }
+ }
+ binding.register.setOnClickListener {
+ if (
+ binding.username.text.toString() != "" &&
+ binding.password.text.toString() != ""
+ ) {
+ val login = Login(
+ binding.username.text.toString(),
+ binding.password.text.toString()
+ )
+ register(login)
+ } else {
+ Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
}
}
@@ -71,9 +57,9 @@ class LoginDialog : DialogFragment() {
"LibreTube ",
HtmlCompat.FROM_HTML_MODE_COMPACT
)
- view.findViewById(R.id.title).text = appName
+ binding.title.text = appName
- builder.setView(view)
+ builder.setView(binding.root)
builder.create()
} ?: throw IllegalStateException("Activity cannot be null")
}
diff --git a/app/src/main/java/com/github/libretube/dialogs/LogoutDialog.kt b/app/src/main/java/com/github/libretube/dialogs/LogoutDialog.kt
new file mode 100644
index 000000000..5ee1b4b37
--- /dev/null
+++ b/app/src/main/java/com/github/libretube/dialogs/LogoutDialog.kt
@@ -0,0 +1,46 @@
+package com.github.libretube.dialogs
+
+import android.app.Dialog
+import android.os.Bundle
+import android.util.TypedValue
+import android.widget.Toast
+import androidx.core.text.HtmlCompat
+import androidx.fragment.app.DialogFragment
+import com.github.libretube.R
+import com.github.libretube.databinding.DialogLogoutBinding
+import com.github.libretube.util.PreferenceHelper
+import com.google.android.material.dialog.MaterialAlertDialogBuilder
+
+class LogoutDialog : DialogFragment() {
+ private val TAG = "LogoutDialog"
+ private lateinit var binding: DialogLogoutBinding
+
+ override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
+ return activity?.let {
+ val builder = MaterialAlertDialogBuilder(it)
+ binding = DialogLogoutBinding.inflate(layoutInflater)
+
+ val user = PreferenceHelper.getUsername(requireContext())
+
+ binding.user.text =
+ binding.user.text.toString() + " (" + user + ")"
+ binding.logout.setOnClickListener {
+ Toast.makeText(context, R.string.loggedout, Toast.LENGTH_SHORT).show()
+ PreferenceHelper.setToken(requireContext(), "")
+ dialog?.dismiss()
+ }
+
+ val typedValue = TypedValue()
+ this.requireActivity().theme.resolveAttribute(R.attr.colorPrimaryDark, typedValue, true)
+ val hexColor = String.format("#%06X", (0xFFFFFF and typedValue.data))
+ val appName = HtmlCompat.fromHtml(
+ "LibreTube ",
+ HtmlCompat.FROM_HTML_MODE_COMPACT
+ )
+ binding.title.text = appName
+
+ builder.setView(binding.root)
+ builder.create()
+ } ?: throw IllegalStateException("Activity cannot be null")
+ }
+}
diff --git a/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt b/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt
index f34042572..e5007999d 100644
--- a/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt
@@ -22,6 +22,7 @@ import com.github.libretube.R
import com.github.libretube.dialogs.CustomInstanceDialog
import com.github.libretube.dialogs.DeleteAccountDialog
import com.github.libretube.dialogs.LoginDialog
+import com.github.libretube.dialogs.LogoutDialog
import com.github.libretube.requireMainActivityRestart
import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
@@ -140,9 +141,15 @@ class InstanceSettings : PreferenceFragmentCompat() {
val login = findPreference("login_register")
login?.setOnPreferenceClickListener {
- requireMainActivityRestart = true
- val newFragment = LoginDialog()
- newFragment.show(childFragmentManager, "Login")
+ val token = PreferenceHelper.getToken(requireContext())
+ if (token == "") {
+ val newFragment = LoginDialog()
+ newFragment.show(childFragmentManager, "Login")
+ } else {
+ val newFragment = LogoutDialog()
+ newFragment.show(childFragmentManager, "Logout")
+ }
+
true
}
diff --git a/app/src/main/res/layout/dialog_logout.xml b/app/src/main/res/layout/dialog_logout.xml
index 4d3bb82ad..777d092a4 100644
--- a/app/src/main/res/layout/dialog_logout.xml
+++ b/app/src/main/res/layout/dialog_logout.xml
@@ -24,6 +24,7 @@
From 92993db5c7281b95df000b9baec6cc2bb197b909 Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Fri, 1 Jul 2022 10:29:00 +0200
Subject: [PATCH 026/202] convert prefs to viewbinding
---
.../com/github/libretube/SettingsActivity.kt | 22 +++++++++----------
.../github/libretube/dialogs/LoginDialog.kt | 3 ++-
.../libretube/preferences/AboutFragment.kt | 8 +++++--
.../libretube/preferences/AdvancedSettings.kt | 6 ++---
.../preferences/AppearanceSettings.kt | 6 ++---
.../libretube/preferences/InstanceSettings.kt | 6 ++---
.../libretube/preferences/PlayerSettings.kt | 6 ++---
.../preferences/SponsorBlockSettings.kt | 6 ++---
.../res/drawable/ic_launcher_monochrome.xml | 21 +++++++++---------
app/src/main/res/layout/chapter_column.xml | 4 ++--
10 files changed, 46 insertions(+), 42 deletions(-)
diff --git a/app/src/main/java/com/github/libretube/SettingsActivity.kt b/app/src/main/java/com/github/libretube/SettingsActivity.kt
index 8e2a3f69b..d091b6d20 100644
--- a/app/src/main/java/com/github/libretube/SettingsActivity.kt
+++ b/app/src/main/java/com/github/libretube/SettingsActivity.kt
@@ -3,11 +3,9 @@ package com.github.libretube
import android.app.NotificationManager
import android.os.Build
import android.os.Bundle
-import android.view.View
-import android.widget.ImageButton
-import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
+import com.github.libretube.databinding.ActivitySettingsBinding
import com.github.libretube.preferences.MainSettings
import com.github.libretube.util.ThemeHelper
import com.google.android.material.color.DynamicColors
@@ -17,24 +15,27 @@ var requireMainActivityRestart = false
class SettingsActivity : AppCompatActivity() {
val TAG = "SettingsActivity"
+ lateinit var binding: ActivitySettingsBinding
+
override fun onCreate(savedInstanceState: Bundle?) {
DynamicColors.applyToActivityIfAvailable(this)
ThemeHelper.updateTheme(this)
+
// makes the preference dialogs use material dialogs
setTheme(R.style.MaterialAlertDialog)
super.onCreate(savedInstanceState)
+
+ binding = ActivitySettingsBinding.inflate(layoutInflater)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
overridePendingTransition(50, 50)
}
- val view = this.findViewById(android.R.id.content)
- view.alpha = 0F
- view.animate().alpha(1F).duration = 300
+ binding.root.alpha = 0F
+ binding.root.animate().alpha(1F).duration = 300
- setContentView(R.layout.activity_settings)
+ setContentView(binding.root)
- val backButton = view.findViewById(R.id.back_imageButton)
- backButton.setOnClickListener {
+ binding.backImageButton.setOnClickListener {
onBackPressed()
}
@@ -66,8 +67,7 @@ class SettingsActivity : AppCompatActivity() {
.beginTransaction()
.replace(R.id.settings, MainSettings())
.commit()
- val topBarTextView = findViewById(R.id.topBar_textView)
- topBarTextView?.text = getString(R.string.settings)
+ binding.topBarTextView.text = getString(R.string.settings)
}
}
}
diff --git a/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt b/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt
index 70a6cd2ea..de9a1733a 100644
--- a/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt
+++ b/app/src/main/java/com/github/libretube/dialogs/LoginDialog.kt
@@ -29,7 +29,8 @@ class LoginDialog : DialogFragment() {
binding.login.setOnClickListener {
if (binding.username.text.toString() != "" && binding.password.text.toString() != "") {
- val login = Login(binding.username.text.toString(), binding.password.text.toString())
+ val login =
+ Login(binding.username.text.toString(), binding.password.text.toString())
login(login)
} else {
Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
diff --git a/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt b/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt
index eb9f25da5..4e6219386 100644
--- a/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt
+++ b/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt
@@ -17,15 +17,19 @@ import com.github.libretube.DONATE_URL
import com.github.libretube.PIPED_GITHUB_URL
import com.github.libretube.R
import com.github.libretube.WEBSITE_URL
+import com.github.libretube.databinding.FragmentAboutBinding
import com.google.android.material.dialog.MaterialAlertDialogBuilder
class AboutFragment : Fragment() {
+ private lateinit var binding: FragmentAboutBinding
+
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
- ): View? {
- return inflater.inflate(R.layout.fragment_about, container, false)
+ ): View {
+ binding = FragmentAboutBinding.inflate(layoutInflater)
+ return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
diff --git a/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt b/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt
index 1de88cba5..0f03b9736 100644
--- a/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt
@@ -1,10 +1,10 @@
package com.github.libretube.preferences
import android.os.Bundle
-import android.widget.TextView
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R
+import com.github.libretube.SettingsActivity
import com.github.libretube.requireMainActivityRestart
import com.github.libretube.util.PreferenceHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder
@@ -15,8 +15,8 @@ class AdvancedSettings : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.advanced_settings, rootKey)
- val topBarTextView = activity?.findViewById(R.id.topBar_textView)
- topBarTextView?.text = getString(R.string.advanced)
+ val settingsActivity = activity as SettingsActivity
+ settingsActivity.binding.topBarTextView.text = getString(R.string.advanced)
val clearHistory = findPreference("clear_history")
clearHistory?.setOnPreferenceClickListener {
diff --git a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt
index b8a4bd076..380424bd4 100644
--- a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt
@@ -1,12 +1,12 @@
package com.github.libretube.preferences
import android.os.Bundle
-import android.widget.TextView
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import com.github.libretube.R
+import com.github.libretube.SettingsActivity
import com.github.libretube.requireMainActivityRestart
import com.github.libretube.util.ThemeHelper
@@ -15,8 +15,8 @@ class AppearanceSettings : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.appearance_settings, rootKey)
- val topBarTextView = activity?.findViewById(R.id.topBar_textView)
- topBarTextView?.text = getString(R.string.appearance)
+ val settingsActivity = activity as SettingsActivity
+ settingsActivity.binding.topBarTextView.text = getString(R.string.appearance)
val themeToggle = findPreference("theme_togglee")
themeToggle?.setOnPreferenceChangeListener { _, _ ->
diff --git a/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt b/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt
index e5007999d..728beed24 100644
--- a/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt
@@ -8,7 +8,6 @@ import android.os.Build
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
-import android.widget.TextView
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.app.ActivityCompat
@@ -19,6 +18,7 @@ import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R
+import com.github.libretube.SettingsActivity
import com.github.libretube.dialogs.CustomInstanceDialog
import com.github.libretube.dialogs.DeleteAccountDialog
import com.github.libretube.dialogs.LoginDialog
@@ -111,8 +111,8 @@ class InstanceSettings : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.instance_settings, rootKey)
- val topBarTextView = activity?.findViewById(R.id.topBar_textView)
- topBarTextView?.text = getString(R.string.instance)
+ val settingsActivity = activity as SettingsActivity
+ settingsActivity.binding.topBarTextView.text = getString(R.string.instance)
val instance = findPreference("selectInstance")
// fetchInstance()
diff --git a/app/src/main/java/com/github/libretube/preferences/PlayerSettings.kt b/app/src/main/java/com/github/libretube/preferences/PlayerSettings.kt
index 84ed41c11..16fd72aa7 100644
--- a/app/src/main/java/com/github/libretube/preferences/PlayerSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/PlayerSettings.kt
@@ -1,9 +1,9 @@
package com.github.libretube.preferences
import android.os.Bundle
-import android.widget.TextView
import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R
+import com.github.libretube.SettingsActivity
class PlayerSettings : PreferenceFragmentCompat() {
val TAG = "PlayerSettings"
@@ -11,7 +11,7 @@ class PlayerSettings : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.player_settings, rootKey)
- val topBarTextView = activity?.findViewById(R.id.topBar_textView)
- topBarTextView?.text = getString(R.string.player)
+ val settingsActivity = activity as SettingsActivity
+ settingsActivity.binding.topBarTextView.text = getString(R.string.player)
}
}
diff --git a/app/src/main/java/com/github/libretube/preferences/SponsorBlockSettings.kt b/app/src/main/java/com/github/libretube/preferences/SponsorBlockSettings.kt
index 4d8def0b3..02c4479c7 100644
--- a/app/src/main/java/com/github/libretube/preferences/SponsorBlockSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/SponsorBlockSettings.kt
@@ -1,9 +1,9 @@
package com.github.libretube.preferences
import android.os.Bundle
-import android.widget.TextView
import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R
+import com.github.libretube.SettingsActivity
class SponsorBlockSettings : PreferenceFragmentCompat() {
private val TAG = "SponsorBlockSettings"
@@ -11,7 +11,7 @@ class SponsorBlockSettings : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.sponsorblock_settings, rootKey)
- val topBarTextView = activity?.findViewById(R.id.topBar_textView)
- topBarTextView?.text = getString(R.string.sponsorblock)
+ val settingsActivity = activity as SettingsActivity
+ settingsActivity.binding.topBarTextView.text = getString(R.string.sponsorblock)
}
}
diff --git a/app/src/main/res/drawable/ic_launcher_monochrome.xml b/app/src/main/res/drawable/ic_launcher_monochrome.xml
index 6cc55ad92..3573449c0 100644
--- a/app/src/main/res/drawable/ic_launcher_monochrome.xml
+++ b/app/src/main/res/drawable/ic_launcher_monochrome.xml
@@ -1,17 +1,16 @@
-
-
+
+
diff --git a/app/src/main/res/layout/chapter_column.xml b/app/src/main/res/layout/chapter_column.xml
index b44de7e06..595130de6 100644
--- a/app/src/main/res/layout/chapter_column.xml
+++ b/app/src/main/res/layout/chapter_column.xml
@@ -3,9 +3,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="100dp"
android:layout_height="wrap_content"
- android:paddingHorizontal="5dp"
android:background="?attr/selectableItemBackground"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:paddingHorizontal="5dp">
Date: Fri, 1 Jul 2022 10:30:29 +0200
Subject: [PATCH 027/202] convert aboutfragment
---
.../libretube/preferences/AboutFragment.kt | 25 +++++++------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt b/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt
index 4e6219386..cfd62721b 100644
--- a/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt
+++ b/app/src/main/java/com/github/libretube/preferences/AboutFragment.kt
@@ -8,14 +8,13 @@ import android.text.Html
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.LinearLayout
-import android.widget.TextView
import androidx.fragment.app.Fragment
import com.github.libretube.AUTHORS_URL
import com.github.libretube.CONTRIBUTING_URL
import com.github.libretube.DONATE_URL
import com.github.libretube.PIPED_GITHUB_URL
import com.github.libretube.R
+import com.github.libretube.SettingsActivity
import com.github.libretube.WEBSITE_URL
import com.github.libretube.databinding.FragmentAboutBinding
import com.google.android.material.dialog.MaterialAlertDialogBuilder
@@ -34,31 +33,25 @@ class AboutFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- val topBarText = activity?.findViewById(R.id.topBar_textView)
- topBarText?.text = getString(R.string.about)
+ val settingsActivity = activity as SettingsActivity
+ settingsActivity.binding.topBarTextView.text = getString(R.string.about)
- val website = view.findViewById(R.id.website)
- website.setOnClickListener {
+ binding.website.setOnClickListener {
openLinkFromHref(WEBSITE_URL)
}
- val authors = view.findViewById(R.id.authors)
- authors.setOnClickListener {
+ binding.authors.setOnClickListener {
openLinkFromHref(AUTHORS_URL)
}
- val piped = view.findViewById(R.id.piped)
- piped.setOnClickListener {
+ binding.piped.setOnClickListener {
openLinkFromHref(PIPED_GITHUB_URL)
}
- val donate = view.findViewById(R.id.donate)
- donate.setOnClickListener {
+ binding.donate.setOnClickListener {
openLinkFromHref(DONATE_URL)
}
- val contributing = view.findViewById(R.id.contributing)
- contributing.setOnClickListener {
+ binding.contributing.setOnClickListener {
openLinkFromHref(CONTRIBUTING_URL)
}
- val license = view.findViewById(R.id.license)
- license.setOnClickListener {
+ binding.license.setOnClickListener {
val licenseString = view.context.assets
.open("gpl3.html").bufferedReader().use {
it.readText()
From e6aefe3c938bfc0c8ec83cc65450e35b15cad3e0 Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Fri, 1 Jul 2022 11:11:24 +0200
Subject: [PATCH 028/202] convert fragments to viewbinding
---
.../libretube/dialogs/CreatePlaylistDialog.kt | 4 +-
.../libretube/fragments/ChannelFragment.kt | 108 +++++++-----------
.../fragments/{Home.kt => HomeFragment.kt} | 36 +++---
.../{Library.kt => LibraryFragment.kt} | 63 +++++-----
.../libretube/fragments/PlayerFragment.kt | 14 +--
.../libretube/fragments/PlaylistFragment.kt | 44 ++++---
.../libretube/fragments/SearchFragment.kt | 82 ++++++-------
...scriptions.kt => SubscriptionsFragment.kt} | 102 +++++++----------
app/src/main/res/layout/fragment_home.xml | 2 +-
app/src/main/res/layout/fragment_library.xml | 8 +-
.../res/layout/fragment_subscriptions.xml | 2 +-
app/src/main/res/navigation/nav.xml | 6 +-
12 files changed, 194 insertions(+), 277 deletions(-)
rename app/src/main/java/com/github/libretube/fragments/{Home.kt => HomeFragment.kt} (72%)
rename app/src/main/java/com/github/libretube/fragments/{Library.kt => LibraryFragment.kt} (57%)
rename app/src/main/java/com/github/libretube/fragments/{Subscriptions.kt => SubscriptionsFragment.kt} (60%)
diff --git a/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt b/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt
index c08a9096a..57c7db895 100644
--- a/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt
+++ b/app/src/main/java/com/github/libretube/dialogs/CreatePlaylistDialog.kt
@@ -10,7 +10,7 @@ import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.github.libretube.R
import com.github.libretube.databinding.DialogCreatePlaylistBinding
-import com.github.libretube.fragments.Library
+import com.github.libretube.fragments.LibraryFragment
import com.github.libretube.obj.Playlists
import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
@@ -82,7 +82,7 @@ class CreatePlaylistDialog : DialogFragment() {
}
// refresh the playlists in the library
try {
- val parent = parentFragment as Library
+ val parent = parentFragment as LibraryFragment
parent.fetchPlaylists()
} catch (e: Exception) {
Log.e(TAG, e.toString())
diff --git a/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt b/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt
index a45f80c71..d6f1e8355 100644
--- a/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/ChannelFragment.kt
@@ -6,16 +6,12 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.ImageView
-import android.widget.ScrollView
-import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.github.libretube.R
import com.github.libretube.adapters.ChannelAdapter
+import com.github.libretube.databinding.FragmentChannelBinding
import com.github.libretube.obj.Subscribe
import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
@@ -26,19 +22,19 @@ import retrofit2.HttpException
import java.io.IOException
class ChannelFragment : Fragment() {
-
- private var channel_id: String? = null
private val TAG = "ChannelFragment"
+ private lateinit var binding: FragmentChannelBinding
+
+ private var channelId: String? = null
var nextPage: String? = null
- var channelAdapter: ChannelAdapter? = null
- var isLoading = true
- var isSubscribed: Boolean = false
- private var refreshLayout: SwipeRefreshLayout? = null
+ private var channelAdapter: ChannelAdapter? = null
+ private var isLoading = true
+ private var isSubscribed: Boolean = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
- channel_id = it.getString("channel_id")
+ channelId = it.getString("channel_id")
}
}
@@ -46,43 +42,39 @@ class ChannelFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
- ): View? {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_channel, container, false)
+ ): View {
+ binding = FragmentChannelBinding.inflate(layoutInflater, container, false)
+ return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- channel_id = channel_id!!.replace("/channel/", "")
- view.findViewById(R.id.channel_name).text = channel_id
- val recyclerView = view.findViewById(R.id.channel_recView)
- recyclerView.layoutManager = LinearLayoutManager(context)
- refreshLayout = view.findViewById(R.id.channel_refresh)
+ channelId = channelId!!.replace("/channel/", "")
+ binding.channelName.text = channelId
+ binding.channelRecView.layoutManager = LinearLayoutManager(context)
val refreshChannel = {
- refreshLayout?.isRefreshing = true
- fetchChannel(view)
- val subButton = view.findViewById(R.id.channel_subscribe)
+ binding.channelRefresh.isRefreshing = true
+ fetchChannel()
if (PreferenceHelper.getToken(requireContext()) != "") {
- isSubscribed(subButton)
+ isSubscribed(binding.channelSubscribe)
}
}
refreshChannel()
- refreshLayout?.setOnRefreshListener {
+ binding.channelRefresh.setOnRefreshListener {
refreshChannel()
}
- val scrollView = view.findViewById(R.id.channel_scrollView)
- scrollView.viewTreeObserver
+ binding.channelScrollView.viewTreeObserver
.addOnScrollChangedListener {
- if (scrollView.getChildAt(0).bottom
- == (scrollView.height + scrollView.scrollY)
+ if (binding.channelScrollView.getChildAt(0).bottom
+ == (binding.channelScrollView.height + binding.channelScrollView.scrollY)
) {
// scroll view is at bottom
if (nextPage != null && !isLoading) {
isLoading = true
- refreshLayout?.isRefreshing = true
+ binding.channelRefresh.isRefreshing = true
fetchNextPage()
}
}
@@ -96,7 +88,7 @@ class ChannelFragment : Fragment() {
val response = try {
val token = PreferenceHelper.getToken(requireContext())
RetrofitInstance.api.isSubscribed(
- channel_id!!,
+ channelId!!,
token
)
} catch (e: IOException) {
@@ -137,7 +129,7 @@ class ChannelFragment : Fragment() {
val token = PreferenceHelper.getToken(requireContext())
RetrofitInstance.api.subscribe(
token,
- Subscribe(channel_id)
+ Subscribe(channelId)
)
} catch (e: IOException) {
println(e)
@@ -160,7 +152,7 @@ class ChannelFragment : Fragment() {
val token = PreferenceHelper.getToken(requireContext())
RetrofitInstance.api.unsubscribe(
token,
- Subscribe(channel_id)
+ Subscribe(channelId)
)
} catch (e: IOException) {
println(e)
@@ -176,55 +168,52 @@ class ChannelFragment : Fragment() {
run()
}
- private fun fetchChannel(view: View) {
+ private fun fetchChannel() {
fun run() {
lifecycleScope.launchWhenCreated {
val response = try {
- RetrofitInstance.api.getChannel(channel_id!!)
+ RetrofitInstance.api.getChannel(channelId!!)
} catch (e: IOException) {
- refreshLayout?.isRefreshing = false
+ binding.channelRefresh.isRefreshing = false
println(e)
Log.e(TAG, "IOException, you might not have internet connection")
return@launchWhenCreated
} catch (e: HttpException) {
- refreshLayout?.isRefreshing = false
+ binding.channelRefresh.isRefreshing = false
Log.e(TAG, "HttpException, unexpected response")
return@launchWhenCreated
}
nextPage = response.nextpage
isLoading = false
- refreshLayout?.isRefreshing = false
+ binding.channelRefresh.isRefreshing = false
runOnUiThread {
- view.findViewById(R.id.channel_scrollView).visibility = View.VISIBLE
- val channelName = view.findViewById(R.id.channel_name)
- channelName.text = response.name
+ binding.channelScrollView.visibility = View.VISIBLE
+ binding.channelName.text = response.name
if (response.verified) {
- channelName.setCompoundDrawablesWithIntrinsicBounds(
+ binding.channelName.setCompoundDrawablesWithIntrinsicBounds(
0,
0,
R.drawable.ic_verified,
0
)
}
- view.findViewById(R.id.channel_subs).text = resources.getString(
+ binding.channelSubs.text = resources.getString(
R.string.subscribers,
response.subscriberCount.formatShort()
)
- val channelDescription = view.findViewById(R.id.channel_description)
if (response.description?.trim() == "") {
- channelDescription.visibility = View.GONE
+ binding.channelDescription.visibility = View.GONE
} else {
- channelDescription.text = response.description?.trim()
+ binding.channelDescription.text = response.description?.trim()
}
- val bannerImage = view.findViewById(R.id.channel_banner)
- val channelImage = view.findViewById(R.id.channel_image)
- Picasso.get().load(response.bannerUrl).into(bannerImage)
- Picasso.get().load(response.avatarUrl).into(channelImage)
+
+ Picasso.get().load(response.bannerUrl).into(binding.channelBanner)
+ Picasso.get().load(response.avatarUrl).into(binding.channelImage)
channelAdapter = ChannelAdapter(
response.relatedStreams!!.toMutableList(),
childFragmentManager
)
- view.findViewById(R.id.channel_recView).adapter = channelAdapter
+ binding.channelRecView.adapter = channelAdapter
}
}
}
@@ -235,21 +224,21 @@ class ChannelFragment : Fragment() {
fun run() {
lifecycleScope.launchWhenCreated {
val response = try {
- RetrofitInstance.api.getChannelNextPage(channel_id!!, nextPage!!)
+ RetrofitInstance.api.getChannelNextPage(channelId!!, nextPage!!)
} catch (e: IOException) {
- refreshLayout?.isRefreshing = false
+ binding.channelRefresh.isRefreshing = false
println(e)
Log.e(TAG, "IOException, you might not have internet connection")
return@launchWhenCreated
} catch (e: HttpException) {
- refreshLayout?.isRefreshing = false
+ binding.channelRefresh.isRefreshing = false
Log.e(TAG, "HttpException, unexpected response," + e.response())
return@launchWhenCreated
}
nextPage = response.nextpage
channelAdapter?.updateItems(response.relatedStreams!!)
isLoading = false
- refreshLayout?.isRefreshing = false
+ binding.channelRefresh.isRefreshing = false
}
}
run()
@@ -260,13 +249,4 @@ class ChannelFragment : Fragment() {
if (!isAdded) return // Fragment not attached to an Activity
activity?.runOnUiThread(action)
}
-
- override fun onDestroyView() {
- val scrollView = view?.findViewById(R.id.channel_scrollView)
- scrollView?.viewTreeObserver?.removeOnScrollChangedListener {
- }
- channelAdapter = null
- view?.findViewById(R.id.channel_recView)?.adapter = null
- super.onDestroyView()
- }
}
diff --git a/app/src/main/java/com/github/libretube/fragments/Home.kt b/app/src/main/java/com/github/libretube/fragments/HomeFragment.kt
similarity index 72%
rename from app/src/main/java/com/github/libretube/fragments/Home.kt
rename to app/src/main/java/com/github/libretube/fragments/HomeFragment.kt
index 573d1ad41..43c5d3369 100644
--- a/app/src/main/java/com/github/libretube/fragments/Home.kt
+++ b/app/src/main/java/com/github/libretube/fragments/HomeFragment.kt
@@ -11,18 +11,18 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.github.libretube.R
import com.github.libretube.adapters.TrendingAdapter
+import com.github.libretube.databinding.FragmentHomeBinding
import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
import retrofit2.HttpException
import java.io.IOException
-class Home : Fragment() {
-
+class HomeFragment : Fragment() {
private val TAG = "HomeFragment"
- private var refreshLayout: SwipeRefreshLayout? = null
+ private lateinit var binding: FragmentHomeBinding
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
@@ -33,27 +33,24 @@ class Home : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
- ): View? {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_home, container, false)
+ ): View {
+ binding = FragmentHomeBinding.inflate(layoutInflater, container, false)
+ return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- val recyclerView = view.findViewById(R.id.recview)
val grid = PreferenceHelper.getString(
requireContext(),
"grid",
resources.getInteger(R.integer.grid_items).toString()
)!!
- recyclerView.layoutManager = GridLayoutManager(view.context, grid.toInt())
- val progressbar = view.findViewById(R.id.progressBar)
- fetchJson(progressbar, recyclerView)
- refreshLayout = view.findViewById(R.id.home_refresh)
- refreshLayout?.isEnabled = true
- refreshLayout?.setOnRefreshListener {
+ binding.recview.layoutManager = GridLayoutManager(view.context, grid.toInt())
+ fetchJson(binding.progressBar, binding.recview)
+ binding.homeRefresh.isEnabled = true
+ binding.homeRefresh.setOnRefreshListener {
Log.d(TAG, "hmm")
- fetchJson(progressbar, recyclerView)
+ fetchJson(binding.progressBar, binding.recview)
}
}
@@ -73,7 +70,7 @@ class Home : Fragment() {
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated
} finally {
- refreshLayout?.isRefreshing = false
+ binding.homeRefresh.isRefreshing = false
}
runOnUiThread {
progressBar.visibility = View.GONE
@@ -89,11 +86,4 @@ class Home : Fragment() {
if (!isAdded) return // Fragment not attached to an Activity
activity?.runOnUiThread(action)
}
-
- override fun onDestroyView() {
- view?.findViewById(R.id.recview)?.adapter = null
- refreshLayout = null
- Log.e(TAG, "destroyview")
- super.onDestroyView()
- }
}
diff --git a/app/src/main/java/com/github/libretube/fragments/Library.kt b/app/src/main/java/com/github/libretube/fragments/LibraryFragment.kt
similarity index 57%
rename from app/src/main/java/com/github/libretube/fragments/Library.kt
rename to app/src/main/java/com/github/libretube/fragments/LibraryFragment.kt
index 4c844066e..b66ce1fc3 100644
--- a/app/src/main/java/com/github/libretube/fragments/Library.kt
+++ b/app/src/main/java/com/github/libretube/fragments/LibraryFragment.kt
@@ -5,29 +5,24 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.ImageView
-import android.widget.TextView
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.github.libretube.R
import com.github.libretube.adapters.PlaylistsAdapter
+import com.github.libretube.databinding.FragmentLibraryBinding
import com.github.libretube.dialogs.CreatePlaylistDialog
import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
-import com.google.android.material.floatingactionbutton.FloatingActionButton
import retrofit2.HttpException
import java.io.IOException
-class Library : Fragment() {
+class LibraryFragment : Fragment() {
private val TAG = "LibraryFragment"
lateinit var token: String
- private lateinit var playlistRecyclerView: RecyclerView
- private lateinit var refreshLayout: SwipeRefreshLayout
+ private lateinit var binding: FragmentLibraryBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -39,48 +34,44 @@ class Library : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
- ): View? {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_library, container, false)
+ ): View {
+ binding = FragmentLibraryBinding.inflate(layoutInflater, container, false)
+ return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- playlistRecyclerView = view.findViewById(R.id.playlist_recView)
- playlistRecyclerView.layoutManager = LinearLayoutManager(view.context)
+ binding.playlistRecView.layoutManager = LinearLayoutManager(view.context)
token = PreferenceHelper.getToken(requireContext())
- refreshLayout = view.findViewById(R.id.playlist_refresh)
if (token != "") {
- view.findViewById(R.id.boogh2).visibility = View.GONE
- view.findViewById(R.id.textLike2).visibility = View.GONE
+ binding.boogh.visibility = View.GONE
+ binding.textLike.visibility = View.GONE
fetchPlaylists()
- refreshLayout.isEnabled = true
- refreshLayout.setOnRefreshListener {
+ binding.playlistRefresh.isEnabled = true
+ binding.playlistRefresh.setOnRefreshListener {
fetchPlaylists()
}
- val createPlaylistButton = view.findViewById(R.id.create_playlist)
- createPlaylistButton.setOnClickListener {
+ binding.createPlaylist.setOnClickListener {
val newFragment = CreatePlaylistDialog()
newFragment.show(childFragmentManager, "Create Playlist")
}
} else {
- refreshLayout.isEnabled = false
- view.findViewById(R.id.create_playlist).visibility = View.GONE
+ binding.playlistRefresh.isEnabled = false
+ binding.createPlaylist.visibility = View.GONE
}
}
override fun onResume() {
// optimize CreatePlaylistFab bottom margin if miniPlayer active
- val createPlaylistButton = view?.findViewById(R.id.create_playlist)
- val layoutParams = createPlaylistButton?.layoutParams as ViewGroup.MarginLayoutParams
+ val layoutParams = binding.createPlaylist.layoutParams as ViewGroup.MarginLayoutParams
layoutParams.bottomMargin = if (isMiniPlayerVisible) 180 else 64
- createPlaylistButton?.layoutParams = layoutParams
+ binding.createPlaylist.layoutParams = layoutParams
super.onResume()
}
fun fetchPlaylists() {
fun run() {
- refreshLayout.isRefreshing = true
+ binding.playlistRefresh.isRefreshing = true
lifecycleScope.launchWhenCreated {
val response = try {
RetrofitInstance.api.playlists(token)
@@ -94,27 +85,27 @@ class Library : Fragment() {
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated
} finally {
- refreshLayout.isRefreshing = false
+ binding.playlistRefresh.isRefreshing = false
}
if (response.isNotEmpty()) {
runOnUiThread {
- view?.findViewById(R.id.boogh2)?.visibility = View.GONE
- view?.findViewById(R.id.textLike2)?.visibility = View.GONE
+ binding.boogh.visibility = View.GONE
+ binding.textLike.visibility = View.GONE
}
val playlistsAdapter = PlaylistsAdapter(
response.toMutableList(),
requireActivity()
)
- playlistRecyclerView.adapter = playlistsAdapter
+ binding.playlistRecView.adapter = playlistsAdapter
} else {
runOnUiThread {
- view?.findViewById(R.id.boogh2).apply {
- this?.visibility = View.VISIBLE
- this?.setImageResource(R.drawable.ic_list)
+ binding.boogh.apply {
+ visibility = View.VISIBLE
+ setImageResource(R.drawable.ic_list)
}
- view?.findViewById(R.id.textLike2).apply {
- this?.visibility = View.VISIBLE
- this?.text = getString(R.string.emptyList)
+ binding.textLike.apply {
+ visibility = View.VISIBLE
+ text = getString(R.string.emptyList)
}
}
}
diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
index 263352f56..6e7b0186e 100644
--- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
@@ -369,10 +369,7 @@ class PlayerFragment : Fragment() {
// pause player if screen off and setting enabled
if (
- this::exoPlayer.isInitialized &&
- exoPlayer != null &&
- !isScreenOn &&
- pausePlayerOnScreenOffEnabled
+ this::exoPlayer.isInitialized && !isScreenOn && pausePlayerOnScreenOffEnabled
) {
exoPlayer.pause()
}
@@ -518,7 +515,7 @@ class PlayerFragment : Fragment() {
// if it's not a playlist then use the next related video
} else if (relatedStreams != null && relatedStreams!!.isNotEmpty()) {
// save next video from related streams for autoplay
- nextStreamId = relatedStreams!![0].url!!.replace("/watch?v=", "")!!
+ nextStreamId = relatedStreams!![0].url!!.replace("/watch?v=", "")
}
}
}
@@ -792,7 +789,7 @@ class PlayerFragment : Fragment() {
val videoSource: MediaSource =
DefaultMediaSourceFactory(dataSourceFactory)
.createMediaSource(videoItem)
- var audioSource: MediaSource =
+ val audioSource: MediaSource =
ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(fromUri(audioUrl))
val mergeSource: MediaSource =
@@ -1178,10 +1175,7 @@ class PlayerFragment : Fragment() {
binding.playerScrollView.getHitRect(bounds)
if (SDK_INT >= Build.VERSION_CODES.O &&
- exoPlayer.isPlaying && (
- binding.playerScrollView.getLocalVisibleRect(bounds) == true ||
- isFullScreen
- )
+ exoPlayer.isPlaying && (binding.playerScrollView.getLocalVisibleRect(bounds) || isFullScreen)
) {
activity?.enterPictureInPictureMode(updatePipParams())
}
diff --git a/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt
index 4e8c20dab..e85c6aaf9 100644
--- a/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt
@@ -5,15 +5,12 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.ProgressBar
-import android.widget.ScrollView
-import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R
import com.github.libretube.adapters.PlaylistAdapter
+import com.github.libretube.databinding.FragmentPlaylistBinding
import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
import retrofit2.HttpException
@@ -21,11 +18,13 @@ import java.io.IOException
class PlaylistFragment : Fragment() {
private val TAG = "PlaylistFragment"
+ private lateinit var binding: FragmentPlaylistBinding
private var playlistId: String? = null
var nextPage: String? = null
- var playlistAdapter: PlaylistAdapter? = null
- var isLoading = true
+ private var playlistAdapter: PlaylistAdapter? = null
+ private var isLoading = true
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
@@ -37,24 +36,22 @@ class PlaylistFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
- ): View? {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_playlist, container, false)
+ ): View {
+ binding = FragmentPlaylistBinding.inflate(layoutInflater, container, false)
+ return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
playlistId = playlistId!!.replace("/playlist?list=", "")
- val recyclerView = view.findViewById(R.id.playlist_recView)
- recyclerView.layoutManager = LinearLayoutManager(context)
+ binding.playlistRecView.layoutManager = LinearLayoutManager(context)
- val progressBar = view.findViewById(R.id.playlist_progress)
- progressBar.visibility = View.VISIBLE
- fetchPlaylist(view)
+ binding.playlistProgress.visibility = View.VISIBLE
+ fetchPlaylist()
}
- private fun fetchPlaylist(view: View) {
+ private fun fetchPlaylist() {
fun run() {
lifecycleScope.launchWhenCreated {
val response = try {
@@ -70,10 +67,10 @@ class PlaylistFragment : Fragment() {
nextPage = response.nextpage
isLoading = false
runOnUiThread {
- view.findViewById(R.id.playlist_progress).visibility = View.GONE
- view.findViewById(R.id.playlist_name).text = response.name
- view.findViewById(R.id.playlist_uploader).text = response.uploader
- view.findViewById(R.id.playlist_totVideos).text =
+ binding.playlistProgress.visibility = View.GONE
+ binding.playlistName.text = response.name
+ binding.playlistUploader.text = response.uploader
+ binding.playlistTotVideos.text =
getString(R.string.videoCount, response.videos.toString())
val user = PreferenceHelper.getUsername(requireContext())
var isOwner = false
@@ -87,12 +84,11 @@ class PlaylistFragment : Fragment() {
requireActivity(),
childFragmentManager
)
- view.findViewById(R.id.playlist_recView).adapter = playlistAdapter
- val scrollView = view.findViewById(R.id.playlist_scrollview)
- scrollView.viewTreeObserver
+ binding.playlistRecView.adapter = playlistAdapter
+ binding.playlistScrollview.viewTreeObserver
.addOnScrollChangedListener {
- if (scrollView.getChildAt(0).bottom
- == (scrollView.height + scrollView.scrollY)
+ if (binding.playlistScrollview.getChildAt(0).bottom
+ == (binding.playlistScrollview.height + binding.playlistScrollview.scrollY)
) {
// scroll view is at bottom
if (nextPage != null && !isLoading) {
diff --git a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt
index cfe515d71..c81a8ec87 100644
--- a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt
@@ -12,7 +12,6 @@ import android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
-import android.widget.ImageView
import android.widget.TextView.GONE
import android.widget.TextView.OnEditorActionListener
import android.widget.TextView.VISIBLE
@@ -20,28 +19,26 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R
import com.github.libretube.adapters.SearchAdapter
import com.github.libretube.adapters.SearchHistoryAdapter
import com.github.libretube.adapters.SearchSuggestionsAdapter
+import com.github.libretube.databinding.FragmentSearchBinding
import com.github.libretube.hideKeyboard
import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
import com.google.android.material.dialog.MaterialAlertDialogBuilder
-import kotlinx.coroutines.GlobalScope
-import kotlinx.coroutines.launch
import retrofit2.HttpException
import java.io.IOException
class SearchFragment : Fragment() {
private val TAG = "SearchFragment"
+ private lateinit var binding: FragmentSearchBinding
+
private var selectedFilter = 0
private var apiSearchFilter = "all"
private var nextPage: String? = null
- private lateinit var searchRecView: RecyclerView
- private lateinit var historyRecView: RecyclerView
- private lateinit var autoTextView: EditText
+
private var searchAdapter: SearchAdapter? = null
private var isLoading: Boolean = true
private var isFetchingSearch: Boolean = false
@@ -56,27 +53,21 @@ class SearchFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
- ): View? {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_search, container, false)
+ ): View {
+ binding = FragmentSearchBinding.inflate(layoutInflater, container, false)
+ return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- searchRecView = view.findViewById(R.id.search_recycler)
- historyRecView = view.findViewById(R.id.history_recycler)
- autoTextView = view.findViewById(R.id.autoCompleteTextView)
-
- val clearSearchButton = view.findViewById(R.id.clearSearch_imageView)
- val filterImageView = view.findViewById(R.id.filterMenu_imageView)
var tempSelectedItem = 0
- clearSearchButton.setOnClickListener {
- autoTextView.text.clear()
+ binding.clearSearchImageView.setOnClickListener {
+ binding.autoCompleteTextView.text.clear()
}
- filterImageView.setOnClickListener {
+ binding.filterMenuImageView.setOnClickListener {
val filterOptions = arrayOf(
getString(R.string.all),
getString(R.string.videos),
@@ -108,7 +99,7 @@ class SearchFragment : Fragment() {
7 -> "music_playlists"
else -> "all"
}
- fetchSearch(autoTextView.text.toString())
+ fetchSearch(binding.autoCompleteTextView.text.toString())
}
.setNegativeButton(getString(R.string.cancel), null)
.create()
@@ -116,16 +107,16 @@ class SearchFragment : Fragment() {
}
// show search history
- historyRecView.layoutManager = LinearLayoutManager(view.context)
+ binding.historyRecycler.layoutManager = LinearLayoutManager(view.context)
showHistory()
- searchRecView.layoutManager = GridLayoutManager(view.context, 1)
- autoTextView.requestFocus()
+ binding.searchRecycler.layoutManager = GridLayoutManager(view.context, 1)
+ binding.autoCompleteTextView.requestFocus()
val imm =
requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
- imm.showSoftInput(autoTextView, InputMethodManager.SHOW_IMPLICIT)
+ imm.showSoftInput(binding.autoCompleteTextView, InputMethodManager.SHOW_IMPLICIT)
- autoTextView.addTextChangedListener(object : TextWatcher {
+ binding.autoCompleteTextView.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(
s: CharSequence?,
start: Int,
@@ -136,18 +127,15 @@ class SearchFragment : Fragment() {
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
if (s!! != "") {
- searchRecView.adapter = null
+ binding.searchRecycler.adapter = null
- searchRecView.viewTreeObserver
+ binding.searchRecycler.viewTreeObserver
.addOnScrollChangedListener {
- if (!searchRecView.canScrollVertically(1)) {
- fetchNextSearchItems(autoTextView.text.toString())
+ if (!binding.searchRecycler.canScrollVertically(1)) {
+ fetchNextSearchItems(binding.autoCompleteTextView.text.toString())
}
}
-
- GlobalScope.launch {
- fetchSuggestions(s.toString(), autoTextView)
- }
+ fetchSuggestions(s.toString(), binding.autoCompleteTextView)
}
}
@@ -157,13 +145,13 @@ class SearchFragment : Fragment() {
}
}
})
- autoTextView.setOnEditorActionListener(
+ binding.autoCompleteTextView.setOnEditorActionListener(
OnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
hideKeyboard()
- searchRecView.visibility = VISIBLE
- historyRecView.visibility = GONE
- fetchSearch(autoTextView.text.toString())
+ binding.searchRecycler.visibility = VISIBLE
+ binding.historyRecycler.visibility = GONE
+ fetchSearch(binding.autoCompleteTextView.text.toString())
return@OnEditorActionListener true
}
false
@@ -174,8 +162,8 @@ class SearchFragment : Fragment() {
private fun fetchSuggestions(query: String, autoTextView: EditText) {
fun run() {
lifecycleScope.launchWhenCreated {
- searchRecView.visibility = GONE
- historyRecView.visibility = VISIBLE
+ binding.searchRecycler.visibility = GONE
+ binding.historyRecycler.visibility = VISIBLE
val response = try {
RetrofitInstance.api.getSuggestions(query)
} catch (e: IOException) {
@@ -188,7 +176,7 @@ class SearchFragment : Fragment() {
}
val suggestionsAdapter =
SearchSuggestionsAdapter(response, autoTextView, this@SearchFragment)
- historyRecView.adapter = suggestionsAdapter
+ binding.historyRecycler.adapter = suggestionsAdapter
}
}
if (!isFetchingSearch) run()
@@ -211,10 +199,10 @@ class SearchFragment : Fragment() {
nextPage = response.nextpage
if (response.items!!.isNotEmpty()) {
runOnUiThread {
- historyRecView.visibility = GONE
- searchRecView.visibility = VISIBLE
+ binding.historyRecycler.visibility = GONE
+ binding.searchRecycler.visibility = VISIBLE
searchAdapter = SearchAdapter(response.items, childFragmentManager)
- searchRecView.adapter = searchAdapter
+ binding.searchRecycler.adapter = searchAdapter
}
}
addToHistory(query)
@@ -265,12 +253,12 @@ class SearchFragment : Fragment() {
}
private fun showHistory() {
- searchRecView.visibility = GONE
+ binding.searchRecycler.visibility = GONE
val historyList = PreferenceHelper.getHistory(requireContext())
if (historyList.isNotEmpty()) {
- historyRecView.adapter =
- SearchHistoryAdapter(requireContext(), historyList, autoTextView, this)
- historyRecView.visibility = VISIBLE
+ binding.historyRecycler.adapter =
+ SearchHistoryAdapter(requireContext(), historyList, binding.autoCompleteTextView, this)
+ binding.historyRecycler.visibility = VISIBLE
}
}
diff --git a/app/src/main/java/com/github/libretube/fragments/Subscriptions.kt b/app/src/main/java/com/github/libretube/fragments/SubscriptionsFragment.kt
similarity index 60%
rename from app/src/main/java/com/github/libretube/fragments/Subscriptions.kt
rename to app/src/main/java/com/github/libretube/fragments/SubscriptionsFragment.kt
index d502a7cf3..fa8ef8ee1 100644
--- a/app/src/main/java/com/github/libretube/fragments/Subscriptions.kt
+++ b/app/src/main/java/com/github/libretube/fragments/SubscriptionsFragment.kt
@@ -5,11 +5,7 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.ImageView
import android.widget.ProgressBar
-import android.widget.RelativeLayout
-import android.widget.ScrollView
-import android.widget.TextView
import android.widget.Toast
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
@@ -17,21 +13,23 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.github.libretube.R
import com.github.libretube.adapters.SubscriptionAdapter
import com.github.libretube.adapters.SubscriptionChannelAdapter
+import com.github.libretube.databinding.FragmentSubscriptionsBinding
import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
import retrofit2.HttpException
import java.io.IOException
-class Subscriptions : Fragment() {
+class SubscriptionsFragment : Fragment() {
val TAG = "SubFragment"
+ private lateinit var binding: FragmentSubscriptionsBinding
+
lateinit var token: String
- var isLoaded = false
+ private var isLoaded = false
private var subscriptionAdapter: SubscriptionAdapter? = null
- private var refreshLayout: SwipeRefreshLayout? = null
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
@@ -42,84 +40,72 @@ class Subscriptions : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
- ): View? {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_subscriptions, container, false)
+ ): View {
+ binding = FragmentSubscriptionsBinding.inflate(layoutInflater, container, false)
+ return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
token = PreferenceHelper.getToken(requireContext())
- refreshLayout = view.findViewById(R.id.sub_refresh)
+
if (token != "") {
- view.findViewById(R.id.loginOrRegister).visibility = View.GONE
- refreshLayout?.isEnabled = true
+ binding.loginOrRegister.visibility = View.GONE
+ binding.subRefresh.isEnabled = true
- var progressBar = view.findViewById(R.id.sub_progress)
- progressBar.visibility = View.VISIBLE
+ binding.subProgress.visibility = View.VISIBLE
- var channelRecView = view.findViewById(R.id.sub_channels)
-
- var feedRecView = view.findViewById(R.id.sub_feed)
val grid = PreferenceHelper.getString(
requireContext(),
"grid",
resources.getInteger(R.integer.grid_items).toString()
)!!
- feedRecView.layoutManager = GridLayoutManager(view.context, grid.toInt())
- fetchFeed(feedRecView, progressBar, view)
+ binding.subFeed.layoutManager = GridLayoutManager(view.context, grid.toInt())
+ fetchFeed(binding.subFeed, binding.subProgress)
- refreshLayout?.setOnRefreshListener {
- fetchChannels(channelRecView)
- fetchFeed(feedRecView, progressBar, view)
+ binding.subRefresh.setOnRefreshListener {
+ fetchChannels(binding.subChannels)
+ fetchFeed(binding.subFeed, binding.subProgress)
}
- var toggleSubs = view.findViewById(R.id.toggle_subs)
- val arrowImageView = view.findViewById(R.id.toggle)
-
- toggleSubs.visibility = View.VISIBLE
+ binding.toggleSubs.visibility = View.VISIBLE
var loadedSubbedChannels = false
- toggleSubs.setOnClickListener {
- arrowImageView.animate().rotationBy(180F).setDuration(100).start()
- if (!channelRecView.isVisible) {
+ binding.toggleSubs.setOnClickListener {
+ binding.toggle.animate().rotationBy(180F).setDuration(100).start()
+ if (!binding.subChannels.isVisible) {
if (!loadedSubbedChannels) {
- channelRecView?.layoutManager = LinearLayoutManager(context)
- fetchChannels(channelRecView)
+ binding.subChannels.layoutManager = LinearLayoutManager(context)
+ fetchChannels(binding.subChannels)
loadedSubbedChannels = true
}
- channelRecView.visibility = View.VISIBLE
- feedRecView.visibility = View.GONE
+ binding.subChannels.visibility = View.VISIBLE
+ binding.subFeed.visibility = View.GONE
} else {
- channelRecView.visibility = View.GONE
- feedRecView.visibility = View.VISIBLE
-
- // toggle button
- val image = view.findViewById(R.id.toggle)
- image.clearAnimation()
+ binding.subChannels.visibility = View.GONE
+ binding.subFeed.visibility = View.VISIBLE
}
}
- val scrollView = view.findViewById(R.id.scrollview_sub)
- scrollView.viewTreeObserver
+ binding.scrollviewSub.viewTreeObserver
.addOnScrollChangedListener {
- if (scrollView.getChildAt(0).bottom
- == (scrollView.height + scrollView.scrollY)
+ if (binding.scrollviewSub.getChildAt(0).bottom
+ == (binding.scrollviewSub.height + binding.scrollviewSub.scrollY)
) {
// scroll view is at bottom
if (isLoaded) {
- refreshLayout?.isRefreshing = true
+ binding.subRefresh.isRefreshing = true
subscriptionAdapter?.updateItems()
- refreshLayout?.isRefreshing = false
+ binding.subRefresh.isRefreshing = false
}
}
}
} else {
- refreshLayout?.isEnabled = false
+ binding.subRefresh.isEnabled = false
}
}
- private fun fetchFeed(feedRecView: RecyclerView, progressBar: ProgressBar, view: View) {
+ private fun fetchFeed(feedRecView: RecyclerView, progressBar: ProgressBar) {
fun run() {
lifecycleScope.launchWhenCreated {
val response = try {
@@ -132,7 +118,7 @@ class Subscriptions : Fragment() {
Log.e(TAG, "HttpException, unexpected response")
return@launchWhenCreated
} finally {
- refreshLayout?.isRefreshing = false
+ binding.subRefresh.isRefreshing = false
}
if (response.isNotEmpty()) {
subscriptionAdapter = SubscriptionAdapter(response, childFragmentManager)
@@ -140,16 +126,15 @@ class Subscriptions : Fragment() {
subscriptionAdapter?.updateItems()
} else {
runOnUiThread {
- with(view.findViewById(R.id.boogh)) {
+ with(binding.boogh) {
visibility = View.VISIBLE
setImageResource(R.drawable.ic_list)
}
- with(view.findViewById(R.id.textLike)) {
+ with(binding.textLike) {
visibility = View.VISIBLE
text = getString(R.string.emptyList)
}
- view.findViewById(R.id.loginOrRegister)
- .visibility = View.VISIBLE
+ binding.loginOrRegister.visibility = View.VISIBLE
}
}
progressBar.visibility = View.GONE
@@ -172,7 +157,7 @@ class Subscriptions : Fragment() {
Log.e(TAG, "HttpException, unexpected response")
return@launchWhenCreated
} finally {
- refreshLayout?.isRefreshing = false
+ binding.subRefresh.isRefreshing = false
}
if (response.isNotEmpty()) {
channelRecView.adapter = SubscriptionChannelAdapter(response.toMutableList())
@@ -184,13 +169,6 @@ class Subscriptions : Fragment() {
run()
}
- override fun onDestroy() {
- Log.e(TAG, "Destroyed")
- super.onDestroy()
- subscriptionAdapter = null
- view?.findViewById(R.id.sub_feed)?.adapter = null
- }
-
private fun Fragment?.runOnUiThread(action: () -> Unit) {
this ?: return
if (!isAdded) return // Fragment not attached to an Activity
diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml
index 2e240e5db..4b859beac 100644
--- a/app/src/main/res/layout/fragment_home.xml
+++ b/app/src/main/res/layout/fragment_home.xml
@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context=".fragments.Home">
+ tools:context=".fragments.HomeFragment">
+ tools:context=".fragments.LibraryFragment">
+ tools:context=".fragments.SubscriptionsFragment">
Date: Fri, 1 Jul 2022 11:37:14 +0200
Subject: [PATCH 029/202] convert adapters to viewbinding
---
.../libretube/adapters/ChannelAdapter.kt | 61 +++++-----
.../libretube/adapters/ChaptersAdapter.kt | 24 ++--
.../libretube/adapters/CommentsAdapter.kt | 104 +++++++++---------
.../libretube/adapters/RepliesAdapter.kt | 68 ++++++------
4 files changed, 131 insertions(+), 126 deletions(-)
diff --git a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt
index 7dbf5d9d7..d6ea63c02 100644
--- a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt
@@ -11,6 +11,8 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R
+import com.github.libretube.databinding.ChannelSubscriptionRowBinding
+import com.github.libretube.databinding.VideoChannelRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.obj.StreamItem
@@ -22,6 +24,8 @@ class ChannelAdapter(
private val childFragmentManager: FragmentManager
) :
RecyclerView.Adapter() {
+ private lateinit var binding: VideoChannelRowBinding
+
override fun getItemCount(): Int {
return videoFeed.size
}
@@ -33,38 +37,39 @@ class ChannelAdapter(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChannelViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
- val cell = layoutInflater.inflate(R.layout.video_channel_row, parent, false)
- return ChannelViewHolder(cell)
+ binding = VideoChannelRowBinding.inflate(layoutInflater, parent, false)
+ return ChannelViewHolder(binding.root)
}
override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) {
val trending = videoFeed[position]
- holder.v.findViewById(R.id.channel_description).text = trending.title
- holder.v.findViewById(R.id.channel_views).text =
- trending.views.formatShort() + " • " +
- DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
- holder.v.findViewById(R.id.channel_duration).text =
- DateUtils.formatElapsedTime(trending.duration!!)
- val thumbnailImage = holder.v.findViewById(R.id.channel_thumbnail)
- Picasso.get().load(trending.thumbnail).into(thumbnailImage)
- holder.v.setOnClickListener {
- var bundle = Bundle()
- bundle.putString("videoId", trending.url!!.replace("/watch?v=", ""))
- var frag = PlayerFragment()
- frag.arguments = bundle
- val activity = holder.v.context as AppCompatActivity
- activity.supportFragmentManager.beginTransaction()
- .remove(PlayerFragment())
- .commit()
- activity.supportFragmentManager.beginTransaction()
- .replace(R.id.container, frag)
- .commitNow()
- }
- holder.v.setOnLongClickListener {
- val videoId = trending.url!!.replace("/watch?v=", "")
- VideoOptionsDialog(videoId, holder.v.context)
- .show(childFragmentManager, VideoOptionsDialog.TAG)
- true
+ binding.apply {
+ channelDescription.text = trending.title
+ channelViews.text =
+ trending.views.formatShort() + " • " +
+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
+ channelDuration.text =
+ DateUtils.formatElapsedTime(trending.duration!!)
+ Picasso.get().load(trending.thumbnail).into(channelThumbnail)
+ root.setOnClickListener {
+ var bundle = Bundle()
+ bundle.putString("videoId", trending.url!!.replace("/watch?v=", ""))
+ var frag = PlayerFragment()
+ frag.arguments = bundle
+ val activity = holder.v.context as AppCompatActivity
+ activity.supportFragmentManager.beginTransaction()
+ .remove(PlayerFragment())
+ .commit()
+ activity.supportFragmentManager.beginTransaction()
+ .replace(R.id.container, frag)
+ .commitNow()
+ }
+ root.setOnLongClickListener {
+ val videoId = trending.url!!.replace("/watch?v=", "")
+ VideoOptionsDialog(videoId, holder.v.context)
+ .show(childFragmentManager, VideoOptionsDialog.TAG)
+ true
+ }
}
}
}
diff --git a/app/src/main/java/com/github/libretube/adapters/ChaptersAdapter.kt b/app/src/main/java/com/github/libretube/adapters/ChaptersAdapter.kt
index 4f625c3aa..b197a6202 100644
--- a/app/src/main/java/com/github/libretube/adapters/ChaptersAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/ChaptersAdapter.kt
@@ -3,10 +3,8 @@ package com.github.libretube.adapters
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.ImageView
-import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
-import com.github.libretube.R
+import com.github.libretube.databinding.ChapterColumnBinding
import com.github.libretube.obj.ChapterSegment
import com.google.android.exoplayer2.ExoPlayer
import com.squareup.picasso.Picasso
@@ -16,24 +14,24 @@ class ChaptersAdapter(
private val exoPlayer: ExoPlayer
) : RecyclerView.Adapter() {
val TAG = "ChaptersAdapter"
+ private lateinit var binding: ChapterColumnBinding
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChaptersViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
- val cell = layoutInflater.inflate(R.layout.chapter_column, parent, false)
- return ChaptersViewHolder(cell)
+ binding = ChapterColumnBinding.inflate(layoutInflater, parent, false)
+ return ChaptersViewHolder(binding.root)
}
override fun onBindViewHolder(holder: ChaptersViewHolder, position: Int) {
val chapter = chapters[position]
- val chapterImage = holder.v.findViewById(R.id.chapter_image)
- Picasso.get().load(chapter.image).fit().centerCrop().into(chapterImage)
+ binding.apply {
+ Picasso.get().load(chapter.image).fit().centerCrop().into(chapterImage)
+ chapterTitle.text = chapter.title
- val chapterTitle = holder.v.findViewById(R.id.chapter_title)
- chapterTitle.text = chapter.title
-
- holder.v.setOnClickListener {
- val chapterStart = chapter.start!!.toLong() * 1000 // s -> ms
- exoPlayer.seekTo(chapterStart)
+ root.setOnClickListener {
+ val chapterStart = chapter.start!!.toLong() * 1000 // s -> ms
+ exoPlayer.seekTo(chapterStart)
+ }
}
}
diff --git a/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt
index 3ce71ac4a..0f7088278 100644
--- a/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt
@@ -14,6 +14,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R
+import com.github.libretube.databinding.CommentsRowBinding
import com.github.libretube.obj.Comment
import com.github.libretube.obj.CommentsPage
import com.github.libretube.util.RetrofitInstance
@@ -29,8 +30,9 @@ class CommentsAdapter(
private val videoId: String,
private val comments: MutableList
) : RecyclerView.Adapter() {
-
private val TAG = "CommentsAdapter"
+ private lateinit var binding: CommentsRowBinding
+
private var isLoading = false
private var nextpage = ""
private var repliesPage = CommentsPage()
@@ -42,59 +44,58 @@ class CommentsAdapter(
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CommentsViewHolder {
- val commentsView =
- LayoutInflater.from(parent.context).inflate(R.layout.comments_row, parent, false)
- return CommentsViewHolder(commentsView)
+ val layoutInflater = LayoutInflater.from(parent.context)
+ binding = CommentsRowBinding.inflate(layoutInflater, parent, false)
+ return CommentsViewHolder(binding.root)
}
- @SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) {
- holder.v.findViewById(R.id.comment_infos).text =
- comments[position].author.toString() +
- " • " + comments[position].commentedTime.toString()
- holder.v.findViewById(R.id.comment_text).text =
- comments[position].commentText.toString()
- val channelImage = holder.v.findViewById(R.id.commentor_image)
- Picasso.get().load(comments[position].thumbnail).fit().centerCrop().into(channelImage)
- holder.v.findViewById(R.id.likes_textView).text =
- comments[position].likeCount?.toLong().formatShort()
- if (comments[position].verified == true) {
- holder.v.findViewById(R.id.verified_imageView).visibility = View.VISIBLE
- }
- if (comments[position].pinned == true) {
- holder.v.findViewById(R.id.pinned_imageView).visibility = View.VISIBLE
- }
- if (comments[position].hearted == true) {
- holder.v.findViewById(R.id.hearted_imageView).visibility = View.VISIBLE
- }
- channelImage.setOnClickListener {
- val activity = holder.v.context as MainActivity
- val bundle = bundleOf("channel_id" to comments[position].commentorUrl)
- activity.navController.navigate(R.id.channel, bundle)
- try {
- val mainMotionLayout = activity.findViewById(R.id.mainMotionLayout)
- if (mainMotionLayout.progress == 0.toFloat()) {
- mainMotionLayout.transitionToEnd()
- activity.findViewById(R.id.playerMotionLayout).transitionToEnd()
- }
- } catch (e: Exception) {
+ val comment = comments[position]
+ binding.apply {
+ commentInfos.text =
+ comment.author.toString() +
+ " • " + comment.commentedTime.toString()
+ commentText.text =
+ comment.commentText.toString()
+ Picasso.get().load(comment.thumbnail).fit().centerCrop().into(commentorImage)
+ likesTextView.text =
+ comment.likeCount?.toLong().formatShort()
+ if (comment.verified == true) {
+ verifiedImageView.visibility = View.VISIBLE
}
- }
- val repliesRecView = holder.v.findViewById(R.id.replies_recView)
- repliesRecView.layoutManager = LinearLayoutManager(holder.v.context)
- val repliesAdapter = RepliesAdapter(CommentsPage().comments)
- repliesRecView.adapter = repliesAdapter
- holder.v.setOnClickListener {
- if (repliesAdapter.itemCount == 0) {
- if (comments[position].repliesPage != null) {
- nextpage = comments[position].repliesPage!!
- fetchReplies(nextpage, repliesAdapter)
- } else {
- Toast.makeText(holder.v.context, R.string.no_replies, Toast.LENGTH_SHORT).show()
+ if (comment.pinned == true) {
+ pinnedImageView.visibility = View.VISIBLE
+ }
+ if (comment.hearted == true) {
+ heartedImageView.visibility = View.VISIBLE
+ }
+ commentorImage.setOnClickListener {
+ val activity = holder.v.context as MainActivity
+ val bundle = bundleOf("channel_id" to comment.commentorUrl)
+ activity.navController.navigate(R.id.channel, bundle)
+ try {
+ val mainMotionLayout = activity.findViewById(R.id.mainMotionLayout)
+ if (mainMotionLayout.progress == 0.toFloat()) {
+ mainMotionLayout.transitionToEnd()
+ activity.findViewById(R.id.playerMotionLayout).transitionToEnd()
+ }
+ } catch (e: Exception) {
+ }
+ }
+ repliesRecView.layoutManager = LinearLayoutManager(holder.v.context)
+ val repliesAdapter = RepliesAdapter(CommentsPage().comments)
+ repliesRecView.adapter = repliesAdapter
+ root.setOnClickListener {
+ if (repliesAdapter.itemCount == 0) {
+ if (comment.repliesPage != null) {
+ nextpage = comment.repliesPage
+ fetchReplies(nextpage, repliesAdapter)
+ } else {
+ Toast.makeText(holder.v.context, R.string.no_replies, Toast.LENGTH_SHORT).show()
+ }
+ } else {
+ repliesAdapter.clear()
}
- // repliesAdapter.updateItems(repliesPage.comments)
- } else {
- repliesAdapter.clear()
}
}
}
@@ -103,19 +104,18 @@ class CommentsAdapter(
return comments.size
}
- private fun fetchReplies(nextpage: String, repliesAdapter: RepliesAdapter) {
+ private fun fetchReplies(nextPage: String, repliesAdapter: RepliesAdapter) {
CoroutineScope(Dispatchers.Main).launch {
if (!isLoading) {
isLoading = true
try {
- repliesPage = RetrofitInstance.api.getCommentsNextPage(videoId, nextpage)
+ repliesPage = RetrofitInstance.api.getCommentsNextPage(videoId, nextPage)
} catch (e: IOException) {
println(e)
Log.e(TAG, "IOException, you might not have internet connection")
} catch (e: HttpException) {
Log.e(TAG, "HttpException, unexpected response," + e.response())
}
- // nextpage = if (repliesPage.nextpage!! != null) repliesPage.nextpage!! else ""
repliesAdapter.updateItems(repliesPage.comments)
isLoading = false
}
diff --git a/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt b/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt
index 7cd46cfc8..43819b104 100644
--- a/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt
@@ -10,6 +10,7 @@ import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R
+import com.github.libretube.databinding.RepliesRowBinding
import com.github.libretube.obj.Comment
import com.github.libretube.util.formatShort
import com.squareup.picasso.Picasso
@@ -19,8 +20,7 @@ class RepliesAdapter(
) : RecyclerView.Adapter() {
private val TAG = "RepliesAdapter"
- private var isLoading = false
- private var nextPage = ""
+ private lateinit var binding: RepliesRowBinding
fun clear() {
val size: Int = replies.size
@@ -35,41 +35,43 @@ class RepliesAdapter(
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RepliesViewHolder {
- var repliesView =
- LayoutInflater.from(parent.context).inflate(R.layout.replies_row, parent, false)
- return RepliesViewHolder(repliesView)
+ val layoutInflater = LayoutInflater.from(parent.context)
+ binding = RepliesRowBinding.inflate(layoutInflater, parent, false)
+ return RepliesViewHolder(binding.root)
}
override fun onBindViewHolder(holder: RepliesViewHolder, position: Int) {
- holder.v.findViewById(R.id.comment_infos).text =
- replies[position].author.toString() +
- " • " + replies[position].commentedTime.toString()
- holder.v.findViewById(R.id.comment_text).text =
- replies[position].commentText.toString()
- val channelImage = holder.v.findViewById(R.id.commentor_image)
- Picasso.get().load(replies[position].thumbnail).fit().centerCrop().into(channelImage)
- holder.v.findViewById(R.id.likes_textView).text =
- replies[position].likeCount?.toLong().formatShort()
- if (replies[position].verified == true) {
- holder.v.findViewById(R.id.verified_imageView).visibility = View.VISIBLE
- }
- if (replies[position].pinned == true) {
- holder.v.findViewById(R.id.pinned_imageView).visibility = View.VISIBLE
- }
- if (replies[position].hearted == true) {
- holder.v.findViewById(R.id.hearted_imageView).visibility = View.VISIBLE
- }
- channelImage.setOnClickListener {
- val activity = holder.v.context as MainActivity
- val bundle = bundleOf("channel_id" to replies[position].commentorUrl)
- activity.navController.navigate(R.id.channel, bundle)
- try {
- val mainMotionLayout = activity.findViewById(R.id.mainMotionLayout)
- if (mainMotionLayout.progress == 0.toFloat()) {
- mainMotionLayout.transitionToEnd()
- activity.findViewById(R.id.playerMotionLayout).transitionToEnd()
+ binding.apply {
+ val reply = replies[position]
+ commentInfos.text =
+ reply.author.toString() +
+ " • " + reply.commentedTime.toString()
+ commentText.text =
+ reply.commentText.toString()
+ Picasso.get().load(reply.thumbnail).fit().centerCrop().into(commentorImage)
+ likesTextView.text =
+ reply.likeCount?.toLong().formatShort()
+ if (reply.verified == true) {
+ verifiedImageView.visibility = View.VISIBLE
+ }
+ if (reply.pinned == true) {
+ pinnedImageView.visibility = View.VISIBLE
+ }
+ if (reply.hearted == true) {
+ heartedImageView.visibility = View.VISIBLE
+ }
+ commentorImage.setOnClickListener {
+ val activity = holder.v.context as MainActivity
+ val bundle = bundleOf("channel_id" to reply.commentorUrl)
+ activity.navController.navigate(R.id.channel, bundle)
+ try {
+ val mainMotionLayout = activity.findViewById(R.id.mainMotionLayout)
+ if (mainMotionLayout.progress == 0.toFloat()) {
+ mainMotionLayout.transitionToEnd()
+ activity.findViewById(R.id.playerMotionLayout).transitionToEnd()
+ }
+ } catch (e: Exception) {
}
- } catch (e: Exception) {
}
}
}
From 8958b9051539c02182c71ac6970974676ca6c723 Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Fri, 1 Jul 2022 12:09:54 +0200
Subject: [PATCH 030/202] convert remaining adapters to viewbinding
---
.../libretube/adapters/PlaylistAdapter.kt | 75 ++++++------
.../libretube/adapters/PlaylistsAdapter.kt | 54 +++++----
.../adapters/SearchHistoryAdapter.kt | 28 +++--
.../adapters/SearchSuggestionsAdapter.kt | 21 ++--
.../libretube/adapters/SubscriptionAdapter.kt | 106 +++++++++--------
.../adapters/SubscriptionChannelAdapter.kt | 49 ++++----
.../libretube/adapters/TrendingAdapter.kt | 110 +++++++++---------
.../libretube/fragments/SearchFragment.kt | 4 +-
8 files changed, 231 insertions(+), 216 deletions(-)
diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt
index 05f26b331..5c432d786 100644
--- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt
@@ -13,6 +13,8 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R
+import com.github.libretube.databinding.PlaylistRowBinding
+import com.github.libretube.databinding.PlaylistsRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.obj.PlaylistId
@@ -34,6 +36,8 @@ class PlaylistAdapter(
private val childFragmentManager: FragmentManager
) : RecyclerView.Adapter() {
private val TAG = "PlaylistAdapter"
+ private lateinit var binding: PlaylistRowBinding
+
override fun getItemCount(): Int {
return videoFeed.size
}
@@ -45,45 +49,44 @@ class PlaylistAdapter(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlaylistViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
- val cell = layoutInflater.inflate(R.layout.playlist_row, parent, false)
- return PlaylistViewHolder(cell)
+ binding = PlaylistRowBinding.inflate(layoutInflater, parent, false)
+ return PlaylistViewHolder(binding.root)
}
override fun onBindViewHolder(holder: PlaylistViewHolder, position: Int) {
val streamItem = videoFeed[position]
- holder.v.findViewById(R.id.playlist_title).text = streamItem.title
- holder.v.findViewById(R.id.playlist_description).text = streamItem.uploaderName
- holder.v.findViewById(R.id.playlist_duration).text =
- DateUtils.formatElapsedTime(streamItem.duration!!)
- val thumbnailImage = holder.v.findViewById(R.id.playlist_thumbnail)
- Picasso.get().load(streamItem.thumbnail).into(thumbnailImage)
- holder.v.setOnClickListener {
- var bundle = Bundle()
- bundle.putString("videoId", streamItem.url!!.replace("/watch?v=", ""))
- bundle.putString("playlistId", playlistId)
- var frag = PlayerFragment()
- frag.arguments = bundle
- val activity = holder.v.context as AppCompatActivity
- activity.supportFragmentManager.beginTransaction()
- .remove(PlayerFragment())
- .commit()
- activity.supportFragmentManager.beginTransaction()
- .replace(R.id.container, frag)
- .commitNow()
- }
- holder.v.setOnLongClickListener {
- val videoId = streamItem.url!!.replace("/watch?v=", "")
- VideoOptionsDialog(videoId, holder.v.context)
- .show(childFragmentManager, VideoOptionsDialog.TAG)
- true
- }
+ binding.apply {
+ playlistTitle.text = streamItem.title
+ playlistDescription.text = streamItem.uploaderName
+ playlistDuration.text = DateUtils.formatElapsedTime(streamItem.duration!!)
+ Picasso.get().load(streamItem.thumbnail).into(playlistThumbnail)
+ root.setOnClickListener {
+ var bundle = Bundle()
+ bundle.putString("videoId", streamItem.url!!.replace("/watch?v=", ""))
+ bundle.putString("playlistId", playlistId)
+ var frag = PlayerFragment()
+ frag.arguments = bundle
+ val activity = holder.v.context as AppCompatActivity
+ activity.supportFragmentManager.beginTransaction()
+ .remove(PlayerFragment())
+ .commit()
+ activity.supportFragmentManager.beginTransaction()
+ .replace(R.id.container, frag)
+ .commitNow()
+ }
+ root.setOnLongClickListener {
+ val videoId = streamItem.url!!.replace("/watch?v=", "")
+ VideoOptionsDialog(videoId, holder.v.context)
+ .show(childFragmentManager, VideoOptionsDialog.TAG)
+ true
+ }
- if (isOwner) {
- val delete = holder.v.findViewById(R.id.delete_playlist)
- delete.visibility = View.VISIBLE
- delete.setOnClickListener {
- val token = PreferenceHelper.getToken(holder.v.context)
- removeFromPlaylist(token, position)
+ if (isOwner) {
+ deletePlaylist.visibility = View.VISIBLE
+ deletePlaylist.setOnClickListener {
+ val token = PreferenceHelper.getToken(holder.v.context)
+ removeFromPlaylist(token, position)
+ }
}
}
}
@@ -111,10 +114,6 @@ class PlaylistAdapter(
videoFeed.removeAt(position)
// FIXME: This needs to run on UI thread?
activity.runOnUiThread { notifyDataSetChanged() }
-
- /*if(playlists.isEmpty()){
- view.findViewById(R.id.boogh2).visibility=View.VISIBLE
- }*/
}
} catch (e: Exception) {
Log.e(TAG, e.toString())
diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt
index 08bdb332c..bb38fafcb 100644
--- a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt
@@ -11,6 +11,7 @@ import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R
+import com.github.libretube.databinding.PlaylistsRowBinding
import com.github.libretube.obj.PlaylistId
import com.github.libretube.obj.Playlists
import com.github.libretube.util.PreferenceHelper
@@ -27,6 +28,8 @@ class PlaylistsAdapter(
private val activity: Activity
) : RecyclerView.Adapter() {
val TAG = "PlaylistsAdapter"
+ private lateinit var binding: PlaylistsRowBinding
+
override fun getItemCount(): Int {
return playlists.size
}
@@ -38,37 +41,38 @@ class PlaylistsAdapter(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlaylistsViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
- val cell = layoutInflater.inflate(R.layout.playlists_row, parent, false)
- return PlaylistsViewHolder(cell)
+ binding = PlaylistsRowBinding.inflate(layoutInflater, parent, false)
+ return PlaylistsViewHolder(binding.root)
}
override fun onBindViewHolder(holder: PlaylistsViewHolder, position: Int) {
val playlist = playlists[position]
- val thumbnailImage = holder.v.findViewById(R.id.playlist_thumbnail)
- Picasso.get().load(playlist.thumbnail).into(thumbnailImage)
- // set imageview drawable as empty playlist if imageview empty
- if (thumbnailImage.drawable == null) {
- thumbnailImage.setImageResource(R.drawable.ic_empty_playlist)
- thumbnailImage.setBackgroundColor(R.attr.colorSurface)
- }
- holder.v.findViewById(R.id.playlist_title).text = playlist.name
- holder.v.findViewById(R.id.delete_playlist).setOnClickListener {
- val builder = MaterialAlertDialogBuilder(holder.v.context)
- builder.setTitle(R.string.deletePlaylist)
- builder.setMessage(R.string.areYouSure)
- builder.setPositiveButton(R.string.yes) { _, _ ->
- val token = PreferenceHelper.getToken(holder.v.context)
- deletePlaylist(playlist.id!!, token, position)
+ binding.apply {
+ Picasso.get().load(playlist.thumbnail).into(playlistThumbnail)
+ // set imageview drawable as empty playlist if imageview empty
+ if (playlistThumbnail.drawable == null) {
+ playlistThumbnail.setImageResource(R.drawable.ic_empty_playlist)
+ playlistThumbnail.setBackgroundColor(R.attr.colorSurface)
}
- builder.setNegativeButton(R.string.cancel) { _, _ ->
+ playlistTitle.text = playlist.name
+ deletePlaylist.setOnClickListener {
+ val builder = MaterialAlertDialogBuilder(holder.v.context)
+ builder.setTitle(R.string.deletePlaylist)
+ builder.setMessage(R.string.areYouSure)
+ builder.setPositiveButton(R.string.yes) { _, _ ->
+ val token = PreferenceHelper.getToken(holder.v.context)
+ deletePlaylist(playlist.id!!, token, position)
+ }
+ builder.setNegativeButton(R.string.cancel) { _, _ ->
+ }
+ builder.show()
+ }
+ root.setOnClickListener {
+ // playlists clicked
+ val activity = holder.v.context as MainActivity
+ val bundle = bundleOf("playlist_id" to playlist.id)
+ activity.navController.navigate(R.id.playlistFragment, bundle)
}
- builder.show()
- }
- holder.v.setOnClickListener {
- // playlists clicked
- val activity = holder.v.context as MainActivity
- val bundle = bundleOf("playlist_id" to playlist.id)
- activity.navController.navigate(R.id.playlistFragment, bundle)
}
}
diff --git a/app/src/main/java/com/github/libretube/adapters/SearchHistoryAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SearchHistoryAdapter.kt
index a25359f30..c649c37c7 100644
--- a/app/src/main/java/com/github/libretube/adapters/SearchHistoryAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/SearchHistoryAdapter.kt
@@ -9,6 +9,8 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R
+import com.github.libretube.databinding.SearchhistoryRowBinding
+import com.github.libretube.databinding.SearchsuggestionRowBinding
import com.github.libretube.fragments.SearchFragment
import com.github.libretube.util.PreferenceHelper
@@ -20,29 +22,33 @@ class SearchHistoryAdapter(
) :
RecyclerView.Adapter() {
+ private lateinit var binding: SearchhistoryRowBinding
+
override fun getItemCount(): Int {
return historyList.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchHistoryViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
- val cell = layoutInflater.inflate(R.layout.searchhistory_row, parent, false)
- return SearchHistoryViewHolder(cell)
+ binding = SearchhistoryRowBinding.inflate(layoutInflater, parent, false)
+ return SearchHistoryViewHolder(binding.root)
}
override fun onBindViewHolder(holder: SearchHistoryViewHolder, position: Int) {
val history = historyList[position]
- holder.v.findViewById(R.id.history_text).text = history
+ binding.apply {
+ historyText.text = history
- holder.v.findViewById(R.id.delete_history).setOnClickListener {
- historyList = historyList - history
- PreferenceHelper.saveHistory(context, historyList)
- notifyDataSetChanged()
- }
+ deleteHistory.setOnClickListener {
+ historyList = historyList - history
+ PreferenceHelper.saveHistory(context, historyList)
+ notifyDataSetChanged()
+ }
- holder.v.setOnClickListener {
- editText.setText(history)
- searchFragment.fetchSearch(history)
+ root.setOnClickListener {
+ editText.setText(history)
+ searchFragment.fetchSearch(history)
+ }
}
}
}
diff --git a/app/src/main/java/com/github/libretube/adapters/SearchSuggestionsAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SearchSuggestionsAdapter.kt
index fb899db41..abd368d18 100644
--- a/app/src/main/java/com/github/libretube/adapters/SearchSuggestionsAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/SearchSuggestionsAdapter.kt
@@ -4,9 +4,8 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
-import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
-import com.github.libretube.R
+import com.github.libretube.databinding.SearchsuggestionRowBinding
import com.github.libretube.fragments.SearchFragment
class SearchSuggestionsAdapter(
@@ -16,23 +15,27 @@ class SearchSuggestionsAdapter(
) :
RecyclerView.Adapter() {
+ private val TAG = "SearchSuggestionsAdapter"
+ private lateinit var binding: SearchsuggestionRowBinding
+
override fun getItemCount(): Int {
return suggestionsList.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchSuggestionsViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
- val cell = layoutInflater.inflate(R.layout.searchsuggestion_row, parent, false)
- return SearchSuggestionsViewHolder(cell)
+ binding = SearchsuggestionRowBinding.inflate(layoutInflater, parent, false)
+ return SearchSuggestionsViewHolder(binding.root)
}
override fun onBindViewHolder(holder: SearchSuggestionsViewHolder, position: Int) {
val suggestion = suggestionsList[position]
- val suggestionTextView = holder.v.findViewById(R.id.suggestion_text)
- suggestionTextView.text = suggestion
- holder.v.setOnClickListener {
- editText.setText(suggestion)
- searchFragment.fetchSearch(editText.text.toString())
+ binding.apply {
+ suggestionText.text = suggestion
+ root.setOnClickListener {
+ editText.setText(suggestion)
+ searchFragment.fetchSearch(editText.text.toString())
+ }
}
}
}
diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt
index a05024ce0..b5fefafa4 100644
--- a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt
@@ -5,8 +5,6 @@ import android.text.format.DateUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.ImageView
-import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.os.bundleOf
@@ -14,6 +12,7 @@ import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R
+import com.github.libretube.databinding.TrendingRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.obj.StreamItem
@@ -23,16 +22,16 @@ import com.squareup.picasso.Picasso
class SubscriptionAdapter(
private val videoFeed: List,
private val childFragmentManager: FragmentManager
-) :
- RecyclerView.Adapter() {
- // private var limitedVideoFeed: MutableList = [""].toMutableList()
+) : RecyclerView.Adapter() {
+ private val TAG = "SubscriptionAdapter"
+ private lateinit var binding: TrendingRowBinding
+
var i = 0
override fun getItemCount(): Int {
return i
}
fun updateItems() {
- // limitedVideoFeed.add("")
i += 10
if (i > videoFeed.size) {
i = videoFeed.size
@@ -42,59 +41,58 @@ class SubscriptionAdapter(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubscriptionViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
- val cell = layoutInflater.inflate(R.layout.trending_row, parent, false)
- return SubscriptionViewHolder(cell)
+ binding = TrendingRowBinding.inflate(layoutInflater, parent, false)
+ return SubscriptionViewHolder(binding.root)
}
override fun onBindViewHolder(holder: SubscriptionViewHolder, position: Int) {
val trending = videoFeed[position]
- holder.v.findViewById(R.id.textView_title).text = trending.title
- holder.v.findViewById(R.id.textView_channel).text =
- trending.uploaderName + " • " +
- trending.views.formatShort() + " • " +
- DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
- val thumbnailImage = holder.v.findViewById(R.id.thumbnail)
- val thumbnailDuration = holder.v.findViewById(R.id.thumbnail_duration)
- if (trending.duration != -1L) {
- thumbnailDuration.text = DateUtils.formatElapsedTime(trending.duration!!)
- } else {
- thumbnailDuration.text = holder.v.context.getString(R.string.live)
- thumbnailDuration.setBackgroundColor(R.attr.colorPrimaryDark)
- }
- val channelImage = holder.v.findViewById(R.id.channel_image)
- channelImage.setOnClickListener {
- val activity = holder.v.context as MainActivity
- val bundle = bundleOf("channel_id" to trending.uploaderUrl)
- activity.navController.navigate(R.id.channel, bundle)
- try {
- val mainMotionLayout = activity.findViewById(R.id.mainMotionLayout)
- if (mainMotionLayout.progress == 0.toFloat()) {
- mainMotionLayout.transitionToEnd()
- activity.findViewById(R.id.playerMotionLayout).transitionToEnd()
- }
- } catch (e: Exception) {
+ binding.apply {
+ textViewTitle.text = trending.title
+ textViewChannel.text =
+ trending.uploaderName + " • " +
+ trending.views.formatShort() + " • " +
+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
+ if (trending.duration != -1L) {
+ thumbnailDuration.text = DateUtils.formatElapsedTime(trending.duration!!)
+ } else {
+ thumbnailDuration.text = holder.v.context.getString(R.string.live)
+ thumbnailDuration.setBackgroundColor(R.attr.colorPrimaryDark)
+ }
+ channelImage.setOnClickListener {
+ val activity = holder.v.context as MainActivity
+ val bundle = bundleOf("channel_id" to trending.uploaderUrl)
+ activity.navController.navigate(R.id.channel, bundle)
+ try {
+ val mainMotionLayout = activity.findViewById(R.id.mainMotionLayout)
+ if (mainMotionLayout.progress == 0.toFloat()) {
+ mainMotionLayout.transitionToEnd()
+ activity.findViewById(R.id.playerMotionLayout).transitionToEnd()
+ }
+ } catch (e: Exception) {
+ }
+ }
+ Picasso.get().load(trending.thumbnail).into(thumbnail)
+ Picasso.get().load(trending.uploaderAvatar).into(channelImage)
+ root.setOnClickListener {
+ val bundle = Bundle()
+ bundle.putString("videoId", trending.url!!.replace("/watch?v=", ""))
+ val frag = PlayerFragment()
+ frag.arguments = bundle
+ val activity = holder.v.context as AppCompatActivity
+ activity.supportFragmentManager.beginTransaction()
+ .remove(PlayerFragment())
+ .commit()
+ activity.supportFragmentManager.beginTransaction()
+ .replace(R.id.container, frag)
+ .commitNow()
+ }
+ root.setOnLongClickListener {
+ val videoId = trending.url!!.replace("/watch?v=", "")
+ VideoOptionsDialog(videoId, holder.v.context)
+ .show(childFragmentManager, VideoOptionsDialog.TAG)
+ true
}
- }
- Picasso.get().load(trending.thumbnail).into(thumbnailImage)
- Picasso.get().load(trending.uploaderAvatar).into(channelImage)
- holder.v.setOnClickListener {
- var bundle = Bundle()
- bundle.putString("videoId", trending.url!!.replace("/watch?v=", ""))
- var frag = PlayerFragment()
- frag.arguments = bundle
- val activity = holder.v.context as AppCompatActivity
- activity.supportFragmentManager.beginTransaction()
- .remove(PlayerFragment())
- .commit()
- activity.supportFragmentManager.beginTransaction()
- .replace(R.id.container, frag)
- .commitNow()
- }
- holder.v.setOnLongClickListener {
- val videoId = trending.url!!.replace("/watch?v=", "")
- VideoOptionsDialog(videoId, holder.v.context)
- .show(childFragmentManager, VideoOptionsDialog.TAG)
- true
}
}
}
diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt
index 7ce63a5ba..02d176df1 100644
--- a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt
@@ -11,6 +11,7 @@ import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R
+import com.github.libretube.databinding.ChannelSubscriptionRowBinding
import com.github.libretube.obj.Subscribe
import com.github.libretube.obj.Subscription
import com.github.libretube.util.PreferenceHelper
@@ -25,8 +26,11 @@ import java.io.IOException
class SubscriptionChannelAdapter(private val subscriptions: MutableList) :
RecyclerView.Adapter() {
val TAG = "SubChannelAdapter"
+ private lateinit var binding: ChannelSubscriptionRowBinding
+
private var subscribed = true
private var isLoading = false
+
override fun getItemCount(): Int {
return subscriptions.size
}
@@ -34,34 +38,31 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList(R.id.subscription_channel_name).text = subscription.name
- val avatar = holder.v.findViewById(R.id.subscription_channel_image)
- Picasso.get().load(subscription.avatar).into(avatar)
- holder.v.setOnClickListener {
- val activity = holder.v.context as MainActivity
- val bundle = bundleOf("channel_id" to subscription.url)
- activity.navController.navigate(R.id.channel, bundle)
- }
- val subscribeBtn = holder.v
- .findViewById(
- R.id.subscription_subscribe
- )
- subscribeBtn.setOnClickListener {
- if (!isLoading) {
- isLoading = true
- val channelId = subscription.url?.replace("/channel/", "")!!
- if (subscribed) {
- unsubscribe(holder.v.context, channelId)
- subscribeBtn.text = holder.v.context.getString(R.string.subscribe)
- } else {
- subscribe(holder.v.context, channelId)
- subscribeBtn.text = holder.v.context.getString(R.string.unsubscribe)
+ binding.apply {
+ subscriptionChannelName.text = subscription.name
+ Picasso.get().load(subscription.avatar).into(subscriptionChannelImage)
+ root.setOnClickListener {
+ val activity = holder.v.context as MainActivity
+ val bundle = bundleOf("channel_id" to subscription.url)
+ activity.navController.navigate(R.id.channel, bundle)
+ }
+ subscriptionSubscribe.setOnClickListener {
+ if (!isLoading) {
+ isLoading = true
+ val channelId = subscription.url?.replace("/channel/", "")!!
+ if (subscribed) {
+ unsubscribe(root.context, channelId)
+ subscriptionSubscribe.text = holder.v.context.getString(R.string.subscribe)
+ } else {
+ subscribe(root.context, channelId)
+ subscriptionSubscribe.text = holder.v.context.getString(R.string.unsubscribe)
+ }
}
}
}
diff --git a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt
index 0d223e54d..2faccc042 100644
--- a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt
@@ -14,6 +14,8 @@ import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R
+import com.github.libretube.databinding.ChannelSubscriptionRowBinding
+import com.github.libretube.databinding.TrendingRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.obj.StreamItem
@@ -24,72 +26,72 @@ class TrendingAdapter(
private val videoFeed: List,
private val childFragmentManager: FragmentManager
) : RecyclerView.Adapter() {
+ private val TAG = "TrendingAdapter"
+ private lateinit var binding: TrendingRowBinding
+
override fun getItemCount(): Int {
return videoFeed.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TrendingViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
- val cell = layoutInflater.inflate(R.layout.trending_row, parent, false)
- return TrendingViewHolder(cell)
+ binding = TrendingRowBinding.inflate(layoutInflater, parent, false)
+ return TrendingViewHolder(binding.root)
}
override fun onBindViewHolder(holder: TrendingViewHolder, position: Int) {
val trending = videoFeed[position]
- holder.v.findViewById(R.id.textView_title).text = trending.title
- holder.v.findViewById(R.id.textView_channel).text =
- trending.uploaderName + " • " +
- trending.views.formatShort() + " • " +
- DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
- val thumbnailImage = holder.v.findViewById(R.id.thumbnail)
- val thumbnailDuration = holder.v.findViewById(R.id.thumbnail_duration)
- if (trending.duration != -1L) {
- thumbnailDuration.text = DateUtils.formatElapsedTime(trending.duration!!)
- } else {
- thumbnailDuration.text = holder.v.context.getString(R.string.live)
- thumbnailDuration.setBackgroundColor(R.attr.colorPrimaryDark)
- }
- val channelImage = holder.v.findViewById(R.id.channel_image)
- channelImage.setOnClickListener {
- val activity = holder.v.context as MainActivity
- val bundle = bundleOf("channel_id" to trending.uploaderUrl)
- activity.navController.navigate(R.id.channel, bundle)
- try {
- val mainMotionLayout = activity.findViewById(R.id.mainMotionLayout)
- if (mainMotionLayout.progress == 0.toFloat()) {
- mainMotionLayout.transitionToEnd()
- activity.findViewById(R.id.playerMotionLayout).transitionToEnd()
- }
- } catch (e: Exception) {
+ binding.apply {
+ textViewTitle.text = trending.title
+ textViewChannel.text =
+ trending.uploaderName + " • " +
+ trending.views.formatShort() + " • " +
+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
+ if (trending.duration != -1L) {
+ thumbnailDuration.text = DateUtils.formatElapsedTime(trending.duration!!)
+ } else {
+ thumbnailDuration.text = holder.v.context.getString(R.string.live)
+ thumbnailDuration.setBackgroundColor(R.attr.colorPrimaryDark)
+ }
+ channelImage.setOnClickListener {
+ val activity = holder.v.context as MainActivity
+ val bundle = bundleOf("channel_id" to trending.uploaderUrl)
+ activity.navController.navigate(R.id.channel, bundle)
+ try {
+ val mainMotionLayout = activity.findViewById(R.id.mainMotionLayout)
+ if (mainMotionLayout.progress == 0.toFloat()) {
+ mainMotionLayout.transitionToEnd()
+ activity.findViewById(R.id.playerMotionLayout).transitionToEnd()
+ }
+ } catch (e: Exception) {
+ }
+ }
+ if (trending.thumbnail!!.isNotEmpty()) {
+ Picasso.get().load(trending.thumbnail).into(thumbnail)
+ }
+ if (trending.uploaderAvatar!!.isNotEmpty()) {
+ Picasso.get().load(trending.uploaderAvatar).into(channelImage)
}
- }
- if (trending.thumbnail!!.isEmpty()) {
- } else {
- Picasso.get().load(trending.thumbnail).into(thumbnailImage)
- }
- if (trending.uploaderAvatar!!.isEmpty()) {
- } else {
- Picasso.get().load(trending.uploaderAvatar).into(channelImage)
- }
- holder.v.setOnClickListener {
- var bundle = Bundle()
- bundle.putString("videoId", trending.url!!.replace("/watch?v=", ""))
- var frag = PlayerFragment()
- frag.arguments = bundle
- val activity = holder.v.context as AppCompatActivity
- activity.supportFragmentManager.beginTransaction()
- .remove(PlayerFragment())
- .commit()
- activity.supportFragmentManager.beginTransaction()
- .replace(R.id.container, frag)
- .commitNow()
- }
- holder.v.setOnLongClickListener {
- val videoId = trending.url!!.replace("/watch?v=", "")
- VideoOptionsDialog(videoId, holder.v.context)
- .show(childFragmentManager, VideoOptionsDialog.TAG)
- true
+ root.setOnClickListener {
+ var bundle = Bundle()
+ bundle.putString("videoId", trending.url!!.replace("/watch?v=", ""))
+ var frag = PlayerFragment()
+ frag.arguments = bundle
+ val activity = holder.v.context as AppCompatActivity
+ activity.supportFragmentManager.beginTransaction()
+ .remove(PlayerFragment())
+ .commit()
+ activity.supportFragmentManager.beginTransaction()
+ .replace(R.id.container, frag)
+ .commitNow()
+ }
+ root.setOnLongClickListener {
+ val videoId = trending.url!!.replace("/watch?v=", "")
+ VideoOptionsDialog(videoId, holder.v.context)
+ .show(childFragmentManager, VideoOptionsDialog.TAG)
+ true
+ }
}
}
}
diff --git a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt
index c81a8ec87..855aaa3b9 100644
--- a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt
@@ -183,6 +183,9 @@ class SearchFragment : Fragment() {
}
fun fetchSearch(query: String) {
+ runOnUiThread {
+ binding.historyRecycler.visibility = GONE
+ }
lifecycleScope.launchWhenCreated {
isFetchingSearch = true
hideKeyboard()
@@ -199,7 +202,6 @@ class SearchFragment : Fragment() {
nextPage = response.nextpage
if (response.items!!.isNotEmpty()) {
runOnUiThread {
- binding.historyRecycler.visibility = GONE
binding.searchRecycler.visibility = VISIBLE
searchAdapter = SearchAdapter(response.items, childFragmentManager)
binding.searchRecycler.adapter = searchAdapter
From 13ba954c6d1bc4910eb43114fccea6b62dac9481 Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Fri, 1 Jul 2022 12:11:30 +0200
Subject: [PATCH 031/202] cleanup
---
.../github/libretube/adapters/ChannelAdapter.kt | 5 +----
.../github/libretube/adapters/CommentsAdapter.kt | 14 +++++++-------
.../github/libretube/adapters/PlaylistAdapter.kt | 3 ---
.../github/libretube/adapters/PlaylistsAdapter.kt | 2 --
.../github/libretube/adapters/RepliesAdapter.kt | 10 +++++-----
.../libretube/adapters/SearchHistoryAdapter.kt | 4 ----
.../libretube/adapters/SubscriptionAdapter.kt | 6 ++++--
.../adapters/SubscriptionChannelAdapter.kt | 5 ++---
.../github/libretube/adapters/TrendingAdapter.kt | 15 +++++++--------
.../github/libretube/fragments/SearchFragment.kt | 7 ++++++-
10 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt
index d6ea63c02..d508172c6 100644
--- a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt
@@ -5,13 +5,10 @@ import android.text.format.DateUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.ImageView
-import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R
-import com.github.libretube.databinding.ChannelSubscriptionRowBinding
import com.github.libretube.databinding.VideoChannelRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment
@@ -47,7 +44,7 @@ class ChannelAdapter(
channelDescription.text = trending.title
channelViews.text =
trending.views.formatShort() + " • " +
- DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
channelDuration.text =
DateUtils.formatElapsedTime(trending.duration!!)
Picasso.get().load(trending.thumbnail).into(channelThumbnail)
diff --git a/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt
index 0f7088278..200aae14c 100644
--- a/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/CommentsAdapter.kt
@@ -1,12 +1,9 @@
package com.github.libretube.adapters
-import android.annotation.SuppressLint
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.ImageView
-import android.widget.TextView
import android.widget.Toast
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.os.bundleOf
@@ -54,7 +51,7 @@ class CommentsAdapter(
binding.apply {
commentInfos.text =
comment.author.toString() +
- " • " + comment.commentedTime.toString()
+ " • " + comment.commentedTime.toString()
commentText.text =
comment.commentText.toString()
Picasso.get().load(comment.thumbnail).fit().centerCrop().into(commentorImage)
@@ -74,10 +71,12 @@ class CommentsAdapter(
val bundle = bundleOf("channel_id" to comment.commentorUrl)
activity.navController.navigate(R.id.channel, bundle)
try {
- val mainMotionLayout = activity.findViewById(R.id.mainMotionLayout)
+ val mainMotionLayout =
+ activity.findViewById(R.id.mainMotionLayout)
if (mainMotionLayout.progress == 0.toFloat()) {
mainMotionLayout.transitionToEnd()
- activity.findViewById(R.id.playerMotionLayout).transitionToEnd()
+ activity.findViewById(R.id.playerMotionLayout)
+ .transitionToEnd()
}
} catch (e: Exception) {
}
@@ -91,7 +90,8 @@ class CommentsAdapter(
nextpage = comment.repliesPage
fetchReplies(nextpage, repliesAdapter)
} else {
- Toast.makeText(holder.v.context, R.string.no_replies, Toast.LENGTH_SHORT).show()
+ Toast.makeText(holder.v.context, R.string.no_replies, Toast.LENGTH_SHORT)
+ .show()
}
} else {
repliesAdapter.clear()
diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt
index 5c432d786..e08c65489 100644
--- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt
@@ -7,14 +7,11 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.ImageView
-import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R
import com.github.libretube.databinding.PlaylistRowBinding
-import com.github.libretube.databinding.PlaylistsRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.obj.PlaylistId
diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt
index bb38fafcb..49a2fa274 100644
--- a/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/PlaylistsAdapter.kt
@@ -5,8 +5,6 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.ImageView
-import android.widget.TextView
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
diff --git a/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt b/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt
index 43819b104..edbdca36a 100644
--- a/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/RepliesAdapter.kt
@@ -3,8 +3,6 @@ package com.github.libretube.adapters
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.ImageView
-import android.widget.TextView
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView
@@ -45,7 +43,7 @@ class RepliesAdapter(
val reply = replies[position]
commentInfos.text =
reply.author.toString() +
- " • " + reply.commentedTime.toString()
+ " • " + reply.commentedTime.toString()
commentText.text =
reply.commentText.toString()
Picasso.get().load(reply.thumbnail).fit().centerCrop().into(commentorImage)
@@ -65,10 +63,12 @@ class RepliesAdapter(
val bundle = bundleOf("channel_id" to reply.commentorUrl)
activity.navController.navigate(R.id.channel, bundle)
try {
- val mainMotionLayout = activity.findViewById(R.id.mainMotionLayout)
+ val mainMotionLayout =
+ activity.findViewById(R.id.mainMotionLayout)
if (mainMotionLayout.progress == 0.toFloat()) {
mainMotionLayout.transitionToEnd()
- activity.findViewById(R.id.playerMotionLayout).transitionToEnd()
+ activity.findViewById(R.id.playerMotionLayout)
+ .transitionToEnd()
}
} catch (e: Exception) {
}
diff --git a/app/src/main/java/com/github/libretube/adapters/SearchHistoryAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SearchHistoryAdapter.kt
index c649c37c7..5b0412c9c 100644
--- a/app/src/main/java/com/github/libretube/adapters/SearchHistoryAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/SearchHistoryAdapter.kt
@@ -5,12 +5,8 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
-import android.widget.ImageView
-import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
-import com.github.libretube.R
import com.github.libretube.databinding.SearchhistoryRowBinding
-import com.github.libretube.databinding.SearchsuggestionRowBinding
import com.github.libretube.fragments.SearchFragment
import com.github.libretube.util.PreferenceHelper
diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt
index b5fefafa4..7462b580f 100644
--- a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt
@@ -64,10 +64,12 @@ class SubscriptionAdapter(
val bundle = bundleOf("channel_id" to trending.uploaderUrl)
activity.navController.navigate(R.id.channel, bundle)
try {
- val mainMotionLayout = activity.findViewById(R.id.mainMotionLayout)
+ val mainMotionLayout =
+ activity.findViewById(R.id.mainMotionLayout)
if (mainMotionLayout.progress == 0.toFloat()) {
mainMotionLayout.transitionToEnd()
- activity.findViewById(R.id.playerMotionLayout).transitionToEnd()
+ activity.findViewById(R.id.playerMotionLayout)
+ .transitionToEnd()
}
} catch (e: Exception) {
}
diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt
index 02d176df1..6a4586ff6 100644
--- a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt
@@ -5,8 +5,6 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.widget.ImageView
-import android.widget.TextView
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
@@ -61,7 +59,8 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList() {
private val TAG = "TrendingAdapter"
- private lateinit var binding: TrendingRowBinding
+ private lateinit var binding: TrendingRowBinding
override fun getItemCount(): Int {
return videoFeed.size
@@ -45,8 +42,8 @@ class TrendingAdapter(
textViewTitle.text = trending.title
textViewChannel.text =
trending.uploaderName + " • " +
- trending.views.formatShort() + " • " +
- DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
+ trending.views.formatShort() + " • " +
+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
if (trending.duration != -1L) {
thumbnailDuration.text = DateUtils.formatElapsedTime(trending.duration!!)
} else {
@@ -58,10 +55,12 @@ class TrendingAdapter(
val bundle = bundleOf("channel_id" to trending.uploaderUrl)
activity.navController.navigate(R.id.channel, bundle)
try {
- val mainMotionLayout = activity.findViewById(R.id.mainMotionLayout)
+ val mainMotionLayout =
+ activity.findViewById(R.id.mainMotionLayout)
if (mainMotionLayout.progress == 0.toFloat()) {
mainMotionLayout.transitionToEnd()
- activity.findViewById(R.id.playerMotionLayout).transitionToEnd()
+ activity.findViewById(R.id.playerMotionLayout)
+ .transitionToEnd()
}
} catch (e: Exception) {
}
diff --git a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt
index 855aaa3b9..e6a9fd737 100644
--- a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt
@@ -259,7 +259,12 @@ class SearchFragment : Fragment() {
val historyList = PreferenceHelper.getHistory(requireContext())
if (historyList.isNotEmpty()) {
binding.historyRecycler.adapter =
- SearchHistoryAdapter(requireContext(), historyList, binding.autoCompleteTextView, this)
+ SearchHistoryAdapter(
+ requireContext(),
+ historyList,
+ binding.autoCompleteTextView,
+ this
+ )
binding.historyRecycler.visibility = VISIBLE
}
}
From afd71c7c5417a84f5306868ef216ca81c460c1ef Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Fri, 1 Jul 2022 15:12:00 +0200
Subject: [PATCH 032/202] viewbind playerview
---
.../libretube/fragments/PlayerFragment.kt | 37 +++++++++----------
.../libretube/util/CustomExoPlayerView.kt | 2 +
2 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
index 6e7b0186e..4681913f9 100644
--- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
@@ -80,7 +80,6 @@ import com.google.android.exoplayer2.upstream.DefaultDataSource
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
import com.google.android.exoplayer2.util.RepeatModeUtil
import com.google.android.material.button.MaterialButton
-import com.google.android.material.card.MaterialCardView
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.squareup.picasso.Picasso
import kotlinx.coroutines.CoroutineScope
@@ -233,7 +232,7 @@ class PlayerFragment : Fragment() {
.remove(this)
.commit()
}
- view.findViewById(R.id.close_imageButton).setOnClickListener {
+ binding.player.binding.closeImageButton.setOnClickListener {
isMiniPlayerVisible = false
binding.playerMotionLayout.transitionToEnd()
val mainActivity = activity as MainActivity
@@ -261,13 +260,12 @@ class PlayerFragment : Fragment() {
if (binding.descLinLayout.isVisible) View.GONE else View.VISIBLE
}
- view.findViewById(R.id.comments_toggle)
- .setOnClickListener {
+ binding.commentsToggle.setOnClickListener {
toggleComments()
}
- val fullScreenButton = view.findViewById(R.id.fullscreen)
- val exoTitle = view.findViewById(R.id.exo_title)
+ val fullScreenButton = binding.player.binding.fullscreen
+ val exoTitle = binding.player.binding.exoTitle
// FullScreen button trigger
fullScreenButton.setOnClickListener {
@@ -303,7 +301,8 @@ class PlayerFragment : Fragment() {
}
// switching between original aspect ratio (black bars) and zoomed to fill device screen
- view.findViewById(R.id.aspect_ratio_button).setOnClickListener {
+ val aspectRatioButton = binding.player.binding.aspectRatioButton
+ aspectRatioButton.setOnClickListener {
if (isZoomed) {
exoPlayerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT
isZoomed = false
@@ -314,7 +313,7 @@ class PlayerFragment : Fragment() {
}
// lock and unlock the player
- val lockPlayerButton = view.findViewById(R.id.lock_player)
+ val lockPlayerButton = binding.player.binding.lockPlayer
lockPlayerButton.setOnClickListener {
// change the locked/unlocked icon
if (!isPlayerLocked) {
@@ -630,7 +629,7 @@ class PlayerFragment : Fragment() {
binding.playerTitle.text = response.title
binding.playerDescription.text = response.description
- view.findViewById(R.id.exo_title).text = response.title
+ binding.player.binding.exoTitle.text = response.title
// Listener for play and pause icon change
exoPlayer.addListener(object : Player.Listener {
@@ -802,8 +801,8 @@ class PlayerFragment : Fragment() {
PreferenceHelper.getString(requireContext(), "player_video_format", "WEBM")
val defres = PreferenceHelper.getString(requireContext(), "default_res", "")!!
- val qualityText = view.findViewById(R.id.quality_text)
- val qualitySelect = view.findViewById(R.id.quality_linLayout)
+ val qualityText = binding.player.binding.qualityText
+ val qualitySelect = binding.player.binding.qualitySelect
var videosNameArray: Array = arrayOf()
var videosUrlArray: Array = arrayOf()
@@ -987,12 +986,12 @@ class PlayerFragment : Fragment() {
private fun lockPlayer(isLocked: Boolean) {
val visibility = if (isLocked) View.VISIBLE else View.INVISIBLE
- exoPlayerView.findViewById(R.id.exo_top_bar_right).visibility = visibility
- exoPlayerView.findViewById(R.id.exo_play_pause).visibility = visibility
- exoPlayerView.findViewById(R.id.exo_ffwd_with_amount).visibility = visibility
- exoPlayerView.findViewById(R.id.exo_rew_with_amount).visibility = visibility
- exoPlayerView.findViewById(R.id.exo_bottom_bar).visibility = visibility
- exoPlayerView.findViewById(R.id.exo_title).visibility =
+ binding.player.binding.exoTopBarRight.visibility = visibility
+ binding.player.binding.exoPlayPause.visibility = visibility
+ binding.player.binding.exoFfwdWithAmount.visibility = visibility
+ binding.player.binding.exoRewWithAmount.visibility = visibility
+ binding.player.binding.exoBottomBar.visibility = visibility
+ binding.player.binding.exoTitle.visibility =
if (isLocked && isFullScreen) View.VISIBLE else View.INVISIBLE
}
@@ -1154,7 +1153,7 @@ class PlayerFragment : Fragment() {
enableTransition(R.id.yt_transition, false)
}
binding.mainContainer.isClickable = true
- view?.findViewById(R.id.exo_top_bar)?.visibility = View.GONE
+ binding.player.binding.exoTopBar.visibility = View.GONE
val mainActivity = activity as MainActivity
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
isFullScreen = false
@@ -1166,7 +1165,7 @@ class PlayerFragment : Fragment() {
exoPlayerView.showController()
exoPlayerView.useController = true
binding.mainContainer.isClickable = false
- view?.findViewById(R.id.exo_top_bar)?.visibility = View.VISIBLE
+ binding.player.binding.exoTopBar.visibility = View.VISIBLE
}
}
diff --git a/app/src/main/java/com/github/libretube/util/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/util/CustomExoPlayerView.kt
index 25ba13df8..acb87ce11 100644
--- a/app/src/main/java/com/github/libretube/util/CustomExoPlayerView.kt
+++ b/app/src/main/java/com/github/libretube/util/CustomExoPlayerView.kt
@@ -4,12 +4,14 @@ import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
+import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
import com.google.android.exoplayer2.ui.StyledPlayerView
internal class CustomExoPlayerView(
context: Context,
attributeSet: AttributeSet? = null
) : StyledPlayerView(context, attributeSet) {
+ val binding: ExoStyledPlayerControlViewBinding = ExoStyledPlayerControlViewBinding.bind(this)
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean {
From 920a920f102b1e32013ff05f1ef82d6d2c37e927 Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Fri, 1 Jul 2022 16:44:14 +0200
Subject: [PATCH 033/202] move noInternetActivity
---
app/src/main/AndroidManifest.xml | 6 ++--
.../java/com/github/libretube/MainActivity.kt | 18 ++---------
.../github/libretube/NoInternetActivity.kt | 31 +++++++++++++++++++
.../libretube/adapters/SearchAdapter.kt | 17 +++++-----
.../main/res/layout/activity_nointernet.xml | 6 ++--
5 files changed, 51 insertions(+), 27 deletions(-)
create mode 100644 app/src/main/java/com/github/libretube/NoInternetActivity.kt
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b5efba744..e9662a30f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -24,8 +24,10 @@
+ android:exported="false" />
+
diff --git a/app/src/main/java/com/github/libretube/MainActivity.kt b/app/src/main/java/com/github/libretube/MainActivity.kt
index 459bb8d4a..e4c3dff78 100644
--- a/app/src/main/java/com/github/libretube/MainActivity.kt
+++ b/app/src/main/java/com/github/libretube/MainActivity.kt
@@ -19,8 +19,6 @@ import android.view.WindowInsets
import android.view.WindowInsetsController
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
-import android.widget.Button
-import android.widget.ImageView
import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
@@ -50,7 +48,6 @@ class MainActivity : AppCompatActivity() {
lateinit var binding: ActivityMainBinding
private lateinit var bottomNavigationView: BottomNavigationView
- private lateinit var toolbar: Toolbar
lateinit var navController: NavController
override fun onCreate(savedInstanceState: Bundle?) {
@@ -70,14 +67,8 @@ class MainActivity : AppCompatActivity() {
// show noInternet Activity if no internet available on app startup
if (!isNetworkAvailable(this)) {
- setContentView(R.layout.activity_nointernet)
- findViewById(R.id.retry_button).setOnClickListener {
- recreate()
- }
- findViewById(R.id.noInternet_settingsImageView).setOnClickListener {
- val intent = Intent(this, SettingsActivity::class.java)
- startActivity(intent)
- }
+ val noInternetIntent = Intent(this, NoInternetActivity::class.java)
+ startActivity(noInternetIntent)
} else {
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
@@ -286,7 +277,6 @@ class MainActivity : AppCompatActivity() {
navController.popBackStack()
}
} catch (e: Exception) {
- // try catch to prevent nointernet activity to crash
try {
navController.popBackStack()
moveTaskToBack(true)
@@ -364,10 +354,6 @@ fun Fragment.hideKeyboard() {
view?.let { activity?.hideKeyboard(it) }
}
-fun Activity.hideKeyboard() {
- hideKeyboard(currentFocus ?: View(this))
-}
-
fun Context.hideKeyboard(view: View) {
val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
diff --git a/app/src/main/java/com/github/libretube/NoInternetActivity.kt b/app/src/main/java/com/github/libretube/NoInternetActivity.kt
new file mode 100644
index 000000000..98deda07f
--- /dev/null
+++ b/app/src/main/java/com/github/libretube/NoInternetActivity.kt
@@ -0,0 +1,31 @@
+package com.github.libretube
+
+import android.content.Intent
+import android.os.Bundle
+import androidx.appcompat.app.AppCompatActivity
+import com.github.libretube.databinding.ActivityNointernetBinding
+import com.github.libretube.util.ThemeHelper
+import com.google.android.material.color.DynamicColors
+
+class NoInternetActivity : AppCompatActivity() {
+ private lateinit var binding: ActivityNointernetBinding
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ DynamicColors.applyToActivityIfAvailable(this)
+ super.onCreate(savedInstanceState)
+ binding = ActivityNointernetBinding.inflate(layoutInflater)
+ binding.retryButton.setOnClickListener {
+ ThemeHelper.restartMainActivity(this)
+ }
+ binding.noInternetSettingsImageView.setOnClickListener {
+ val intent = Intent(this, SettingsActivity::class.java)
+ startActivity(intent)
+ }
+ setContentView(binding.root)
+ }
+
+ override fun onBackPressed() {
+ finishAffinity()
+ super.onBackPressed()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt
index d7a8d465d..5247725c7 100644
--- a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt
+++ b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt
@@ -13,6 +13,9 @@ import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R
+import com.github.libretube.databinding.ChannelSearchRowBinding
+import com.github.libretube.databinding.PlaylistSearchRowBinding
+import com.github.libretube.databinding.VideoSearchRowBinding
import com.github.libretube.dialogs.PlaylistOptionsDialog
import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment
@@ -37,15 +40,15 @@ class SearchAdapter(
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchViewHolder {
- val layout = when (viewType) {
- 0 -> R.layout.video_search_row
- 1 -> R.layout.channel_search_row
- 2 -> R.layout.playlist_search_row
+ val layoutInflater = LayoutInflater.from(parent.context)
+
+ val binding = when (viewType) {
+ 0 -> VideoSearchRowBinding.inflate(layoutInflater, parent, false)
+ 1 -> ChannelSearchRowBinding.inflate(layoutInflater, parent, false)
+ 2 -> PlaylistSearchRowBinding.inflate(layoutInflater, parent, false)
else -> throw IllegalArgumentException("Invalid type")
}
- val layoutInflater = LayoutInflater.from(parent.context)
- val cell = layoutInflater.inflate(layout, parent, false)
- return SearchViewHolder(cell, childFragmentManager)
+ return SearchViewHolder(binding.root, childFragmentManager)
}
override fun onBindViewHolder(holder: SearchViewHolder, position: Int) {
diff --git a/app/src/main/res/layout/activity_nointernet.xml b/app/src/main/res/layout/activity_nointernet.xml
index 69874d73e..c0fde8737 100644
--- a/app/src/main/res/layout/activity_nointernet.xml
+++ b/app/src/main/res/layout/activity_nointernet.xml
@@ -6,10 +6,12 @@
From a08a14758bf560787dd588e5ddae9aa372a0dc7c Mon Sep 17 00:00:00 2001
From: Bnyro
Date: Fri, 1 Jul 2022 16:54:20 +0200
Subject: [PATCH 034/202] structure
---
app/src/main/AndroidManifest.xml | 22 +++++++++----------
.../{ => activities}/MainActivity.kt | 4 ++--
.../{ => activities}/NoInternetActivity.kt | 2 +-
.../{ => activities}/RouterActivity.kt | 3 ++-
.../{ => activities}/SettingsActivity.kt | 3 ++-
.../libretube/adapters/CommentsAdapter.kt | 2 +-
.../libretube/adapters/PlaylistsAdapter.kt | 2 +-
.../libretube/adapters/RepliesAdapter.kt | 2 +-
.../libretube/adapters/SearchAdapter.kt | 2 +-
.../libretube/adapters/SubscriptionAdapter.kt | 2 +-
.../adapters/SubscriptionChannelAdapter.kt | 2 +-
.../libretube/adapters/TrendingAdapter.kt | 2 +-
.../libretube/dialogs/DeleteAccountDialog.kt | 2 +-
.../libretube/dialogs/DownloadDialog.kt | 2 +-
.../libretube/dialogs/VideoOptionsDialog.kt | 2 +-
.../libretube/fragments/PlayerFragment.kt | 4 ++--
.../libretube/fragments/SearchFragment.kt | 2 +-
.../libretube/preferences/AboutFragment.kt | 12 +++++-----
.../libretube/preferences/AdvancedSettings.kt | 4 ++--
.../preferences/AppearanceSettings.kt | 4 ++--
.../libretube/preferences/InstanceSettings.kt | 4 ++--
.../libretube/preferences/MainSettings.kt | 4 ++--
.../libretube/preferences/PlayerSettings.kt | 2 +-
.../preferences/SponsorBlockSettings.kt | 2 +-
.../libretube/{ => util}/BackgroundMode.kt | 5 +----
.../github/libretube/{ => util}/Constants.kt | 2 +-
.../libretube/util/DescriptionAdapter.kt | 2 +-
.../github/libretube/util/UpdateChecker.kt | 1 -
28 files changed, 50 insertions(+), 52 deletions(-)
rename app/src/main/java/com/github/libretube/{ => activities}/MainActivity.kt (99%)
rename app/src/main/java/com/github/libretube/{ => activities}/NoInternetActivity.kt (96%)
rename app/src/main/java/com/github/libretube/{ => activities}/RouterActivity.kt (96%)
rename app/src/main/java/com/github/libretube/{ => activities}/SettingsActivity.kt (97%)
rename app/src/main/java/com/github/libretube/{ => util}/BackgroundMode.kt (97%)
rename app/src/main/java/com/github/libretube/{ => util}/Constants.kt (92%)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e9662a30f..3081a7847 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,13 +26,13 @@
android:configChanges="orientation|screenSize"
android:exported="false" />
+ android:targetActivity=".activities.MainActivity">