Compare commits
96 Commits
Author | SHA1 | Date | |
---|---|---|---|
327f6f0e8d | |||
d6f1a360d2 | |||
24ec69d7f7 | |||
c80692bd34 | |||
b5e9f70be6 | |||
d446081331 | |||
8178cff72c | |||
950d99b5de | |||
b7855cb1a2 | |||
b298fbfa3e | |||
d83929f80a | |||
b932ed2c13 | |||
36073d340d | |||
0e14540b69 | |||
57327a8ad0 | |||
bbfa278d6b | |||
439decf6a9 | |||
2277cc5f05 | |||
4204ffccee | |||
31407e709d | |||
44d26bb1cf | |||
8a8a433023 | |||
5c27292543 | |||
e475348d39 | |||
9f8358e471 | |||
4fd8d42d85 | |||
498990c48a | |||
1cddf26c9a | |||
325a239b86 | |||
2c4ef9c3ce | |||
4dbd191c4f | |||
01e489da10 | |||
53a7062c6d | |||
3425e1e593 | |||
9970635ff8 | |||
c1f174a5b8 | |||
3587e7c524 | |||
3911ad15a6 | |||
d40b35da59 | |||
ccb6e184cc | |||
74e45b1820 | |||
0a1336f0e0 | |||
d5a0dcb980 | |||
83e7c41ca0 | |||
1d1b0c11a9 | |||
3b2c4e2ac6 | |||
2d77fe580f | |||
7ae20f43f8 | |||
f03c1b206b | |||
d99a58f2cf | |||
5aeaf7f34b | |||
af0b484d16 | |||
0a6791b752 | |||
e73e306d05 | |||
52189abbff | |||
d721f12d74 | |||
69f28bb647 | |||
2b2295d831 | |||
179586b8c4 | |||
1afad9e06a | |||
59c73fd864 | |||
6820344750 | |||
680504791c | |||
41e500a8f8 | |||
448af1ef9a | |||
041e8c0bd6 | |||
0b7300e93a | |||
94c5f5a705 | |||
fa2f8a7b05 | |||
aeb288142e | |||
635c43f458 | |||
d36138431b | |||
9cdf857730 | |||
52a6152af6 | |||
9d3312c081 | |||
1146236f46 | |||
ec19ee1e55 | |||
cc37e40158 | |||
bdd12de34d | |||
e64692d0d3 | |||
7da8c0f664 | |||
fc41c077dc | |||
50800da4b9 | |||
a9219e8a91 | |||
5eedadef47 | |||
14cde8e625 | |||
1f2ecd591d | |||
9a2eb6cd49 | |||
aa38514bcb | |||
f2fddfb16c | |||
05300682c1 | |||
a3714a4ecf | |||
500584b9ef | |||
33ac822957 | |||
d3ffc32d9b | |||
a6dfd842e3 |
17
.github/stale.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Number of days of inactivity before an issue becomes stale
|
||||||
|
daysUntilStale: 60
|
||||||
|
# Number of days of inactivity before a stale issue is closed
|
||||||
|
daysUntilClose: 7
|
||||||
|
# Issues with these labels will never be considered stale
|
||||||
|
exemptLabels:
|
||||||
|
- pinned
|
||||||
|
- security
|
||||||
|
# Label to use when marking an issue as stale
|
||||||
|
staleLabel: inactive
|
||||||
|
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||||
|
markComment: >
|
||||||
|
This issue has been automatically marked as stale because it has not had
|
||||||
|
recent activity. It will be closed if no further activity occurs. Thank you
|
||||||
|
for your contributions.
|
||||||
|
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||||
|
closeComment: false
|
@ -68,7 +68,7 @@ assembleDebug:
|
|||||||
cache:
|
cache:
|
||||||
key: "${CI_COMMIT_TAG}"
|
key: "${CI_COMMIT_TAG}"
|
||||||
paths:
|
paths:
|
||||||
- app/build/outputs/apk/fdroid_acad/debug/app-fdroid_acad-debug.apk
|
- app/build/outputs/apk/fdroid_peertube_apps_educ/debug/app-fdroid_peertube_apps_educ-debug.apk
|
||||||
- app/build/outputs/apk/fdroid_full/debug/app-fdroid_full-debug.apk
|
- app/build/outputs/apk/fdroid_full/debug/app-fdroid_full-debug.apk
|
||||||
policy: push
|
policy: push
|
||||||
script:
|
script:
|
||||||
@ -76,11 +76,11 @@ assembleDebug:
|
|||||||
|
|
||||||
# Basic android and gradle stuff
|
# Basic android and gradle stuff
|
||||||
# Check linting
|
# Check linting
|
||||||
lintFdroid_acadDebug:
|
lintfdroid_peertube_apps_educDebug:
|
||||||
interruptible: true
|
interruptible: true
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- ./gradlew -Pci --console=plain :app:lintFdroid_acadDebug -PbuildDir=lint
|
- ./gradlew -Pci --console=plain :app:lintfdroid_peertube_apps_educDebug -PbuildDir=lint
|
||||||
except:
|
except:
|
||||||
- tags
|
- tags
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ putApkOnTags:
|
|||||||
cache:
|
cache:
|
||||||
key: "${CI_COMMIT_TAG}"
|
key: "${CI_COMMIT_TAG}"
|
||||||
paths:
|
paths:
|
||||||
- app/build/outputs/apk/fdroid_acad/debug/app-fdroid_acad-debug.apk
|
- app/build/outputs/apk/fdroid_peertube_apps_educ/debug/app-fdroid_peertube_apps_educ-debug.apk
|
||||||
- app/build/outputs/apk/fdroid_full/debug/app-fdroid_full-debug.apk
|
- app/build/outputs/apk/fdroid_full/debug/app-fdroid_full-debug.apk
|
||||||
policy: pull
|
policy: pull
|
||||||
script:
|
script:
|
||||||
@ -120,11 +120,11 @@ putApkOnTags:
|
|||||||
- export NC_UPLOAD_URL="${NC_REMOTE_DIR}/${CI_COMMIT_TAG}"
|
- export NC_UPLOAD_URL="${NC_REMOTE_DIR}/${CI_COMMIT_TAG}"
|
||||||
- export NC_DOWNLOAD_URL="${NC_SHARE_URL}/download?path=%2F${CI_COMMIT_TAG}%2F&files="
|
- export NC_DOWNLOAD_URL="${NC_SHARE_URL}/download?path=%2F${CI_COMMIT_TAG}%2F&files="
|
||||||
- 'export HEADER="Private-Token: ${GITLAB_API_TOKEN}"'
|
- 'export HEADER="Private-Token: ${GITLAB_API_TOKEN}"'
|
||||||
- export acadUrl="${NC_DOWNLOAD_URL}app-fdroid_acad-debug.apk"
|
- export acadUrl="${NC_DOWNLOAD_URL}app-fdroid_peertube_apps_educ-debug.apk"
|
||||||
- export fullUrl="${NC_DOWNLOAD_URL}app-fdroid_full-debug.apk"
|
- export fullUrl="${NC_DOWNLOAD_URL}app-fdroid_full-debug.apk"
|
||||||
- 'curl -s -u "${NC_USER}:${NC_PASSWORD}" -X MKCOL "${NC_UPLOAD_URL}"'
|
- 'curl -s -u "${NC_USER}:${NC_PASSWORD}" -X MKCOL "${NC_UPLOAD_URL}"'
|
||||||
- 'curl -s -u "${NC_USER}:${NC_PASSWORD}" -T app/build/outputs/apk/fdroid_full/debug/app-fdroid_full-debug.apk "${NC_UPLOAD_URL}/app-fdroid_full-debug.apk"'
|
- 'curl -s -u "${NC_USER}:${NC_PASSWORD}" -T app/build/outputs/apk/fdroid_full/debug/app-fdroid_full-debug.apk "${NC_UPLOAD_URL}/app-fdroid_full-debug.apk"'
|
||||||
- 'curl -s -u "${NC_USER}:${NC_PASSWORD}" -T app/build/outputs/apk/fdroid_acad/debug/app-fdroid_acad-debug.apk "${NC_UPLOAD_URL}/app-fdroid_acad-debug.apk"'
|
- 'curl -s -u "${NC_USER}:${NC_PASSWORD}" -T app/build/outputs/apk/fdroid_peertube_apps_educ/debug/app-fdroid_peertube_apps_educ-debug.apk "${NC_UPLOAD_URL}/app-fdroid_peertube_apps_educ-debug.apk"'
|
||||||
- export description=$(curl -s --header "${HEADER}" "${DESCRIPTION_URL}" | jq .release.description | sed -e 's@"@@g')
|
- export description=$(curl -s --header "${HEADER}" "${DESCRIPTION_URL}" | jq .release.description | sed -e 's@"@@g')
|
||||||
- if [[ $description == 'null' ]]; then export METHOD="POST"; echo -e "[Get the acad version](${acadUrl})\n\n[Get the full version](${fullUrl})" > /tmp/text; fi
|
- if [[ $description == 'null' ]]; then export METHOD="POST"; echo -e "[Get the acad version](${acadUrl})\n\n[Get the full version](${fullUrl})" > /tmp/text; fi
|
||||||
- if [[ $description != 'null' ]]; then export METHOD="PUT"; echo -e "${description}\n\n[Get the acad version](${acadUrl})\n\n[Get the full version](${fullUrl})" > /tmp/text; fi
|
- if [[ $description != 'null' ]]; then export METHOD="PUT"; echo -e "${description}\n\n[Get the acad version](${acadUrl})\n\n[Get the full version](${fullUrl})" > /tmp/text; fi
|
||||||
|
@ -9,8 +9,8 @@ android {
|
|||||||
|
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 30
|
versionCode 34
|
||||||
versionName "1.10.0"
|
versionName "1.11.0"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@ -38,8 +38,9 @@ android {
|
|||||||
checkReleaseBuilds false
|
checkReleaseBuilds false
|
||||||
abortOnError false
|
abortOnError false
|
||||||
}
|
}
|
||||||
|
//boolean full_instances if set to false means TubeAcad
|
||||||
productFlavors {
|
productFlavors {
|
||||||
fdroid_acad {
|
fdroid_peertube_apps_educ {
|
||||||
applicationId "app.fedilab.fedilabtube"
|
applicationId "app.fedilab.fedilabtube"
|
||||||
resValue "string", "app_name", "TubeAcad"
|
resValue "string", "app_name", "TubeAcad"
|
||||||
resValue "string", "app_id", "app.fedilab.fedilabtube"
|
resValue "string", "app_id", "app.fedilab.fedilabtube"
|
||||||
@ -49,8 +50,9 @@ android {
|
|||||||
buildConfigField "boolean", "surfing_mode", "false"
|
buildConfigField "boolean", "surfing_mode", "false"
|
||||||
buildConfigField "boolean", "sepia_search", "false"
|
buildConfigField "boolean", "sepia_search", "false"
|
||||||
buildConfigField "boolean", "instance_switcher", "true"
|
buildConfigField "boolean", "instance_switcher", "true"
|
||||||
|
buildConfigField "boolean", "allow_remote_connections", "false"
|
||||||
}
|
}
|
||||||
google_acad {
|
google_peertube_apps_educ {
|
||||||
applicationId "app.fedilab.fedilabtube"
|
applicationId "app.fedilab.fedilabtube"
|
||||||
resValue "string", "app_name", "TubeAcad"
|
resValue "string", "app_name", "TubeAcad"
|
||||||
resValue "string", "app_id", "app.fedilab.fedilabtube"
|
resValue "string", "app_id", "app.fedilab.fedilabtube"
|
||||||
@ -60,6 +62,7 @@ android {
|
|||||||
buildConfigField "boolean", "surfing_mode", "false"
|
buildConfigField "boolean", "surfing_mode", "false"
|
||||||
buildConfigField "boolean", "sepia_search", "false"
|
buildConfigField "boolean", "sepia_search", "false"
|
||||||
buildConfigField "boolean", "instance_switcher", "true"
|
buildConfigField "boolean", "instance_switcher", "true"
|
||||||
|
buildConfigField "boolean", "allow_remote_connections", "false"
|
||||||
}
|
}
|
||||||
fdroid_full {
|
fdroid_full {
|
||||||
applicationId "app.fedilab.tubelab"
|
applicationId "app.fedilab.tubelab"
|
||||||
@ -71,6 +74,7 @@ android {
|
|||||||
buildConfigField "boolean", "surfing_mode", "true"
|
buildConfigField "boolean", "surfing_mode", "true"
|
||||||
buildConfigField "boolean", "sepia_search", "true"
|
buildConfigField "boolean", "sepia_search", "true"
|
||||||
buildConfigField "boolean", "instance_switcher", "true"
|
buildConfigField "boolean", "instance_switcher", "true"
|
||||||
|
buildConfigField "boolean", "allow_remote_connections", "true"
|
||||||
}
|
}
|
||||||
google_full {
|
google_full {
|
||||||
applicationId "app.fedilab.tubelab"
|
applicationId "app.fedilab.tubelab"
|
||||||
@ -82,6 +86,7 @@ android {
|
|||||||
buildConfigField "boolean", "surfing_mode", "true"
|
buildConfigField "boolean", "surfing_mode", "true"
|
||||||
buildConfigField "boolean", "sepia_search", "true"
|
buildConfigField "boolean", "sepia_search", "true"
|
||||||
buildConfigField "boolean", "instance_switcher", "true"
|
buildConfigField "boolean", "instance_switcher", "true"
|
||||||
|
buildConfigField "boolean", "allow_remote_connections", "true"
|
||||||
}
|
}
|
||||||
queermotion {
|
queermotion {
|
||||||
applicationId "org.queermotion.peertube"
|
applicationId "org.queermotion.peertube"
|
||||||
@ -93,6 +98,7 @@ android {
|
|||||||
buildConfigField "boolean", "surfing_mode", "false"
|
buildConfigField "boolean", "surfing_mode", "false"
|
||||||
buildConfigField "boolean", "sepia_search", "false"
|
buildConfigField "boolean", "sepia_search", "false"
|
||||||
buildConfigField "boolean", "instance_switcher", "false"
|
buildConfigField "boolean", "instance_switcher", "false"
|
||||||
|
buildConfigField "boolean", "allow_remote_connections", "false"
|
||||||
}
|
}
|
||||||
bittube {
|
bittube {
|
||||||
applicationId "app.fedilab.bittube"
|
applicationId "app.fedilab.bittube"
|
||||||
@ -104,28 +110,34 @@ android {
|
|||||||
buildConfigField "boolean", "surfing_mode", "false"
|
buildConfigField "boolean", "surfing_mode", "false"
|
||||||
buildConfigField "boolean", "sepia_search", "false"
|
buildConfigField "boolean", "sepia_search", "false"
|
||||||
buildConfigField "boolean", "instance_switcher", "true"
|
buildConfigField "boolean", "instance_switcher", "true"
|
||||||
|
buildConfigField "boolean", "allow_remote_connections", "false"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
fdroid_acad {
|
fdroid_peertube_apps_educ {
|
||||||
res.srcDirs = ['src/main/res', 'src/acad/res']
|
res.srcDirs = ['src/main/res', 'src/acad/res']
|
||||||
|
java.srcDirs = ['src/main/java', 'src/acad/java']
|
||||||
}
|
}
|
||||||
google_acad {
|
google_peertube_apps_educ {
|
||||||
res.srcDirs = ['src/main/res', 'src/acad/res']
|
res.srcDirs = ['src/main/res', 'src/acad/res']
|
||||||
|
java.srcDirs = ['src/main/java', 'src/acad/java']
|
||||||
}
|
}
|
||||||
fdroid_full {
|
fdroid_full {
|
||||||
res.srcDirs = ['src/main/res', 'src/full/res']
|
res.srcDirs = ['src/main/res', 'src/full/res']
|
||||||
|
java.srcDirs = ['src/main/java', 'src/full/java']
|
||||||
}
|
}
|
||||||
google_full {
|
google_full {
|
||||||
res.srcDirs = ['src/main/res', 'src/full/res']
|
res.srcDirs = ['src/main/res', 'src/full/res']
|
||||||
|
java.srcDirs = ['src/main/java', 'src/full/java']
|
||||||
}
|
}
|
||||||
queermotion {
|
queermotion {
|
||||||
res.srcDirs = ['src/main/res', 'src/queermotion/res']
|
res.srcDirs = ['src/main/res', 'src/queermotion/res']
|
||||||
|
java.srcDirs = ['src/main/java', 'src/full/java']
|
||||||
}
|
}
|
||||||
bittube {
|
bittube {
|
||||||
res.srcDirs = ['src/main/res', 'src/bittube/res']
|
res.srcDirs = ['src/main/res', 'src/bittube/res']
|
||||||
|
java.srcDirs = ['src/main/java', 'src/full/java']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,14 +165,15 @@ dependencies {
|
|||||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||||
implementation 'androidx.browser:browser:1.3.0'
|
implementation 'androidx.browser:browser:1.3.0'
|
||||||
implementation 'androidx.documentfile:documentfile:1.0.1'
|
implementation 'androidx.documentfile:documentfile:1.0.1'
|
||||||
|
implementation project(path: ':torrentStream')
|
||||||
testImplementation 'junit:junit:4.13.1'
|
testImplementation 'junit:junit:4.13.1'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||||
|
|
||||||
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
|
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
|
||||||
implementation 'com.github.GrenderG:Toasty:1.4.2'
|
implementation 'com.github.GrenderG:Toasty:1.4.2'
|
||||||
implementation 'com.google.android.exoplayer:exoplayer:2.12.1'
|
implementation 'com.google.android.exoplayer:exoplayer:2.12.2'
|
||||||
implementation 'com.google.android.exoplayer:extension-mediasession:2.12.1'
|
implementation 'com.google.android.exoplayer:extension-mediasession:2.12.2'
|
||||||
implementation "com.github.mabbas007:TagsEditText:1.0.5"
|
implementation "com.github.mabbas007:TagsEditText:1.0.5"
|
||||||
implementation "com.github.bumptech.glide:glide:4.11.0"
|
implementation "com.github.bumptech.glide:glide:4.11.0"
|
||||||
annotationProcessor "com.github.bumptech.glide:compiler:4.11.0"
|
annotationProcessor "com.github.bumptech.glide:compiler:4.11.0"
|
||||||
@ -174,7 +187,6 @@ dependencies {
|
|||||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||||
implementation 'com.github.mancj:MaterialSearchBar:0.8.5'
|
implementation 'com.github.mancj:MaterialSearchBar:0.8.5'
|
||||||
|
|
||||||
implementation "com.github.TorrentStream:TorrentStream-Android:2.7.0"
|
|
||||||
|
|
||||||
implementation "io.github.kobakei:ratethisapp:1.2.0"
|
implementation "io.github.kobakei:ratethisapp:1.2.0"
|
||||||
implementation 'com.github.vkay94:DoubleTapPlayerView:1.0.0'
|
implementation 'com.github.vkay94:DoubleTapPlayerView:1.0.0'
|
||||||
@ -189,4 +201,8 @@ dependencies {
|
|||||||
implementation 'org.slf4j:slf4j-simple:1.7.30'
|
implementation 'org.slf4j:slf4j-simple:1.7.30'
|
||||||
|
|
||||||
|
|
||||||
|
fdroid_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2'
|
||||||
|
google_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2'
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
35
app/src/acad/java/app/fedilab/fedilabtube/FedilabTube.java
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package app.fedilab.fedilabtube;
|
||||||
|
/* Copyright 2020 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import org.matomo.sdk.Matomo;
|
||||||
|
import org.matomo.sdk.Tracker;
|
||||||
|
import org.matomo.sdk.TrackerBuilder;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class FedilabTube extends BaseFedilabTube {
|
||||||
|
|
||||||
|
private Tracker mMatomoTracker;
|
||||||
|
|
||||||
|
public synchronized Tracker getTracker() {
|
||||||
|
if (mMatomoTracker != null) return mMatomoTracker;
|
||||||
|
mMatomoTracker = TrackerBuilder.createDefault("https://wa.phm.education.gouv.fr/snp/matomo.php", 11).build(Matomo.getInstance(this));
|
||||||
|
return mMatomoTracker;
|
||||||
|
}
|
||||||
|
}
|
47
app/src/acad/java/app/fedilab/fedilabtube/Matomo.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package app.fedilab.fedilabtube;
|
||||||
|
/* Copyright 2020 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import org.matomo.sdk.Tracker;
|
||||||
|
import org.matomo.sdk.extra.TrackHelper;
|
||||||
|
|
||||||
|
public class Matomo {
|
||||||
|
|
||||||
|
public static void sendScreen(Context _mcontext, String path, String title) {
|
||||||
|
Tracker tracker = ((FedilabTube) ((Activity) _mcontext).getApplication()).getTracker();
|
||||||
|
TrackHelper.track().screen(path).title(title).with(tracker);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendEvent(Context _mcontext, String category, String action, String label, float value) {
|
||||||
|
Tracker tracker = ((FedilabTube) ((Activity) _mcontext).getApplication()).getTracker();
|
||||||
|
TrackHelper.track().event(category, action).name(label).value(value).with(tracker);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void sendValue(Context _mcontext, String path, int index, String dimensionValue) {
|
||||||
|
Tracker tracker = ((FedilabTube) ((Activity) _mcontext).getApplication()).getTracker();
|
||||||
|
TrackHelper.track().screen(path).dimension(index, dimensionValue).with(tracker);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void trackInstall(Context _mcontext) {
|
||||||
|
Tracker tracker = ((FedilabTube) ((Activity) _mcontext).getApplication()).getTracker();
|
||||||
|
TrackHelper.track().download().with(tracker);
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,8 @@
|
|||||||
<color name="tag_color">#bbF2690D</color>
|
<color name="tag_color">#bbF2690D</color>
|
||||||
<color name="tag_color_text">#FAFAFA</color>
|
<color name="tag_color_text">#FAFAFA</color>
|
||||||
<color name="positive_thumbs">#2b90d9</color>
|
<color name="positive_thumbs">#2b90d9</color>
|
||||||
|
<color name="favorite">#ca8f04</color>
|
||||||
|
<color name="bookmark">#795548</color>
|
||||||
<color name="negative_thumbs">#F44336</color>
|
<color name="negative_thumbs">#F44336</color>
|
||||||
<color name="backgroundDark">#DD000000</color>
|
<color name="backgroundDark">#DD000000</color>
|
||||||
<color name="red_1">#F44336</color>
|
<color name="red_1">#F44336</color>
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
<color name="tag_color">#bbF2690D</color>
|
<color name="tag_color">#bbF2690D</color>
|
||||||
<color name="tag_color_text">#FAFAFA</color>
|
<color name="tag_color_text">#FAFAFA</color>
|
||||||
<color name="positive_thumbs">#2b90d9</color>
|
<color name="positive_thumbs">#2b90d9</color>
|
||||||
|
<color name="favorite">#ca8f04</color>
|
||||||
|
<color name="bookmark">#795548</color>
|
||||||
<color name="negative_thumbs">#F44336</color>
|
<color name="negative_thumbs">#F44336</color>
|
||||||
<color name="backgroundDark">#DD000000</color>
|
<color name="backgroundDark">#DD000000</color>
|
||||||
<color name="red_1">#F44336</color>
|
<color name="red_1">#F44336</color>
|
||||||
|
20
app/src/full/java/app/fedilab/fedilabtube/FedilabTube.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package app.fedilab.fedilabtube;
|
||||||
|
/* Copyright 2020 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class FedilabTube extends BaseFedilabTube {
|
||||||
|
}
|
41
app/src/full/java/app/fedilab/fedilabtube/Matomo.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package app.fedilab.fedilabtube;
|
||||||
|
/* Copyright 2020 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||||
|
public class Matomo {
|
||||||
|
|
||||||
|
public static void sendScreen(Context _mcontext, String path, String title) {
|
||||||
|
//Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendEvent(Context _mcontext, String category, String action, String label, float value) {
|
||||||
|
//Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void sendValue(Context _mcontext, String path, int index, String dimensionValue) {
|
||||||
|
//Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void trackInstall(Context _mcontext) {
|
||||||
|
//Do nothing
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,8 @@
|
|||||||
<color name="tag_color_text">#FAFAFA</color>
|
<color name="tag_color_text">#FAFAFA</color>
|
||||||
<color name="positive_thumbs">#2b90d9</color>
|
<color name="positive_thumbs">#2b90d9</color>
|
||||||
<color name="negative_thumbs">#F44336</color>
|
<color name="negative_thumbs">#F44336</color>
|
||||||
|
<color name="favorite">#ca8f04</color>
|
||||||
|
<color name="bookmark">#795548</color>
|
||||||
<color name="backgroundDark">#DD000000</color>
|
<color name="backgroundDark">#DD000000</color>
|
||||||
<color name="red_1">#F44336</color>
|
<color name="red_1">#F44336</color>
|
||||||
<color name="gray_light">#80808080</color>
|
<color name="gray_light">#80808080</color>
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
-->
|
-->
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission
|
||||||
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
|
tools:ignore="ScopedStorage" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
@ -127,11 +129,26 @@
|
|||||||
android:name=".WebviewConnectActivity"
|
android:name=".WebviewConnectActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
android:label="@string/app_name" />
|
android:label="@string/app_name" />
|
||||||
|
<activity
|
||||||
|
android:name=".MastodonWebviewConnectActivity"
|
||||||
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
|
android:label="@string/app_name" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".LoginActivity"
|
android:name=".LoginActivity"
|
||||||
android:configChanges="orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
android:windowSoftInputMode="stateAlwaysHidden">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
|
<data
|
||||||
|
android:host="backtotubelab"
|
||||||
|
android:scheme="tubelab" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".SettingsActivity"
|
android:name=".SettingsActivity"
|
||||||
|
@ -17,16 +17,16 @@ package app.fedilab.fedilabtube;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.Html;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.text.style.UnderlineSpan;
|
import android.text.style.UnderlineSpan;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.Button;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@ -37,13 +37,13 @@ import androidx.fragment.app.FragmentStatePagerAdapter;
|
|||||||
import androidx.viewpager.widget.PagerAdapter;
|
import androidx.viewpager.widget.PagerAdapter;
|
||||||
import androidx.viewpager.widget.ViewPager;
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||||
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
||||||
|
import app.fedilab.fedilabtube.databinding.ActivityAccountBinding;
|
||||||
import app.fedilab.fedilabtube.fragment.DisplayAccountsFragment;
|
import app.fedilab.fedilabtube.fragment.DisplayAccountsFragment;
|
||||||
import app.fedilab.fedilabtube.fragment.DisplayChannelsFragment;
|
import app.fedilab.fedilabtube.fragment.DisplayChannelsFragment;
|
||||||
import app.fedilab.fedilabtube.fragment.DisplayNotificationsFragment;
|
import app.fedilab.fedilabtube.fragment.DisplayNotificationsFragment;
|
||||||
@ -56,15 +56,14 @@ import app.fedilab.fedilabtube.sqlite.Sqlite;
|
|||||||
public class AccountActivity extends AppCompatActivity {
|
public class AccountActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
private ViewPager mPager;
|
private ActivityAccountBinding binding;
|
||||||
private TabLayout tabLayout;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
binding = ActivityAccountBinding.inflate(getLayoutInflater());
|
||||||
setContentView(R.layout.activity_account);
|
View view = binding.getRoot();
|
||||||
|
setContentView(view);
|
||||||
if (getSupportActionBar() != null)
|
if (getSupportActionBar() != null)
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
@ -75,34 +74,27 @@ public class AccountActivity extends AppCompatActivity {
|
|||||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
|
||||||
|
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
|
||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||||
|
|
||||||
TextView instanceView = findViewById(R.id.instance);
|
|
||||||
Account account = new AccountDAO(AccountActivity.this, db).getAccountByToken(token);
|
Account account = new AccountDAO(AccountActivity.this, db).getAccountByToken(token);
|
||||||
|
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
Helper.logoutCurrentUser(AccountActivity.this, null);
|
Helper.logoutCurrentUser(AccountActivity.this, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageView profile_picture = findViewById(R.id.profile_picture);
|
|
||||||
TextView username = findViewById(R.id.username);
|
|
||||||
TextView displayname = findViewById(R.id.displayname);
|
|
||||||
|
|
||||||
setTitle(String.format("@%s", account.getUsername()));
|
setTitle(String.format("@%s", account.getUsername()));
|
||||||
|
|
||||||
Helper.loadGiF(AccountActivity.this, account.getAvatar().getPath(), profile_picture);
|
Helper.loadGiF(AccountActivity.this, account.getAvatar().getPath(), binding.profilePicture);
|
||||||
username.setText(String.format("@%s", account.getUsername()));
|
binding.username.setText(String.format("@%s", account.getUsername()));
|
||||||
displayname.setText(account.getDisplayName());
|
binding.displayname.setText(account.getDisplayName());
|
||||||
|
|
||||||
instanceView.setText(account.getHost());
|
binding.instance.setText(account.getHost());
|
||||||
FloatingActionButton edit_profile = findViewById(R.id.edit_profile);
|
binding.editProfile.setOnClickListener(v -> startActivity(new Intent(AccountActivity.this, MyAccountActivity.class)));
|
||||||
edit_profile.setOnClickListener(v -> startActivity(new Intent(AccountActivity.this, MyAccountActivity.class)));
|
|
||||||
|
|
||||||
Button logout_button = findViewById(R.id.logout_button);
|
binding.logoutButton.setOnClickListener(v -> {
|
||||||
logout_button.setOnClickListener(v -> {
|
|
||||||
AlertDialog.Builder dialogBuilderLogoutAccount = new AlertDialog.Builder(AccountActivity.this);
|
AlertDialog.Builder dialogBuilderLogoutAccount = new AlertDialog.Builder(AccountActivity.this);
|
||||||
dialogBuilderLogoutAccount.setMessage(getString(R.string.logout_account_confirmation, account.getUsername(), account.getHost()));
|
dialogBuilderLogoutAccount.setMessage(getString(R.string.logout_account_confirmation, account.getUsername(), account.getHost()));
|
||||||
dialogBuilderLogoutAccount.setPositiveButton(R.string.action_logout, (dialog, id) -> {
|
dialogBuilderLogoutAccount.setPositiveButton(R.string.action_logout, (dialog, id) -> {
|
||||||
@ -114,84 +106,93 @@ public class AccountActivity extends AppCompatActivity {
|
|||||||
alertDialogLogoutAccount.show();
|
alertDialogLogoutAccount.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
Button settings = findViewById(R.id.settings);
|
binding.settings.setOnClickListener(v -> {
|
||||||
settings.setOnClickListener(v -> {
|
|
||||||
Intent intent = new Intent(AccountActivity.this, SettingsActivity.class);
|
Intent intent = new Intent(AccountActivity.this, SettingsActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
tabLayout = findViewById(R.id.account_tabLayout);
|
|
||||||
mPager = findViewById(R.id.account_viewpager);
|
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.title_notifications)));
|
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.title_muted)));
|
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.title_channel)));
|
|
||||||
|
|
||||||
|
|
||||||
mPager.setOffscreenPageLimit(3);
|
if (Helper.isLoggedIn(AccountActivity.this)) {
|
||||||
|
binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.title_notifications)));
|
||||||
|
binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.title_muted)));
|
||||||
|
binding.accountTabLayout.addTab(binding.accountTabLayout.newTab().setText(getString(R.string.title_channel)));
|
||||||
|
|
||||||
|
binding.accountViewpager.setOffscreenPageLimit(3);
|
||||||
|
|
||||||
|
|
||||||
mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
binding.accountViewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int position) {
|
|
||||||
TabLayout.Tab tab = tabLayout.getTabAt(position);
|
|
||||||
if (tab != null)
|
|
||||||
tab.select();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int state) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public void onTabSelected(TabLayout.Tab tab) {
|
|
||||||
mPager.setCurrentItem(tab.getPosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTabUnselected(TabLayout.Tab tab) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTabReselected(TabLayout.Tab tab) {
|
|
||||||
Fragment fragment = null;
|
|
||||||
if (mPager.getAdapter() != null)
|
|
||||||
fragment = (Fragment) mPager.getAdapter().instantiateItem(mPager, tab.getPosition());
|
|
||||||
switch (tab.getPosition()) {
|
|
||||||
case 0:
|
|
||||||
if (fragment != null) {
|
|
||||||
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
|
|
||||||
displayNotificationsFragment.scrollToTop();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if (fragment != null) {
|
|
||||||
DisplayAccountsFragment displayAccountsFragment = ((DisplayAccountsFragment) fragment);
|
|
||||||
displayAccountsFragment.scrollToTop();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (fragment != null) {
|
|
||||||
DisplayChannelsFragment displayChannelsFragment = ((DisplayChannelsFragment) fragment);
|
|
||||||
displayChannelsFragment.scrollToTop();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
PagerAdapter mPagerAdapter = new AccountsPagerAdapter(getSupportFragmentManager());
|
@Override
|
||||||
mPager.setAdapter(mPagerAdapter);
|
public void onPageSelected(int position) {
|
||||||
|
TabLayout.Tab tab = binding.accountTabLayout.getTabAt(position);
|
||||||
|
if (tab != null)
|
||||||
|
tab.select();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
binding.accountTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onTabSelected(TabLayout.Tab tab) {
|
||||||
|
binding.accountViewpager.setCurrentItem(tab.getPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTabUnselected(TabLayout.Tab tab) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTabReselected(TabLayout.Tab tab) {
|
||||||
|
Fragment fragment = null;
|
||||||
|
if (binding.accountViewpager.getAdapter() != null)
|
||||||
|
fragment = (Fragment) binding.accountViewpager.getAdapter().instantiateItem(binding.accountViewpager, tab.getPosition());
|
||||||
|
switch (tab.getPosition()) {
|
||||||
|
case 0:
|
||||||
|
if (fragment != null) {
|
||||||
|
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
|
||||||
|
displayNotificationsFragment.scrollToTop();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (fragment != null) {
|
||||||
|
DisplayAccountsFragment displayAccountsFragment = ((DisplayAccountsFragment) fragment);
|
||||||
|
displayAccountsFragment.scrollToTop();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (fragment != null) {
|
||||||
|
DisplayChannelsFragment displayChannelsFragment = ((DisplayChannelsFragment) fragment);
|
||||||
|
displayChannelsFragment.scrollToTop();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
PagerAdapter mPagerAdapter = new AccountsPagerAdapter(getSupportFragmentManager());
|
||||||
|
binding.accountViewpager.setAdapter(mPagerAdapter);
|
||||||
|
} else {
|
||||||
|
binding.accountTabLayout.setVisibility(View.GONE);
|
||||||
|
binding.accountViewpager.setVisibility(View.GONE);
|
||||||
|
binding.editProfile.setVisibility(View.GONE);
|
||||||
|
binding.remoteAccount.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||||
|
binding.remoteAccount.setText(Html.fromHtml(getString(R.string.remote_account_from, account.getSoftware()), Html.FROM_HTML_MODE_LEGACY));
|
||||||
|
else
|
||||||
|
binding.remoteAccount.setText(Html.fromHtml(getString(R.string.remote_account_from, account.getSoftware())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,6 +74,7 @@ import static app.fedilab.fedilabtube.helper.Helper.peertubeInformation;
|
|||||||
public class AllPlaylistsActivity extends AppCompatActivity implements PlaylistAdapter.AllPlaylistRemoved {
|
public class AllPlaylistsActivity extends AppCompatActivity implements PlaylistAdapter.AllPlaylistRemoved {
|
||||||
|
|
||||||
|
|
||||||
|
private static final int PICK_AVATAR = 467;
|
||||||
PlaylistAdapter playlistAdapter;
|
PlaylistAdapter playlistAdapter;
|
||||||
private HashMap<Integer, String> privacyToSend;
|
private HashMap<Integer, String> privacyToSend;
|
||||||
private String idChannel;
|
private String idChannel;
|
||||||
@ -81,7 +82,6 @@ public class AllPlaylistsActivity extends AppCompatActivity implements PlaylistA
|
|||||||
private Playlist playlistToEdit;
|
private Playlist playlistToEdit;
|
||||||
private List<ChannelData.Channel> myChannels;
|
private List<ChannelData.Channel> myChannels;
|
||||||
private ChannelData.Channel selectedChannel;
|
private ChannelData.Channel selectedChannel;
|
||||||
private static final int PICK_AVATAR = 467;
|
|
||||||
private AddPlaylistBinding bindingDialog;
|
private AddPlaylistBinding bindingDialog;
|
||||||
private Uri inputData;
|
private Uri inputData;
|
||||||
private ActivityAllPlaylistBinding binding;
|
private ActivityAllPlaylistBinding binding;
|
||||||
@ -197,7 +197,7 @@ public class AllPlaylistsActivity extends AppCompatActivity implements PlaylistA
|
|||||||
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
|
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
|
||||||
startActivityForResult(intent, PICK_AVATAR);
|
startActivityForResult(intent, PICK_AVATAR);
|
||||||
});
|
});
|
||||||
Helper.loadGiF(AllPlaylistsActivity.this, playlistParam.getThumbnailPath(), bindingDialog.profilePicture);
|
Helper.loadGiF(AllPlaylistsActivity.this, playlistParam != null ? playlistParam.getThumbnailPath() : null, bindingDialog.profilePicture);
|
||||||
alertDialog.setOnShowListener(dialogInterface -> {
|
alertDialog.setOnShowListener(dialogInterface -> {
|
||||||
|
|
||||||
Button button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
Button button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||||
|
@ -35,7 +35,7 @@ import app.fedilab.fedilabtube.helper.ThemeHelper;
|
|||||||
import app.fedilab.fedilabtube.services.GlobalUploadObserver;
|
import app.fedilab.fedilabtube.services.GlobalUploadObserver;
|
||||||
import app.fedilab.fedilabtube.worker.WorkHelper;
|
import app.fedilab.fedilabtube.worker.WorkHelper;
|
||||||
|
|
||||||
public class FedilabTube extends MultiDexApplication {
|
public class BaseFedilabTube extends MultiDexApplication {
|
||||||
|
|
||||||
static String UPLOAD_CHANNEL_ID = "upload_info_peertube";
|
static String UPLOAD_CHANNEL_ID = "upload_info_peertube";
|
||||||
|
|
||||||
@ -48,12 +48,12 @@ public class FedilabTube extends MultiDexApplication {
|
|||||||
Configuration myConfig = new Configuration.Builder()
|
Configuration myConfig = new Configuration.Builder()
|
||||||
.setMinimumLoggingLevel(android.util.Log.INFO)
|
.setMinimumLoggingLevel(android.util.Log.INFO)
|
||||||
.build();
|
.build();
|
||||||
WorkManager.initialize(FedilabTube.this, myConfig);
|
WorkManager.initialize(BaseFedilabTube.this, myConfig);
|
||||||
if (interval >= 15) {
|
if (interval >= 15) {
|
||||||
WorkHelper.fetchNotifications(this, interval);
|
WorkHelper.fetchNotifications(this, interval);
|
||||||
}
|
}
|
||||||
createNotificationChannel();
|
createNotificationChannel();
|
||||||
UploadServiceConfig.initialize(FedilabTube.this, UPLOAD_CHANNEL_ID, true);
|
UploadServiceConfig.initialize(BaseFedilabTube.this, UPLOAD_CHANNEL_ID, true);
|
||||||
|
|
||||||
new GlobalRequestObserver(this, new GlobalUploadObserver());
|
new GlobalRequestObserver(this, new GlobalUploadObserver());
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public class FedilabTube extends MultiDexApplication {
|
|||||||
protected void attachBaseContext(Context base) {
|
protected void attachBaseContext(Context base) {
|
||||||
super.attachBaseContext(base);
|
super.attachBaseContext(base);
|
||||||
|
|
||||||
MultiDex.install(FedilabTube.this);
|
MultiDex.install(BaseFedilabTube.this);
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
int themePref = sharedpreferences.getInt(Helper.SET_THEME, Helper.DEFAULT_MODE);
|
int themePref = sharedpreferences.getInt(Helper.SET_THEME, Helper.DEFAULT_MODE);
|
||||||
ThemeHelper.switchTo(themePref);
|
ThemeHelper.switchTo(themePref);
|
@ -26,6 +26,8 @@ import android.util.Patterns;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -35,12 +37,17 @@ import androidx.core.content.ContextCompat;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.client.mastodon.RetrofitMastodonAPI;
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||||
import app.fedilab.fedilabtube.client.entities.Error;
|
import app.fedilab.fedilabtube.client.entities.Error;
|
||||||
import app.fedilab.fedilabtube.client.entities.Oauth;
|
import app.fedilab.fedilabtube.client.entities.Oauth;
|
||||||
import app.fedilab.fedilabtube.client.entities.OauthParams;
|
import app.fedilab.fedilabtube.client.entities.OauthParams;
|
||||||
import app.fedilab.fedilabtube.client.entities.Token;
|
import app.fedilab.fedilabtube.client.entities.Token;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.WellKnownNodeinfo;
|
||||||
import app.fedilab.fedilabtube.databinding.ActivityLoginBinding;
|
import app.fedilab.fedilabtube.databinding.ActivityLoginBinding;
|
||||||
import app.fedilab.fedilabtube.helper.Helper;
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
import app.fedilab.fedilabtube.helper.HelperAcadInstance;
|
import app.fedilab.fedilabtube.helper.HelperAcadInstance;
|
||||||
@ -56,6 +63,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
private static String client_id;
|
private static String client_id;
|
||||||
private static String client_secret;
|
private static String client_secret;
|
||||||
private ActivityLoginBinding binding;
|
private ActivityLoginBinding binding;
|
||||||
|
private String acadInstance;
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
@Override
|
@Override
|
||||||
@ -111,75 +119,84 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
binding.loginPasswdContainer.setLayoutParams(layoutParamsP);
|
binding.loginPasswdContainer.setLayoutParams(layoutParamsP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!BuildConfig.full_instances) {
|
if (!BuildConfig.full_instances) {
|
||||||
binding.loginUid.setOnFocusChangeListener((v, hasFocus) -> {
|
binding.loginUid.setOnFocusChangeListener((v, hasFocus) -> {
|
||||||
if (!hasFocus) {
|
if (!hasFocus) {
|
||||||
if (binding.loginUid.getText() != null && android.util.Patterns.EMAIL_ADDRESS.matcher(binding.loginUid.getText().toString().trim()).matches()) {
|
if (binding.loginUid.getText() != null && android.util.Patterns.EMAIL_ADDRESS.matcher(binding.loginUid.getText().toString().trim()).matches()) {
|
||||||
String[] emailArray = binding.loginUid.getText().toString().split("@");
|
String[] emailArray = binding.loginUid.getText().toString().split("@");
|
||||||
if (emailArray.length > 1 && Arrays.asList(HelperAcadInstance.openid).contains(emailArray[1])) {
|
if (emailArray.length > 1) {
|
||||||
binding.loginButton.callOnClick();
|
binding.loginButton.callOnClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
binding.loginUidContainer.setVisibility(View.GONE);
|
||||||
|
binding.loginPasswdContainer.setVisibility(View.GONE);
|
||||||
|
binding.loginInstanceContainer.setVisibility(View.GONE);
|
||||||
|
binding.createAnAccountPeertube.setVisibility(View.GONE);
|
||||||
|
binding.instancePickerTitle.setVisibility(View.VISIBLE);
|
||||||
|
binding.instancePicker.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
HashMap<String, String> instancesMap = new HashMap<>(HelperAcadInstance.instances_themes);
|
||||||
|
Iterator<Map.Entry<String, String>> it = instancesMap.entrySet().iterator();
|
||||||
|
String[] academiesKey = new String[HelperAcadInstance.instances_themes.size()];
|
||||||
|
String[] academiesValue = new String[HelperAcadInstance.instances_themes.size()];
|
||||||
|
String acad = HelperInstance.getLiveInstance(LoginActivity.this);
|
||||||
|
int position = 0;
|
||||||
|
int i = 0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Map.Entry<String, String> pair = it.next();
|
||||||
|
academiesKey[i] = pair.getKey();
|
||||||
|
academiesValue[i] = pair.getValue();
|
||||||
|
if (pair.getValue().compareTo(acad) == 0) {
|
||||||
|
position = i;
|
||||||
|
}
|
||||||
|
it.remove();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
binding.instancePicker.setSelection(position, true);
|
||||||
|
ArrayAdapter<String> adapterChannel = new ArrayAdapter<>(LoginActivity.this,
|
||||||
|
android.R.layout.simple_spinner_dropdown_item, academiesKey);
|
||||||
|
binding.instancePicker.setAdapter(adapterChannel);
|
||||||
|
binding.instancePicker.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
acadInstance = academiesValue[position];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (BuildConfig.allow_remote_connections) {
|
||||||
|
binding.loginInstance.setOnFocusChangeListener((v, hasFocus) -> {
|
||||||
|
if (!hasFocus) {
|
||||||
|
if (binding.loginInstance.getText() != null) {
|
||||||
|
new Thread(() -> {
|
||||||
|
String testInstance = binding.loginInstance.getText().toString();
|
||||||
|
WellKnownNodeinfo.NodeInfo instanceNodeInfo = null;
|
||||||
|
if (BuildConfig.allow_remote_connections) {
|
||||||
|
instanceNodeInfo = new RetrofitPeertubeAPI(LoginActivity.this, testInstance, null).getNodeInfo();
|
||||||
|
}
|
||||||
|
if (instanceNodeInfo != null &&
|
||||||
|
(instanceNodeInfo.getSoftware().getName().toUpperCase().trim().compareTo("MASTODON") == 0 ||
|
||||||
|
instanceNodeInfo.getSoftware().getName().toUpperCase().trim().compareTo("PLEROMA") == 0)
|
||||||
|
) {
|
||||||
|
connectToFediverse(testInstance, instanceNodeInfo);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.loginButton.setOnClickListener(v -> {
|
binding.loginButton.setOnClickListener(v -> {
|
||||||
|
|
||||||
if (binding.loginUid.getText() != null && binding.loginUid.getText().toString().contains("@") && !android.util.Patterns.EMAIL_ADDRESS.matcher(binding.loginUid.getText().toString().trim()).matches()) {
|
|
||||||
Toasty.error(LoginActivity.this, getString(R.string.email_error)).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
binding.loginButton.setEnabled(false);
|
|
||||||
String instance, host;
|
|
||||||
if (!BuildConfig.full_instances) {
|
if (!BuildConfig.full_instances) {
|
||||||
String[] emailArray = binding.loginUid.getText().toString().split("@");
|
|
||||||
if (emailArray.length > 1 && !Arrays.asList(HelperAcadInstance.valideEmails).contains(emailArray[1])) {
|
|
||||||
Toasty.error(LoginActivity.this, getString(R.string.email_error_domain, emailArray[1])).show();
|
|
||||||
binding.loginButton.setEnabled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
host = emailArray[1];
|
|
||||||
instance = HelperInstance.getPeertubeUrl(host);
|
|
||||||
} else {
|
|
||||||
if (binding.loginInstance.getText() == null || binding.loginInstance.getText().toString().trim().length() == 0) {
|
|
||||||
Toasty.error(LoginActivity.this, getString(R.string.not_valide_instance)).show();
|
|
||||||
binding.loginButton.setEnabled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
instance = host = binding.loginInstance.getText().toString().trim().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (instance.startsWith("http")) {
|
|
||||||
try {
|
|
||||||
URL url = new URL(instance);
|
|
||||||
instance = url.getHost();
|
|
||||||
host = instance;
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else if (instance.endsWith("/")) {
|
|
||||||
try {
|
|
||||||
URL url = new URL("https://" + instance);
|
|
||||||
instance = url.getHost();
|
|
||||||
host = instance;
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!Patterns.WEB_URL.matcher("https://" + instance).matches()) {
|
|
||||||
Toasty.error(LoginActivity.this, getString(R.string.not_valide_instance)).show();
|
|
||||||
binding.loginButton.setEnabled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String finalInstance = instance;
|
|
||||||
String finalHost = host;
|
|
||||||
if (Arrays.asList(HelperAcadInstance.openid).contains(host) && !BuildConfig.full_instances) {
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Oauth oauth = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).oauthClient(null, null, null, null);
|
Oauth oauth = new RetrofitPeertubeAPI(LoginActivity.this, acadInstance, null).oauthClient(null, null, null, null);
|
||||||
if (oauth == null) {
|
if (oauth == null) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
binding.loginButton.setEnabled(true);
|
binding.loginButton.setEnabled(true);
|
||||||
@ -196,7 +213,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
editor.apply();
|
editor.apply();
|
||||||
Intent intent = new Intent(LoginActivity.this, WebviewConnectActivity.class);
|
Intent intent = new Intent(LoginActivity.this, WebviewConnectActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString("url", "https://" + HelperInstance.getPeertubeUrl(finalHost) + "/plugins/auth-openid-connect/0.0.1/auth/openid-connect");
|
b.putString("url", "https://" + acadInstance + "/plugins/auth-openid-connect/0.0.1/auth/openid-connect");
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
@ -210,64 +227,168 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
}).start();
|
}).start();
|
||||||
} else {
|
} else {
|
||||||
new Thread(() -> {
|
if (binding.loginUid.getText() != null && binding.loginUid.getText().toString().contains("@") && !android.util.Patterns.EMAIL_ADDRESS.matcher(binding.loginUid.getText().toString().trim()).matches()) {
|
||||||
Oauth oauth = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).oauthClient(Helper.CLIENT_NAME_VALUE, Helper.WEBSITE_VALUE, Helper.OAUTH_SCOPES_PEERTUBE, Helper.WEBSITE_VALUE);
|
Toasty.error(LoginActivity.this, getString(R.string.email_error)).show();
|
||||||
if (oauth == null) {
|
return;
|
||||||
runOnUiThread(() -> {
|
}
|
||||||
binding.loginButton.setEnabled(true);
|
binding.loginButton.setEnabled(false);
|
||||||
Toasty.error(LoginActivity.this, getString(R.string.client_error), Toast.LENGTH_LONG).show();
|
String instance;
|
||||||
});
|
if (!BuildConfig.full_instances) {
|
||||||
|
String[] emailArray = binding.loginUid.getText().toString().split("@");
|
||||||
|
if (emailArray.length > 1 && !Arrays.asList(HelperAcadInstance.valideEmails).contains(emailArray[1])) {
|
||||||
|
Toasty.error(LoginActivity.this, getString(R.string.email_error_domain, emailArray[1])).show();
|
||||||
|
binding.loginButton.setEnabled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
client_id = oauth.getClient_id();
|
instance = HelperInstance.getLiveInstance(LoginActivity.this);
|
||||||
client_secret = oauth.getClient_secret();
|
} else {
|
||||||
|
if (binding.loginInstance.getText() == null || binding.loginInstance.getText().toString().trim().length() == 0) {
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
Toasty.error(LoginActivity.this, getString(R.string.not_valide_instance)).show();
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
binding.loginButton.setEnabled(true);
|
||||||
editor.putString(Helper.CLIENT_ID, client_id);
|
return;
|
||||||
editor.putString(Helper.CLIENT_SECRET, client_secret);
|
|
||||||
editor.apply();
|
|
||||||
OauthParams oauthParams = new OauthParams();
|
|
||||||
oauthParams.setClient_id(client_id);
|
|
||||||
oauthParams.setClient_secret(client_secret);
|
|
||||||
oauthParams.setGrant_type("password");
|
|
||||||
oauthParams.setScope("user");
|
|
||||||
oauthParams.setUsername(binding.loginUid.getText().toString().trim());
|
|
||||||
if (binding.loginPasswd.getText() != null) {
|
|
||||||
oauthParams.setPassword(binding.loginPasswd.getText().toString());
|
|
||||||
}
|
}
|
||||||
|
instance = binding.loginInstance.getText().toString().trim().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (instance.startsWith("http")) {
|
||||||
try {
|
try {
|
||||||
Token token = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).manageToken(oauthParams);
|
URL url = new URL(instance);
|
||||||
proceedLogin(token, finalHost);
|
instance = url.getHost();
|
||||||
} catch (final Exception | Error e) {
|
} catch (MalformedURLException e) {
|
||||||
oauthParams.setUsername(binding.loginUid.getText().toString().toLowerCase().trim());
|
e.printStackTrace();
|
||||||
try {
|
|
||||||
Token token = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).manageToken(oauthParams);
|
|
||||||
proceedLogin(token, finalHost);
|
|
||||||
} catch (Error error) {
|
|
||||||
Error.displayError(LoginActivity.this, error);
|
|
||||||
error.printStackTrace();
|
|
||||||
runOnUiThread(() -> binding.loginButton.setEnabled(true));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).start();
|
} else if (instance.endsWith("/")) {
|
||||||
|
try {
|
||||||
|
URL url = new URL("https://" + instance);
|
||||||
|
instance = url.getHost();
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!Patterns.WEB_URL.matcher("https://" + instance).matches()) {
|
||||||
|
Toasty.error(LoginActivity.this, getString(R.string.not_valide_instance)).show();
|
||||||
|
binding.loginButton.setEnabled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String finalInstance = instance;
|
||||||
|
if (BuildConfig.full_instances) {
|
||||||
|
new Thread(() -> {
|
||||||
|
WellKnownNodeinfo.NodeInfo instanceNodeInfo = null;
|
||||||
|
if (BuildConfig.allow_remote_connections) {
|
||||||
|
instanceNodeInfo = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).getNodeInfo();
|
||||||
|
}
|
||||||
|
connectToFediverse(finalInstance, instanceNodeInfo);
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Oauth process for Peertube
|
||||||
|
*
|
||||||
|
* @param finalInstance String
|
||||||
|
*/
|
||||||
|
private void connectToFediverse(String finalInstance, WellKnownNodeinfo.NodeInfo instanceNodeInfo) {
|
||||||
|
Oauth oauth = null;
|
||||||
|
String software;
|
||||||
|
if (instanceNodeInfo != null) {
|
||||||
|
software = instanceNodeInfo.getSoftware().getName().toUpperCase().trim();
|
||||||
|
switch (software) {
|
||||||
|
case "MASTODON":
|
||||||
|
case "PLEROMA":
|
||||||
|
oauth = new RetrofitMastodonAPI(LoginActivity.this, finalInstance, null).oauthClient(Helper.CLIENT_NAME_VALUE, Helper.REDIRECT_CONTENT_WEB, Helper.OAUTH_SCOPES_MASTODON, Helper.WEBSITE_VALUE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "FRIENDICA":
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
oauth = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).oauthClient(Helper.CLIENT_NAME_VALUE, Helper.WEBSITE_VALUE, Helper.OAUTH_SCOPES_PEERTUBE, Helper.WEBSITE_VALUE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
oauth = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).oauthClient(Helper.CLIENT_NAME_VALUE, Helper.WEBSITE_VALUE, Helper.OAUTH_SCOPES_PEERTUBE, Helper.WEBSITE_VALUE);
|
||||||
|
software = "PEERTUBE";
|
||||||
|
}
|
||||||
|
if (oauth == null) {
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
binding.loginButton.setEnabled(true);
|
||||||
|
Toasty.error(LoginActivity.this, getString(R.string.client_error), Toast.LENGTH_LONG).show();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
client_id = oauth.getClient_id();
|
||||||
|
client_secret = oauth.getClient_secret();
|
||||||
|
|
||||||
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
|
editor.putString(Helper.CLIENT_ID, client_id);
|
||||||
|
editor.putString(Helper.CLIENT_SECRET, client_secret);
|
||||||
|
editor.apply();
|
||||||
|
OauthParams oauthParams = new OauthParams();
|
||||||
|
oauthParams.setClient_id(client_id);
|
||||||
|
oauthParams.setClient_secret(client_secret);
|
||||||
|
oauthParams.setGrant_type("password");
|
||||||
|
final boolean isMastodonAPI = software.compareTo("MASTODON") == 0 || software.compareTo("PLEROMA") == 0;
|
||||||
|
if (software.compareTo("PEERTUBE") == 0) {
|
||||||
|
oauthParams.setScope("user");
|
||||||
|
} else if (isMastodonAPI) {
|
||||||
|
oauthParams.setScope("read write follow");
|
||||||
|
}
|
||||||
|
if (binding.loginUid.getText() != null) {
|
||||||
|
oauthParams.setUsername(binding.loginUid.getText().toString().trim());
|
||||||
|
}
|
||||||
|
if (binding.loginPasswd.getText() != null) {
|
||||||
|
oauthParams.setPassword(binding.loginPasswd.getText().toString());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Token token = null;
|
||||||
|
if (software.compareTo("PEERTUBE") == 0) {
|
||||||
|
token = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).manageToken(oauthParams);
|
||||||
|
} else if (isMastodonAPI) {
|
||||||
|
Intent i = new Intent(LoginActivity.this, MastodonWebviewConnectActivity.class);
|
||||||
|
i.putExtra("software", software);
|
||||||
|
i.putExtra("instance", finalInstance);
|
||||||
|
i.putExtra("client_id", client_id);
|
||||||
|
i.putExtra("client_secret", client_secret);
|
||||||
|
startActivity(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
proceedLogin(token, finalInstance, software.compareTo("PEERTUBE") == 0 ? null : software);
|
||||||
|
} catch (final Exception | Error e) {
|
||||||
|
oauthParams.setUsername(binding.loginUid.getText().toString().toLowerCase().trim());
|
||||||
|
try {
|
||||||
|
if (software.compareTo("PEERTUBE") == 0) {
|
||||||
|
Token token = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).manageToken(oauthParams);
|
||||||
|
proceedLogin(token, finalInstance, software.compareTo("PEERTUBE") == 0 ? null : software);
|
||||||
|
}
|
||||||
|
} catch (Error error) {
|
||||||
|
Error.displayError(LoginActivity.this, error);
|
||||||
|
error.printStackTrace();
|
||||||
|
runOnUiThread(() -> binding.loginButton.setEnabled(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("ApplySharedPref")
|
@SuppressLint("ApplySharedPref")
|
||||||
private void proceedLogin(Token token, String host) {
|
private void proceedLogin(Token token, String host, String software) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
|
boolean remote_account = software != null && software.toUpperCase().trim().compareTo("PEERTUBE") != 0;
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token.getAccess_token());
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token.getAccess_token());
|
||||||
editor.putString(Helper.PREF_INSTANCE, host);
|
editor.putString(Helper.PREF_SOFTWARE, remote_account ? software : null);
|
||||||
|
editor.putString(Helper.PREF_REMOTE_INSTANCE, remote_account ? host : null);
|
||||||
|
if (!remote_account) {
|
||||||
|
editor.putString(Helper.PREF_INSTANCE, host);
|
||||||
|
}
|
||||||
editor.commit();
|
editor.commit();
|
||||||
//Update the account with the token;
|
//Update the account with the token;
|
||||||
updateCredential(LoginActivity.this, token.getAccess_token(), client_id, client_secret, token.getRefresh_token(), host);
|
updateCredential(LoginActivity.this, token.getAccess_token(), client_id, client_secret, token.getRefresh_token(), host, software);
|
||||||
} else {
|
} else {
|
||||||
binding.loginButton.setEnabled(true);
|
binding.loginButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,11 @@ import java.net.URL;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -80,6 +83,7 @@ import app.fedilab.fedilabtube.databinding.ActivityMainBinding;
|
|||||||
import app.fedilab.fedilabtube.fragment.DisplayOverviewFragment;
|
import app.fedilab.fedilabtube.fragment.DisplayOverviewFragment;
|
||||||
import app.fedilab.fedilabtube.fragment.DisplayVideosFragment;
|
import app.fedilab.fedilabtube.fragment.DisplayVideosFragment;
|
||||||
import app.fedilab.fedilabtube.helper.Helper;
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
|
import app.fedilab.fedilabtube.helper.HelperAcadInstance;
|
||||||
import app.fedilab.fedilabtube.helper.HelperInstance;
|
import app.fedilab.fedilabtube.helper.HelperInstance;
|
||||||
import app.fedilab.fedilabtube.helper.PlaylistExportHelper;
|
import app.fedilab.fedilabtube.helper.PlaylistExportHelper;
|
||||||
import app.fedilab.fedilabtube.helper.SwitchAccountHelper;
|
import app.fedilab.fedilabtube.helper.SwitchAccountHelper;
|
||||||
@ -96,8 +100,9 @@ import su.litvak.chromecast.api.v2.MediaStatus;
|
|||||||
|
|
||||||
import static app.fedilab.fedilabtube.MainActivity.TypeOfConnection.NORMAL;
|
import static app.fedilab.fedilabtube.MainActivity.TypeOfConnection.NORMAL;
|
||||||
import static app.fedilab.fedilabtube.MainActivity.TypeOfConnection.SURFING;
|
import static app.fedilab.fedilabtube.MainActivity.TypeOfConnection.SURFING;
|
||||||
|
import static app.fedilab.fedilabtube.helper.Helper.isLoggedInType;
|
||||||
import static app.fedilab.fedilabtube.helper.Helper.peertubeInformation;
|
import static app.fedilab.fedilabtube.helper.Helper.peertubeInformation;
|
||||||
import static app.fedilab.fedilabtube.helper.HelperAcadInstance.academies;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements ChromeCastsListener {
|
public class MainActivity extends AppCompatActivity implements ChromeCastsListener {
|
||||||
|
|
||||||
@ -107,16 +112,53 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
public static UserMe userMe;
|
public static UserMe userMe;
|
||||||
public static InstanceData.InstanceConfig instanceConfig;
|
public static InstanceData.InstanceConfig instanceConfig;
|
||||||
public static TypeOfConnection typeOfConnection;
|
public static TypeOfConnection typeOfConnection;
|
||||||
|
public static List<ChromeCast> chromeCasts;
|
||||||
|
public static ChromeCast chromeCast;
|
||||||
|
public static boolean chromecastActivated = false;
|
||||||
private DisplayVideosFragment recentFragment, locaFragment, trendingFragment, subscriptionFragment, mostLikedFragment;
|
private DisplayVideosFragment recentFragment, locaFragment, trendingFragment, subscriptionFragment, mostLikedFragment;
|
||||||
private DisplayOverviewFragment overviewFragment;
|
private DisplayOverviewFragment overviewFragment;
|
||||||
private ActivityMainBinding binding;
|
private ActivityMainBinding binding;
|
||||||
|
private final BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
||||||
|
= item -> {
|
||||||
|
int itemId = item.getItemId();
|
||||||
|
String type = null;
|
||||||
|
if (itemId == R.id.navigation_discover) {
|
||||||
|
setTitleCustom(R.string.title_discover);
|
||||||
|
binding.viewpager.setCurrentItem(0);
|
||||||
|
type = HelperAcadInstance.DISCOVER;
|
||||||
|
} else if (itemId == R.id.navigation_subscription) {
|
||||||
|
binding.viewpager.setCurrentItem(1);
|
||||||
|
setTitleCustom(R.string.subscriptions);
|
||||||
|
type = HelperAcadInstance.SUBSCRIPTIONS;
|
||||||
|
} else if (itemId == R.id.navigation_trending) {
|
||||||
|
setTitleCustom(R.string.title_trending);
|
||||||
|
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||||
|
binding.viewpager.setCurrentItem(2);
|
||||||
|
} else {
|
||||||
|
binding.viewpager.setCurrentItem(1);
|
||||||
|
}
|
||||||
|
type = HelperAcadInstance.TRENDING;
|
||||||
|
} else if (itemId == R.id.navigation_most_liked) {
|
||||||
|
setTitleCustom(R.string.title_most_liked);
|
||||||
|
binding.viewpager.setCurrentItem(2);
|
||||||
|
type = HelperAcadInstance.MOSTLIKED;
|
||||||
|
} else if (itemId == R.id.navigation_recently_added) {
|
||||||
|
setTitleCustom(R.string.title_recently_added);
|
||||||
|
binding.viewpager.setCurrentItem(3);
|
||||||
|
type = HelperAcadInstance.RECENTLY_ADDED;
|
||||||
|
} else if (itemId == R.id.navigation_local) {
|
||||||
|
setTitleCustom(R.string.title_local);
|
||||||
|
binding.viewpager.setCurrentItem(4);
|
||||||
|
type = HelperAcadInstance.LOCAL;
|
||||||
|
}
|
||||||
|
if (type != null) {
|
||||||
|
Matomo.sendScreen(MainActivity.this, "TIMELINE", type);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
private BroadcastReceiver manage_chromecast;
|
private BroadcastReceiver manage_chromecast;
|
||||||
public static List<ChromeCast> chromeCasts;
|
|
||||||
public static ChromeCast chromeCast;
|
|
||||||
private VideoData.Video castedTube;
|
private VideoData.Video castedTube;
|
||||||
|
|
||||||
public static boolean chromecastActivated = false;
|
|
||||||
|
|
||||||
@SuppressLint("ApplySharedPref")
|
@SuppressLint("ApplySharedPref")
|
||||||
public static void showRadioButtonDialogFullInstances(Activity activity, boolean storeInDb) {
|
public static void showRadioButtonDialogFullInstances(Activity activity, boolean storeInDb) {
|
||||||
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
@ -190,35 +232,6 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
|
||||||
= item -> {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
if (itemId == R.id.navigation_discover) {
|
|
||||||
setTitleCustom(R.string.title_discover);
|
|
||||||
binding.viewpager.setCurrentItem(0);
|
|
||||||
} else if (itemId == R.id.navigation_subscription) {
|
|
||||||
binding.viewpager.setCurrentItem(1);
|
|
||||||
setTitleCustom(R.string.subscriptions);
|
|
||||||
} else if (itemId == R.id.navigation_trending) {
|
|
||||||
setTitleCustom(R.string.title_trending);
|
|
||||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
|
||||||
binding.viewpager.setCurrentItem(2);
|
|
||||||
} else {
|
|
||||||
binding.viewpager.setCurrentItem(1);
|
|
||||||
}
|
|
||||||
} else if (itemId == R.id.navigation_most_liked) {
|
|
||||||
setTitleCustom(R.string.title_most_liked);
|
|
||||||
binding.viewpager.setCurrentItem(2);
|
|
||||||
} else if (itemId == R.id.navigation_recently_added) {
|
|
||||||
setTitleCustom(R.string.title_recently_added);
|
|
||||||
binding.viewpager.setCurrentItem(3);
|
|
||||||
} else if (itemId == R.id.navigation_local) {
|
|
||||||
setTitleCustom(R.string.title_local);
|
|
||||||
binding.viewpager.setCurrentItem(4);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newChromeCastDiscovered(ChromeCast chromeCast) {
|
public void newChromeCastDiscovered(ChromeCast chromeCast) {
|
||||||
if (chromeCasts == null) {
|
if (chromeCasts == null) {
|
||||||
@ -308,6 +321,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
int tryFind = 0;
|
int tryFind = 0;
|
||||||
while (ChromeCasts.get().isEmpty() && tryFind < 5) {
|
while (ChromeCasts.get().isEmpty() && tryFind < 5) {
|
||||||
try {
|
try {
|
||||||
|
//noinspection BusyWait
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
tryFind++;
|
tryFind++;
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
@ -341,9 +355,8 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
|
|
||||||
typeOfConnection = TypeOfConnection.UNKNOWN;
|
typeOfConnection = TypeOfConnection.UNKNOWN;
|
||||||
|
|
||||||
BottomNavigationView navView = findViewById(R.id.nav_view);
|
|
||||||
|
|
||||||
navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
|
binding.navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
|
||||||
|
|
||||||
if (getSupportActionBar() != null) {
|
if (getSupportActionBar() != null) {
|
||||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||||
@ -382,6 +395,8 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
}
|
}
|
||||||
binding.viewpager.setOffscreenPageLimit(5);
|
binding.viewpager.setOffscreenPageLimit(5);
|
||||||
|
|
||||||
|
Matomo.sendEvent(MainActivity.this, "UTILISATEUR", "DEMARRAGE", HelperInstance.getLiveInstance(MainActivity.this), Helper.isLoggedIn(MainActivity.this) ? 1 : 0);
|
||||||
|
|
||||||
|
|
||||||
binding.viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
binding.viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -416,12 +431,11 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
setTitleCustom(R.string.title_discover);
|
setTitleCustom(R.string.title_discover);
|
||||||
|
|
||||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||||
|
binding.navView.inflateMenu(R.menu.bottom_nav_menu_connected);
|
||||||
navView.inflateMenu(R.menu.bottom_nav_menu_connected);
|
|
||||||
refreshToken();
|
refreshToken();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
navView.inflateMenu(R.menu.bottom_nav_menu);
|
binding.navView.inflateMenu(R.menu.bottom_nav_menu);
|
||||||
}
|
}
|
||||||
peertubeInformation = new PeertubeInformation();
|
peertubeInformation = new PeertubeInformation();
|
||||||
peertubeInformation.setCategories(new LinkedHashMap<>());
|
peertubeInformation.setCategories(new LinkedHashMap<>());
|
||||||
@ -547,7 +561,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
private void refreshToken() {
|
private void refreshToken() {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
String tokenStr = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
String tokenStr = Helper.getToken(MainActivity.this);
|
||||||
String instance = HelperInstance.getLiveInstance(MainActivity.this);
|
String instance = HelperInstance.getLiveInstance(MainActivity.this);
|
||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
String instanceShar = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
String instanceShar = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||||
@ -566,25 +580,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
oauthParams.setAccess_token(account.getToken());
|
oauthParams.setAccess_token(account.getToken());
|
||||||
try {
|
try {
|
||||||
Token token = new RetrofitPeertubeAPI(MainActivity.this).manageToken(oauthParams);
|
Token token = new RetrofitPeertubeAPI(MainActivity.this).manageToken(oauthParams);
|
||||||
if (token == null && Helper.instanceOnline(instance)) {
|
if (token == null) {
|
||||||
runOnUiThread(() -> {
|
|
||||||
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
|
|
||||||
alt_bld.setTitle(R.string.refresh_token_failed);
|
|
||||||
alt_bld.setMessage(R.string.refresh_token_failed_message);
|
|
||||||
alt_bld.setNegativeButton(R.string.action_logout, (dialog, id) -> {
|
|
||||||
dialog.dismiss();
|
|
||||||
Helper.logoutCurrentUser(MainActivity.this, finalAccount);
|
|
||||||
});
|
|
||||||
alt_bld.setPositiveButton(R.string._retry, (dialog, id) -> {
|
|
||||||
dialog.dismiss();
|
|
||||||
refreshToken();
|
|
||||||
});
|
|
||||||
AlertDialog alert = alt_bld.create();
|
|
||||||
alert.show();
|
|
||||||
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
} else if (token == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
@ -622,7 +618,22 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
}
|
}
|
||||||
instanceConfig = new RetrofitPeertubeAPI(MainActivity.this).getConfigInstance();
|
instanceConfig = new RetrofitPeertubeAPI(MainActivity.this).getConfigInstance();
|
||||||
} catch (Error error) {
|
} catch (Error error) {
|
||||||
runOnUiThread(() -> Helper.logoutCurrentUser(MainActivity.this, finalAccount));
|
runOnUiThread(() -> {
|
||||||
|
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
|
||||||
|
alt_bld.setTitle(R.string.refresh_token_failed);
|
||||||
|
alt_bld.setMessage(R.string.refresh_token_failed_message);
|
||||||
|
alt_bld.setNegativeButton(R.string.action_logout, (dialog, id) -> {
|
||||||
|
dialog.dismiss();
|
||||||
|
Helper.logoutCurrentUser(MainActivity.this, finalAccount);
|
||||||
|
});
|
||||||
|
alt_bld.setPositiveButton(R.string._retry, (dialog, id) -> {
|
||||||
|
dialog.dismiss();
|
||||||
|
refreshToken();
|
||||||
|
});
|
||||||
|
AlertDialog alert = alt_bld.create();
|
||||||
|
alert.show();
|
||||||
|
|
||||||
|
});
|
||||||
error.printStackTrace();
|
error.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -701,6 +712,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
mostLikedItem.setVisible(false);
|
mostLikedItem.setVisible(false);
|
||||||
incognitoItem.setVisible(false);
|
incognitoItem.setVisible(false);
|
||||||
break;
|
break;
|
||||||
|
case REMOTE_ACCOUNT:
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
accountItem.setVisible(true);
|
accountItem.setVisible(true);
|
||||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||||
@ -754,7 +766,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
typeOfConnection = NORMAL;
|
typeOfConnection = NORMAL;
|
||||||
if (!Helper.isLoggedIn(MainActivity.this)) {
|
if (!Helper.canMakeAction(MainActivity.this)) {
|
||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
List<Account> accounts = new AccountDAO(MainActivity.this, db).getAllAccount();
|
List<Account> accounts = new AccountDAO(MainActivity.this, db).getAllAccount();
|
||||||
if (accounts != null && accounts.size() > 0) {
|
if (accounts != null && accounts.size() > 0) {
|
||||||
@ -772,13 +784,16 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
String type = null;
|
||||||
|
String action = "TIMELINE";
|
||||||
if (item.getItemId() == R.id.action_change_instance) {
|
if (item.getItemId() == R.id.action_change_instance) {
|
||||||
if (BuildConfig.full_instances) {
|
if (BuildConfig.full_instances) {
|
||||||
showRadioButtonDialogFullInstances(MainActivity.this, false);
|
showRadioButtonDialogFullInstances(MainActivity.this, false);
|
||||||
} else {
|
} else {
|
||||||
showRadioButtonDialog();
|
showRadioButtonDialog();
|
||||||
}
|
}
|
||||||
return true;
|
action = "CHANGE_INSTANCE";
|
||||||
|
type = "";
|
||||||
} else if (item.getItemId() == R.id.action_settings) {
|
} else if (item.getItemId() == R.id.action_settings) {
|
||||||
Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
|
Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
@ -787,39 +802,37 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
if (typeOfConnection == SURFING) {
|
if (typeOfConnection == SURFING) {
|
||||||
SwitchAccountHelper.switchDialog(MainActivity.this, false);
|
SwitchAccountHelper.switchDialog(MainActivity.this, false);
|
||||||
} else {
|
} else {
|
||||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
if (Helper.canMakeAction(MainActivity.this)) {
|
||||||
intent = new Intent(MainActivity.this, AccountActivity.class);
|
intent = new Intent(MainActivity.this, AccountActivity.class);
|
||||||
} else {
|
} else {
|
||||||
intent = new Intent(MainActivity.this, LoginActivity.class);
|
intent = new Intent(MainActivity.this, LoginActivity.class);
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} else if (item.getItemId() == R.id.action_upload) {
|
} else if (item.getItemId() == R.id.action_upload) {
|
||||||
Intent intent = new Intent(MainActivity.this, PeertubeUploadActivity.class);
|
Intent intent = new Intent(MainActivity.this, PeertubeUploadActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
|
||||||
} else if (item.getItemId() == R.id.action_myvideos) {
|
} else if (item.getItemId() == R.id.action_myvideos) {
|
||||||
Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
|
Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable("type", TimelineVM.TimelineType.MY_VIDEOS);
|
bundle.putSerializable("type", TimelineVM.TimelineType.MY_VIDEOS);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
type = HelperAcadInstance.MYVIDEOS;
|
||||||
} else if (item.getItemId() == R.id.action_history) {
|
} else if (item.getItemId() == R.id.action_history) {
|
||||||
Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
|
Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable("type", TimelineVM.TimelineType.HISTORY);
|
bundle.putSerializable("type", TimelineVM.TimelineType.HISTORY);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
type = HelperAcadInstance.HISTORY;
|
||||||
} else if (item.getItemId() == R.id.action_most_liked) {
|
} else if (item.getItemId() == R.id.action_most_liked) {
|
||||||
Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
|
Intent intent = new Intent(MainActivity.this, VideosTimelineActivity.class);
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable("type", TimelineVM.TimelineType.MOST_LIKED);
|
bundle.putSerializable("type", TimelineVM.TimelineType.MOST_LIKED);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
type = HelperAcadInstance.MOSTLIKED;
|
||||||
} else if (item.getItemId() == R.id.action_playlist) {
|
} else if (item.getItemId() == R.id.action_playlist) {
|
||||||
Intent intent;
|
Intent intent;
|
||||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||||
@ -828,15 +841,12 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
intent = new Intent(MainActivity.this, AllLocalPlaylistsActivity.class);
|
intent = new Intent(MainActivity.this, AllLocalPlaylistsActivity.class);
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
|
||||||
} else if (item.getItemId() == R.id.action_sepia_search) {
|
} else if (item.getItemId() == R.id.action_sepia_search) {
|
||||||
Intent intent = new Intent(MainActivity.this, SepiaSearchActivity.class);
|
Intent intent = new Intent(MainActivity.this, SepiaSearchActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
|
||||||
} else if (item.getItemId() == R.id.action_about) {
|
} else if (item.getItemId() == R.id.action_about) {
|
||||||
Intent intent = new Intent(MainActivity.this, AboutActivity.class);
|
Intent intent = new Intent(MainActivity.this, AboutActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
|
||||||
} else if (item.getItemId() == R.id.action_incognito) {
|
} else if (item.getItemId() == R.id.action_incognito) {
|
||||||
item.setChecked(!item.isChecked());
|
item.setChecked(!item.isChecked());
|
||||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
@ -855,8 +865,10 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
}).start();
|
}).start();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (type != null) {
|
||||||
return super.onOptionsItemSelected(item);
|
Matomo.sendScreen(MainActivity.this, action, type);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -884,14 +896,23 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
String acad = HelperInstance.getLiveInstance(MainActivity.this);
|
String acad = HelperInstance.getLiveInstance(MainActivity.this);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String item : academies) {
|
HashMap<String, String> instancesMap = new HashMap<>(HelperAcadInstance.instances_themes);
|
||||||
if (HelperInstance.getPeertubeUrl(item).compareTo(acad) == 0) {
|
Iterator<Map.Entry<String, String>> it = instancesMap.entrySet().iterator();
|
||||||
break;
|
String[] academiesKey = new String[HelperAcadInstance.instances_themes.size()];
|
||||||
|
String[] academiesValue = new String[HelperAcadInstance.instances_themes.size()];
|
||||||
|
int position = 0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Map.Entry<String, String> pair = it.next();
|
||||||
|
academiesKey[i] = pair.getKey();
|
||||||
|
academiesValue[i] = pair.getValue();
|
||||||
|
if (pair.getValue().compareTo(acad) == 0) {
|
||||||
|
position = i;
|
||||||
}
|
}
|
||||||
|
it.remove();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
alt_bld.setSingleChoiceItems(academies, i, (dialog, item) -> {
|
alt_bld.setSingleChoiceItems(academiesKey, position, (dialog, item) -> {
|
||||||
String newInstance = academies[item];
|
String newInstance = academiesValue[item];
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_INSTANCE, newInstance);
|
editor.putString(Helper.PREF_INSTANCE, newInstance);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
@ -918,6 +939,13 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum TypeOfConnection {
|
||||||
|
UNKNOWN,
|
||||||
|
NORMAL,
|
||||||
|
SURFING,
|
||||||
|
REMOTE_ACCOUNT,
|
||||||
|
}
|
||||||
|
|
||||||
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
|
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
|
||||||
|
|
||||||
ScreenSlidePagerAdapter(FragmentManager fm) {
|
ScreenSlidePagerAdapter(FragmentManager fm) {
|
||||||
@ -962,10 +990,4 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
|||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum TypeOfConnection {
|
|
||||||
UNKNOWN,
|
|
||||||
NORMAL,
|
|
||||||
SURFING
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -0,0 +1,194 @@
|
|||||||
|
/* Copyright 2020 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
package app.fedilab.fedilabtube;
|
||||||
|
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.webkit.CookieManager;
|
||||||
|
import android.webkit.CookieSyncManager;
|
||||||
|
import android.webkit.WebChromeClient;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.client.mastodon.RetrofitMastodonAPI;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.Error;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.OauthParams;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.Token;
|
||||||
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
|
import es.dmoral.toasty.Toasty;
|
||||||
|
|
||||||
|
|
||||||
|
public class MastodonWebviewConnectActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
|
private WebView webView;
|
||||||
|
private AlertDialog alert;
|
||||||
|
private String clientId, clientSecret;
|
||||||
|
private String instance, software;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static void clearCookies(Context context) {
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
|
CookieManager.getInstance().removeAllCookies(null);
|
||||||
|
CookieManager.getInstance().flush();
|
||||||
|
} else {
|
||||||
|
CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context);
|
||||||
|
cookieSyncMngr.startSync();
|
||||||
|
CookieManager cookieManager = CookieManager.getInstance();
|
||||||
|
cookieManager.removeAllCookie();
|
||||||
|
cookieManager.removeSessionCookie();
|
||||||
|
cookieSyncMngr.stopSync();
|
||||||
|
cookieSyncMngr.sync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String redirectUserToAuthorizeAndLogin(String clientId, String instance) {
|
||||||
|
String queryString = Helper.CLIENT_ID + "=" + clientId;
|
||||||
|
queryString += "&" + Helper.REDIRECT_URI + "=" + Uri.encode(Helper.REDIRECT_CONTENT_WEB);
|
||||||
|
queryString += "&response_type=code";
|
||||||
|
queryString += "&scope=read write follow";
|
||||||
|
return "https://" + instance + "/oauth/authorize?" + queryString;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setContentView(R.layout.activity_webview_connect);
|
||||||
|
Bundle b = getIntent().getExtras();
|
||||||
|
if (b != null) {
|
||||||
|
instance = b.getString("instance");
|
||||||
|
clientId = b.getString("client_id");
|
||||||
|
clientSecret = b.getString("client_secret");
|
||||||
|
software = b.getString("software");
|
||||||
|
}
|
||||||
|
if (instance == null)
|
||||||
|
finish();
|
||||||
|
if (getSupportActionBar() != null)
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
setTitle(R.string.login);
|
||||||
|
webView = findViewById(R.id.webviewConnect);
|
||||||
|
clearCookies(MastodonWebviewConnectActivity.this);
|
||||||
|
webView.getSettings().setJavaScriptEnabled(true);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
|
||||||
|
} else {
|
||||||
|
CookieManager.getInstance().setAcceptCookie(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
final ProgressBar pbar = findViewById(R.id.progress_bar);
|
||||||
|
webView.setWebChromeClient(new WebChromeClient() {
|
||||||
|
@Override
|
||||||
|
public void onProgressChanged(WebView view, int progress) {
|
||||||
|
if (progress < 100 && pbar.getVisibility() == ProgressBar.GONE) {
|
||||||
|
pbar.setVisibility(ProgressBar.VISIBLE);
|
||||||
|
}
|
||||||
|
pbar.setProgress(progress);
|
||||||
|
if (progress == 100) {
|
||||||
|
pbar.setVisibility(ProgressBar.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (instance == null) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
webView.setWebViewClient(new WebViewClient() {
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
super.shouldOverrideUrlLoading(view, url);
|
||||||
|
if (url.contains(Helper.REDIRECT_CONTENT_WEB)) {
|
||||||
|
String[] val = url.split("code=");
|
||||||
|
if (val.length < 2) {
|
||||||
|
Toasty.error(MastodonWebviewConnectActivity.this, getString(R.string.toast_code_error), Toast.LENGTH_LONG).show();
|
||||||
|
Intent myIntent = new Intent(MastodonWebviewConnectActivity.this, LoginActivity.class);
|
||||||
|
startActivity(myIntent);
|
||||||
|
finish();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String code = val[1];
|
||||||
|
OauthParams oauthParams = new OauthParams();
|
||||||
|
oauthParams.setClient_id(clientId);
|
||||||
|
oauthParams.setClient_secret(clientSecret);
|
||||||
|
oauthParams.setGrant_type("authorization_code");
|
||||||
|
oauthParams.setCode(code);
|
||||||
|
oauthParams.setRedirect_uri(Helper.REDIRECT_CONTENT_WEB);
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Token token = new RetrofitMastodonAPI(MastodonWebviewConnectActivity.this, instance, null).manageToken(oauthParams);
|
||||||
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token.getAccess_token());
|
||||||
|
editor.apply();
|
||||||
|
new RetrofitMastodonAPI(MastodonWebviewConnectActivity.this, instance, token.getAccess_token()).updateCredential(MastodonWebviewConnectActivity.this, clientId, clientSecret, token.getRefresh_token(), software);
|
||||||
|
} catch (Exception | Error ignored) {
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
webView.loadUrl(redirectUserToAuthorizeAndLogin(clientId, instance));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
int itemId = item.getItemId();
|
||||||
|
if (itemId == android.R.id.home) {
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (webView != null && webView.canGoBack()) {
|
||||||
|
webView.goBack();
|
||||||
|
} else {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (alert != null) {
|
||||||
|
alert.dismiss();
|
||||||
|
alert = null;
|
||||||
|
}
|
||||||
|
if (webView != null) {
|
||||||
|
webView.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -74,6 +74,8 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.frostwire.jlibtorrent.SessionManager;
|
||||||
import com.github.se_bastiaan.torrentstream.StreamStatus;
|
import com.github.se_bastiaan.torrentstream.StreamStatus;
|
||||||
import com.github.se_bastiaan.torrentstream.Torrent;
|
import com.github.se_bastiaan.torrentstream.Torrent;
|
||||||
import com.github.se_bastiaan.torrentstream.TorrentOptions;
|
import com.github.se_bastiaan.torrentstream.TorrentOptions;
|
||||||
@ -96,13 +98,16 @@ import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
|
|||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||||
|
import com.google.android.exoplayer2.ui.DefaultTimeBar;
|
||||||
import com.google.android.exoplayer2.ui.PlayerControlView;
|
import com.google.android.exoplayer2.ui.PlayerControlView;
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
|
import com.google.android.exoplayer2.upstream.DataSpec;
|
||||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||||
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
|
import com.google.android.exoplayer2.upstream.FileDataSource;
|
||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
import com.google.android.exoplayer2.util.MimeTypes;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import com.google.android.exoplayer2.video.VideoListener;
|
import com.google.android.exoplayer2.video.VideoListener;
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -115,6 +120,8 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -125,7 +132,9 @@ import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
|||||||
import app.fedilab.fedilabtube.client.data.CaptionData.Caption;
|
import app.fedilab.fedilabtube.client.data.CaptionData.Caption;
|
||||||
import app.fedilab.fedilabtube.client.data.CommentData;
|
import app.fedilab.fedilabtube.client.data.CommentData;
|
||||||
import app.fedilab.fedilabtube.client.data.CommentData.Comment;
|
import app.fedilab.fedilabtube.client.data.CommentData.Comment;
|
||||||
|
import app.fedilab.fedilabtube.client.data.InstanceData;
|
||||||
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
||||||
|
import app.fedilab.fedilabtube.client.data.PluginData;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||||
import app.fedilab.fedilabtube.client.entities.Error;
|
import app.fedilab.fedilabtube.client.entities.Error;
|
||||||
import app.fedilab.fedilabtube.client.entities.File;
|
import app.fedilab.fedilabtube.client.entities.File;
|
||||||
@ -133,6 +142,7 @@ import app.fedilab.fedilabtube.client.entities.MenuItemView;
|
|||||||
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
||||||
import app.fedilab.fedilabtube.client.entities.Report;
|
import app.fedilab.fedilabtube.client.entities.Report;
|
||||||
import app.fedilab.fedilabtube.client.entities.UserSettings;
|
import app.fedilab.fedilabtube.client.entities.UserSettings;
|
||||||
|
import app.fedilab.fedilabtube.client.mastodon.RetrofitMastodonAPI;
|
||||||
import app.fedilab.fedilabtube.databinding.ActivityPeertubeBinding;
|
import app.fedilab.fedilabtube.databinding.ActivityPeertubeBinding;
|
||||||
import app.fedilab.fedilabtube.drawer.CommentListAdapter;
|
import app.fedilab.fedilabtube.drawer.CommentListAdapter;
|
||||||
import app.fedilab.fedilabtube.drawer.MenuAdapter;
|
import app.fedilab.fedilabtube.drawer.MenuAdapter;
|
||||||
@ -148,6 +158,7 @@ import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
|||||||
import app.fedilab.fedilabtube.viewmodel.PostActionsVM;
|
import app.fedilab.fedilabtube.viewmodel.PostActionsVM;
|
||||||
import app.fedilab.fedilabtube.viewmodel.SearchVM;
|
import app.fedilab.fedilabtube.viewmodel.SearchVM;
|
||||||
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
|
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
|
||||||
|
import app.fedilab.fedilabtube.viewmodel.mastodon.MastodonPostActionsVM;
|
||||||
import app.fedilab.fedilabtube.webview.CustomWebview;
|
import app.fedilab.fedilabtube.webview.CustomWebview;
|
||||||
import app.fedilab.fedilabtube.webview.MastalabWebChromeClient;
|
import app.fedilab.fedilabtube.webview.MastalabWebChromeClient;
|
||||||
import app.fedilab.fedilabtube.webview.MastalabWebViewClient;
|
import app.fedilab.fedilabtube.webview.MastalabWebViewClient;
|
||||||
@ -165,6 +176,7 @@ import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPL
|
|||||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT;
|
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT;
|
||||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_VIDEO;
|
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_VIDEO;
|
||||||
import static app.fedilab.fedilabtube.helper.Helper.CAST_ID;
|
import static app.fedilab.fedilabtube.helper.Helper.CAST_ID;
|
||||||
|
import static app.fedilab.fedilabtube.helper.Helper.canMakeAction;
|
||||||
import static app.fedilab.fedilabtube.helper.Helper.getAttColor;
|
import static app.fedilab.fedilabtube.helper.Helper.getAttColor;
|
||||||
import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
|
import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
|
||||||
import static app.fedilab.fedilabtube.helper.Helper.loadGiF;
|
import static app.fedilab.fedilabtube.helper.Helper.loadGiF;
|
||||||
@ -207,6 +219,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
private boolean isRemote;
|
private boolean isRemote;
|
||||||
private boolean willPlayFromIntent;
|
private boolean willPlayFromIntent;
|
||||||
private String chromeCastVideoURL;
|
private String chromeCastVideoURL;
|
||||||
|
private app.fedilab.fedilabtube.client.mastodon.Status status;
|
||||||
|
|
||||||
public static void hideKeyboard(Activity activity) {
|
public static void hideKeyboard(Activity activity) {
|
||||||
if (activity != null && activity.getWindow() != null) {
|
if (activity != null && activity.getWindow() != null) {
|
||||||
@ -233,7 +246,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStreamStarted(Torrent torrent) {
|
public void onStreamStarted(Torrent torrent) {
|
||||||
startStream(torrent.getVideoFile().getAbsolutePath(), null, autoPlay, -1, null, null, true);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -243,10 +257,45 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStreamReady(Torrent torrent) {
|
public void onStreamReady(Torrent torrent) {
|
||||||
|
if (torrent.getVideoFile() != null) {
|
||||||
|
for (int i = 0; i < torrent.getFileNames().length; i++) {
|
||||||
|
torrent.getTorrentHandle().renameFile(i, torrent.getFileNames()[0].replaceAll("[^a-zA-Z0-9/.-]", "_"));
|
||||||
|
}
|
||||||
|
startStream(peertube, torrent.getVideoFile().getAbsolutePath().replaceAll("[^a-zA-Z0-9/.-]", "_"), null, autoPlay, -1, null, null, true);
|
||||||
|
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
|
||||||
|
ConstraintLayout torrent_info = controlView.findViewById(R.id.torrent_info);
|
||||||
|
TextView dowload_rate = controlView.findViewById(R.id.dowload_rate);
|
||||||
|
TextView upload_rate = controlView.findViewById(R.id.upload_rate);
|
||||||
|
torrent_info.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
new Timer().scheduleAtFixedRate(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
SessionManager sessionManager = torrentStream.getSessionManager();
|
||||||
|
if (sessionManager != null) {
|
||||||
|
long upload = sessionManager.uploadRate();
|
||||||
|
long download = sessionManager.downloadRate();
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
dowload_rate.setText(String.format("▼ %s", Helper.rateSize(PeertubeActivity.this, download)));
|
||||||
|
upload_rate.setText(String.format("▲ %s", Helper.rateSize(PeertubeActivity.this, upload)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
} else {
|
||||||
|
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStreamProgress(Torrent torrent, StreamStatus status) {
|
public void onStreamProgress(Torrent torrent, StreamStatus status) {
|
||||||
|
if (binding != null) {
|
||||||
|
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
|
||||||
|
TextView peers_number = controlView.findViewById(R.id.peers_number);
|
||||||
|
peers_number.setText(getString(R.string.peers, status.peers));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -265,13 +314,13 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||||
if (Helper.isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
if (Helper.canMakeAction(PeertubeActivity.this) && !sepiaSearch) {
|
||||||
Account account = new AccountDAO(PeertubeActivity.this, db).getAccountByToken(token);
|
Account account = new AccountDAO(PeertubeActivity.this, db).getAccountByToken(token);
|
||||||
Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, binding.myPp);
|
Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, binding.myPp);
|
||||||
}
|
}
|
||||||
isRemote = false;
|
isRemote = false;
|
||||||
TorrentOptions torrentOptions = new TorrentOptions.Builder()
|
TorrentOptions torrentOptions = new TorrentOptions.Builder()
|
||||||
.saveLocation(getCacheDir())
|
.saveLocation(getCacheDir() + "/torrent/")
|
||||||
.autoDownload(true)
|
.autoDownload(true)
|
||||||
.removeFilesAfterStop(true)
|
.removeFilesAfterStop(true)
|
||||||
.build();
|
.build();
|
||||||
@ -294,7 +343,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
|
||||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||||
0,
|
0,
|
||||||
3.0f
|
4.0f
|
||||||
);
|
);
|
||||||
binding.videoContainer.setLayoutParams(param);
|
binding.videoContainer.setLayoutParams(param);
|
||||||
}
|
}
|
||||||
@ -316,8 +365,20 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
peertube = b.getParcelable("video");
|
peertube = b.getParcelable("video");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
willPlayFromIntent = manageIntentUrl(intent);
|
willPlayFromIntent = manageIntentUrl(intent);
|
||||||
|
|
||||||
|
if (BuildConfig.allow_remote_connections && Helper.isLoggedInType(PeertubeActivity.this) == MainActivity.TypeOfConnection.REMOTE_ACCOUNT) {
|
||||||
|
binding.peertubeLikeCount.setVisibility(View.GONE);
|
||||||
|
binding.peertubeDislikeCount.setVisibility(View.GONE);
|
||||||
|
binding.peertubePlaylist.setVisibility(View.GONE);
|
||||||
|
binding.peertubeReblog.setVisibility(View.VISIBLE);
|
||||||
|
binding.peertubeFavorite.setVisibility(View.VISIBLE);
|
||||||
|
binding.peertubeBookmark.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
binding.peertubePlaylist.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
binding.peertubeDescriptionMore.setOnClickListener(v -> {
|
binding.peertubeDescriptionMore.setOnClickListener(v -> {
|
||||||
if (show_more_content != null && peertube != null) {
|
if (show_more_content != null && peertube != null) {
|
||||||
if (binding.peertubeDescriptionMore.getText().toString().compareTo(getString(R.string.show_more)) == 0) {
|
if (binding.peertubeDescriptionMore.getText().toString().compareTo(getString(R.string.show_more)) == 0) {
|
||||||
@ -329,7 +390,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!Helper.isLoggedIn(PeertubeActivity.this) || sepiaSearch) {
|
if (!Helper.canMakeAction(PeertubeActivity.this) || sepiaSearch) {
|
||||||
binding.writeCommentContainer.setVisibility(View.GONE);
|
binding.writeCommentContainer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
||||||
@ -438,7 +499,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
openFullscreenDialog();
|
openFullscreenDialog();
|
||||||
}
|
}
|
||||||
binding.postCommentButton.setOnClickListener(v -> {
|
binding.postCommentButton.setOnClickListener(v -> {
|
||||||
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
if (canMakeAction(PeertubeActivity.this) && !sepiaSearch) {
|
||||||
openPostComment(null, 0);
|
openPostComment(null, 0);
|
||||||
} else {
|
} else {
|
||||||
if (sepiaSearch) {
|
if (sepiaSearch) {
|
||||||
@ -486,6 +547,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
peertube = apiResponse.getPeertubes().get(0);
|
peertube = apiResponse.getPeertubes().get(0);
|
||||||
|
Matomo.sendScreen(PeertubeActivity.this, "VIDEO_REGARDEE", peertube.getUuid());
|
||||||
if (peertube.isNsfw()) {
|
if (peertube.isNsfw()) {
|
||||||
binding.videoSensitive.setVisibility(View.VISIBLE);
|
binding.videoSensitive.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
@ -661,13 +723,42 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
if (autoFullscreen && autoPlay) {
|
if (autoFullscreen && autoPlay) {
|
||||||
openFullscreenDialog();
|
openFullscreenDialog();
|
||||||
}
|
}
|
||||||
binding.peertubePlaylist.setVisibility(View.VISIBLE);
|
|
||||||
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
|
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
|
||||||
if (!isRemote) {
|
if (!isRemote) {
|
||||||
feedsViewModel.getVideo(sepiaSearch ? peertubeInstance : null, videoUuid, isMyVideo).observe(PeertubeActivity.this, this::manageVIewVideo);
|
feedsViewModel.getVideo(sepiaSearch ? peertubeInstance : null, videoUuid, isMyVideo).observe(PeertubeActivity.this, this::manageVIewVideo);
|
||||||
}
|
}
|
||||||
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
|
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
|
||||||
captionsViewModel.getCaptions(sepiaSearch ? peertubeInstance : null, videoUuid).observe(PeertubeActivity.this, this::manageCaptions);
|
captionsViewModel.getCaptions(sepiaSearch ? peertubeInstance : null, videoUuid).observe(PeertubeActivity.this, this::manageCaptions);
|
||||||
|
|
||||||
|
//Post view count
|
||||||
|
new Thread(() -> {
|
||||||
|
String videoId = peertube != null ? peertube.getUuid() : videoUuid;
|
||||||
|
new RetrofitPeertubeAPI(PeertubeActivity.this).postView(videoId);
|
||||||
|
}).start();
|
||||||
|
//manage plugin
|
||||||
|
new Thread(() -> {
|
||||||
|
String videoInstance = peertubeInstance != null ? peertubeInstance : peertube.getAccount().getHost();
|
||||||
|
InstanceData.InstanceConfig instanceConfig = new RetrofitPeertubeAPI(PeertubeActivity.this, videoInstance, null).getConfigInstance();
|
||||||
|
if (instanceConfig != null && instanceConfig.getPlugin() != null && instanceConfig.getPlugin().getRegistered() != null) {
|
||||||
|
for (PluginData.PluginInfo pluginInfo : instanceConfig.getPlugin().getRegistered()) {
|
||||||
|
if (pluginInfo.getName().compareTo("player-watermark") == 0) {
|
||||||
|
PluginData.WaterMark getWaterMark = new RetrofitPeertubeAPI(PeertubeActivity.this, videoInstance, null).getWaterMark();
|
||||||
|
if (getWaterMark != null && getWaterMark.getDescription() != null && getWaterMark.getDescription().getWatermarkImageUrl() != null) {
|
||||||
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
Runnable myRunnable = () -> {
|
||||||
|
Glide.with(binding.watermark.getContext())
|
||||||
|
.asDrawable()
|
||||||
|
.load(getWaterMark.getDescription().getWatermarkImageUrl())
|
||||||
|
.into(binding.watermark);
|
||||||
|
binding.watermark.setVisibility(View.VISIBLE);
|
||||||
|
};
|
||||||
|
mainHandler.post(myRunnable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
RetrofitPeertubeAPI api;
|
RetrofitPeertubeAPI api;
|
||||||
@ -958,7 +1049,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
binding.loader.setVisibility(View.GONE);
|
binding.loader.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (apiResponse.getPeertubes() == null || apiResponse.getPeertubes().get(0) == null || apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this) == null) {
|
if (apiResponse.getPeertubes() == null || apiResponse.getPeertubes().get(0) == null || (!apiResponse.getPeertubes().get(0).isLive() && apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this) == null)) {
|
||||||
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||||
binding.loader.setVisibility(View.GONE);
|
binding.loader.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
@ -974,6 +1065,23 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
userHistory.setCurrentTime(previousPositionHistory);
|
userHistory.setCurrentTime(previousPositionHistory);
|
||||||
peertube.setUserHistory(userHistory);
|
peertube.setUserHistory(userHistory);
|
||||||
|
|
||||||
|
|
||||||
|
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
|
||||||
|
DefaultTimeBar exo_progress = controlView.findViewById(R.id.exo_progress);
|
||||||
|
TextView exo_duration = controlView.findViewById(R.id.exo_duration);
|
||||||
|
TextView exo_live_badge = controlView.findViewById(R.id.exo_live_badge);
|
||||||
|
if (peertube.isLive()) {
|
||||||
|
exo_progress.setVisibility(View.INVISIBLE);
|
||||||
|
exo_duration.setVisibility(View.GONE);
|
||||||
|
exo_live_badge.setVisibility(View.VISIBLE);
|
||||||
|
exo_live_badge.setText(R.string.live);
|
||||||
|
exo_live_badge.setBackgroundResource(R.drawable.rounded_live);
|
||||||
|
} else {
|
||||||
|
exo_progress.setVisibility(View.VISIBLE);
|
||||||
|
exo_live_badge.setVisibility(View.GONE);
|
||||||
|
exo_duration.setBackground(null);
|
||||||
|
}
|
||||||
|
|
||||||
if (peertube.getUserHistory() != null) {
|
if (peertube.getUserHistory() != null) {
|
||||||
position = peertube.getUserHistory().getCurrentTime() * 1000;
|
position = peertube.getUserHistory().getCurrentTime() * 1000;
|
||||||
}
|
}
|
||||||
@ -989,10 +1097,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
PlaylistsVM viewModel = new ViewModelProvider(this).get(PlaylistsVM.class);
|
PlaylistsVM viewModel = new ViewModelProvider(this).get(PlaylistsVM.class);
|
||||||
viewModel.videoExists(videoIds).observe(this, this::manageVIewPlaylist);
|
viewModel.videoExists(videoIds).observe(this, this::manageVIewPlaylist);
|
||||||
|
|
||||||
if (!Helper.isLoggedIn(PeertubeActivity.this) || sepiaSearch) {
|
if (!Helper.canMakeAction(PeertubeActivity.this) || sepiaSearch) {
|
||||||
binding.writeCommentContainer.setVisibility(View.GONE);
|
binding.writeCommentContainer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (peertube.isNsfw()) {
|
if (peertube.isNsfw()) {
|
||||||
binding.videoSensitive.setVisibility(View.VISIBLE);
|
binding.videoSensitive.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
@ -1025,7 +1134,13 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
LinkedHashMap<Integer, String> categoryInit = new LinkedHashMap<>(peertubeInformation.getCategories());
|
LinkedHashMap<Integer, String> categoryInit = new LinkedHashMap<>(peertubeInformation.getCategories());
|
||||||
info_category.setText(categoryInit.get(peertube.getCategory().getId()));
|
info_category.setText(categoryInit.get(peertube.getCategory().getId()));
|
||||||
|
|
||||||
info_duration.setText(Helper.secondsToString(peertube.getDuration()));
|
if (peertube.isLive()) {
|
||||||
|
info_duration.setText(R.string.live);
|
||||||
|
info_duration.setBackgroundResource(R.drawable.rounded_live);
|
||||||
|
} else {
|
||||||
|
info_duration.setText(Helper.secondsToString(peertube.getDuration()));
|
||||||
|
}
|
||||||
|
|
||||||
String format = DateFormat.getDateInstance(DateFormat.LONG).format(peertube.getPublishedAt());
|
String format = DateFormat.getDateInstance(DateFormat.LONG).format(peertube.getPublishedAt());
|
||||||
info_published_at.setText(format);
|
info_published_at.setText(format);
|
||||||
List<String> tags = peertube.getTags();
|
List<String> tags = peertube.getTags();
|
||||||
@ -1108,6 +1223,36 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
changeColor();
|
changeColor();
|
||||||
initResolution();
|
initResolution();
|
||||||
|
|
||||||
|
binding.peertubeReblog.setOnClickListener(v -> {
|
||||||
|
if (status != null) {
|
||||||
|
MastodonPostActionsVM mastodonPostActionsVM = new ViewModelProvider(PeertubeActivity.this).get(MastodonPostActionsVM.class);
|
||||||
|
RetrofitMastodonAPI.actionType type = status.isReblogged() ? RetrofitMastodonAPI.actionType.UNBOOST : RetrofitMastodonAPI.actionType.BOOST;
|
||||||
|
mastodonPostActionsVM.post(type, status).observe(PeertubeActivity.this, this::manageVIewPostActionsMastodon);
|
||||||
|
} else {
|
||||||
|
Toasty.error(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
binding.peertubeFavorite.setOnClickListener(v -> {
|
||||||
|
if (status != null) {
|
||||||
|
MastodonPostActionsVM mastodonPostActionsVM = new ViewModelProvider(PeertubeActivity.this).get(MastodonPostActionsVM.class);
|
||||||
|
RetrofitMastodonAPI.actionType type = status.isFavourited() ? RetrofitMastodonAPI.actionType.UNFAVOURITE : RetrofitMastodonAPI.actionType.FAVOURITE;
|
||||||
|
mastodonPostActionsVM.post(type, status).observe(PeertubeActivity.this, this::manageVIewPostActionsMastodon);
|
||||||
|
} else {
|
||||||
|
Toasty.error(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
binding.peertubeBookmark.setOnClickListener(v -> {
|
||||||
|
if (status != null) {
|
||||||
|
MastodonPostActionsVM mastodonPostActionsVM = new ViewModelProvider(PeertubeActivity.this).get(MastodonPostActionsVM.class);
|
||||||
|
RetrofitMastodonAPI.actionType type = status.isBookmarked() ? RetrofitMastodonAPI.actionType.UNBOOKMARK : RetrofitMastodonAPI.actionType.BOOKMARK;
|
||||||
|
mastodonPostActionsVM.post(type, status).observe(PeertubeActivity.this, this::manageVIewPostActionsMastodon);
|
||||||
|
} else {
|
||||||
|
Toasty.error(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
binding.peertubeLikeCount.setOnClickListener(v -> {
|
binding.peertubeLikeCount.setOnClickListener(v -> {
|
||||||
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
||||||
String newState = peertube.getMyRating().equals("like") ? "none" : "like";
|
String newState = peertube.getMyRating().equals("like") ? "none" : "like";
|
||||||
@ -1159,6 +1304,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (BuildConfig.allow_remote_connections && Helper.isLoggedInType(PeertubeActivity.this) == MainActivity.TypeOfConnection.REMOTE_ACCOUNT) {
|
||||||
|
String url = "https://" + peertube.getChannel().getHost() + "/videos/watch/" + peertube.getUuid();
|
||||||
|
MastodonPostActionsVM postActionsVM = new ViewModelProvider(PeertubeActivity.this).get(MastodonPostActionsVM.class);
|
||||||
|
postActionsVM.searchRemoteStatus(url).observe(PeertubeActivity.this, this::retrieveRemoteStatus);
|
||||||
|
}
|
||||||
|
|
||||||
if (mode != Helper.VIDEO_MODE_WEBVIEW) {
|
if (mode != Helper.VIDEO_MODE_WEBVIEW) {
|
||||||
|
|
||||||
@ -1169,8 +1319,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
binding.doubleTapPlayerView.setPlayer(player);
|
binding.doubleTapPlayerView.setPlayer(player);
|
||||||
binding.loader.setVisibility(View.GONE);
|
binding.loader.setVisibility(View.GONE);
|
||||||
startStream(
|
startStream(
|
||||||
apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this),
|
apiResponse.getPeertubes().get(0),
|
||||||
apiResponse.getPeertubes().get(0).getStreamingPlaylists().size() > 0 ? apiResponse.getPeertubes().get(0).getStreamingPlaylists().get(0).getPlaylistUrl() : null,
|
null,
|
||||||
|
null,
|
||||||
autoPlay, position, null, null, true);
|
autoPlay, position, null, null, true);
|
||||||
player.prepare();
|
player.prepare();
|
||||||
player.setPlayWhenReady(autoPlay);
|
player.setPlayWhenReady(autoPlay);
|
||||||
@ -1258,53 +1409,85 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
private void stream(String videoURL, String streamingPlaylistsURLS, boolean autoPlay, long position, Uri subtitles, String lang) {
|
* Manage video to play with different factors
|
||||||
if (videoURL != null && !videoURL.endsWith("m3u8")) {
|
*
|
||||||
if (videoURL.endsWith(".torrent")) {
|
* @param video VideoData.Video
|
||||||
torrentStream.startStream(videoURL);
|
* @param localTorrentUrl String if not null that will be used
|
||||||
return;
|
* @param resolution String the current resolution asked
|
||||||
} else {
|
* @param autoPlay boolean
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
* @param position int current position
|
||||||
int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB);
|
* @param subtitles Uri uri for subtitles
|
||||||
ProgressiveMediaSource videoSource;
|
* @param lang String ("en","fr", etc.)
|
||||||
SingleSampleMediaSource subtitleSource = null;
|
*/
|
||||||
if (video_cache == 0) {
|
private void stream(VideoData.Video video, String localTorrentUrl, String resolution, boolean autoPlay, long position, Uri subtitles, String lang) {
|
||||||
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
|
String videoURL = localTorrentUrl == null ? video.getFileUrl(resolution, PeertubeActivity.this) : localTorrentUrl;
|
||||||
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
|
int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB);
|
||||||
|
if (videoURL != null && (videoURL.endsWith(".torrent") || videoURL.startsWith("magnet"))) {
|
||||||
|
torrentStream.startStream(videoURL);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
ProgressiveMediaSource videoSource = null;
|
||||||
|
HlsMediaSource hlsMediaSource = null;
|
||||||
|
SingleSampleMediaSource subtitleSource = null;
|
||||||
|
DataSource.Factory dataSourceFactory = null;
|
||||||
|
if (localTorrentUrl != null) {
|
||||||
|
DataSpec dataSpec = new DataSpec(Uri.fromFile(new java.io.File(localTorrentUrl)));
|
||||||
|
FileDataSource fileDataSource = new FileDataSource();
|
||||||
|
try {
|
||||||
|
fileDataSource.open(dataSpec);
|
||||||
|
dataSourceFactory = () -> fileDataSource;
|
||||||
|
} catch (FileDataSource.FileDataSourceException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (video_cache == 0 || dataSourceFactory != null) {
|
||||||
|
if (dataSourceFactory == null) {
|
||||||
|
dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
|
||||||
Util.getUserAgent(PeertubeActivity.this, null), null);
|
Util.getUserAgent(PeertubeActivity.this, null), null);
|
||||||
|
}
|
||||||
|
|
||||||
if (subtitles != null) {
|
if (subtitles != null) {
|
||||||
MediaItem.Subtitle mediaSubtitle = new MediaItem.Subtitle(subtitles, MimeTypes.TEXT_VTT, lang);
|
MediaItem.Subtitle mediaSubtitle = new MediaItem.Subtitle(subtitles, MimeTypes.TEXT_VTT, lang);
|
||||||
subtitleSource = new SingleSampleMediaSource.Factory(dataSourceFactory).createMediaSource(mediaSubtitle, C.TIME_UNSET);
|
subtitleSource = new SingleSampleMediaSource.Factory(dataSourceFactory).createMediaSource(mediaSubtitle, C.TIME_UNSET);
|
||||||
}
|
}
|
||||||
MediaItem mediaItem = new MediaItem.Builder().setUri(videoURL).build();
|
MediaItem mediaItem = new MediaItem.Builder().setUri(Uri.parse(videoURL)).build();
|
||||||
|
if (videoURL != null && !videoURL.endsWith("m3u8")) {
|
||||||
videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItem);
|
videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(mediaItem);
|
||||||
} else {
|
} else {
|
||||||
CacheDataSourceFactory cacheDataSourceFactory = new CacheDataSourceFactory(PeertubeActivity.this);
|
hlsMediaSource = new HlsMediaSource.Factory(dataSourceFactory)
|
||||||
MediaItem mediaItem = new MediaItem.Builder().setUri(videoURL).build();
|
|
||||||
videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory)
|
|
||||||
.createMediaSource(mediaItem);
|
.createMediaSource(mediaItem);
|
||||||
if (subtitles != null) {
|
|
||||||
MediaItem.Subtitle mediaSubtitle = new MediaItem.Subtitle(subtitles, MimeTypes.TEXT_VTT, lang, Format.NO_VALUE);
|
|
||||||
subtitleSource = new SingleSampleMediaSource.Factory(cacheDataSourceFactory).createMediaSource(mediaSubtitle, C.TIME_UNSET);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (lang != null && subtitleSource != null) {
|
} else {
|
||||||
MergingMediaSource mergedSource =
|
CacheDataSourceFactory cacheDataSourceFactory = new CacheDataSourceFactory(PeertubeActivity.this);
|
||||||
new MergingMediaSource(videoSource, subtitleSource);
|
MediaItem mediaItem = new MediaItem.Builder().setUri(videoURL).build();
|
||||||
player.setMediaSource(mergedSource);
|
videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory)
|
||||||
|
.createMediaSource(mediaItem);
|
||||||
|
if (subtitles != null) {
|
||||||
|
MediaItem.Subtitle mediaSubtitle = new MediaItem.Subtitle(subtitles, MimeTypes.TEXT_VTT, lang, Format.NO_VALUE);
|
||||||
|
subtitleSource = new SingleSampleMediaSource.Factory(cacheDataSourceFactory).createMediaSource(mediaSubtitle, C.TIME_UNSET);
|
||||||
|
}
|
||||||
|
if (videoURL != null && !videoURL.endsWith("m3u8")) {
|
||||||
|
videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory).createMediaSource(mediaItem);
|
||||||
} else {
|
} else {
|
||||||
player.setMediaSource(videoSource);
|
hlsMediaSource = new HlsMediaSource.Factory(cacheDataSourceFactory)
|
||||||
|
.createMediaSource(mediaItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
if (lang != null && subtitleSource != null && videoSource != null) {
|
||||||
if (streamingPlaylistsURLS == null && videoURL != null) {
|
MergingMediaSource mergedSource =
|
||||||
streamingPlaylistsURLS = videoURL;
|
new MergingMediaSource(videoSource, subtitleSource);
|
||||||
|
player.setMediaSource(mergedSource);
|
||||||
|
} else if (lang != null && subtitleSource != null) {
|
||||||
|
MergingMediaSource mergedSource =
|
||||||
|
new MergingMediaSource(hlsMediaSource, subtitleSource);
|
||||||
|
player.setMediaSource(mergedSource);
|
||||||
|
} else if (videoSource != null) {
|
||||||
|
player.setMediaSource(videoSource);
|
||||||
|
} else {
|
||||||
|
player.setMediaSource(hlsMediaSource);
|
||||||
}
|
}
|
||||||
MediaItem mediaItem = new MediaItem.Builder().setUri(Uri.parse(streamingPlaylistsURLS)).build();
|
|
||||||
HlsMediaSource hlsMediaSource = new HlsMediaSource.Factory(new DefaultHttpDataSourceFactory(System.getProperty("http.agent")))
|
|
||||||
.createMediaSource(mediaItem);
|
|
||||||
player.setMediaSource(hlsMediaSource);
|
|
||||||
}
|
}
|
||||||
player.prepare();
|
player.prepare();
|
||||||
if (position > 0) {
|
if (position > 0) {
|
||||||
@ -1318,14 +1501,14 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
private void fetchComments() {
|
private void fetchComments() {
|
||||||
if (peertube.isCommentsEnabled()) {
|
if (peertube.isCommentsEnabled()) {
|
||||||
if (Helper.isLoggedIn(PeertubeActivity.this)) {
|
if (Helper.canMakeAction(PeertubeActivity.this)) {
|
||||||
binding.postCommentButton.setVisibility(View.VISIBLE);
|
binding.postCommentButton.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
binding.postCommentButton.setVisibility(View.GONE);
|
binding.postCommentButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||||
commentViewModel.getThread(sepiaSearch ? peertubeInstance : null, videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
commentViewModel.getThread(sepiaSearch ? peertubeInstance : null, videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
||||||
if (Helper.isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
if (Helper.canMakeAction(PeertubeActivity.this) && !sepiaSearch) {
|
||||||
binding.writeCommentContainer.setVisibility(View.VISIBLE);
|
binding.writeCommentContainer.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
binding.peertubeComments.setVisibility(View.VISIBLE);
|
binding.peertubeComments.setVisibility(View.VISIBLE);
|
||||||
@ -1340,8 +1523,21 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startStream(String videoURL, String streamingPlaylistsURLS, boolean autoPlay, long position, Uri subtitles, String lang, boolean promptNSFW) {
|
private void startStream(VideoData.Video video, String torrentLocal, String resolution, boolean autoPlay, long position, Uri subtitles, String lang, boolean promptNSFW) {
|
||||||
|
|
||||||
|
String videoURL;
|
||||||
|
if (torrentLocal != null) {
|
||||||
|
videoURL = torrentLocal;
|
||||||
|
} else {
|
||||||
|
videoURL = peertube.getFileUrl(resolution, PeertubeActivity.this);
|
||||||
|
}
|
||||||
|
if (peertube != null && peertube.isWaitTranscoding() && peertube.isLive()) {
|
||||||
|
View parentLayout = findViewById(android.R.id.content);
|
||||||
|
Snackbar snackbar = Snackbar.make(parentLayout, R.string.live_not_started, Snackbar.LENGTH_INDEFINITE);
|
||||||
|
snackbar.setAction(R.string.close, view -> finish());
|
||||||
|
snackbar.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
chromeCastVideoURL = videoURL;
|
chromeCastVideoURL = videoURL;
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
String nsfwAction = sharedpreferences.getString(getString(R.string.set_video_sensitive_choice), Helper.BLUR);
|
String nsfwAction = sharedpreferences.getString(getString(R.string.set_video_sensitive_choice), Helper.BLUR);
|
||||||
@ -1357,13 +1553,13 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
finish();
|
finish();
|
||||||
});
|
});
|
||||||
dialogBuilder.setPositiveButton(R.string.play, (dialog, id) -> {
|
dialogBuilder.setPositiveButton(R.string.play, (dialog, id) -> {
|
||||||
stream(videoURL, streamingPlaylistsURLS, autoPlay, position, subtitles, lang);
|
stream(video, null, resolution, autoPlay, position, subtitles, lang);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
alertDialog = dialogBuilder.create();
|
alertDialog = dialogBuilder.create();
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
} else {
|
} else {
|
||||||
stream(videoURL, streamingPlaylistsURLS, autoPlay, position, subtitles, lang);
|
stream(video, torrentLocal, resolution, autoPlay, position, subtitles, lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1383,7 +1579,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
|
||||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||||
0,
|
0,
|
||||||
3.0f
|
4.0f
|
||||||
);
|
);
|
||||||
binding.videoContainer.setLayoutParams(param);
|
binding.videoContainer.setLayoutParams(param);
|
||||||
}
|
}
|
||||||
@ -1591,6 +1787,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
@Override
|
@Override
|
||||||
public void onAnimationStart(Animation animation) {
|
public void onAnimationStart(Animation animation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animation animation) {
|
public void onAnimationEnd(Animation animation) {
|
||||||
binding.peertubeInformationContainer.setVisibility(View.GONE);
|
binding.peertubeInformationContainer.setVisibility(View.GONE);
|
||||||
@ -1743,8 +1940,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
binding.doubleTapPlayerView.setPlayer(player);
|
binding.doubleTapPlayerView.setPlayer(player);
|
||||||
binding.loader.setVisibility(View.GONE);
|
binding.loader.setVisibility(View.GONE);
|
||||||
startStream(
|
startStream(
|
||||||
peertube.getFileUrl(res, PeertubeActivity.this),
|
peertube,
|
||||||
peertube.getStreamingPlaylists().size() > 0 ? peertube.getStreamingPlaylists().get(0).getPlaylistUrl() : null,
|
null,
|
||||||
|
res,
|
||||||
true, position, null, null, false);
|
true, position, null, null, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1783,7 +1981,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
binding.mediaVideo.player(player);
|
binding.mediaVideo.player(player);
|
||||||
binding.doubleTapPlayerView.setPlayer(player);
|
binding.doubleTapPlayerView.setPlayer(player);
|
||||||
startStream(
|
startStream(
|
||||||
peertube.getFileUrl(null, PeertubeActivity.this),
|
peertube,
|
||||||
|
null,
|
||||||
null,
|
null,
|
||||||
true,
|
true,
|
||||||
newPosition,
|
newPosition,
|
||||||
@ -1842,7 +2041,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void closeSubMenuMenuOptions() {
|
public void closeSubMenuMenuOptions() {
|
||||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||||
@ -1872,19 +2070,30 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
|
|
||||||
private void sendComment(Comment comment, int position) {
|
private void sendComment(Comment comment, int position) {
|
||||||
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
if (canMakeAction(PeertubeActivity.this) && !sepiaSearch) {
|
||||||
if (comment == null) {
|
if (comment == null) {
|
||||||
String commentStr = binding.addCommentWrite.getText() != null ? binding.addCommentWrite.getText().toString() : "";
|
String commentStr = binding.addCommentWrite.getText() != null ? binding.addCommentWrite.getText().toString() : "";
|
||||||
if (commentStr.trim().length() > 0) {
|
if (commentStr.trim().length() > 0) {
|
||||||
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
if (Helper.isLoggedIn(PeertubeActivity.this)) {
|
||||||
viewModelComment.comment(ADD_COMMENT, peertube.getId(), null, commentStr).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(ADD_COMMENT, 0, apiResponse1));
|
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
||||||
|
viewModelComment.comment(ADD_COMMENT, peertube.getId(), null, commentStr).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(ADD_COMMENT, 0, apiResponse1));
|
||||||
|
} else {//Remote account is posting a message
|
||||||
|
String url = "https://" + peertube.getChannel().getHost() + "/videos/watch/" + peertube.getUuid();
|
||||||
|
MastodonPostActionsVM viewModelCommentMastodon = new ViewModelProvider(PeertubeActivity.this).get(MastodonPostActionsVM.class);
|
||||||
|
viewModelCommentMastodon.comment(url, commentStr).observe(PeertubeActivity.this, status -> manageVIewPostActionsMastodon(ADD_COMMENT, position, status));
|
||||||
|
}
|
||||||
binding.addCommentWrite.setText("");
|
binding.addCommentWrite.setText("");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String commentView = binding.addCommentWrite.getText() != null ? binding.addCommentWrite.getText().toString() : "";
|
String commentView = binding.addCommentWrite.getText() != null ? binding.addCommentWrite.getText().toString() : "";
|
||||||
if (commentView.trim().length() > 0) {
|
if (commentView.trim().length() > 0) {
|
||||||
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
if (Helper.isLoggedIn(PeertubeActivity.this)) {
|
||||||
viewModelComment.comment(REPLY, peertube.getId(), comment.getId(), commentView).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(REPLY, position, apiResponse1));
|
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
||||||
|
viewModelComment.comment(REPLY, peertube.getId(), comment.getId(), commentView).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(REPLY, position, apiResponse1));
|
||||||
|
} else {//Remote account is posting a message
|
||||||
|
MastodonPostActionsVM viewModelCommentMastodon = new ViewModelProvider(PeertubeActivity.this).get(MastodonPostActionsVM.class);
|
||||||
|
viewModelCommentMastodon.comment(comment.getUrl(), commentView).observe(PeertubeActivity.this, status -> manageVIewPostActionsMastodon(REPLY, position, status));
|
||||||
|
}
|
||||||
binding.addCommentWrite.setText("");
|
binding.addCommentWrite.setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1924,6 +2133,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
binding.replyThread.startAnimation(animate);
|
binding.replyThread.startAnimation(animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void openPostComment(Comment comment, int position) {
|
public void openPostComment(Comment comment, int position) {
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
binding.replyContent.setVisibility(View.VISIBLE);
|
binding.replyContent.setVisibility(View.VISIBLE);
|
||||||
@ -1974,8 +2184,10 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
binding.postComment.startAnimation(animateComment);
|
binding.postComment.startAnimation(animateComment);
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
binding.addCommentWrite.setText(String.format("@%s ", comment.getAccount().getAcct()));
|
binding.addCommentWrite.setText(String.format("@%s ", comment.getAccount().getAcct()));
|
||||||
binding.addCommentWrite.setSelection(binding.addCommentWrite.getText() != null ? binding.addCommentWrite.getText().length() : 0);
|
} else {
|
||||||
|
binding.addCommentWrite.setText(String.format("@%s ", peertube.getAccount().getAcct()));
|
||||||
}
|
}
|
||||||
|
binding.addCommentWrite.setSelection(binding.addCommentWrite.getText() != null ? binding.addCommentWrite.getText().length() : 0);
|
||||||
|
|
||||||
binding.send.setOnClickListener(null);
|
binding.send.setOnClickListener(null);
|
||||||
binding.send.setOnClickListener(v -> sendComment(comment, position));
|
binding.send.setOnClickListener(v -> sendComment(comment, position));
|
||||||
@ -2010,6 +2222,45 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
binding.postComment.startAnimation(animateComment);
|
binding.postComment.startAnimation(animateComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void manageVIewPostActionsMastodon(app.fedilab.fedilabtube.client.mastodon.Status status) {
|
||||||
|
if (status != null) {
|
||||||
|
this.status = status;
|
||||||
|
changeColorMastodon();
|
||||||
|
binding.peertubeFavorite.setText(String.valueOf(status.getFavouriteCount()));
|
||||||
|
binding.peertubeReblog.setText(String.valueOf(status.getReblogsCount()));
|
||||||
|
} else {
|
||||||
|
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toasty.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void manageVIewPostActionsMastodon(RetrofitPeertubeAPI.ActionType statusAction, int position, app.fedilab.fedilabtube.client.mastodon.Status status) {
|
||||||
|
if (peertube.isCommentsEnabled() && statusAction == ADD_COMMENT) {
|
||||||
|
if (status != null) {
|
||||||
|
Comment comment = app.fedilab.fedilabtube.client.mastodon.Status.convertStatusToComment(status);
|
||||||
|
comments.add(0, comment);
|
||||||
|
commentListAdapter.notifyItemInserted(0);
|
||||||
|
}
|
||||||
|
} else if (peertube.isCommentsEnabled() && statusAction == REPLY) {
|
||||||
|
if (status != null) {
|
||||||
|
Comment comment = app.fedilab.fedilabtube.client.mastodon.Status.convertStatusToComment(status);
|
||||||
|
if (commentsThread == null) {
|
||||||
|
commentsThread = new ArrayList<>();
|
||||||
|
}
|
||||||
|
commentsThread.add(position + 1, comment);
|
||||||
|
commentReplyListAdapter.notifyItemInserted(position + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void retrieveRemoteStatus(app.fedilab.fedilabtube.client.mastodon.Status status) {
|
||||||
|
this.status = status;
|
||||||
|
if (status != null) {
|
||||||
|
changeColorMastodon();
|
||||||
|
binding.peertubeFavorite.setText(String.valueOf(status.getFavouriteCount()));
|
||||||
|
binding.peertubeReblog.setText(String.valueOf(status.getReblogsCount()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "RedundantSuppression"})
|
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||||
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int position, APIResponse apiResponse) {
|
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int position, APIResponse apiResponse) {
|
||||||
|
|
||||||
@ -2020,8 +2271,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
}
|
}
|
||||||
} else if (peertube.isCommentsEnabled() && statusAction == REPLY) {
|
} else if (peertube.isCommentsEnabled() && statusAction == REPLY) {
|
||||||
if (apiResponse.getComments() != null && apiResponse.getComments().size() > 0) {
|
if (apiResponse.getComments() != null && apiResponse.getComments().size() > 0) {
|
||||||
commentsThread.add(position, apiResponse.getComments().get(0));
|
commentsThread.add(position + 1, apiResponse.getComments().get(0));
|
||||||
commentReplyListAdapter.notifyItemInserted(position);
|
commentReplyListAdapter.notifyItemInserted(position + 1);
|
||||||
}
|
}
|
||||||
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT) {
|
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT) {
|
||||||
Toasty.success(PeertubeActivity.this, getString(R.string.successful_report), Toasty.LENGTH_LONG).show();
|
Toasty.success(PeertubeActivity.this, getString(R.string.successful_report), Toasty.LENGTH_LONG).show();
|
||||||
@ -2063,6 +2314,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
openMainMenuOptions();
|
openMainMenuOptions();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRequestedOrientationCustom(int orientationCustom) {
|
private void setRequestedOrientationCustom(int orientationCustom) {
|
||||||
@ -2086,6 +2338,47 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void changeColorMastodon() {
|
||||||
|
Drawable reblog = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_baseline_repeat_24);
|
||||||
|
Drawable favorite = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_baseline_star_24);
|
||||||
|
Drawable bookmark = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_baseline_bookmark_24);
|
||||||
|
|
||||||
|
int color = getAttColor(this, android.R.attr.colorControlNormal);
|
||||||
|
|
||||||
|
if (reblog != null) {
|
||||||
|
reblog.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||||
|
DrawableCompat.setTint(reblog, color);
|
||||||
|
}
|
||||||
|
if (favorite != null) {
|
||||||
|
favorite.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||||
|
DrawableCompat.setTint(favorite, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bookmark != null) {
|
||||||
|
bookmark.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||||
|
DrawableCompat.setTint(bookmark, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status.isReblogged()) {
|
||||||
|
reblog.setColorFilter(getResources().getColor(R.color.positive_thumbs), PorterDuff.Mode.SRC_ATOP);
|
||||||
|
DrawableCompat.setTint(reblog, getResources().getColor(R.color.positive_thumbs));
|
||||||
|
}
|
||||||
|
if (status.isFavourited()) {
|
||||||
|
favorite.setColorFilter(getResources().getColor(R.color.favorite), PorterDuff.Mode.SRC_ATOP);
|
||||||
|
DrawableCompat.setTint(favorite, getResources().getColor(R.color.favorite));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status.isBookmarked()) {
|
||||||
|
bookmark.setColorFilter(getResources().getColor(R.color.bookmark), PorterDuff.Mode.SRC_ATOP);
|
||||||
|
DrawableCompat.setTint(bookmark, getResources().getColor(R.color.bookmark));
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.peertubeReblog.setCompoundDrawablesWithIntrinsicBounds(null, reblog, null, null);
|
||||||
|
binding.peertubeFavorite.setCompoundDrawablesWithIntrinsicBounds(null, favorite, null, null);
|
||||||
|
binding.peertubeBookmark.setCompoundDrawablesWithIntrinsicBounds(null, bookmark, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
private void changeColor() {
|
private void changeColor() {
|
||||||
|
|
||||||
Drawable thumbUp = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_baseline_thumb_up_alt_24);
|
Drawable thumbUp = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_baseline_thumb_up_alt_24);
|
||||||
@ -2272,8 +2565,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum videoOrientation {
|
enum videoOrientation {
|
||||||
LANDSCAPE,
|
LANDSCAPE,
|
||||||
PORTRAIT
|
PORTRAIT
|
||||||
|
@ -455,6 +455,10 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
videoParams.setChannelId(channelToSendId);
|
videoParams.setChannelId(channelToSendId);
|
||||||
videoParams.setPrivacy(finalPrivacyToSend.getId());
|
videoParams.setPrivacy(finalPrivacyToSend.getId());
|
||||||
List<String> tags = binding.pVideoTags.getTags();
|
List<String> tags = binding.pVideoTags.getTags();
|
||||||
|
if (tags.size() > 5) {
|
||||||
|
Toasty.error(PeertubeEditUploadActivity.this, getString(R.string.max_tag_size), Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
videoParams.setTags(tags);
|
videoParams.setTags(tags);
|
||||||
binding.setUploadSubmit.setEnabled(false);
|
binding.setUploadSubmit.setEnabled(false);
|
||||||
MyVideoVM myVideoVM = new ViewModelProvider(PeertubeEditUploadActivity.this).get(MyVideoVM.class);
|
MyVideoVM myVideoVM = new ViewModelProvider(PeertubeEditUploadActivity.this).get(MyVideoVM.class);
|
||||||
|
@ -163,8 +163,7 @@ public class PeertubeRegisterActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
String host = emailArray[1];
|
instance = HelperInstance.getLiveInstance(PeertubeRegisterActivity.this);
|
||||||
instance = HelperInstance.getPeertubeUrl(host);
|
|
||||||
}
|
}
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
instance = instance.toLowerCase().trim();
|
instance = instance.toLowerCase().trim();
|
||||||
|
@ -37,7 +37,6 @@ import androidx.core.content.ContextCompat;
|
|||||||
import androidx.documentfile.provider.DocumentFile;
|
import androidx.documentfile.provider.DocumentFile;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
|
||||||
import net.gotev.uploadservice.data.UploadNotificationAction;
|
import net.gotev.uploadservice.data.UploadNotificationAction;
|
||||||
import net.gotev.uploadservice.data.UploadNotificationConfig;
|
import net.gotev.uploadservice.data.UploadNotificationConfig;
|
||||||
import net.gotev.uploadservice.data.UploadNotificationStatusConfig;
|
import net.gotev.uploadservice.data.UploadNotificationStatusConfig;
|
||||||
@ -322,7 +321,7 @@ public class PeertubeUploadActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
String token = Helper.getToken(PeertubeUploadActivity.this);
|
||||||
|
|
||||||
new MultipartUploadRequest(PeertubeUploadActivity.this, "https://" + HelperInstance.getLiveInstance(PeertubeUploadActivity.this) + "/api/v1/videos/upload")
|
new MultipartUploadRequest(PeertubeUploadActivity.this, "https://" + HelperInstance.getLiveInstance(PeertubeUploadActivity.this) + "/api/v1/videos/upload")
|
||||||
.setMethod("POST")
|
.setMethod("POST")
|
||||||
|
@ -160,16 +160,14 @@ public class ShowChannelActivity extends AppCompatActivity {
|
|||||||
if (accounts != null && accounts.size() > 0) {
|
if (accounts != null && accounts.size() > 0) {
|
||||||
if (accounts.size() > 1) {
|
if (accounts.size() > 1) {
|
||||||
final OwnAccountsAdapter accountsListAdapter = new OwnAccountsAdapter(ShowChannelActivity.this, accounts);
|
final OwnAccountsAdapter accountsListAdapter = new OwnAccountsAdapter(ShowChannelActivity.this, accounts);
|
||||||
builderSingle.setAdapter(accountsListAdapter, (dialog, which) -> {
|
builderSingle.setAdapter(accountsListAdapter, (dialog, which) -> new Thread(() -> {
|
||||||
new Thread(() -> {
|
try {
|
||||||
try {
|
RetrofitPeertubeAPI peertubeAPI = new RetrofitPeertubeAPI(ShowChannelActivity.this, accounts.get(which).getHost(), accounts.get(which).getToken());
|
||||||
RetrofitPeertubeAPI peertubeAPI = new RetrofitPeertubeAPI(ShowChannelActivity.this, accounts.get(which).getHost(), accounts.get(which).getToken());
|
peertubeAPI.post(FOLLOW, channel.getAcct(), null);
|
||||||
peertubeAPI.post(FOLLOW, channel.getAcct(), null);
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
}).start());
|
||||||
}).start();
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
RetrofitPeertubeAPI peertubeAPI = new RetrofitPeertubeAPI(ShowChannelActivity.this, accounts.get(0).getHost(), accounts.get(0).getToken());
|
RetrofitPeertubeAPI peertubeAPI = new RetrofitPeertubeAPI(ShowChannelActivity.this, accounts.get(0).getHost(), accounts.get(0).getToken());
|
||||||
peertubeAPI.post(FOLLOW, channel.getAcct(), null);
|
peertubeAPI.post(FOLLOW, channel.getAcct(), null);
|
||||||
@ -362,7 +360,11 @@ public class ShowChannelActivity extends AppCompatActivity {
|
|||||||
public void manageVIewRelationship(APIResponse apiResponse) {
|
public void manageVIewRelationship(APIResponse apiResponse) {
|
||||||
|
|
||||||
if (apiResponse.getError() != null) {
|
if (apiResponse.getError() != null) {
|
||||||
Toasty.error(ShowChannelActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
if (apiResponse.getError().getError().length() > 500) {
|
||||||
|
Toasty.info(ShowChannelActivity.this, getString(R.string.remote_account), Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
Toasty.error(ShowChannelActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.relationship = apiResponse.getRelationships();
|
this.relationship = apiResponse.getRelationships();
|
||||||
|
@ -19,6 +19,7 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.webkit.CookieManager;
|
import android.webkit.CookieManager;
|
||||||
import android.webkit.CookieSyncManager;
|
import android.webkit.CookieSyncManager;
|
||||||
import android.webkit.WebChromeClient;
|
import android.webkit.WebChromeClient;
|
||||||
@ -91,7 +92,9 @@ public class WebviewConnectActivity extends AppCompatActivity {
|
|||||||
} else {
|
} else {
|
||||||
CookieManager.getInstance().setAcceptCookie(true);
|
CookieManager.getInstance().setAcceptCookie(true);
|
||||||
}
|
}
|
||||||
|
if (getSupportActionBar() != null)
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
setTitle(R.string.login);
|
||||||
|
|
||||||
final ProgressBar pbar = findViewById(R.id.progress_bar);
|
final ProgressBar pbar = findViewById(R.id.progress_bar);
|
||||||
webView.setWebChromeClient(new WebChromeClient() {
|
webView.setWebChromeClient(new WebChromeClient() {
|
||||||
@ -122,8 +125,11 @@ public class WebviewConnectActivity extends AppCompatActivity {
|
|||||||
oauthParams.setClient_id(sharedpreferences.getString(Helper.CLIENT_ID, null));
|
oauthParams.setClient_id(sharedpreferences.getString(Helper.CLIENT_ID, null));
|
||||||
oauthParams.setClient_secret(sharedpreferences.getString(Helper.CLIENT_SECRET, null));
|
oauthParams.setClient_secret(sharedpreferences.getString(Helper.CLIENT_SECRET, null));
|
||||||
oauthParams.setGrant_type("password");
|
oauthParams.setGrant_type("password");
|
||||||
|
oauthParams.setScope("upload");
|
||||||
|
oauthParams.setResponse_type("code");
|
||||||
oauthParams.setUsername(username);
|
oauthParams.setUsername(username);
|
||||||
oauthParams.setExternalAuthToken(externalAuthToken);
|
oauthParams.setExternalAuthToken(externalAuthToken);
|
||||||
|
oauthParams.setPassword(externalAuthToken);
|
||||||
String instance = new URL(url).getHost();
|
String instance = new URL(url).getHost();
|
||||||
Token token = null;
|
Token token = null;
|
||||||
try {
|
try {
|
||||||
@ -134,9 +140,11 @@ public class WebviewConnectActivity extends AppCompatActivity {
|
|||||||
if (token != null) {
|
if (token != null) {
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token.getAccess_token());
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token.getAccess_token());
|
||||||
|
editor.putString(Helper.PREF_SOFTWARE, null);
|
||||||
|
editor.putString(Helper.PREF_REMOTE_INSTANCE, null);
|
||||||
editor.putString(Helper.PREF_INSTANCE, instance);
|
editor.putString(Helper.PREF_INSTANCE, instance);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
updateCredential(WebviewConnectActivity.this, token.getAccess_token(), clientId, clientSecret, token.getRefresh_token(), new URL(url).getHost());
|
updateCredential(WebviewConnectActivity.this, token.getAccess_token(), clientId, clientSecret, token.getRefresh_token(), new URL(url).getHost(), null);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -151,6 +159,17 @@ public class WebviewConnectActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
int itemId = item.getItemId();
|
||||||
|
if (itemId == android.R.id.home) {
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (webView != null && webView.canGoBack()) {
|
if (webView != null && webView.canGoBack()) {
|
||||||
|
@ -25,6 +25,7 @@ import app.fedilab.fedilabtube.client.data.CommentData;
|
|||||||
import app.fedilab.fedilabtube.client.data.InstanceData;
|
import app.fedilab.fedilabtube.client.data.InstanceData;
|
||||||
import app.fedilab.fedilabtube.client.data.NotificationData;
|
import app.fedilab.fedilabtube.client.data.NotificationData;
|
||||||
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
||||||
|
import app.fedilab.fedilabtube.client.data.PluginData;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoPlaylistData;
|
import app.fedilab.fedilabtube.client.data.VideoPlaylistData;
|
||||||
import app.fedilab.fedilabtube.client.entities.CaptionsParams;
|
import app.fedilab.fedilabtube.client.entities.CaptionsParams;
|
||||||
@ -70,6 +71,9 @@ public interface PeertubeService {
|
|||||||
@GET(".well-known/nodeinfo")
|
@GET(".well-known/nodeinfo")
|
||||||
Call<WellKnownNodeinfo> getWellKnownNodeinfo();
|
Call<WellKnownNodeinfo> getWellKnownNodeinfo();
|
||||||
|
|
||||||
|
@GET("plugins/peertube-plugin-player-watermark/public-settings")
|
||||||
|
Call<PluginData.WaterMark> waterMark();
|
||||||
|
|
||||||
//Instance info
|
//Instance info
|
||||||
@GET("config/about")
|
@GET("config/about")
|
||||||
Call<InstanceData.InstanceInfo> configAbout();
|
Call<InstanceData.InstanceInfo> configAbout();
|
||||||
@ -103,6 +107,21 @@ public interface PeertubeService {
|
|||||||
@GET("client/locales/{local}/server.json")
|
@GET("client/locales/{local}/server.json")
|
||||||
Call<Map<String, String>> getTranslations(@Path("local") String local);
|
Call<Map<String, String>> getTranslations(@Path("local") String local);
|
||||||
|
|
||||||
|
|
||||||
|
//TOKEN
|
||||||
|
//Refresh
|
||||||
|
@FormUrlEncoded
|
||||||
|
@POST("users/token")
|
||||||
|
Call<Token> createOpenIdToken(
|
||||||
|
@Field("client_id") String client_id,
|
||||||
|
@Field("client_secret") String client_secret,
|
||||||
|
@Field("response_type") String response_type,
|
||||||
|
@Field("grant_type") String grant_type,
|
||||||
|
@Field("scope") String scope,
|
||||||
|
@Field("username") String username,
|
||||||
|
@Field("password") String password,
|
||||||
|
@Field("externalAuthToken") String externalAuthToken);
|
||||||
|
|
||||||
//TOKEN
|
//TOKEN
|
||||||
//Refresh
|
//Refresh
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@ -169,27 +188,55 @@ public interface PeertubeService {
|
|||||||
//Timelines Authenticated
|
//Timelines Authenticated
|
||||||
//Subscriber timeline
|
//Subscriber timeline
|
||||||
@GET("users/me/subscriptions/videos?sort=-publishedAt")
|
@GET("users/me/subscriptions/videos?sort=-publishedAt")
|
||||||
Call<VideoData> getSubscriptionVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
Call<VideoData> getSubscriptionVideos(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Query("start") String maxId,
|
||||||
|
@Query("count") String coun,
|
||||||
|
@Query("languageOneOf") List<String> languageOneOf);
|
||||||
|
|
||||||
//Overview videos
|
//Overview videos
|
||||||
@GET("overviews/videos")
|
@GET("overviews/videos")
|
||||||
Call<OverviewVideo> getOverviewVideos(@Header("Authorization") String credentials, @Query("page") String page, @Query("languageOneOf") List<String> languageOneOf);
|
Call<OverviewVideo> getOverviewVideos(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Query("page") String page,
|
||||||
|
@Query("nsfw") String nsfw,
|
||||||
|
@Query("languageOneOf") List<String> languageOneOf);
|
||||||
|
|
||||||
//Most liked videos
|
//Most liked videos
|
||||||
@GET("videos?sort=-likes")
|
@GET("videos?sort=-likes")
|
||||||
Call<VideoData> getMostLikedVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
Call<VideoData> getMostLikedVideos(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Query("start") String maxId,
|
||||||
|
@Query("count") String count,
|
||||||
|
@Query("nsfw") String nsfw,
|
||||||
|
@Query("languageOneOf") List<String> languageOneOf);
|
||||||
|
|
||||||
//Trending videos
|
//Trending videos
|
||||||
@GET("videos?sort=-trending")
|
@GET("videos?sort=-trending")
|
||||||
Call<VideoData> getTrendingVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
Call<VideoData> getTrendingVideos(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Query("start") String maxId,
|
||||||
|
@Query("count") String count,
|
||||||
|
@Query("nsfw") String nsfw,
|
||||||
|
@Query("languageOneOf") List<String> languageOneOf);
|
||||||
|
|
||||||
//Recently added videos
|
//Recently added videos
|
||||||
@GET("videos?sort=-publishedAt")
|
@GET("videos?sort=-publishedAt")
|
||||||
Call<VideoData> getRecentlyAddedVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
Call<VideoData> getRecentlyAddedVideos(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Query("start") String maxId,
|
||||||
|
@Query("count") String count,
|
||||||
|
@Query("nsfw") String nsfw,
|
||||||
|
@Query("languageOneOf") List<String> languageOneOf);
|
||||||
|
|
||||||
//Local videos
|
//Local videos
|
||||||
@GET("videos?sort=-publishedAt&filter=local")
|
@GET("videos?sort=-publishedAt&filter=local")
|
||||||
Call<VideoData> getLocalVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List<String> languageOneOf);
|
Call<VideoData> getLocalVideos(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Query("start") String maxId,
|
||||||
|
@Query("count") String count,
|
||||||
|
@Query("nsfw") String nsfw,
|
||||||
|
@Query("languageOneOf") List<String> languageOneOf);
|
||||||
|
|
||||||
//History
|
//History
|
||||||
@GET("users/me/history/videos")
|
@GET("users/me/history/videos")
|
||||||
@ -197,6 +244,7 @@ public interface PeertubeService {
|
|||||||
@Header("Authorization") String credentials,
|
@Header("Authorization") String credentials,
|
||||||
@Query("start") String maxId,
|
@Query("start") String maxId,
|
||||||
@Query("count") String count,
|
@Query("count") String count,
|
||||||
|
@Query("nsfw") String nsfw,
|
||||||
@Query("startDate") String startDate,
|
@Query("startDate") String startDate,
|
||||||
@Query("endDate") String endDate
|
@Query("endDate") String endDate
|
||||||
);
|
);
|
||||||
@ -211,7 +259,8 @@ public interface PeertubeService {
|
|||||||
@Header("Authorization") String credentials,
|
@Header("Authorization") String credentials,
|
||||||
@Query("search") String search,
|
@Query("search") String search,
|
||||||
@Query("start") String maxId,
|
@Query("start") String maxId,
|
||||||
@Query("count") String count);
|
@Query("count") String count,
|
||||||
|
@Query("nsfw") String nsfw);
|
||||||
|
|
||||||
//Search channels
|
//Search channels
|
||||||
@GET("search/video-channels")
|
@GET("search/video-channels")
|
||||||
@ -228,7 +277,8 @@ public interface PeertubeService {
|
|||||||
@Header("Authorization") String credentials,
|
@Header("Authorization") String credentials,
|
||||||
@Query("tagsOneOf") List<String> tagsOneOf,
|
@Query("tagsOneOf") List<String> tagsOneOf,
|
||||||
@Query("start") String maxId,
|
@Query("start") String maxId,
|
||||||
@Query("count") String count);
|
@Query("count") String count,
|
||||||
|
@Query("nsfw") String nsfw);
|
||||||
|
|
||||||
//Get notifications
|
//Get notifications
|
||||||
@GET("users/me/notifications")
|
@GET("users/me/notifications")
|
||||||
@ -254,9 +304,17 @@ public interface PeertubeService {
|
|||||||
@GET("users/me/videos?sort=-publishedAt")
|
@GET("users/me/videos?sort=-publishedAt")
|
||||||
Call<VideoData> getMyVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count);
|
Call<VideoData> getMyVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count);
|
||||||
|
|
||||||
//Get my video
|
//Get user videos
|
||||||
@GET("accounts/{name}/videos?sort=-publishedAt")
|
@GET("accounts/{name}/videos?sort=-publishedAt")
|
||||||
Call<VideoData> getVideosForAccount(@Path("name") String name, @Query("start") String maxId, @Query("count") String count);
|
Call<VideoData> getVideosForAccount(
|
||||||
|
@Path("name") String name,
|
||||||
|
@Query("start") String maxId,
|
||||||
|
@Query("count") String count,
|
||||||
|
@Query("nsfw") String nsfw
|
||||||
|
);
|
||||||
|
|
||||||
|
@POST("videos/{id}/views")
|
||||||
|
Call<String> postView(@Path("id") String id);
|
||||||
|
|
||||||
@Multipart
|
@Multipart
|
||||||
@PUT("videos/{id}")
|
@PUT("videos/{id}")
|
||||||
@ -303,7 +361,11 @@ public interface PeertubeService {
|
|||||||
Call<ChannelData> getAllChannels();
|
Call<ChannelData> getAllChannels();
|
||||||
|
|
||||||
@GET("video-channels/{channelHandle}/videos")
|
@GET("video-channels/{channelHandle}/videos")
|
||||||
Call<VideoData> getChannelVideos(@Path("channelHandle") String channelHandle, @Query("start") String maxId, @Query("count") String count);
|
Call<VideoData> getChannelVideos(
|
||||||
|
@Path("channelHandle") String channelHandle,
|
||||||
|
@Query("start") String maxId,
|
||||||
|
@Query("count") String count,
|
||||||
|
@Query("nsfw") String nsfw);
|
||||||
|
|
||||||
@POST("video-channels")
|
@POST("video-channels")
|
||||||
Call<ChannelData.ChannelCreation> addChannel(@Header("Authorization") String credentials, @Body ChannelParams channelParams);
|
Call<ChannelData.ChannelCreation> addChannel(@Header("Authorization") String credentials, @Body ChannelParams channelParams);
|
||||||
|
@ -23,6 +23,7 @@ import android.net.Uri;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
|
import android.webkit.URLUtil;
|
||||||
|
|
||||||
import androidx.documentfile.provider.DocumentFile;
|
import androidx.documentfile.provider.DocumentFile;
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ import app.fedilab.fedilabtube.client.data.CommentData;
|
|||||||
import app.fedilab.fedilabtube.client.data.InstanceData;
|
import app.fedilab.fedilabtube.client.data.InstanceData;
|
||||||
import app.fedilab.fedilabtube.client.data.NotificationData;
|
import app.fedilab.fedilabtube.client.data.NotificationData;
|
||||||
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
||||||
|
import app.fedilab.fedilabtube.client.data.PluginData;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoPlaylistData;
|
import app.fedilab.fedilabtube.client.data.VideoPlaylistData;
|
||||||
import app.fedilab.fedilabtube.client.entities.AccountCreation;
|
import app.fedilab.fedilabtube.client.entities.AccountCreation;
|
||||||
@ -90,13 +92,14 @@ import retrofit2.Response;
|
|||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "RedundantSuppression"})
|
@SuppressWarnings({"unused", "RedundantSuppression", "ConstantConditions"})
|
||||||
public class RetrofitPeertubeAPI {
|
public class RetrofitPeertubeAPI {
|
||||||
|
|
||||||
private final String finalUrl;
|
private final String finalUrl;
|
||||||
private final Context _context;
|
private final Context _context;
|
||||||
private final String instance;
|
private final String instance;
|
||||||
private final String count;
|
private final String count;
|
||||||
|
private final String showNSFWVideos;
|
||||||
private String token;
|
private String token;
|
||||||
private Set<String> selection;
|
private Set<String> selection;
|
||||||
|
|
||||||
@ -106,6 +109,14 @@ public class RetrofitPeertubeAPI {
|
|||||||
finalUrl = "https://" + HelperInstance.getLiveInstance(context) + "/api/v1/";
|
finalUrl = "https://" + HelperInstance.getLiveInstance(context) + "/api/v1/";
|
||||||
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
count = String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE));
|
count = String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE));
|
||||||
|
String currentSensitive = sharedpreferences.getString(_context.getString(R.string.set_video_sensitive_choice), Helper.BLUR);
|
||||||
|
if (currentSensitive.compareTo(Helper.DO_NOT_LIST) == 0) {
|
||||||
|
showNSFWVideos = "false";
|
||||||
|
} else if (currentSensitive.compareTo(Helper.BLUR) == 0) {
|
||||||
|
showNSFWVideos = "both";
|
||||||
|
} else {
|
||||||
|
showNSFWVideos = "true";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RetrofitPeertubeAPI(Context context, String instance, String token) {
|
public RetrofitPeertubeAPI(Context context, String instance, String token) {
|
||||||
@ -115,18 +126,21 @@ public class RetrofitPeertubeAPI {
|
|||||||
finalUrl = "https://" + instance + "/api/v1/";
|
finalUrl = "https://" + instance + "/api/v1/";
|
||||||
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
count = String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE));
|
count = String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE));
|
||||||
|
String currentSensitive = sharedpreferences.getString(_context.getString(R.string.set_video_sensitive_choice), Helper.BLUR);
|
||||||
|
if (currentSensitive.compareTo(Helper.DO_NOT_LIST) == 0) {
|
||||||
|
showNSFWVideos = "false";
|
||||||
|
} else if (currentSensitive.compareTo(Helper.BLUR) == 0) {
|
||||||
|
showNSFWVideos = "both";
|
||||||
|
} else {
|
||||||
|
showNSFWVideos = "true";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void updateCredential(Activity activity, String token, String client_id, String client_secret, String refresh_token, String host) {
|
public static void updateCredential(Activity activity, String token, String client_id, String client_secret, String refresh_token, String host, String software) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
AccountData.Account account;
|
AccountData.Account account;
|
||||||
String instance;
|
String instance = host;
|
||||||
if (host.startsWith("tube") || BuildConfig.full_instances) {
|
|
||||||
instance = host;
|
|
||||||
} else {
|
|
||||||
instance = HelperInstance.getPeertubeUrl(host);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
UserMe userMe = new RetrofitPeertubeAPI(activity, instance, token).verifyCredentials();
|
UserMe userMe = new RetrofitPeertubeAPI(activity, instance, token).verifyCredentials();
|
||||||
account = userMe.getAccount();
|
account = userMe.getAccount();
|
||||||
@ -151,7 +165,8 @@ public class RetrofitPeertubeAPI {
|
|||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||||
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
||||||
if (!host.startsWith("tube")) {
|
boolean remote_account = software != null && software.toUpperCase().trim().compareTo("PEERTUBE") != 0;
|
||||||
|
if (!remote_account) {
|
||||||
editor.putString(Helper.PREF_INSTANCE, host);
|
editor.putString(Helper.PREF_INSTANCE, host);
|
||||||
}
|
}
|
||||||
editor.apply();
|
editor.apply();
|
||||||
@ -159,7 +174,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
new AccountDAO(activity, db).updateAccountCredential(account);
|
new AccountDAO(activity, db).updateAccountCredential(account);
|
||||||
else {
|
else {
|
||||||
if (account.getUsername() != null && account.getCreatedAt() != null)
|
if (account.getUsername() != null && account.getCreatedAt() != null)
|
||||||
new AccountDAO(activity, db).insertAccount(account);
|
new AccountDAO(activity, db).insertAccount(account, software);
|
||||||
}
|
}
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> {
|
Runnable myRunnable = () -> {
|
||||||
@ -187,13 +202,16 @@ public class RetrofitPeertubeAPI {
|
|||||||
.build();
|
.build();
|
||||||
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
token = Helper.getToken(_context);
|
||||||
}
|
}
|
||||||
selection = sharedpreferences.getStringSet(_context.getString(R.string.set_video_language_choice), null);
|
selection = sharedpreferences.getStringSet(_context.getString(R.string.set_video_language_choice), null);
|
||||||
return retrofit.create(PeertubeService.class);
|
return retrofit.create(PeertubeService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PeertubeService initTranslation() {
|
private PeertubeService initTranslation() {
|
||||||
|
if (!URLUtil.isValidUrl("https://" + instance)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Retrofit retrofit = new Retrofit.Builder()
|
Retrofit retrofit = new Retrofit.Builder()
|
||||||
.baseUrl("https://" + instance)
|
.baseUrl("https://" + instance)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
@ -208,7 +226,9 @@ public class RetrofitPeertubeAPI {
|
|||||||
public Token manageToken(OauthParams oauthParams) throws Error {
|
public Token manageToken(OauthParams oauthParams) throws Error {
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
Call<Token> refreshTokenCall = null;
|
Call<Token> refreshTokenCall = null;
|
||||||
if (oauthParams.getGrant_type().compareTo("password") == 0) {
|
if (oauthParams.getExternalAuthToken() != null) {
|
||||||
|
refreshTokenCall = peertubeService.createOpenIdToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getResponse_type(), oauthParams.getGrant_type(), oauthParams.getScope(), oauthParams.getUsername(), oauthParams.getPassword(), oauthParams.getExternalAuthToken());
|
||||||
|
} else if (oauthParams.getGrant_type().compareTo("password") == 0) {
|
||||||
refreshTokenCall = peertubeService.createToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getGrant_type(), oauthParams.getUsername(), oauthParams.getPassword());
|
refreshTokenCall = peertubeService.createToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getGrant_type(), oauthParams.getUsername(), oauthParams.getPassword());
|
||||||
} else if (oauthParams.getGrant_type().compareTo("refresh_token") == 0) {
|
} else if (oauthParams.getGrant_type().compareTo("refresh_token") == 0) {
|
||||||
refreshTokenCall = peertubeService.refreshToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getRefresh_token(), oauthParams.getGrant_type());
|
refreshTokenCall = peertubeService.refreshToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getRefresh_token(), oauthParams.getGrant_type());
|
||||||
@ -222,6 +242,8 @@ public class RetrofitPeertubeAPI {
|
|||||||
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, tokenReply.getAccess_token());
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, tokenReply.getAccess_token());
|
||||||
|
editor.putString(Helper.PREF_SOFTWARE, null);
|
||||||
|
editor.putString(Helper.PREF_REMOTE_INSTANCE, null);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
SQLiteDatabase db = Sqlite.getInstance(_context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(_context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
new AccountDAO(_context, db).updateAccountToken(tokenReply);
|
new AccountDAO(_context, db).updateAccountToken(tokenReply);
|
||||||
@ -245,6 +267,22 @@ public class RetrofitPeertubeAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST a view count for a video
|
||||||
|
*/
|
||||||
|
public void postView(String videoUuid) {
|
||||||
|
if (videoUuid == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PeertubeService peertubeService = init();
|
||||||
|
Call<String> postViewCall = peertubeService.postView(videoUuid);
|
||||||
|
try {
|
||||||
|
Response<String> dd = postViewCall.execute();
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve notifications
|
* Retrieve notifications
|
||||||
*
|
*
|
||||||
@ -335,7 +373,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
public APIResponse getVideosForChannel(String channelId, String max_id) {
|
public APIResponse getVideosForChannel(String channelId, String max_id) {
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
Call<VideoData> videoCall = peertubeService.getChannelVideos(channelId, max_id, count);
|
Call<VideoData> videoCall = peertubeService.getChannelVideos(channelId, max_id, count, showNSFWVideos);
|
||||||
if (videoCall != null) {
|
if (videoCall != null) {
|
||||||
try {
|
try {
|
||||||
Response<VideoData> response = videoCall.execute();
|
Response<VideoData> response = videoCall.execute();
|
||||||
@ -380,7 +418,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
public APIResponse getHistory(String max_id, String startDate, String endDate) {
|
public APIResponse getHistory(String max_id, String startDate, String endDate) {
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
Call<VideoData> videoCall = peertubeService.getHistory(getToken(), max_id, count, startDate, endDate);
|
Call<VideoData> videoCall = peertubeService.getHistory(getToken(), max_id, count, showNSFWVideos, startDate, endDate);
|
||||||
if (videoCall != null) {
|
if (videoCall != null) {
|
||||||
try {
|
try {
|
||||||
Response<VideoData> response = videoCall.execute();
|
Response<VideoData> response = videoCall.execute();
|
||||||
@ -409,29 +447,29 @@ public class RetrofitPeertubeAPI {
|
|||||||
videoCall = peertubeService.getMyVideos(getToken(), max_id, count);
|
videoCall = peertubeService.getMyVideos(getToken(), max_id, count);
|
||||||
break;
|
break;
|
||||||
case ACCOUNT_VIDEOS:
|
case ACCOUNT_VIDEOS:
|
||||||
videoCall = peertubeService.getVideosForAccount(forAccount, max_id, count);
|
videoCall = peertubeService.getVideosForAccount(forAccount, max_id, count, showNSFWVideos);
|
||||||
break;
|
break;
|
||||||
case SUBSCRIBTIONS:
|
case SUBSCRIBTIONS:
|
||||||
if (forAccount == null) {
|
if (forAccount == null) {
|
||||||
videoCall = peertubeService.getSubscriptionVideos(getToken(), max_id, count, filter);
|
videoCall = peertubeService.getSubscriptionVideos(getToken(), max_id, count, filter);
|
||||||
} else {
|
} else {
|
||||||
videoCall = peertubeService.getChannelVideos(forAccount, max_id, count);
|
videoCall = peertubeService.getChannelVideos(forAccount, max_id, count, showNSFWVideos);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MOST_LIKED:
|
case MOST_LIKED:
|
||||||
videoCall = peertubeService.getMostLikedVideos(getToken(), max_id, count, filter);
|
videoCall = peertubeService.getMostLikedVideos(getToken(), max_id, count, showNSFWVideos, filter);
|
||||||
break;
|
break;
|
||||||
case LOCAL:
|
case LOCAL:
|
||||||
videoCall = peertubeService.getLocalVideos(getToken(), max_id, count, filter);
|
videoCall = peertubeService.getLocalVideos(getToken(), max_id, count, showNSFWVideos, filter);
|
||||||
break;
|
break;
|
||||||
case TRENDING:
|
case TRENDING:
|
||||||
videoCall = peertubeService.getTrendingVideos(getToken(), max_id, count, filter);
|
videoCall = peertubeService.getTrendingVideos(getToken(), max_id, count, showNSFWVideos, filter);
|
||||||
break;
|
break;
|
||||||
case HISTORY:
|
case HISTORY:
|
||||||
videoCall = peertubeService.getHistory(getToken(), max_id, count, null, null);
|
videoCall = peertubeService.getHistory(getToken(), max_id, count, showNSFWVideos, null, null);
|
||||||
break;
|
break;
|
||||||
case RECENT:
|
case RECENT:
|
||||||
videoCall = peertubeService.getRecentlyAddedVideos(getToken(), max_id, count, filter);
|
videoCall = peertubeService.getRecentlyAddedVideos(getToken(), max_id, count, showNSFWVideos, filter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (videoCall != null) {
|
if (videoCall != null) {
|
||||||
@ -462,7 +500,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
ArrayList<String> filter = selection != null ? new ArrayList<>(selection) : null;
|
ArrayList<String> filter = selection != null ? new ArrayList<>(selection) : null;
|
||||||
Call<OverviewVideo> overviewVideoCall = peertubeService.getOverviewVideos(getToken(), page, filter);
|
Call<OverviewVideo> overviewVideoCall = peertubeService.getOverviewVideos(getToken(), page, showNSFWVideos, filter);
|
||||||
try {
|
try {
|
||||||
Response<OverviewVideo> response = overviewVideoCall.execute();
|
Response<OverviewVideo> response = overviewVideoCall.execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
@ -698,6 +736,26 @@ public class RetrofitPeertubeAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get watermark info
|
||||||
|
*
|
||||||
|
* @return PluginData.WaterMark
|
||||||
|
*/
|
||||||
|
public PluginData.WaterMark getWaterMark() {
|
||||||
|
|
||||||
|
PeertubeService peertubeService = init();
|
||||||
|
Call<PluginData.WaterMark> waterMarkCall = peertubeService.waterMark();
|
||||||
|
try {
|
||||||
|
Response<PluginData.WaterMark> response = waterMarkCall.execute();
|
||||||
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
|
return response.body();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get video quota
|
* Get video quota
|
||||||
*
|
*
|
||||||
@ -902,7 +960,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
*/
|
*/
|
||||||
public APIResponse searchNextVideos(List<String> tags) {
|
public APIResponse searchNextVideos(List<String> tags) {
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
Call<VideoData> searchVideosCall = peertubeService.searchNextVideo(getToken(), tags, "0", "20");
|
Call<VideoData> searchVideosCall = peertubeService.searchNextVideo(getToken(), tags, "0", "20", showNSFWVideos);
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
try {
|
try {
|
||||||
Response<VideoData> response = searchVideosCall.execute();
|
Response<VideoData> response = searchVideosCall.execute();
|
||||||
@ -928,7 +986,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
*/
|
*/
|
||||||
public APIResponse searchPeertube(String query, String max_id) {
|
public APIResponse searchPeertube(String query, String max_id) {
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
Call<VideoData> searchVideosCall = peertubeService.searchVideos(getToken(), query, max_id, count);
|
Call<VideoData> searchVideosCall = peertubeService.searchVideos(getToken(), query, max_id, count, showNSFWVideos);
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
try {
|
try {
|
||||||
Response<VideoData> response = searchVideosCall.execute();
|
Response<VideoData> response = searchVideosCall.execute();
|
||||||
@ -1588,6 +1646,9 @@ public class RetrofitPeertubeAPI {
|
|||||||
error.setStatusCode(responseCode);
|
error.setStatusCode(responseCode);
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
}
|
}
|
||||||
|
if (responseCode == 404 || responseCode == 502) {
|
||||||
|
error.setError(_context.getString(R.string.instance_not_availabe));
|
||||||
|
}
|
||||||
apiResponse.setError(error);
|
apiResponse.setError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class AccountData {
|
|||||||
private String client_id;
|
private String client_id;
|
||||||
private String client_secret;
|
private String client_secret;
|
||||||
private String refresh_token;
|
private String refresh_token;
|
||||||
|
private String software;
|
||||||
|
|
||||||
public Account() {
|
public Account() {
|
||||||
}
|
}
|
||||||
@ -241,6 +241,14 @@ public class AccountData {
|
|||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSoftware() {
|
||||||
|
return software;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoftware(String software) {
|
||||||
|
this.software = software;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,4 +1,18 @@
|
|||||||
package app.fedilab.fedilabtube.client.data;
|
package app.fedilab.fedilabtube.client.data;
|
||||||
|
/* Copyright 2020 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
@ -366,6 +380,16 @@ public class InstanceData {
|
|||||||
public static class InstanceConfig {
|
public static class InstanceConfig {
|
||||||
@SerializedName("user")
|
@SerializedName("user")
|
||||||
private User user;
|
private User user;
|
||||||
|
@SerializedName("plugin")
|
||||||
|
private PluginData.Plugin plugin;
|
||||||
|
|
||||||
|
public PluginData.Plugin getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlugin(PluginData.Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
public User getUser() {
|
public User getUser() {
|
||||||
return user;
|
return user;
|
||||||
@ -376,6 +400,7 @@ public class InstanceData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class User {
|
public static class User {
|
||||||
@SerializedName("videoQuota")
|
@SerializedName("videoQuota")
|
||||||
private long videoQuota;
|
private long videoQuota;
|
||||||
|
@ -0,0 +1,125 @@
|
|||||||
|
package app.fedilab.fedilabtube.client.data;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/* Copyright 2020 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
@SuppressWarnings("ALL")
|
||||||
|
public class PluginData {
|
||||||
|
|
||||||
|
public static class Plugin {
|
||||||
|
@SerializedName("registered")
|
||||||
|
private List<PluginInfo> registered;
|
||||||
|
@SerializedName("registeredExternalAuths")
|
||||||
|
private List<PluginInfo> registeredExternalAuths;
|
||||||
|
@SerializedName("registeredIdAndPassAuths")
|
||||||
|
private List<PluginInfo> registeredIdAndPassAuths;
|
||||||
|
|
||||||
|
public List<PluginInfo> getRegistered() {
|
||||||
|
return registered;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegistered(List<PluginInfo> registered) {
|
||||||
|
this.registered = registered;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PluginInfo> getRegisteredExternalAuths() {
|
||||||
|
return registeredExternalAuths;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegisteredExternalAuths(List<PluginInfo> registeredExternalAuths) {
|
||||||
|
this.registeredExternalAuths = registeredExternalAuths;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PluginInfo> getRegisteredIdAndPassAuths() {
|
||||||
|
return registeredIdAndPassAuths;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegisteredIdAndPassAuths(List<PluginInfo> registeredIdAndPassAuths) {
|
||||||
|
this.registeredIdAndPassAuths = registeredIdAndPassAuths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class WaterMark {
|
||||||
|
@SerializedName("publicSettings")
|
||||||
|
private PublicSettings description;
|
||||||
|
|
||||||
|
public PublicSettings getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(PublicSettings description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PublicSettings {
|
||||||
|
@SerializedName("watermark-image-url")
|
||||||
|
private String watermarkImageUrl;
|
||||||
|
@SerializedName("watermark-target-url")
|
||||||
|
private String watermarkTargetUrl;
|
||||||
|
|
||||||
|
public String getWatermarkImageUrl() {
|
||||||
|
return watermarkImageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWatermarkImageUrl(String watermarkImageUrl) {
|
||||||
|
this.watermarkImageUrl = watermarkImageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWatermarkTargetUrl() {
|
||||||
|
return watermarkTargetUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWatermarkTargetUrl(String watermarkTargetUrl) {
|
||||||
|
this.watermarkTargetUrl = watermarkTargetUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PluginInfo {
|
||||||
|
@SerializedName("description")
|
||||||
|
private String description;
|
||||||
|
@SerializedName("name")
|
||||||
|
private String name;
|
||||||
|
@SerializedName("version")
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(String version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -88,6 +88,8 @@ public class VideoData {
|
|||||||
private List<File> files;
|
private List<File> files;
|
||||||
@SerializedName("id")
|
@SerializedName("id")
|
||||||
private String id;
|
private String id;
|
||||||
|
@SerializedName("isLive")
|
||||||
|
private boolean isLive = false;
|
||||||
@SerializedName("isLocal")
|
@SerializedName("isLocal")
|
||||||
private boolean isLocal;
|
private boolean isLocal;
|
||||||
@SerializedName("language")
|
@SerializedName("language")
|
||||||
@ -163,6 +165,7 @@ public class VideoData {
|
|||||||
this.files = new ArrayList<>();
|
this.files = new ArrayList<>();
|
||||||
in.readList(this.files, File.class.getClassLoader());
|
in.readList(this.files, File.class.getClassLoader());
|
||||||
this.id = in.readString();
|
this.id = in.readString();
|
||||||
|
this.isLive = in.readByte() != 0;
|
||||||
this.isLocal = in.readByte() != 0;
|
this.isLocal = in.readByte() != 0;
|
||||||
this.language = in.readParcelable(ItemStr.class.getClassLoader());
|
this.language = in.readParcelable(ItemStr.class.getClassLoader());
|
||||||
this.licence = in.readParcelable(Item.class.getClassLoader());
|
this.licence = in.readParcelable(Item.class.getClassLoader());
|
||||||
@ -194,18 +197,9 @@ public class VideoData {
|
|||||||
public String getFileUrl(String resolution, Context context) {
|
public String getFileUrl(String resolution, Context context) {
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
int mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL);
|
int mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL);
|
||||||
|
List<File> files = getAllFile(context);
|
||||||
if (files != null && files.size() > 0) {
|
if (files != null && files.size() > 0) {
|
||||||
return getFile(context, files, resolution, mode);
|
return getFile(context, files, resolution, mode);
|
||||||
} else if (streamingPlaylists != null && streamingPlaylists.size() > 0) {
|
|
||||||
List<File> files = new ArrayList<>();
|
|
||||||
for (StreamingPlaylists streamingPlaylists : streamingPlaylists) {
|
|
||||||
if (streamingPlaylists.getFiles().size() > 0) {
|
|
||||||
files.addAll(streamingPlaylists.getFiles());
|
|
||||||
} else {
|
|
||||||
return streamingPlaylists.getPlaylistUrl();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getFile(context, files, resolution, mode);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -213,7 +207,7 @@ public class VideoData {
|
|||||||
public List<File> getAllFile(Context context) {
|
public List<File> getAllFile(Context context) {
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
int mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL);
|
int mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL);
|
||||||
if (files != null) {
|
if (files != null && files.size() > 0) {
|
||||||
return files;
|
return files;
|
||||||
} else if (streamingPlaylists != null) {
|
} else if (streamingPlaylists != null) {
|
||||||
List<File> files = new ArrayList<>();
|
List<File> files = new ArrayList<>();
|
||||||
@ -222,7 +216,7 @@ public class VideoData {
|
|||||||
}
|
}
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
return null;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -413,6 +407,14 @@ public class VideoData {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLive() {
|
||||||
|
return isLive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLive(boolean live) {
|
||||||
|
isLive = live;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isLocal() {
|
public boolean isLocal() {
|
||||||
return isLocal;
|
return isLocal;
|
||||||
}
|
}
|
||||||
@ -668,6 +670,7 @@ public class VideoData {
|
|||||||
dest.writeString(this.embedUrl);
|
dest.writeString(this.embedUrl);
|
||||||
dest.writeList(this.files);
|
dest.writeList(this.files);
|
||||||
dest.writeString(this.id);
|
dest.writeString(this.id);
|
||||||
|
dest.writeByte(this.isLive ? (byte) 1 : (byte) 0);
|
||||||
dest.writeByte(this.isLocal ? (byte) 1 : (byte) 0);
|
dest.writeByte(this.isLocal ? (byte) 1 : (byte) 0);
|
||||||
dest.writeParcelable(this.language, flags);
|
dest.writeParcelable(this.language, flags);
|
||||||
dest.writeParcelable(this.licence, flags);
|
dest.writeParcelable(this.licence, flags);
|
||||||
|
@ -23,7 +23,6 @@ import com.google.gson.annotations.SerializedName;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "RedundantSuppression"})
|
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||||
public class VideoPlaylistData {
|
public class VideoPlaylistData {
|
||||||
|
|
||||||
|
@ -38,7 +38,12 @@ public class OauthParams {
|
|||||||
private String refresh_token;
|
private String refresh_token;
|
||||||
@SerializedName("access_token")
|
@SerializedName("access_token")
|
||||||
private String access_token;
|
private String access_token;
|
||||||
|
@SerializedName("response_type")
|
||||||
|
private String response_type;
|
||||||
|
@SerializedName("code")
|
||||||
|
private String code;
|
||||||
|
@SerializedName("redirect_uri")
|
||||||
|
private String redirect_uri;
|
||||||
|
|
||||||
public String getClient_secret() {
|
public String getClient_secret() {
|
||||||
return client_secret;
|
return client_secret;
|
||||||
@ -111,4 +116,28 @@ public class OauthParams {
|
|||||||
public void setAccess_token(String access_token) {
|
public void setAccess_token(String access_token) {
|
||||||
this.access_token = access_token;
|
this.access_token = access_token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getResponse_type() {
|
||||||
|
return response_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResponse_type(String response_type) {
|
||||||
|
this.response_type = response_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRedirect_uri() {
|
||||||
|
return redirect_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRedirect_uri(String redirect_uri) {
|
||||||
|
this.redirect_uri = redirect_uri;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,255 @@
|
|||||||
|
package app.fedilab.fedilabtube.client.mastodon;
|
||||||
|
/* Copyright 2020 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.client.data.AccountData;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.Avatar;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||||
|
public class MastodonAccount {
|
||||||
|
|
||||||
|
|
||||||
|
public static class Account implements Parcelable {
|
||||||
|
public static final Creator<Account> CREATOR = new Creator<Account>() {
|
||||||
|
@Override
|
||||||
|
public Account createFromParcel(Parcel source) {
|
||||||
|
return new Account(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Account[] newArray(int size) {
|
||||||
|
return new Account[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@SerializedName("avatar")
|
||||||
|
private String avatar;
|
||||||
|
@SerializedName("created_at")
|
||||||
|
private Date createdAt;
|
||||||
|
@SerializedName("note")
|
||||||
|
private String description;
|
||||||
|
@SerializedName("display_name")
|
||||||
|
private String displayName;
|
||||||
|
@SerializedName("followers_count")
|
||||||
|
private int followersCount;
|
||||||
|
@SerializedName("following_count")
|
||||||
|
private int followingCount;
|
||||||
|
@SerializedName("id")
|
||||||
|
private String id;
|
||||||
|
@SerializedName("username")
|
||||||
|
private String username;
|
||||||
|
@SerializedName("updated_at")
|
||||||
|
private Date updatedAt;
|
||||||
|
@SerializedName("url")
|
||||||
|
private String url;
|
||||||
|
private String token;
|
||||||
|
private String client_id;
|
||||||
|
private String client_secret;
|
||||||
|
private String refresh_token;
|
||||||
|
private String software;
|
||||||
|
private String host;
|
||||||
|
|
||||||
|
public Account() {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Account(Parcel in) {
|
||||||
|
this.avatar = in.readString();
|
||||||
|
long tmpCreatedAt = in.readLong();
|
||||||
|
this.createdAt = tmpCreatedAt == -1 ? null : new Date(tmpCreatedAt);
|
||||||
|
this.description = in.readString();
|
||||||
|
this.displayName = in.readString();
|
||||||
|
this.followersCount = in.readInt();
|
||||||
|
this.followingCount = in.readInt();
|
||||||
|
this.id = in.readString();
|
||||||
|
this.username = in.readString();
|
||||||
|
long tmpUpdatedAt = in.readLong();
|
||||||
|
this.updatedAt = tmpUpdatedAt == -1 ? null : new Date(tmpUpdatedAt);
|
||||||
|
this.url = in.readString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar() {
|
||||||
|
return avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvatar(String avatar) {
|
||||||
|
this.avatar = avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Date createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayName() {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplayName(String displayName) {
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFollowersCount() {
|
||||||
|
return followersCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFollowersCount(int followersCount) {
|
||||||
|
this.followersCount = followersCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFollowingCount() {
|
||||||
|
return followingCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFollowingCount(int followingCount) {
|
||||||
|
this.followingCount = followingCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Date getUpdatedAt() {
|
||||||
|
return updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedAt(Date updatedAt) {
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAcct() {
|
||||||
|
return username + "@" + host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToken(String token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClient_id() {
|
||||||
|
return client_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClient_id(String client_id) {
|
||||||
|
this.client_id = client_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClient_secret() {
|
||||||
|
return client_secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClient_secret(String client_secret) {
|
||||||
|
this.client_secret = client_secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRefresh_token() {
|
||||||
|
return refresh_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRefresh_token(String refresh_token) {
|
||||||
|
this.refresh_token = refresh_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getSoftware() {
|
||||||
|
return software;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoftware(String software) {
|
||||||
|
this.software = software;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeString(this.avatar);
|
||||||
|
dest.writeLong(this.createdAt != null ? this.createdAt.getTime() : -1);
|
||||||
|
dest.writeString(this.description);
|
||||||
|
dest.writeString(this.displayName);
|
||||||
|
dest.writeInt(this.followersCount);
|
||||||
|
dest.writeInt(this.followingCount);
|
||||||
|
dest.writeString(this.id);
|
||||||
|
dest.writeString(this.username);
|
||||||
|
dest.writeLong(this.updatedAt != null ? this.updatedAt.getTime() : -1);
|
||||||
|
dest.writeString(this.url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AccountData.Account convertToPeertubeAccount(MastodonAccount.Account initialAccount) {
|
||||||
|
AccountData.Account account = new AccountData.Account();
|
||||||
|
Avatar avatar = new Avatar();
|
||||||
|
avatar.setPath(initialAccount.getAvatar());
|
||||||
|
account.setAvatar(avatar);
|
||||||
|
account.setDescription(initialAccount.getDescription());
|
||||||
|
account.setDisplayName(initialAccount.getDisplayName());
|
||||||
|
account.setUsername(initialAccount.getUsername());
|
||||||
|
account.setHost(initialAccount.getHost());
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,102 @@
|
|||||||
|
package app.fedilab.fedilabtube.client.mastodon;
|
||||||
|
/* Copyright 2020 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.client.entities.Oauth;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.Token;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.http.Field;
|
||||||
|
import retrofit2.http.FormUrlEncoded;
|
||||||
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.Header;
|
||||||
|
import retrofit2.http.POST;
|
||||||
|
import retrofit2.http.Path;
|
||||||
|
import retrofit2.http.Query;
|
||||||
|
|
||||||
|
interface MastodonService {
|
||||||
|
|
||||||
|
@POST("apps")
|
||||||
|
Call<Oauth> getOauth(
|
||||||
|
@Query("client_name") String client_name,
|
||||||
|
@Query("redirect_uris") String redirect_uris,
|
||||||
|
@Query("scopes") String scopes,
|
||||||
|
@Query("website") String website);
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
|
@POST("/oauth/token")
|
||||||
|
Call<Token> createToken(
|
||||||
|
@Field("grant_type") String grant_type,
|
||||||
|
@Field("client_id") String client_id,
|
||||||
|
@Field("client_secret") String client_secret,
|
||||||
|
@Field("redirect_uri") String redirect_uri,
|
||||||
|
@Field("code") String code);
|
||||||
|
|
||||||
|
@GET("accounts/verify_credentials")
|
||||||
|
Call<MastodonAccount.Account> verifyCredentials(@Header("Authorization") String credentials);
|
||||||
|
|
||||||
|
@GET("search?type=statuses&resolve=true")
|
||||||
|
Call<Results> searchMessage(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Query("q") String messageURL
|
||||||
|
);
|
||||||
|
|
||||||
|
@POST("statuses")
|
||||||
|
Call<Status> postReply(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Query("in_reply_to_id") String inReplyToId,
|
||||||
|
@Query("status") String content,
|
||||||
|
@Query("visibility") String visibility
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@POST("statuses/{id}/reblog")
|
||||||
|
Call<Status> boost(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Path("id") String id
|
||||||
|
);
|
||||||
|
|
||||||
|
@POST("statuses/{id}/unreblog")
|
||||||
|
Call<Status> unBoost(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Path("id") String id
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@POST("statuses/{id}/favourite")
|
||||||
|
Call<Status> favourite(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Path("id") String id
|
||||||
|
);
|
||||||
|
|
||||||
|
@POST("statuses/{id}/unfavourite")
|
||||||
|
Call<Status> unfavourite(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Path("id") String id
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@POST("statuses/{id}/bookmark")
|
||||||
|
Call<Status> bookmark(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Path("id") String id
|
||||||
|
);
|
||||||
|
|
||||||
|
@POST("statuses/{id}/unbookmark")
|
||||||
|
Call<Status> unbookmark(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Path("id") String id
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package app.fedilab.fedilabtube.client.mastodon;
|
||||||
|
/* Copyright 2021 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class Results {
|
||||||
|
|
||||||
|
@SerializedName("accounts")
|
||||||
|
private List<MastodonAccount.Account> accounts;
|
||||||
|
@SerializedName("statuses")
|
||||||
|
private List<Status> statuses;
|
||||||
|
|
||||||
|
public List<MastodonAccount.Account> getAccounts() {
|
||||||
|
return accounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccounts(List<MastodonAccount.Account> accounts) {
|
||||||
|
this.accounts = accounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Status> getStatuses() {
|
||||||
|
return statuses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatuses(List<Status> statuses) {
|
||||||
|
this.statuses = statuses;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,336 @@
|
|||||||
|
package app.fedilab.fedilabtube.client.mastodon;
|
||||||
|
/* Copyright 2020 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.MainActivity;
|
||||||
|
import app.fedilab.fedilabtube.R;
|
||||||
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.Error;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.Oauth;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.OauthParams;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.Token;
|
||||||
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
|
import app.fedilab.fedilabtube.sqlite.MastodonAccountDAO;
|
||||||
|
import app.fedilab.fedilabtube.sqlite.Sqlite;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Response;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
|
||||||
|
public class RetrofitMastodonAPI {
|
||||||
|
|
||||||
|
private final String finalUrl;
|
||||||
|
private final String finalUrl2;
|
||||||
|
private final Context _context;
|
||||||
|
private String instance;
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
public Status search(String url) throws Error {
|
||||||
|
MastodonService mastodonService2 = init2();
|
||||||
|
Call<Results> statusCall = mastodonService2.searchMessage(getToken(), url);
|
||||||
|
Response<Results> response;
|
||||||
|
try {
|
||||||
|
response = statusCall.execute();
|
||||||
|
if (response.isSuccessful() && response.body() != null && response.body().getStatuses() != null && response.body().getStatuses().size() > 0) {
|
||||||
|
return response.body().getStatuses().get(0);
|
||||||
|
} else {
|
||||||
|
Error error = new Error();
|
||||||
|
error.setStatusCode(response.code());
|
||||||
|
if (response.errorBody() != null) {
|
||||||
|
error.setError(response.errorBody().string());
|
||||||
|
} else {
|
||||||
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public RetrofitMastodonAPI(Context context) {
|
||||||
|
_context = context;
|
||||||
|
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
this.instance = sharedpreferences.getString(Helper.PREF_REMOTE_INSTANCE, null);
|
||||||
|
this.token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||||
|
finalUrl = "https://" + this.instance + "/api/v1/";
|
||||||
|
finalUrl2 = "https://" + this.instance + "/api/v2/";
|
||||||
|
}
|
||||||
|
|
||||||
|
public RetrofitMastodonAPI(Context context, String instance, String token) {
|
||||||
|
_context = context;
|
||||||
|
this.instance = instance;
|
||||||
|
this.token = token;
|
||||||
|
finalUrl = "https://" + instance + "/api/v1/";
|
||||||
|
finalUrl2 = "https://" + this.instance + "/api/v2/";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateCredential(Activity activity, String client_id, String client_secret, String refresh_token, String software) {
|
||||||
|
new Thread(() -> {
|
||||||
|
MastodonAccount.Account account;
|
||||||
|
try {
|
||||||
|
account = new RetrofitMastodonAPI(activity, instance, token).verifyCredentials();
|
||||||
|
} catch (Error error) {
|
||||||
|
Error.displayError(activity, error);
|
||||||
|
error.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
//At the state the instance can be encoded
|
||||||
|
instance = URLDecoder.decode(instance, "utf-8");
|
||||||
|
} catch (UnsupportedEncodingException ignored) {
|
||||||
|
}
|
||||||
|
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
account.setToken(token);
|
||||||
|
account.setClient_id(client_id);
|
||||||
|
account.setClient_secret(client_secret);
|
||||||
|
account.setRefresh_token(refresh_token);
|
||||||
|
account.setHost(instance);
|
||||||
|
account.setSoftware(software);
|
||||||
|
SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
|
boolean userExists = new MastodonAccountDAO(activity, db).userExist(account);
|
||||||
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
|
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||||
|
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
||||||
|
if (token != null) {
|
||||||
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token);
|
||||||
|
}
|
||||||
|
editor.putString(Helper.PREF_REMOTE_INSTANCE, account.getHost());
|
||||||
|
editor.putString(Helper.PREF_SOFTWARE, software);
|
||||||
|
editor.apply();
|
||||||
|
if (userExists) {
|
||||||
|
new MastodonAccountDAO(activity, db).updateAccountCredential(account);
|
||||||
|
} else {
|
||||||
|
if (account.getUsername() != null && account.getCreatedAt() != null) {
|
||||||
|
new MastodonAccountDAO(activity, db).insertAccount(account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
Runnable myRunnable = () -> {
|
||||||
|
Intent mainActivity = new Intent(activity, MainActivity.class);
|
||||||
|
mainActivity.putExtra(Helper.INTENT_ACTION, Helper.ADD_USER_INTENT);
|
||||||
|
activity.startActivity(mainActivity);
|
||||||
|
activity.finish();
|
||||||
|
};
|
||||||
|
mainHandler.post(myRunnable);
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private MastodonService init() {
|
||||||
|
Retrofit retrofit = new Retrofit.Builder()
|
||||||
|
.baseUrl(finalUrl)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.build();
|
||||||
|
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
if (token == null) {
|
||||||
|
token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||||
|
}
|
||||||
|
return retrofit.create(MastodonService.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MastodonService init2() {
|
||||||
|
Retrofit retrofit = new Retrofit.Builder()
|
||||||
|
.baseUrl(finalUrl2)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.build();
|
||||||
|
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
if (token == null) {
|
||||||
|
token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||||
|
}
|
||||||
|
return retrofit.create(MastodonService.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Oauth
|
||||||
|
*
|
||||||
|
* @return APIResponse
|
||||||
|
*/
|
||||||
|
public Oauth oauthClient(String client_name, String redirect_uris, String scopes, String website) {
|
||||||
|
MastodonService mastodonService = init();
|
||||||
|
try {
|
||||||
|
Call<Oauth> oauth;
|
||||||
|
oauth = mastodonService.getOauth(client_name, redirect_uris, scopes, website);
|
||||||
|
Response<Oauth> response = oauth.execute();
|
||||||
|
|
||||||
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
|
return response.body();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Verifiy credential of the authenticated user *synchronously*
|
||||||
|
* @return Account
|
||||||
|
*/
|
||||||
|
public MastodonAccount.Account verifyCredentials() throws Error {
|
||||||
|
MastodonService mastodonService = init();
|
||||||
|
Call<MastodonAccount.Account> accountCall = mastodonService.verifyCredentials("Bearer " + token);
|
||||||
|
APIResponse apiResponse = new APIResponse();
|
||||||
|
try {
|
||||||
|
Response<MastodonAccount.Account> response = accountCall.execute();
|
||||||
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
|
return response.body();
|
||||||
|
} else {
|
||||||
|
Error error = new Error();
|
||||||
|
error.setStatusCode(response.code());
|
||||||
|
if (response.errorBody() != null) {
|
||||||
|
error.setError(response.errorBody().string());
|
||||||
|
} else {
|
||||||
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
Error error = new Error();
|
||||||
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
|
apiResponse.setError(error);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Verifiy credential of the authenticated user *synchronously*
|
||||||
|
* @return Account
|
||||||
|
*/
|
||||||
|
public Token manageToken(OauthParams oauthParams) throws Error {
|
||||||
|
MastodonService mastodonService = init();
|
||||||
|
Call<Token> createToken = mastodonService.createToken(
|
||||||
|
oauthParams.getGrant_type(),
|
||||||
|
oauthParams.getClient_id(),
|
||||||
|
oauthParams.getClient_secret(),
|
||||||
|
oauthParams.getRedirect_uri(),
|
||||||
|
oauthParams.getCode()
|
||||||
|
);
|
||||||
|
if (createToken != null) {
|
||||||
|
try {
|
||||||
|
Response<Token> response = createToken.execute();
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
return response.body();
|
||||||
|
} else {
|
||||||
|
Error error = new Error();
|
||||||
|
error.setStatusCode(response.code());
|
||||||
|
if (response.errorBody() != null) {
|
||||||
|
error.setError(response.errorBody().string());
|
||||||
|
} else {
|
||||||
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Status commentAction(String url, String content) throws Error {
|
||||||
|
MastodonService mastodonService = init();
|
||||||
|
Status status = search(url);
|
||||||
|
if (status != null) {
|
||||||
|
Call<Status> postReplyCall = mastodonService.postReply(getToken(), status.getId(), content, null);
|
||||||
|
try {
|
||||||
|
Response<Status> responsePost = postReplyCall.execute();
|
||||||
|
if (responsePost.isSuccessful()) {
|
||||||
|
Status statusReturned = responsePost.body();
|
||||||
|
if (statusReturned != null && statusReturned.getAccount() != null) {
|
||||||
|
statusReturned.getAccount().setHost(instance);
|
||||||
|
}
|
||||||
|
return statusReturned;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Status postAction(actionType type, Status status) throws Error {
|
||||||
|
MastodonService mastodonService = init();
|
||||||
|
Call<Status> postAction = null;
|
||||||
|
if (status != null) {
|
||||||
|
switch (type) {
|
||||||
|
case BOOST:
|
||||||
|
postAction = mastodonService.boost(getToken(), status.getId());
|
||||||
|
break;
|
||||||
|
case UNBOOST:
|
||||||
|
postAction = mastodonService.unBoost(getToken(), status.getId());
|
||||||
|
break;
|
||||||
|
case FAVOURITE:
|
||||||
|
postAction = mastodonService.favourite(getToken(), status.getId());
|
||||||
|
break;
|
||||||
|
case UNFAVOURITE:
|
||||||
|
postAction = mastodonService.unfavourite(getToken(), status.getId());
|
||||||
|
break;
|
||||||
|
case BOOKMARK:
|
||||||
|
postAction = mastodonService.bookmark(getToken(), status.getId());
|
||||||
|
break;
|
||||||
|
case UNBOOKMARK:
|
||||||
|
postAction = mastodonService.unbookmark(getToken(), status.getId());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (postAction != null) {
|
||||||
|
Response<Status> responsePost = postAction.execute();
|
||||||
|
if (responsePost.isSuccessful()) {
|
||||||
|
Status statusReturned = responsePost.body();
|
||||||
|
if (statusReturned != null && statusReturned.getAccount() != null) {
|
||||||
|
statusReturned.getAccount().setHost(instance);
|
||||||
|
}
|
||||||
|
return statusReturned;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum actionType {
|
||||||
|
BOOST,
|
||||||
|
UNBOOST,
|
||||||
|
FAVOURITE,
|
||||||
|
UNFAVOURITE,
|
||||||
|
BOOKMARK,
|
||||||
|
UNBOOKMARK
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getToken() {
|
||||||
|
if (token != null) {
|
||||||
|
return "Bearer " + token;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,149 @@
|
|||||||
|
package app.fedilab.fedilabtube.client.mastodon;
|
||||||
|
/* Copyright 2021 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.client.data.CommentData;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class Status {
|
||||||
|
|
||||||
|
@SerializedName("id")
|
||||||
|
private String id;
|
||||||
|
@SerializedName("in_reply_to_id")
|
||||||
|
private String inReplyToCommentId;
|
||||||
|
@SerializedName("account")
|
||||||
|
private MastodonAccount.Account account;
|
||||||
|
@SerializedName("url")
|
||||||
|
private String url;
|
||||||
|
@SerializedName("content")
|
||||||
|
private String text;
|
||||||
|
@SerializedName("created_at")
|
||||||
|
private Date createdAt;
|
||||||
|
@SerializedName("reblogs_count")
|
||||||
|
private int reblogsCount;
|
||||||
|
@SerializedName("favourites_count")
|
||||||
|
private int favouritesCount;
|
||||||
|
@SerializedName("favourited")
|
||||||
|
private boolean favourited;
|
||||||
|
@SerializedName("reblogged")
|
||||||
|
private boolean reblogged;
|
||||||
|
@SerializedName("bookmarked")
|
||||||
|
private boolean bookmarked;
|
||||||
|
|
||||||
|
public static CommentData.Comment convertStatusToComment(Status status) {
|
||||||
|
CommentData.Comment comment = new CommentData.Comment();
|
||||||
|
comment.setAccount(MastodonAccount.convertToPeertubeAccount(status.getAccount()));
|
||||||
|
comment.setCreatedAt(status.getCreatedAt());
|
||||||
|
comment.setText(status.getText());
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInReplyToCommentId() {
|
||||||
|
return inReplyToCommentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInReplyToCommentId(String inReplyToCommentId) {
|
||||||
|
this.inReplyToCommentId = inReplyToCommentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MastodonAccount.Account getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccount(MastodonAccount.Account account) {
|
||||||
|
this.account = account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Date createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getReblogsCount() {
|
||||||
|
return reblogsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReblogsCount(int reblogsCount) {
|
||||||
|
this.reblogsCount = reblogsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFavouriteCount() {
|
||||||
|
return favouritesCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFavourited() {
|
||||||
|
return favourited;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFavourited(boolean favourited) {
|
||||||
|
this.favourited = favourited;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isReblogged() {
|
||||||
|
return reblogged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReblogged(boolean reblogged) {
|
||||||
|
this.reblogged = reblogged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFavouritesCount() {
|
||||||
|
return favouritesCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFavouritesCount(int favouritesCount) {
|
||||||
|
this.favouritesCount = favouritesCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBookmarked() {
|
||||||
|
return bookmarked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBookmarked(boolean bookmarked) {
|
||||||
|
this.bookmarked = bookmarked;
|
||||||
|
}
|
||||||
|
}
|
@ -19,11 +19,14 @@ import android.graphics.Color;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.graphics.ColorUtils;
|
import androidx.core.graphics.ColorUtils;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.client.data.ChannelData;
|
import app.fedilab.fedilabtube.client.data.ChannelData;
|
||||||
import app.fedilab.fedilabtube.databinding.DrawerHorizontalAccountBinding;
|
import app.fedilab.fedilabtube.databinding.DrawerHorizontalAccountBinding;
|
||||||
import app.fedilab.fedilabtube.helper.Helper;
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
|
@ -66,7 +66,6 @@ import es.dmoral.toasty.Toasty;
|
|||||||
|
|
||||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.MUTE;
|
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.MUTE;
|
||||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPLY;
|
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPLY;
|
||||||
import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
|
|
||||||
|
|
||||||
|
|
||||||
public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
@ -75,11 +74,11 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
private final List<Comment> comments;
|
private final List<Comment> comments;
|
||||||
private final CommentListAdapter commentListAdapter;
|
private final CommentListAdapter commentListAdapter;
|
||||||
private final boolean isThread;
|
private final boolean isThread;
|
||||||
|
private final String instance;
|
||||||
|
private final boolean sepiaSearch;
|
||||||
public AllCommentRemoved allCommentRemoved;
|
public AllCommentRemoved allCommentRemoved;
|
||||||
boolean isVideoOwner;
|
boolean isVideoOwner;
|
||||||
private Context context;
|
private Context context;
|
||||||
private final String instance;
|
|
||||||
private final boolean sepiaSearch;
|
|
||||||
|
|
||||||
public CommentListAdapter(List<Comment> comments, boolean isVideoOwner, boolean isThread, String instance, boolean sepiaSearch) {
|
public CommentListAdapter(List<Comment> comments, boolean isVideoOwner, boolean isThread, String instance, boolean sepiaSearch) {
|
||||||
this.comments = comments;
|
this.comments = comments;
|
||||||
@ -247,6 +246,9 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
if (context instanceof PeertubeActivity && !isThread) {
|
if (context instanceof PeertubeActivity && !isThread) {
|
||||||
holder.binding.mainContainer.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment));
|
holder.binding.mainContainer.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment));
|
||||||
holder.binding.commentContent.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment));
|
holder.binding.commentContent.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment));
|
||||||
|
holder.binding.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment));
|
||||||
|
} else if (context instanceof PeertubeActivity) {
|
||||||
|
holder.binding.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i));
|
||||||
}
|
}
|
||||||
if (comment.getTotalReplies() > 0) {
|
if (comment.getTotalReplies() > 0) {
|
||||||
holder.binding.numberOfReplies.setVisibility(View.VISIBLE);
|
holder.binding.numberOfReplies.setVisibility(View.VISIBLE);
|
||||||
@ -275,7 +277,11 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
|
|
||||||
String avatarUrl;
|
String avatarUrl;
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
avatarUrl = comment.getAccount().getAvatar() != null ? "https://" + instance + comment.getAccount().getAvatar().getPath() : null;
|
if (comment.getAccount().getAvatar() != null && comment.getAccount().getAvatar().getPath().startsWith("http")) {
|
||||||
|
avatarUrl = comment.getAccount().getAvatar().getPath();
|
||||||
|
} else {
|
||||||
|
avatarUrl = comment.getAccount().getAvatar() != null ? "https://" + instance + comment.getAccount().getAvatar().getPath() : null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
avatarUrl = comment.getAccount().getAvatar() != null ? comment.getAccount().getAvatar().getPath() : null;
|
avatarUrl = comment.getAccount().getAvatar() != null ? comment.getAccount().getAvatar().getPath() : null;
|
||||||
}
|
}
|
||||||
@ -300,7 +306,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
holder.binding.postReplyButton.setVisibility(View.GONE);
|
holder.binding.postReplyButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
holder.binding.postReplyButton.setOnClickListener(v -> {
|
holder.binding.postReplyButton.setOnClickListener(v -> {
|
||||||
if (isLoggedIn(context) && !sepiaSearch) {
|
if (Helper.canMakeAction(context) && !sepiaSearch) {
|
||||||
((PeertubeActivity) context).openPostComment(comment, i);
|
((PeertubeActivity) context).openPostComment(comment, i);
|
||||||
} else {
|
} else {
|
||||||
if (sepiaSearch) {
|
if (sepiaSearch) {
|
||||||
@ -311,9 +317,8 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
if (isLoggedIn(context) && !sepiaSearch) {
|
if (Helper.canMakeAction(context) && !sepiaSearch) {
|
||||||
holder.binding.replyButton.setVisibility(View.VISIBLE);
|
holder.binding.replyButton.setVisibility(View.VISIBLE);
|
||||||
holder.binding.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i));
|
|
||||||
} else {
|
} else {
|
||||||
holder.binding.replyButton.setVisibility(View.GONE);
|
holder.binding.replyButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,12 @@ public class OwnAccountsAdapter extends ArrayAdapter<Account> {
|
|||||||
|
|
||||||
holder.account_un.setText(String.format("@%s", account.getAcct()));
|
holder.account_un.setText(String.format("@%s", account.getAcct()));
|
||||||
//Profile picture
|
//Profile picture
|
||||||
Helper.loadGiF(holder.account_pp.getContext(), "https://" + account.getHost() + account.getAvatar().getPath(), holder.account_pp);
|
if (account.getAvatar() != null && account.getAvatar().getPath().startsWith("http")) {
|
||||||
|
Helper.loadGiF(holder.account_pp.getContext(), account.getAvatar().getPath(), holder.account_pp);
|
||||||
|
} else {
|
||||||
|
Helper.loadGiF(holder.account_pp.getContext(), "https://" + account.getHost() + account.getAvatar().getPath(), holder.account_pp);
|
||||||
|
}
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,8 @@ import app.fedilab.fedilabtube.R;
|
|||||||
import app.fedilab.fedilabtube.ShowChannelActivity;
|
import app.fedilab.fedilabtube.ShowChannelActivity;
|
||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||||
|
import app.fedilab.fedilabtube.client.data.AccountData;
|
||||||
|
import app.fedilab.fedilabtube.client.data.ChannelData;
|
||||||
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||||
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
||||||
@ -82,12 +84,15 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
private Context context;
|
private Context context;
|
||||||
private TimelineVM.TimelineType timelineType;
|
private TimelineVM.TimelineType timelineType;
|
||||||
private boolean sepiaSearch;
|
private boolean sepiaSearch;
|
||||||
|
private ChannelData.Channel forChannel;
|
||||||
|
private AccountData.Account forAccount;
|
||||||
|
|
||||||
|
public PeertubeAdapter(List<VideoData.Video> videos, TimelineVM.TimelineType timelineType, boolean sepiaSearch, ChannelData.Channel forChannel, AccountData.Account forAccount) {
|
||||||
public PeertubeAdapter(List<VideoData.Video> videos, TimelineVM.TimelineType timelineType, boolean sepiaSearch) {
|
|
||||||
this.videos = videos;
|
this.videos = videos;
|
||||||
this.timelineType = timelineType;
|
this.timelineType = timelineType;
|
||||||
this.sepiaSearch = sepiaSearch || timelineType == SEPIA_SEARCH;
|
this.sepiaSearch = sepiaSearch || timelineType == SEPIA_SEARCH;
|
||||||
|
this.forChannel = forChannel;
|
||||||
|
this.forAccount = forAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -127,16 +132,30 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
ownVideos = Helper.isVideoOwner(context, video);
|
ownVideos = Helper.isVideoOwner(context, video);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String instance = null;
|
String instance = null;
|
||||||
if (sepiaSearch) {
|
if (sepiaSearch) {
|
||||||
instance = video.getAccount().getHost();
|
instance = video.getAccount().getHost();
|
||||||
|
} else if (forChannel != null) {
|
||||||
|
instance = forChannel.getHost();
|
||||||
|
} else if (forAccount != null) {
|
||||||
|
instance = forAccount.getHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
holder.binding.peertubeAccountName.setText(video.getChannel().getAcct());
|
holder.binding.peertubeAccountName.setText(video.getChannel().getAcct());
|
||||||
Helper.loadGiF(context, instance, video.getChannel().getAvatar() != null ? video.getChannel().getAvatar().getPath() : null, holder.binding.peertubeProfile);
|
Helper.loadGiF(context, instance, video.getChannel().getAvatar() != null ? video.getChannel().getAvatar().getPath() : null, holder.binding.peertubeProfile);
|
||||||
|
|
||||||
holder.binding.peertubeTitle.setText(video.getName());
|
holder.binding.peertubeTitle.setText(video.getName());
|
||||||
holder.binding.peertubeDuration.setText(Helper.secondsToString(video.getDuration()));
|
if (video.isLive()) {
|
||||||
|
holder.binding.peertubeDuration.setText(R.string.live);
|
||||||
|
holder.binding.peertubeDuration.setBackgroundResource(R.drawable.rounded_live);
|
||||||
|
} else {
|
||||||
|
holder.binding.peertubeDuration.setText(Helper.secondsToString(video.getDuration()));
|
||||||
|
holder.binding.peertubeDuration.setBackgroundResource(R.drawable.rounded_corner);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
holder.binding.peertubeDate.setText(String.format(" - %s", Helper.dateDiff(context, video.getCreatedAt())));
|
holder.binding.peertubeDate.setText(String.format(" - %s", Helper.dateDiff(context, video.getCreatedAt())));
|
||||||
holder.binding.peertubeViews.setText(context.getString(R.string.number_view_video, Helper.withSuffix(video.getViews())));
|
holder.binding.peertubeViews.setText(context.getString(R.string.number_view_video, Helper.withSuffix(video.getViews())));
|
||||||
|
|
||||||
@ -172,8 +191,8 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
Intent intent = new Intent(context, ShowChannelActivity.class);
|
Intent intent = new Intent(context, ShowChannelActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putParcelable("channel", video.getChannel());
|
b.putParcelable("channel", video.getChannel());
|
||||||
b.putBoolean("sepia_search", sepiaSearch);
|
b.putBoolean("sepia_search", sepiaSearch || forChannel != null);
|
||||||
if (sepiaSearch) {
|
if (sepiaSearch || forChannel != null) {
|
||||||
b.putString("peertube_instance", video.getAccount().getHost());
|
b.putString("peertube_instance", video.getAccount().getHost());
|
||||||
}
|
}
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
@ -389,14 +408,6 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface RelationShipListener {
|
|
||||||
Map<String, Boolean> getRelationShip();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface PlaylistListener {
|
|
||||||
Map<String, List<PlaylistExist>> getPlaylist();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("CheckResult")
|
@SuppressLint("CheckResult")
|
||||||
private void loadImage(ImageView target, String instance, String urlPreview, String thumbnail, boolean blur) {
|
private void loadImage(ImageView target, String instance, String urlPreview, String thumbnail, boolean blur) {
|
||||||
if (urlPreview == null || urlPreview.startsWith("null")) {
|
if (urlPreview == null || urlPreview.startsWith("null")) {
|
||||||
@ -459,6 +470,14 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface RelationShipListener {
|
||||||
|
Map<String, Boolean> getRelationShip();
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface PlaylistListener {
|
||||||
|
Map<String, List<PlaylistExist>> getPlaylist();
|
||||||
|
}
|
||||||
|
|
||||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
DrawerPeertubeBinding binding;
|
DrawerPeertubeBinding binding;
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.PopupMenu;
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
@ -68,8 +68,8 @@ import static app.fedilab.fedilabtube.PeertubeUploadActivity.MY_PERMISSIONS_REQU
|
|||||||
|
|
||||||
public class DisplayChannelsFragment extends Fragment implements ChannelListAdapter.AllChannelRemoved, ChannelListAdapter.EditAlertDialog {
|
public class DisplayChannelsFragment extends Fragment implements ChannelListAdapter.AllChannelRemoved, ChannelListAdapter.EditAlertDialog {
|
||||||
|
|
||||||
private Context context;
|
|
||||||
private static final int PICK_AVATAR = 467;
|
private static final int PICK_AVATAR = 467;
|
||||||
|
private Context context;
|
||||||
private ChannelListAdapter channelListAdapter;
|
private ChannelListAdapter channelListAdapter;
|
||||||
private List<ChannelData.Channel> channels;
|
private List<ChannelData.Channel> channels;
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -30,7 +30,6 @@ import android.widget.AdapterView;
|
|||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -96,7 +96,7 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
|
|||||||
binding.loader.setVisibility(View.VISIBLE);
|
binding.loader.setVisibility(View.VISIBLE);
|
||||||
binding.loadingNextVideos.setVisibility(View.GONE);
|
binding.loadingNextVideos.setVisibility(View.GONE);
|
||||||
|
|
||||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH, true);
|
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH, true, null, null);
|
||||||
binding.lvVideos.setAdapter(peertubeAdapater);
|
binding.lvVideos.setAdapter(peertubeAdapater);
|
||||||
|
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
|
|||||||
|
|
||||||
//If no item were inserted previously the adapter is created
|
//If no item were inserted previously the adapter is created
|
||||||
if (previousPosition == 0) {
|
if (previousPosition == 0) {
|
||||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH, true);
|
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH, true, null, null);
|
||||||
binding.lvVideos.setAdapter(peertubeAdapater);
|
binding.lvVideos.setAdapter(peertubeAdapater);
|
||||||
} else
|
} else
|
||||||
peertubeAdapater.notifyItemRangeInserted(previousPosition, videoData.data.size());
|
peertubeAdapater.notifyItemRangeInserted(previousPosition, videoData.data.size());
|
||||||
|
@ -70,7 +70,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||||||
|
|
||||||
private LinearLayoutManager mLayoutManager;
|
private LinearLayoutManager mLayoutManager;
|
||||||
private GridLayoutManager gLayoutManager;
|
private GridLayoutManager gLayoutManager;
|
||||||
private boolean flag_loading;
|
private boolean flag_loading, flag_loading_account;
|
||||||
private Context context;
|
private Context context;
|
||||||
private PeertubeAdapter peertubeAdapater;
|
private PeertubeAdapter peertubeAdapater;
|
||||||
private AccountsHorizontalListAdapter accountsHorizontalListAdapter;
|
private AccountsHorizontalListAdapter accountsHorizontalListAdapter;
|
||||||
@ -127,6 +127,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||||||
startDate = bundle.getString("startDate", null);
|
startDate = bundle.getString("startDate", null);
|
||||||
endDate = bundle.getString("endDate", null);
|
endDate = bundle.getString("endDate", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel != null) {
|
if (channel != null) {
|
||||||
channelId = channel.getAcct();
|
channelId = channel.getAcct();
|
||||||
} else if (account != null) {
|
} else if (account != null) {
|
||||||
@ -136,13 +137,14 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||||||
//forChannel = type == TimelineVM.TimelineType.ACCOUNT_VIDEOS ? channelId : null;
|
//forChannel = type == TimelineVM.TimelineType.ACCOUNT_VIDEOS ? channelId : null;
|
||||||
max_id_accounts = null;
|
max_id_accounts = null;
|
||||||
flag_loading = true;
|
flag_loading = true;
|
||||||
|
flag_loading_account = false;
|
||||||
firstLoad = true;
|
firstLoad = true;
|
||||||
check_ScrollingUp = false;
|
check_ScrollingUp = false;
|
||||||
|
|
||||||
binding.loader.setVisibility(View.VISIBLE);
|
binding.loader.setVisibility(View.VISIBLE);
|
||||||
binding.loadingNextVideos.setVisibility(View.GONE);
|
binding.loadingNextVideos.setVisibility(View.GONE);
|
||||||
|
|
||||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch);
|
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch, forChannel, account);
|
||||||
peertubeAdapater.playlistListener = this;
|
peertubeAdapater.playlistListener = this;
|
||||||
peertubeAdapater.relationShipListener = this;
|
peertubeAdapater.relationShipListener = this;
|
||||||
binding.lvVideos.setAdapter(peertubeAdapater);
|
binding.lvVideos.setAdapter(peertubeAdapater);
|
||||||
@ -152,6 +154,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||||||
= new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
|
= new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
|
||||||
binding.lvAccounts.setLayoutManager(layoutManager);
|
binding.lvAccounts.setLayoutManager(layoutManager);
|
||||||
binding.lvAccounts.setAdapter(accountsHorizontalListAdapter);
|
binding.lvAccounts.setAdapter(accountsHorizontalListAdapter);
|
||||||
|
|
||||||
if (!Helper.isTablet(context)) {
|
if (!Helper.isTablet(context)) {
|
||||||
mLayoutManager = new LinearLayoutManager(context);
|
mLayoutManager = new LinearLayoutManager(context);
|
||||||
binding.lvVideos.setLayoutManager(mLayoutManager);
|
binding.lvVideos.setLayoutManager(mLayoutManager);
|
||||||
@ -170,10 +173,11 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||||||
binding.lvAccounts.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
binding.lvAccounts.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||||
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
|
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
|
||||||
if (dy > 0) {
|
if (dx > 0) {
|
||||||
int visibleItemCount = layoutManager.getChildCount();
|
int visibleItemCount = layoutManager.getChildCount();
|
||||||
int totalItemCount = layoutManager.getItemCount();
|
int totalItemCount = layoutManager.getItemCount();
|
||||||
if (firstVisibleItem + visibleItemCount == totalItemCount && context != null) {
|
if (firstVisibleItem + visibleItemCount == totalItemCount && context != null && !flag_loading_account) {
|
||||||
|
flag_loading_account = true;
|
||||||
viewModelAccounts.getAccounts(RetrofitPeertubeAPI.DataType.SUBSCRIBER, max_id_accounts).observe(DisplayVideosFragment.this.requireActivity(), apiResponse -> manageViewAccounts(apiResponse));
|
viewModelAccounts.getAccounts(RetrofitPeertubeAPI.DataType.SUBSCRIBER, max_id_accounts).observe(DisplayVideosFragment.this.requireActivity(), apiResponse -> manageViewAccounts(apiResponse));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,6 +298,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||||||
|
|
||||||
|
|
||||||
private void manageViewAccounts(APIResponse apiResponse) {
|
private void manageViewAccounts(APIResponse apiResponse) {
|
||||||
|
flag_loading_account = false;
|
||||||
if (apiResponse != null && apiResponse.getChannels() != null && apiResponse.getChannels().size() > 0) {
|
if (apiResponse != null && apiResponse.getChannels() != null && apiResponse.getChannels().size() > 0) {
|
||||||
if (binding.topAccountContainer.getVisibility() == View.GONE) {
|
if (binding.topAccountContainer.getVisibility() == View.GONE) {
|
||||||
binding.topAccountContainer.setVisibility(View.VISIBLE);
|
binding.topAccountContainer.setVisibility(View.VISIBLE);
|
||||||
@ -320,8 +325,13 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||||||
if (this.peertubes == null || apiResponse == null || (apiResponse.getError() != null)) {
|
if (this.peertubes == null || apiResponse == null || (apiResponse.getError() != null)) {
|
||||||
if (apiResponse == null)
|
if (apiResponse == null)
|
||||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||||
else {
|
else if (apiResponse.getError() != null) {
|
||||||
Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
if (apiResponse.getError().getError().length() > 500) {
|
||||||
|
Toasty.info(context, getString(R.string.remote_account), Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
binding.swipeContainer.setRefreshing(false);
|
binding.swipeContainer.setRefreshing(false);
|
||||||
flag_loading = false;
|
flag_loading = false;
|
||||||
@ -356,7 +366,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||||||
|
|
||||||
//If no item were inserted previously the adapter is created
|
//If no item were inserted previously the adapter is created
|
||||||
if (previousPosition == 0) {
|
if (previousPosition == 0) {
|
||||||
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch);
|
peertubeAdapater = new PeertubeAdapter(this.peertubes, type, sepiaSearch, forChannel, account);
|
||||||
peertubeAdapater.playlistListener = DisplayVideosFragment.this;
|
peertubeAdapater.playlistListener = DisplayVideosFragment.this;
|
||||||
peertubeAdapater.relationShipListener = DisplayVideosFragment.this;
|
peertubeAdapater.relationShipListener = DisplayVideosFragment.this;
|
||||||
binding.lvVideos.setAdapter(peertubeAdapater);
|
binding.lvVideos.setAdapter(peertubeAdapater);
|
||||||
@ -432,11 +442,9 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
if (binding.lvVideos != null) {
|
try {
|
||||||
try {
|
binding.lvVideos.setAdapter(null);
|
||||||
binding.lvVideos.setAdapter(null);
|
} catch (Exception ignored) {
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ package app.fedilab.fedilabtube.helper;
|
|||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.client.data.CommentData;
|
import app.fedilab.fedilabtube.client.data.CommentData;
|
||||||
|
|
||||||
public class CommentDecorationHelper {
|
public class CommentDecorationHelper {
|
||||||
|
@ -77,10 +77,10 @@ import es.dmoral.toasty.Toasty;
|
|||||||
import jp.wasabeef.glide.transformations.BlurTransformation;
|
import jp.wasabeef.glide.transformations.BlurTransformation;
|
||||||
|
|
||||||
import static android.content.Context.DOWNLOAD_SERVICE;
|
import static android.content.Context.DOWNLOAD_SERVICE;
|
||||||
|
import static android.content.Context.MODE_PRIVATE;
|
||||||
|
|
||||||
public class Helper {
|
public class Helper {
|
||||||
|
|
||||||
public static PeertubeInformation peertubeInformation;
|
|
||||||
public static final int RELOAD_MYVIDEOS = 10;
|
public static final int RELOAD_MYVIDEOS = 10;
|
||||||
public static final String SET_VIDEO_MODE = "set_video_mode";
|
public static final String SET_VIDEO_MODE = "set_video_mode";
|
||||||
public static final String SET_QUALITY_MODE = "set_quality_mode";
|
public static final String SET_QUALITY_MODE = "set_quality_mode";
|
||||||
@ -103,16 +103,22 @@ public class Helper {
|
|||||||
public static final String SET_SHARE_DETAILS = "set_share_details";
|
public static final String SET_SHARE_DETAILS = "set_share_details";
|
||||||
public static final String NOTIFICATION_INTERVAL = "notification_interval";
|
public static final String NOTIFICATION_INTERVAL = "notification_interval";
|
||||||
public static final String LAST_NOTIFICATION_READ = "last_notification_read";
|
public static final String LAST_NOTIFICATION_READ = "last_notification_read";
|
||||||
|
public static final String REDIRECT_CONTENT_WEB = "tubelab://backtotubelab";
|
||||||
public static final int DEFAULT_VIDEO_CACHE_MB = 100;
|
public static final int DEFAULT_VIDEO_CACHE_MB = 100;
|
||||||
@SuppressWarnings({"unused", "RedundantSuppression"})
|
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||||
public static final String TAG = "mastodon_etalab";
|
public static final String TAG = "mastodon_etalab";
|
||||||
public static final String ID = "id";
|
public static final String ID = "id";
|
||||||
public static final String CLIENT_ID = "client_id";
|
public static final String CLIENT_ID = "client_id";
|
||||||
public static final String CLIENT_SECRET = "client_secret";
|
public static final String CLIENT_SECRET = "client_secret";
|
||||||
|
public static final String REDIRECT_URI = "redirect_uri";
|
||||||
public static final String WEBSITE_VALUE = "https://fedilab.app";
|
public static final String WEBSITE_VALUE = "https://fedilab.app";
|
||||||
public static final String CLIENT_NAME_VALUE = "TubeLab";
|
public static final String CLIENT_NAME_VALUE = "TubeLab";
|
||||||
public static final String OAUTH_SCOPES_PEERTUBE = "openid profile";
|
public static final String OAUTH_SCOPES_PEERTUBE = "openid profile";
|
||||||
|
public static final String OAUTH_SCOPES_MASTODON = "read write follow";
|
||||||
|
public static final String REDIRECT_CONTENT = "urn:ietf:wg:oauth:2.0:oob";
|
||||||
public static final String PREF_KEY_OAUTH_TOKEN = "oauth_token";
|
public static final String PREF_KEY_OAUTH_TOKEN = "oauth_token";
|
||||||
|
public static final String PREF_SOFTWARE = "pref_software";
|
||||||
|
public static final String PREF_REMOTE_INSTANCE = "pref_remote_instance";
|
||||||
public static final Pattern redirectPattern = Pattern.compile("externalAuthToken=(\\w+)&username=([\\w.-]+)");
|
public static final Pattern redirectPattern = Pattern.compile("externalAuthToken=(\\w+)&username=([\\w.-]+)");
|
||||||
public static final String SET_VIDEO_CACHE = "set_video_cache";
|
public static final String SET_VIDEO_CACHE = "set_video_cache";
|
||||||
public static final String RECEIVE_CAST_SETTINGS = "receive_cast_settings";
|
public static final String RECEIVE_CAST_SETTINGS = "receive_cast_settings";
|
||||||
@ -132,8 +138,7 @@ public class Helper {
|
|||||||
public static final int VIDEOS_PER_PAGE = 10;
|
public static final int VIDEOS_PER_PAGE = 10;
|
||||||
public static final String RECEIVE_ACTION = "receive_action";
|
public static final String RECEIVE_ACTION = "receive_action";
|
||||||
public static final String SET_UNFOLLOW_VALIDATION = "set_unfollow_validation";
|
public static final String SET_UNFOLLOW_VALIDATION = "set_unfollow_validation";
|
||||||
|
public static PeertubeInformation peertubeInformation;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a date in String -> format yyyy-MM-dd HH:mm:ss
|
* Convert a date in String -> format yyyy-MM-dd HH:mm:ss
|
||||||
@ -339,7 +344,7 @@ public class Helper {
|
|||||||
} else {
|
} else {
|
||||||
webView = rootView.findViewById(webviewId);
|
webView = rootView.findViewById(webviewId);
|
||||||
}
|
}
|
||||||
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
|
|
||||||
webView.getSettings().setJavaScriptEnabled(true);
|
webView.getSettings().setJavaScriptEnabled(true);
|
||||||
webView.getSettings().setUseWideViewPort(true);
|
webView.getSettings().setUseWideViewPort(true);
|
||||||
@ -418,7 +423,7 @@ public class Helper {
|
|||||||
* @param account Account
|
* @param account Account
|
||||||
*/
|
*/
|
||||||
public static void logoutCurrentUser(Activity activity, Account account) {
|
public static void logoutCurrentUser(Activity activity, Account account) {
|
||||||
SharedPreferences sharedpreferences = activity.getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = activity.getSharedPreferences(APP_PREFS, MODE_PRIVATE);
|
||||||
//Current user
|
//Current user
|
||||||
SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
|
|
||||||
@ -456,7 +461,7 @@ public class Helper {
|
|||||||
* @param activity Activity
|
* @param activity Activity
|
||||||
*/
|
*/
|
||||||
public static void logoutNoRemoval(Activity activity) {
|
public static void logoutNoRemoval(Activity activity) {
|
||||||
SharedPreferences sharedpreferences = activity.getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = activity.getSharedPreferences(APP_PREFS, MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(PREF_KEY_OAUTH_TOKEN, null);
|
editor.putString(PREF_KEY_OAUTH_TOKEN, null);
|
||||||
editor.putString(CLIENT_ID, null);
|
editor.putString(CLIENT_ID, null);
|
||||||
@ -484,11 +489,46 @@ public class Helper {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static boolean isLoggedIn(Context context) {
|
public static boolean isLoggedIn(Context context) {
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
return isLoggedInType(context) == MainActivity.TypeOfConnection.NORMAL;
|
||||||
String prefKeyOauthTokenT = sharedpreferences.getString(PREF_KEY_OAUTH_TOKEN, null);
|
|
||||||
return (prefKeyOauthTokenT != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some actions like following writing comment can be performed with remote accounts
|
||||||
|
*
|
||||||
|
* @param context Context
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static boolean canMakeAction(Context context) {
|
||||||
|
return (isLoggedInType(context) == MainActivity.TypeOfConnection.NORMAL || isLoggedInType(context) == MainActivity.TypeOfConnection.REMOTE_ACCOUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns boolean depending if the user is authenticated
|
||||||
|
*
|
||||||
|
* @param context Context
|
||||||
|
* @return MainActivity.TypeOfConnection
|
||||||
|
*/
|
||||||
|
public static MainActivity.TypeOfConnection isLoggedInType(Context context) {
|
||||||
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
|
String prefKeyOauthTokenT = sharedpreferences.getString(PREF_KEY_OAUTH_TOKEN, null);
|
||||||
|
String prefSoftware = sharedpreferences.getString(PREF_SOFTWARE, null);
|
||||||
|
if (prefKeyOauthTokenT != null && prefSoftware == null) {
|
||||||
|
return MainActivity.TypeOfConnection.NORMAL;
|
||||||
|
} else if (prefKeyOauthTokenT != null) {
|
||||||
|
return MainActivity.TypeOfConnection.REMOTE_ACCOUNT;
|
||||||
|
} else {
|
||||||
|
return MainActivity.TypeOfConnection.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getToken(Context context) {
|
||||||
|
if (isLoggedInType(context) == MainActivity.TypeOfConnection.NORMAL) {
|
||||||
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
|
return sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts dp to pixel
|
* Converts dp to pixel
|
||||||
@ -514,7 +554,7 @@ public class Helper {
|
|||||||
|
|
||||||
|
|
||||||
public static boolean isOwner(Context context, Account account) {
|
public static boolean isOwner(Context context, Account account) {
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
String userName = sharedpreferences.getString(Helper.PREF_KEY_NAME, "");
|
String userName = sharedpreferences.getString(Helper.PREF_KEY_NAME, "");
|
||||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, "");
|
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, "");
|
||||||
if (instance != null && userName != null) {
|
if (instance != null && userName != null) {
|
||||||
@ -525,7 +565,7 @@ public class Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isVideoOwner(Context context, VideoData.Video video) {
|
public static boolean isVideoOwner(Context context, VideoData.Video video) {
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
String userName = sharedpreferences.getString(Helper.PREF_KEY_NAME, "");
|
String userName = sharedpreferences.getString(Helper.PREF_KEY_NAME, "");
|
||||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, "");
|
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, "");
|
||||||
if (video == null) {
|
if (video == null) {
|
||||||
@ -552,7 +592,7 @@ public class Helper {
|
|||||||
if (files == null || files.size() == 0) {
|
if (files == null || files.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
int video_quality = sharedpreferences.getInt(Helper.SET_QUALITY_MODE, Helper.QUALITY_HIGH);
|
int video_quality = sharedpreferences.getInt(Helper.SET_QUALITY_MODE, Helper.QUALITY_HIGH);
|
||||||
if (video_quality == QUALITY_HIGH) {
|
if (video_quality == QUALITY_HIGH) {
|
||||||
return files.get(0);
|
return files.get(0);
|
||||||
@ -630,4 +670,25 @@ public class Helper {
|
|||||||
return String.format(Locale.getDefault(), "%s%s", df.format(rounded), context.getString(R.string.mb));
|
return String.format(Locale.getDefault(), "%s%s", df.format(rounded), context.getString(R.string.mb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String rateSize(Context context, long size) {
|
||||||
|
if (size > 1000000000) {
|
||||||
|
float rounded = (float) size / 1000000000;
|
||||||
|
DecimalFormat df = new DecimalFormat("#.#");
|
||||||
|
return String.format(Locale.getDefault(), "%s%s", df.format(rounded), context.getString(R.string.gb));
|
||||||
|
} else if (size > 1000000) {
|
||||||
|
float rounded = (float) size / 1000000;
|
||||||
|
DecimalFormat df = new DecimalFormat("#.#");
|
||||||
|
return String.format(Locale.getDefault(), "%s%s", df.format(rounded), context.getString(R.string.mb));
|
||||||
|
} else if (size > 1000) {
|
||||||
|
float rounded = (float) size / 1000000;
|
||||||
|
DecimalFormat df = new DecimalFormat("#.#");
|
||||||
|
return String.format(Locale.getDefault(), "%s%s", df.format(rounded), context.getString(R.string.kb));
|
||||||
|
} else {
|
||||||
|
float rounded = (float) size / 1000000;
|
||||||
|
DecimalFormat df = new DecimalFormat("#.#");
|
||||||
|
return String.format(Locale.getDefault(), "%s%s", df.format(rounded), context.getString(R.string.b));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,49 +14,25 @@ package app.fedilab.fedilabtube.helper;
|
|||||||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class HelperAcadInstance {
|
public class HelperAcadInstance {
|
||||||
|
|
||||||
|
|
||||||
//List of available academies
|
public static Map<String, String> instances_themes;
|
||||||
|
|
||||||
public static String[] openid = {
|
|
||||||
"ac-normandie.fr",
|
|
||||||
"education.fr",
|
|
||||||
"education.gouv.fr"
|
|
||||||
//TODO: remove this one used for tests
|
|
||||||
// "ac-orleans-tours.fr"
|
|
||||||
};
|
|
||||||
|
|
||||||
public static String[] academies = {
|
|
||||||
"ac-aix-marseille.fr",
|
|
||||||
"ac-amiens.fr",
|
|
||||||
"ac-besancon.fr",
|
|
||||||
"ac-bordeaux.fr",
|
|
||||||
"clermont-ferrand.fr",
|
|
||||||
"ac-corse.fr",
|
|
||||||
"ac-creteil.fr",
|
|
||||||
"ac-dijon.fr",
|
|
||||||
"ac-grenoble.fr",
|
|
||||||
"education.fr",
|
|
||||||
"ac-lille.fr",
|
|
||||||
"ac-limoges.fr",
|
|
||||||
"ac-lyon.fr",
|
|
||||||
"ac-mayotte.fr",
|
|
||||||
"ac-montpellier.fr",
|
|
||||||
"ac-nancy.fr",
|
|
||||||
"ac-nantes.fr",
|
|
||||||
"ac-normandie.fr",
|
|
||||||
"ac-orleans-tours.fr",
|
|
||||||
"ac-paris.fr",
|
|
||||||
"ac-poitiers.fr",
|
|
||||||
"outremer.fr",
|
|
||||||
"ac-rennes.fr",
|
|
||||||
"ac-strasbourg.fr",
|
|
||||||
"ac-toulouse.fr",
|
|
||||||
"ac-versailles.fr"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
public static String LOCAL = "LOCALES";
|
||||||
|
public static String DISCOVER = "DECOUVRIR";
|
||||||
|
public static String MOSTLIKED = "PLUS_APPRECIEES";
|
||||||
|
public static String RECENTLY_ADDED = "AJOUTE_RECEMMENT";
|
||||||
|
public static String TRENDING = "TENDANCE";
|
||||||
|
public static String HISTORY = "HISTORIQUE";
|
||||||
|
public static String SUBSCRIPTIONS = "ABONNEMENTS";
|
||||||
|
public static String MYVIDEOS = "VIDEOS";
|
||||||
|
|
||||||
|
//List of available emails
|
||||||
public static String[] valideEmails = {
|
public static String[] valideEmails = {
|
||||||
"ac-aix-marseille.fr",
|
"ac-aix-marseille.fr",
|
||||||
"ac-amiens.fr",
|
"ac-amiens.fr",
|
||||||
@ -95,4 +71,20 @@ public class HelperAcadInstance {
|
|||||||
"igesr.gouv.fr"
|
"igesr.gouv.fr"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static {
|
||||||
|
Map<String, String> is = new LinkedHashMap<>();
|
||||||
|
is.put("Normandie", "tube-normandie.beta.education.fr");
|
||||||
|
is.put("Enseignement professionnel", "tube-enseignement-professionnel.apps.education.fr");
|
||||||
|
is.put("Action éducative", "tube-action-educative.apps.education.fr");
|
||||||
|
is.put("Numérique éducatif", "tube-numerique-educatif.apps.education.fr");
|
||||||
|
is.put("Institutionnel", "tube-institutionnelle.apps.education.fr");
|
||||||
|
is.put("2d - langues vivantes", "tube-2d-langues-vivantes.apps.education.fr");
|
||||||
|
is.put("2d - éducation physique et sportive", "tube-2d-education-physique-et-sportive.apps.education.fr");
|
||||||
|
is.put("2d - arts, lettres et sciences humaines", "tube-2d-arts-lettres-sciences-humaines.apps.education.fr");
|
||||||
|
is.put("Maternelle", "tube-maternelle.apps.education.fr");
|
||||||
|
is.put("Cycle 2", "tube-cycle-2.apps.education.fr");
|
||||||
|
is.put("Cycle 3", "tube-cycle-3.apps.education.fr");
|
||||||
|
instances_themes = Collections.unmodifiableMap(is);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,40 +23,6 @@ import app.fedilab.fedilabtube.BuildConfig;
|
|||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
public class HelperInstance {
|
public class HelperInstance {
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the peertube URL depending of the academic domain name
|
|
||||||
*
|
|
||||||
* @param acad String academic domain name
|
|
||||||
* @return String the peertube URL
|
|
||||||
*/
|
|
||||||
public static String getPeertubeUrl(String acad) {
|
|
||||||
|
|
||||||
if (BuildConfig.full_instances) {
|
|
||||||
return acad;
|
|
||||||
}
|
|
||||||
if (acad.compareTo("education.gouv.fr") == 0 || acad.compareTo("igesr.gouv.fr") == 0) {
|
|
||||||
acad = "education.fr";
|
|
||||||
} else if (acad.compareTo("ac-nancy-metz.fr") == 0) {
|
|
||||||
acad = "ac-nancy.fr";
|
|
||||||
} else if (acad.compareTo("clermont.fr") == 0) {
|
|
||||||
acad = "clermont-ferrand.fr";
|
|
||||||
} else if (acad.compareTo("ac-wf.wf") == 0 || acad.compareTo("ac-mayotte.fr") == 0 || acad.compareTo("ac-noumea.nc") == 0
|
|
||||||
|| acad.compareTo("ac-guadeloupe.fr") == 0 || acad.compareTo("monvr.pf") == 0 || acad.compareTo("ac-reunion.fr") == 0 ||
|
|
||||||
acad.compareTo("ac-martinique.fr") == 0 || acad.compareTo("ac-guyane.fr") == 0
|
|
||||||
) {
|
|
||||||
acad = "outremer.fr";
|
|
||||||
}
|
|
||||||
if (!acad.contains("ac-lyon.fr")) {
|
|
||||||
//TODO: remove hack for test with openid
|
|
||||||
/*if( acad.contains("orleans-tours.fr")) {
|
|
||||||
return "tube-normandie.beta.education.fr";
|
|
||||||
}*/
|
|
||||||
return "tube-" + acad.replaceAll("ac-|\\.fr", "") + ".beta.education.fr";
|
|
||||||
} else {
|
|
||||||
return "tube.ac-lyon.fr";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the instance of the authenticated user
|
* Returns the instance of the authenticated user
|
||||||
@ -75,15 +41,11 @@ public class HelperInstance {
|
|||||||
} else if (BuildConfig.FLAVOR.compareTo("queermotion") == 0) {
|
} else if (BuildConfig.FLAVOR.compareTo("queermotion") == 0) {
|
||||||
return sharedpreferences.getString(Helper.PREF_INSTANCE, "queermotion.org");
|
return sharedpreferences.getString(Helper.PREF_INSTANCE, "queermotion.org");
|
||||||
} else {
|
} else {
|
||||||
acad = sharedpreferences.getString(Helper.PREF_INSTANCE, "tube.ac-lyon.fr");
|
acad = sharedpreferences.getString(Helper.PREF_INSTANCE, "tube-institutionnelle.apps.education.fr");
|
||||||
if (acad == null) {
|
if (acad == null) {
|
||||||
acad = "tube.ac-lyon.fr";
|
acad = "tube-institutionnelle.apps.education.fr";
|
||||||
}
|
|
||||||
if (acad.startsWith("tube-")) {
|
|
||||||
return acad;
|
|
||||||
} else {
|
|
||||||
return getPeertubeUrl(acad);
|
|
||||||
}
|
}
|
||||||
|
return acad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,9 +53,14 @@ public class SwitchAccountHelper {
|
|||||||
builderSingle.setAdapter(accountsListAdapter, (dialog, which) -> {
|
builderSingle.setAdapter(accountsListAdapter, (dialog, which) -> {
|
||||||
final AccountData.Account account = accountArray[which];
|
final AccountData.Account account = accountArray[which];
|
||||||
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
|
boolean remote_account = account.getSoftware() != null && account.getSoftware().toUpperCase().trim().compareTo("PEERTUBE") != 0;
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, account.getToken());
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, account.getToken());
|
||||||
editor.putString(Helper.PREF_INSTANCE, account.getHost());
|
editor.putString(Helper.PREF_SOFTWARE, remote_account ? account.getSoftware() : null);
|
||||||
|
editor.putString(Helper.PREF_REMOTE_INSTANCE, remote_account ? account.getHost() : null);
|
||||||
|
if (!remote_account) {
|
||||||
|
editor.putString(Helper.PREF_INSTANCE, account.getHost());
|
||||||
|
}
|
||||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||||
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
@ -51,7 +51,7 @@ public class AccountDAO {
|
|||||||
* @param account Account
|
* @param account Account
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public boolean insertAccount(Account account) {
|
public boolean insertAccount(Account account, String software) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
if (account.getCreatedAt() == null)
|
if (account.getCreatedAt() == null)
|
||||||
account.setCreatedAt(new Date());
|
account.setCreatedAt(new Date());
|
||||||
@ -74,6 +74,9 @@ public class AccountDAO {
|
|||||||
values.put(Sqlite.COL_AVATAR_STATIC, "");
|
values.put(Sqlite.COL_AVATAR_STATIC, "");
|
||||||
values.put(Sqlite.COL_HEADER, "");
|
values.put(Sqlite.COL_HEADER, "");
|
||||||
values.put(Sqlite.COL_HEADER_STATIC, "");
|
values.put(Sqlite.COL_HEADER_STATIC, "");
|
||||||
|
if (software != null && software.toUpperCase().trim().compareTo("PEERTUBE") != 0) {
|
||||||
|
values.put(Sqlite.COL_SOFTWARE, software.toUpperCase().trim());
|
||||||
|
}
|
||||||
if (account.getClient_id() != null && account.getClient_secret() != null) {
|
if (account.getClient_id() != null && account.getClient_secret() != null) {
|
||||||
values.put(Sqlite.COL_CLIENT_ID, account.getClient_id());
|
values.put(Sqlite.COL_CLIENT_ID, account.getClient_id());
|
||||||
values.put(Sqlite.COL_CLIENT_SECRET, account.getClient_secret());
|
values.put(Sqlite.COL_CLIENT_SECRET, account.getClient_secret());
|
||||||
@ -233,6 +236,23 @@ public class AccountDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all Peertube Account only in db
|
||||||
|
*
|
||||||
|
* @return Account List<Account>
|
||||||
|
*/
|
||||||
|
public List<Account> getAllPeertubeAccount() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
Cursor c = db.query(Sqlite.TABLE_USER_ACCOUNT, null, Sqlite.COL_SOFTWARE + "=? OR " + Sqlite.COL_SOFTWARE + "is null", new String[]{"PEERTUBE"}, null, null, Sqlite.COL_INSTANCE + " ASC", null);
|
||||||
|
return cursorToListUser(c);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Account by token
|
* Returns an Account by token
|
||||||
*
|
*
|
||||||
@ -314,6 +334,7 @@ public class AccountDAO {
|
|||||||
account.setCreatedAt(Helper.stringToDate(context, c.getString(c.getColumnIndex(Sqlite.COL_CREATED_AT))));
|
account.setCreatedAt(Helper.stringToDate(context, c.getString(c.getColumnIndex(Sqlite.COL_CREATED_AT))));
|
||||||
account.setHost(c.getString(c.getColumnIndex(Sqlite.COL_INSTANCE)));
|
account.setHost(c.getString(c.getColumnIndex(Sqlite.COL_INSTANCE)));
|
||||||
account.setToken(c.getString(c.getColumnIndex(Sqlite.COL_OAUTHTOKEN)));
|
account.setToken(c.getString(c.getColumnIndex(Sqlite.COL_OAUTHTOKEN)));
|
||||||
|
account.setSoftware(c.getString(c.getColumnIndex(Sqlite.COL_SOFTWARE)));
|
||||||
account.setClient_id(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_ID)));
|
account.setClient_id(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_ID)));
|
||||||
account.setClient_secret(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_SECRET)));
|
account.setClient_secret(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_SECRET)));
|
||||||
account.setRefresh_token(c.getString(c.getColumnIndex(Sqlite.COL_REFRESH_TOKEN)));
|
account.setRefresh_token(c.getString(c.getColumnIndex(Sqlite.COL_REFRESH_TOKEN)));
|
||||||
@ -354,6 +375,7 @@ public class AccountDAO {
|
|||||||
account.setCreatedAt(Helper.stringToDate(context, c.getString(c.getColumnIndex(Sqlite.COL_CREATED_AT))));
|
account.setCreatedAt(Helper.stringToDate(context, c.getString(c.getColumnIndex(Sqlite.COL_CREATED_AT))));
|
||||||
account.setHost(c.getString(c.getColumnIndex(Sqlite.COL_INSTANCE)));
|
account.setHost(c.getString(c.getColumnIndex(Sqlite.COL_INSTANCE)));
|
||||||
account.setToken(c.getString(c.getColumnIndex(Sqlite.COL_OAUTHTOKEN)));
|
account.setToken(c.getString(c.getColumnIndex(Sqlite.COL_OAUTHTOKEN)));
|
||||||
|
account.setSoftware(c.getString(c.getColumnIndex(Sqlite.COL_SOFTWARE)));
|
||||||
account.setClient_id(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_ID)));
|
account.setClient_id(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_ID)));
|
||||||
account.setClient_secret(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_SECRET)));
|
account.setClient_secret(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_SECRET)));
|
||||||
account.setRefresh_token(c.getString(c.getColumnIndex(Sqlite.COL_REFRESH_TOKEN)));
|
account.setRefresh_token(c.getString(c.getColumnIndex(Sqlite.COL_REFRESH_TOKEN)));
|
||||||
|
@ -0,0 +1,222 @@
|
|||||||
|
package app.fedilab.fedilabtube.sqlite;
|
||||||
|
/* Copyright 2020 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.client.mastodon.MastodonAccount.Account;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.Token;
|
||||||
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
|
import app.fedilab.fedilabtube.helper.HelperInstance;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
|
public class MastodonAccountDAO {
|
||||||
|
|
||||||
|
private final SQLiteDatabase db;
|
||||||
|
public Context context;
|
||||||
|
|
||||||
|
|
||||||
|
public MastodonAccountDAO(Context context, SQLiteDatabase db) {
|
||||||
|
//Creation of the DB with tables
|
||||||
|
this.context = context;
|
||||||
|
this.db = db;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert an Account in database
|
||||||
|
*
|
||||||
|
* @param account Account
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean insertAccount(Account account) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
if (account.getCreatedAt() == null)
|
||||||
|
account.setCreatedAt(new Date());
|
||||||
|
if (account.getDescription() == null)
|
||||||
|
account.setDescription("");
|
||||||
|
values.put(Sqlite.COL_USER_ID, account.getId());
|
||||||
|
values.put(Sqlite.COL_USERNAME, account.getUsername());
|
||||||
|
values.put(Sqlite.COL_ACCT, account.getUsername() + "@" + account.getHost());
|
||||||
|
values.put(Sqlite.COL_DISPLAYED_NAME, account.getDisplayName() != null ? account.getDisplayName() : account.getUsername());
|
||||||
|
values.put(Sqlite.COL_FOLLOWERS_COUNT, account.getFollowersCount());
|
||||||
|
values.put(Sqlite.COL_FOLLOWING_COUNT, account.getFollowingCount());
|
||||||
|
values.put(Sqlite.COL_NOTE, account.getDescription());
|
||||||
|
values.put(Sqlite.COL_URL, account.getUrl());
|
||||||
|
values.put(Sqlite.COL_AVATAR, account.getAvatar());
|
||||||
|
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(account.getCreatedAt()));
|
||||||
|
values.put(Sqlite.COL_INSTANCE, account.getHost());
|
||||||
|
values.put(Sqlite.COL_LOCKED, false);
|
||||||
|
values.put(Sqlite.COL_STATUSES_COUNT, 0);
|
||||||
|
values.put(Sqlite.COL_URL, "");
|
||||||
|
values.put(Sqlite.COL_AVATAR_STATIC, "");
|
||||||
|
values.put(Sqlite.COL_HEADER, "");
|
||||||
|
values.put(Sqlite.COL_HEADER_STATIC, "");
|
||||||
|
if (account.getSoftware() != null && account.getSoftware().toUpperCase().trim().compareTo("PEERTUBE") != 0) {
|
||||||
|
values.put(Sqlite.COL_SOFTWARE, account.getSoftware().toUpperCase().trim());
|
||||||
|
}
|
||||||
|
if (account.getClient_id() != null && account.getClient_secret() != null) {
|
||||||
|
values.put(Sqlite.COL_CLIENT_ID, account.getClient_id());
|
||||||
|
values.put(Sqlite.COL_CLIENT_SECRET, account.getClient_secret());
|
||||||
|
}
|
||||||
|
if (account.getRefresh_token() != null) {
|
||||||
|
values.put(Sqlite.COL_REFRESH_TOKEN, account.getRefresh_token());
|
||||||
|
}
|
||||||
|
if (account.getToken() != null)
|
||||||
|
values.put(Sqlite.COL_OAUTHTOKEN, account.getToken());
|
||||||
|
|
||||||
|
//Inserts account
|
||||||
|
try {
|
||||||
|
db.insertOrThrow(Sqlite.TABLE_USER_ACCOUNT, null, values);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an Account in database
|
||||||
|
*
|
||||||
|
* @param account Account
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public int updateAccount(Account account) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
if (account.getCreatedAt() == null)
|
||||||
|
account.setCreatedAt(new Date());
|
||||||
|
if (account.getDescription() == null)
|
||||||
|
account.setDescription("");
|
||||||
|
values.put(Sqlite.COL_USER_ID, account.getId());
|
||||||
|
values.put(Sqlite.COL_USERNAME, account.getUsername());
|
||||||
|
values.put(Sqlite.COL_ACCT, account.getUsername() + "@" + account.getHost());
|
||||||
|
values.put(Sqlite.COL_DISPLAYED_NAME, account.getDisplayName());
|
||||||
|
values.put(Sqlite.COL_FOLLOWERS_COUNT, account.getFollowersCount());
|
||||||
|
values.put(Sqlite.COL_FOLLOWING_COUNT, account.getFollowingCount());
|
||||||
|
values.put(Sqlite.COL_NOTE, account.getDescription());
|
||||||
|
values.put(Sqlite.COL_URL, account.getUrl());
|
||||||
|
values.put(Sqlite.COL_AVATAR, account.getAvatar());
|
||||||
|
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(account.getCreatedAt()));
|
||||||
|
|
||||||
|
try {
|
||||||
|
return db.update(Sqlite.TABLE_USER_ACCOUNT,
|
||||||
|
values, Sqlite.COL_USERNAME + " = ? AND " + Sqlite.COL_INSTANCE + " =?",
|
||||||
|
new String[]{account.getUsername(), account.getHost()});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an Account token in database
|
||||||
|
*
|
||||||
|
* @param token Token
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public int updateAccountToken(Token token) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
if (token.getRefresh_token() != null) {
|
||||||
|
values.put(Sqlite.COL_REFRESH_TOKEN, token.getRefresh_token());
|
||||||
|
}
|
||||||
|
if (token.getAccess_token() != null)
|
||||||
|
values.put(Sqlite.COL_OAUTHTOKEN, token.getAccess_token());
|
||||||
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
|
String instance = HelperInstance.getLiveInstance(context);
|
||||||
|
try {
|
||||||
|
return db.update(Sqlite.TABLE_USER_ACCOUNT,
|
||||||
|
values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =?",
|
||||||
|
new String[]{userId, instance});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an Account in database
|
||||||
|
*
|
||||||
|
* @param account Account
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public int updateAccountCredential(Account account) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
if (account.getCreatedAt() == null)
|
||||||
|
account.setCreatedAt(new Date());
|
||||||
|
if (account.getDescription() == null)
|
||||||
|
account.setDescription("");
|
||||||
|
values.put(Sqlite.COL_USERNAME, account.getUsername());
|
||||||
|
values.put(Sqlite.COL_ACCT, account.getUsername() + "@" + account.getHost());
|
||||||
|
values.put(Sqlite.COL_DISPLAYED_NAME, account.getDisplayName());
|
||||||
|
values.put(Sqlite.COL_FOLLOWERS_COUNT, account.getFollowersCount());
|
||||||
|
values.put(Sqlite.COL_FOLLOWING_COUNT, account.getFollowingCount());
|
||||||
|
values.put(Sqlite.COL_NOTE, account.getDescription());
|
||||||
|
values.put(Sqlite.COL_URL, account.getUrl());
|
||||||
|
values.put(Sqlite.COL_AVATAR, account.getAvatar());
|
||||||
|
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(account.getCreatedAt()));
|
||||||
|
|
||||||
|
if (account.getClient_id() != null && account.getClient_secret() != null) {
|
||||||
|
values.put(Sqlite.COL_CLIENT_ID, account.getClient_id());
|
||||||
|
values.put(Sqlite.COL_CLIENT_SECRET, account.getClient_secret());
|
||||||
|
}
|
||||||
|
if (account.getRefresh_token() != null) {
|
||||||
|
values.put(Sqlite.COL_REFRESH_TOKEN, account.getRefresh_token());
|
||||||
|
}
|
||||||
|
if (account.getToken() != null)
|
||||||
|
values.put(Sqlite.COL_OAUTHTOKEN, account.getToken());
|
||||||
|
return db.update(Sqlite.TABLE_USER_ACCOUNT,
|
||||||
|
values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =?",
|
||||||
|
new String[]{account.getId(), account.getHost()});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int removeUser(Account account) {
|
||||||
|
return db.delete(Sqlite.TABLE_USER_ACCOUNT, Sqlite.COL_USER_ID + " = '" + account.getId() +
|
||||||
|
"' AND " + Sqlite.COL_INSTANCE + " = '" + account.getHost() + "'", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if the current user is already stored in data base
|
||||||
|
*
|
||||||
|
* @param account Account
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean userExist(Account account) {
|
||||||
|
Cursor mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_USER_ACCOUNT
|
||||||
|
+ " where " + Sqlite.COL_USERNAME + " = '" + account.getUsername() + "' AND " + Sqlite.COL_INSTANCE + " = '" + account.getHost() + "'", null);
|
||||||
|
mCount.moveToFirst();
|
||||||
|
int count = mCount.getInt(0);
|
||||||
|
mCount.close();
|
||||||
|
return (count > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -15,13 +15,19 @@ package app.fedilab.fedilabtube.sqlite;
|
|||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class Sqlite extends SQLiteOpenHelper {
|
public class Sqlite extends SQLiteOpenHelper {
|
||||||
|
|
||||||
public static final int DB_VERSION = 3;
|
public static final int DB_VERSION = 4;
|
||||||
public static final String DB_NAME = "mastodon_etalab_db";
|
public static final String DB_NAME = "mastodon_etalab_db";
|
||||||
/***
|
/***
|
||||||
* List of tables to manage users and data
|
* List of tables to manage users and data
|
||||||
@ -67,6 +73,7 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||||||
static final String TABLE_VIDEOS = "VIDEOS";
|
static final String TABLE_VIDEOS = "VIDEOS";
|
||||||
static final String COL_VIDEO_DATA = "VIDEO_DATA";
|
static final String COL_VIDEO_DATA = "VIDEO_DATA";
|
||||||
static final String COL_PLAYLIST_ID = "PLAYLIST_ID";
|
static final String COL_PLAYLIST_ID = "PLAYLIST_ID";
|
||||||
|
static final String COL_SOFTWARE = "SOFTWARE";
|
||||||
private static final String CREATE_TABLE_USER_ACCOUNT = "CREATE TABLE " + TABLE_USER_ACCOUNT + " ("
|
private static final String CREATE_TABLE_USER_ACCOUNT = "CREATE TABLE " + TABLE_USER_ACCOUNT + " ("
|
||||||
+ COL_USER_ID + " TEXT, " + COL_USERNAME + " TEXT NOT NULL, " + COL_ACCT + " TEXT NOT NULL, "
|
+ COL_USER_ID + " TEXT, " + COL_USERNAME + " TEXT NOT NULL, " + COL_ACCT + " TEXT NOT NULL, "
|
||||||
+ COL_DISPLAYED_NAME + " TEXT NOT NULL, " + COL_LOCKED + " INTEGER NOT NULL, "
|
+ COL_DISPLAYED_NAME + " TEXT NOT NULL, " + COL_LOCKED + " INTEGER NOT NULL, "
|
||||||
@ -79,8 +86,11 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||||||
+ COL_CLIENT_ID + " TEXT, " + COL_CLIENT_SECRET + " TEXT, " + COL_REFRESH_TOKEN + " TEXT,"
|
+ COL_CLIENT_ID + " TEXT, " + COL_CLIENT_SECRET + " TEXT, " + COL_REFRESH_TOKEN + " TEXT,"
|
||||||
+ COL_UPDATED_AT + " TEXT, "
|
+ COL_UPDATED_AT + " TEXT, "
|
||||||
+ COL_PRIVACY + " TEXT, "
|
+ COL_PRIVACY + " TEXT, "
|
||||||
|
+ COL_SOFTWARE + " TEXT NOT NULL DEFAULT \"PEERTUBE\", "
|
||||||
+ COL_SENSITIVE + " INTEGER DEFAULT 0, "
|
+ COL_SENSITIVE + " INTEGER DEFAULT 0, "
|
||||||
+ COL_INSTANCE + " TEXT NOT NULL, " + COL_OAUTHTOKEN + " TEXT NOT NULL, " + COL_CREATED_AT + " TEXT NOT NULL)";
|
+ COL_INSTANCE + " TEXT NOT NULL, " + COL_OAUTHTOKEN + " TEXT NOT NULL, " + COL_CREATED_AT + " TEXT NOT NULL)";
|
||||||
|
|
||||||
|
|
||||||
public static SQLiteDatabase db;
|
public static SQLiteDatabase db;
|
||||||
private static Sqlite sInstance;
|
private static Sqlite sInstance;
|
||||||
private final String CREATE_TABLE_PEERTUBE_FAVOURITES = "CREATE TABLE "
|
private final String CREATE_TABLE_PEERTUBE_FAVOURITES = "CREATE TABLE "
|
||||||
@ -136,15 +146,44 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||||||
@Override
|
@Override
|
||||||
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
switch (oldVersion) {
|
switch (oldVersion) {
|
||||||
|
case 4:
|
||||||
|
dropColumn(TABLE_USER_ACCOUNT, new String[]{COL_SOFTWARE});
|
||||||
case 3:
|
case 3:
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_VIDEOS);
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_VIDEOS);
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOCAL_PLAYLISTS);
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOCAL_PLAYLISTS);
|
||||||
case 2:
|
case 2:
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_BOOKMARKED_INSTANCES);
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_BOOKMARKED_INSTANCES);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
private void dropColumn(
|
||||||
|
String tableName,
|
||||||
|
String[] colsToRemove) {
|
||||||
|
List<String> updatedTableColumns = getTableColumns(tableName);
|
||||||
|
// Remove the columns we don't want anymore from the table's list of columns
|
||||||
|
updatedTableColumns.removeAll(Arrays.asList(colsToRemove));
|
||||||
|
String columnsSeperated = TextUtils.join(",", updatedTableColumns);
|
||||||
|
db.execSQL("ALTER TABLE " + tableName + " RENAME TO " + tableName + "_old;");
|
||||||
|
// Creating the table on its new format (no redundant columns)
|
||||||
|
db.execSQL("CREATE TABLE " + tableName);
|
||||||
|
// Populating the table with the data
|
||||||
|
db.execSQL("INSERT INTO " + tableName + "(" + columnsSeperated + ") SELECT "
|
||||||
|
+ columnsSeperated + " FROM " + tableName + "_old;");
|
||||||
|
db.execSQL("DROP TABLE " + tableName + "_old;");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getTableColumns(String tableName) {
|
||||||
|
ArrayList<String> columns = new ArrayList<>();
|
||||||
|
String cmd = "pragma table_info(" + tableName + ");";
|
||||||
|
Cursor cur = db.rawQuery(cmd, null);
|
||||||
|
while (cur.moveToNext()) {
|
||||||
|
columns.add(cur.getString(cur.getColumnIndex("name")));
|
||||||
|
}
|
||||||
|
cur.close();
|
||||||
|
return columns;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
switch (oldVersion) {
|
switch (oldVersion) {
|
||||||
@ -153,6 +192,8 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||||||
case 2:
|
case 2:
|
||||||
db.execSQL(CREATE_TABLE_LOCAL_PLAYLISTS);
|
db.execSQL(CREATE_TABLE_LOCAL_PLAYLISTS);
|
||||||
db.execSQL(CREATE_TABLE_VIDEOS);
|
db.execSQL(CREATE_TABLE_VIDEOS);
|
||||||
|
case 3:
|
||||||
|
db.execSQL("ALTER TABLE " + TABLE_USER_ACCOUNT + " ADD COLUMN " + COL_SOFTWARE + " TEXT NOT NULL DEFAULT \"PEERTUBE\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,12 @@ public class AccountsVM extends AndroidViewModel {
|
|||||||
Context _mContext = getApplication().getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
RetrofitPeertubeAPI retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
RetrofitPeertubeAPI retrofitPeertubeAPI;
|
||||||
|
if (acct.split("@").length > 1) {
|
||||||
|
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, acct.split("@")[1], null);
|
||||||
|
} else {
|
||||||
|
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
||||||
|
}
|
||||||
APIResponse apiResponse = retrofitPeertubeAPI.getAccount(acct);
|
APIResponse apiResponse = retrofitPeertubeAPI.getAccount(acct);
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
||||||
|
@ -26,6 +26,7 @@ import androidx.lifecycle.AndroidViewModel;
|
|||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.AccountActivity;
|
||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||||
import app.fedilab.fedilabtube.client.data.AccountData;
|
import app.fedilab.fedilabtube.client.data.AccountData;
|
||||||
@ -63,7 +64,7 @@ public class ChannelsVM extends AndroidViewModel {
|
|||||||
if (type == RetrofitPeertubeAPI.DataType.MY_CHANNELS) {
|
if (type == RetrofitPeertubeAPI.DataType.MY_CHANNELS) {
|
||||||
SharedPreferences sharedpreferences = _mContext.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
SharedPreferences sharedpreferences = _mContext.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
SQLiteDatabase db = Sqlite.getInstance(_mContext.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(_mContext.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
String token = Helper.getToken(_mContext);
|
||||||
AccountData.Account account = new AccountDAO(_mContext, db).getAccountByToken(token);
|
AccountData.Account account = new AccountDAO(_mContext, db).getAccountByToken(token);
|
||||||
finalElement = account.getUsername() + "@" + account.getHost();
|
finalElement = account.getUsername() + "@" + account.getHost();
|
||||||
}
|
}
|
||||||
|
@ -97,8 +97,7 @@ public class PlaylistsVM extends AndroidViewModel {
|
|||||||
Context _mContext = getApplication().getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
SharedPreferences sharedpreferences = _mContext.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
String token = Helper.getToken(_mContext);
|
||||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
|
||||||
SQLiteDatabase db = Sqlite.getInstance(_mContext.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(_mContext.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
Account account = new AccountDAO(_mContext, db).getAccountByToken(token);
|
Account account = new AccountDAO(_mContext, db).getAccountByToken(token);
|
||||||
int statusCode = -1;
|
int statusCode = -1;
|
||||||
|
@ -0,0 +1,116 @@
|
|||||||
|
package app.fedilab.fedilabtube.viewmodel.mastodon;
|
||||||
|
/* Copyright 2021 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.client.entities.Error;
|
||||||
|
import app.fedilab.fedilabtube.client.mastodon.RetrofitMastodonAPI;
|
||||||
|
import app.fedilab.fedilabtube.client.mastodon.Status;
|
||||||
|
|
||||||
|
|
||||||
|
public class MastodonPostActionsVM extends AndroidViewModel {
|
||||||
|
private MutableLiveData<Status> statusMutableLiveData;
|
||||||
|
|
||||||
|
public MastodonPostActionsVM(@NonNull Application application) {
|
||||||
|
super(application);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public LiveData<Status> post(RetrofitMastodonAPI.actionType type, Status status) {
|
||||||
|
statusMutableLiveData = new MutableLiveData<>();
|
||||||
|
postAction(type, status);
|
||||||
|
return statusMutableLiveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<Status> comment(String url, String content) {
|
||||||
|
statusMutableLiveData = new MutableLiveData<>();
|
||||||
|
postComment(url, content);
|
||||||
|
return statusMutableLiveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<Status> searchRemoteStatus(String url) {
|
||||||
|
statusMutableLiveData = new MutableLiveData<>();
|
||||||
|
search(url);
|
||||||
|
return statusMutableLiveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void search(String videoURL) {
|
||||||
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
RetrofitMastodonAPI mastodonAPI = new RetrofitMastodonAPI(_mContext);
|
||||||
|
Status status = null;
|
||||||
|
try {
|
||||||
|
status = mastodonAPI.search(videoURL);
|
||||||
|
} catch (Error error) {
|
||||||
|
error.printStackTrace();
|
||||||
|
}
|
||||||
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
Status finalStatus = status;
|
||||||
|
Runnable myRunnable = () -> statusMutableLiveData.setValue(finalStatus);
|
||||||
|
mainHandler.post(myRunnable);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void postComment(String videoURL, String content) {
|
||||||
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
RetrofitMastodonAPI mastodonAPI = new RetrofitMastodonAPI(_mContext);
|
||||||
|
Status status = null;
|
||||||
|
try {
|
||||||
|
status = mastodonAPI.commentAction(videoURL, content);
|
||||||
|
} catch (Error error) {
|
||||||
|
error.printStackTrace();
|
||||||
|
}
|
||||||
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
Status finalStatus = status;
|
||||||
|
Runnable myRunnable = () -> statusMutableLiveData.setValue(finalStatus);
|
||||||
|
mainHandler.post(myRunnable);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void postAction(RetrofitMastodonAPI.actionType type, Status status) {
|
||||||
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
RetrofitMastodonAPI mastodonAPI = new RetrofitMastodonAPI(_mContext);
|
||||||
|
Status statusReply = mastodonAPI.postAction(type, status);
|
||||||
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
Runnable myRunnable = () -> statusMutableLiveData.setValue(statusReply);
|
||||||
|
mainHandler.post(myRunnable);
|
||||||
|
} catch (Exception | Error e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -79,7 +79,7 @@ public class NotificationsWorker extends Worker {
|
|||||||
public Result doWork() {
|
public Result doWork() {
|
||||||
Context applicationContext = getApplicationContext();
|
Context applicationContext = getApplicationContext();
|
||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
List<AccountData.Account> accounts = new AccountDAO(applicationContext, db).getAllAccount();
|
List<AccountData.Account> accounts = new AccountDAO(applicationContext, db).getAllPeertubeAccount();
|
||||||
if (accounts == null || accounts.size() == 0) {
|
if (accounts == null || accounts.size() == 0) {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ public class NotificationsWorker extends Worker {
|
|||||||
@SuppressWarnings({"SwitchStatementWithoutDefaultBranch", "DuplicateBranchesInSwitch"})
|
@SuppressWarnings({"SwitchStatementWithoutDefaultBranch", "DuplicateBranchesInSwitch"})
|
||||||
private void fetchNotification() {
|
private void fetchNotification() {
|
||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
List<AccountData.Account> accounts = new AccountDAO(getApplicationContext(), db).getAllAccount();
|
List<AccountData.Account> accounts = new AccountDAO(getApplicationContext(), db).getAllPeertubeAccount();
|
||||||
SharedPreferences sharedpreferences = getApplicationContext().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getApplicationContext().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
for (AccountData.Account account : accounts) {
|
for (AccountData.Account account : accounts) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="24dp"
|
android:width="24dp"
|
||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
android:tint="?attr/colorControlNormal"
|
|
||||||
android:viewportWidth="24"
|
android:viewportWidth="24"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
android:viewportHeight="24">
|
android:viewportHeight="24">
|
||||||
<path
|
<path
|
||||||
android:fillColor="@android:color/white"
|
android:fillColor="@android:color/white"
|
||||||
|
10
app/src/main/res/drawable/ic_baseline_repeat_24.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M7,7h10v3l4,-4 -4,-4v3L5,5v6h2L7,7zM17,17L7,17v-3l-4,4 4,4v-3h12v-6h-2v4z" />
|
||||||
|
</vector>
|
10
app/src/main/res/drawable/ic_baseline_star_24.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z" />
|
||||||
|
</vector>
|
15
app/src/main/res/drawable/rounded_live.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/red_1" />
|
||||||
|
|
||||||
|
<solid android:color="@color/red_1" />
|
||||||
|
|
||||||
|
<padding
|
||||||
|
android:bottom="1dp"
|
||||||
|
android:left="1dp"
|
||||||
|
android:right="1dp"
|
||||||
|
android:top="1dp" />
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
</shape>
|
@ -159,6 +159,16 @@
|
|||||||
app:tabTextColor="@android:color/white" />
|
app:tabTextColor="@android:color/white" />
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/remote_account"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_margin="20dp"
|
||||||
|
android:autoLink="web"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<androidx.viewpager.widget.ViewPager
|
<androidx.viewpager.widget.ViewPager
|
||||||
android:id="@+id/account_viewpager"
|
android:id="@+id/account_viewpager"
|
||||||
@ -175,5 +185,6 @@
|
|||||||
android:layout_margin="@dimen/fab_margin_button"
|
android:layout_margin="@dimen/fab_margin_button"
|
||||||
android:src="@drawable/ic_baseline_add_24"
|
android:src="@drawable/ic_baseline_add_24"
|
||||||
android:tint="@android:color/white"
|
android:tint="@android:color/white"
|
||||||
android:visibility="gone" />
|
android:visibility="gone"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
@ -120,6 +120,36 @@
|
|||||||
android:importantForAutofill="no" />
|
android:importantForAutofill="no" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/instance_picker_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:text="@string/instances_picker"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/instance_picker"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/login_button"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/instance_picker_title" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.Barrier
|
||||||
|
android:id="@+id/barrier"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:barrierDirection="bottom"
|
||||||
|
app:constraint_referenced_ids="login_passwd_container,instance_picker" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/login_button"
|
android:id="@+id/login_button"
|
||||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||||
@ -139,7 +169,7 @@
|
|||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/login_passwd_container" />
|
app:layout_constraintTop_toBottomOf="@id/barrier" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -49,7 +49,6 @@
|
|||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<com.github.vkay94.dtpv.DoubleTapPlayerView
|
<com.github.vkay94.dtpv.DoubleTapPlayerView
|
||||||
android:id="@+id/doubleTapPlayerView"
|
android:id="@+id/doubleTapPlayerView"
|
||||||
android:animateLayoutChanges="true"
|
android:animateLayoutChanges="true"
|
||||||
@ -67,6 +66,15 @@
|
|||||||
app:yt_playerView="@+id/doubleTapPlayerView"
|
app:yt_playerView="@+id/doubleTapPlayerView"
|
||||||
android:gravity="center" />
|
android:gravity="center" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/watermark"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_gravity="top|start"
|
||||||
|
android:contentDescription="@string/watermark"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/cast_controller"
|
android:id="@+id/cast_controller"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -264,6 +272,54 @@
|
|||||||
app:drawableTopCompat="@drawable/ic_baseline_thumb_down_alt_24"
|
app:drawableTopCompat="@drawable/ic_baseline_thumb_down_alt_24"
|
||||||
tools:ignore="HardcodedText" />
|
tools:ignore="HardcodedText" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/peertube_reblog"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:drawablePadding="5dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text="0"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:drawableTopCompat="@drawable/ic_baseline_repeat_24"
|
||||||
|
tools:ignore="HardcodedText" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/peertube_favorite"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:drawablePadding="5dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text="0"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:drawableTopCompat="@drawable/ic_baseline_star_24"
|
||||||
|
tools:ignore="HardcodedText" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/peertube_bookmark"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:drawablePadding="5dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text=""
|
||||||
|
android:visibility="gone"
|
||||||
|
app:drawableTopCompat="@drawable/ic_baseline_bookmark_24"
|
||||||
|
tools:ignore="HardcodedText" />
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/peertube_playlist"
|
android:id="@+id/peertube_playlist"
|
||||||
|
@ -83,7 +83,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:labelFor="@+id/p_video_tags"
|
android:labelFor="@+id/p_video_tags"
|
||||||
android:text="@string/tags" />
|
android:text="@string/tags" />
|
||||||
|
|
||||||
<mabbas007.tagsedittext.TagsEditText
|
<mabbas007.tagsedittext.TagsEditText
|
||||||
android:id="@+id/p_video_tags"
|
android:id="@+id/p_video_tags"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -93,8 +92,9 @@
|
|||||||
android:minLines="2"
|
android:minLines="2"
|
||||||
TagsEditText:allowSpaceInTag="true"
|
TagsEditText:allowSpaceInTag="true"
|
||||||
TagsEditText:tagsCloseImagePadding="@dimen/defaultTagsCloseImagePadding"
|
TagsEditText:tagsCloseImagePadding="@dimen/defaultTagsCloseImagePadding"
|
||||||
|
TagsEditText:tagsBackground="?colorAccent"
|
||||||
TagsEditText:tagsCloseImageRight="@drawable/tag_close"
|
TagsEditText:tagsCloseImageRight="@drawable/tag_close"
|
||||||
TagsEditText:tagsTextColor="?colorAccent"
|
TagsEditText:tagsTextColor="@color/white"
|
||||||
TagsEditText:tagsTextSize="@dimen/defaultTagsTextSize" />
|
TagsEditText:tagsTextSize="@dimen/defaultTagsTextSize" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -112,21 +112,22 @@
|
|||||||
android:id="@+id/number_of_replies"
|
android:id="@+id/number_of_replies"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/comment_content"
|
app:layout_constraintTop_toBottomOf="@+id/comment_content"
|
||||||
app:layout_constraintStart_toStartOf="@id/comment_account_profile"
|
app:layout_constraintStart_toStartOf="@id/comment_account_profile"
|
||||||
|
android:layout_marginEnd="15dp"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/replyButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="?attr/colorAccent"/>
|
android:textColor="?attr/colorAccent" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
app:layout_constraintTop_toBottomOf="@+id/comment_content"
|
android:layout_marginStart="10dp"
|
||||||
app:layout_constraintStart_toStartOf="@id/comment_account_profile"
|
app:layout_constraintStart_toEndOf="@id/number_of_replies"
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:id="@+id/replyButton"
|
android:id="@+id/replyButton"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/number_of_replies"
|
||||||
android:text="@string/reply"
|
android:text="@string/reply"
|
||||||
android:textColor="?attr/colorAccent"
|
android:textColor="?attr/colorAccent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||||
|
@ -55,6 +55,44 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/torrent_info"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/seekbar_controller"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dowload_rate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:textColor="#FFBEBEBE"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/upload_rate"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/upload_rate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:textColor="#FFBEBEBE"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/peers_number"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/peers_number"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:textColor="#FFBEBEBE"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/seekbar_controller"
|
android:id="@+id/seekbar_controller"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
@ -103,6 +141,17 @@
|
|||||||
android:textColor="#FFBEBEBE"
|
android:textColor="#FFBEBEBE"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/exo_live_badge"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:paddingStart="4dp"
|
||||||
|
android:paddingEnd="4dp"
|
||||||
|
android:textColor="#FFF"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/exo_fullscreen_button"
|
android:id="@+id/exo_fullscreen_button"
|
||||||
android:layout_width="32dp"
|
android:layout_width="32dp"
|
||||||
|
@ -135,6 +135,9 @@
|
|||||||
<string name="action_follow">Subscribe</string>
|
<string name="action_follow">Subscribe</string>
|
||||||
<string name="action_mute">كتم</string>
|
<string name="action_mute">كتم</string>
|
||||||
<string name="unlimited">Unlimited</string>
|
<string name="unlimited">Unlimited</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Total video quota</string>
|
||||||
@ -350,4 +353,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
||||||
<string name="set_video_language">Language filter</string>
|
<string name="set_video_language">Language filter</string>
|
||||||
<string name="set_video_language_description">Filter videos with different languages</string>
|
<string name="set_video_language_description">Filter videos with different languages</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -131,6 +131,9 @@
|
|||||||
<string name="action_follow">Abonnieren</string>
|
<string name="action_follow">Abonnieren</string>
|
||||||
<string name="action_mute">Lautlos</string>
|
<string name="action_mute">Lautlos</string>
|
||||||
<string name="unlimited">Unbegrenzt</string>
|
<string name="unlimited">Unbegrenzt</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Gesamtes Video-Kontingent</string>
|
<string name="total_video_quota">Gesamtes Video-Kontingent</string>
|
||||||
@ -346,4 +349,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
||||||
<string name="set_video_language">Sprachfilter</string>
|
<string name="set_video_language">Sprachfilter</string>
|
||||||
<string name="set_video_language_description">Videos mit verschiedenen Sprachen filtern</string>
|
<string name="set_video_language_description">Videos mit verschiedenen Sprachen filtern</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -131,6 +131,9 @@
|
|||||||
<string name="action_follow">Subscribe</string>
|
<string name="action_follow">Subscribe</string>
|
||||||
<string name="action_mute">Σίγαση</string>
|
<string name="action_mute">Σίγαση</string>
|
||||||
<string name="unlimited">Unlimited</string>
|
<string name="unlimited">Unlimited</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Total video quota</string>
|
||||||
@ -345,4 +348,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
||||||
<string name="set_video_language">Φίλτρο Γλώσσας</string>
|
<string name="set_video_language">Φίλτρο Γλώσσας</string>
|
||||||
<string name="set_video_language_description">Φιλτράρετε βίντεο με διάφορες γλώσσες</string>
|
<string name="set_video_language_description">Φιλτράρετε βίντεο με διάφορες γλώσσες</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -131,6 +131,9 @@
|
|||||||
<string name="action_follow">Subscribe</string>
|
<string name="action_follow">Subscribe</string>
|
||||||
<string name="action_mute">Silenciar</string>
|
<string name="action_mute">Silenciar</string>
|
||||||
<string name="unlimited">Unlimited</string>
|
<string name="unlimited">Unlimited</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Total video quota</string>
|
||||||
@ -346,4 +349,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
||||||
<string name="set_video_language">Filtro de idioma</string>
|
<string name="set_video_language">Filtro de idioma</string>
|
||||||
<string name="set_video_language_description">Filtrar los videos con diferentes idiomas</string>
|
<string name="set_video_language_description">Filtrar los videos con diferentes idiomas</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -131,6 +131,9 @@
|
|||||||
<string name="action_follow">S\'abonner</string>
|
<string name="action_follow">S\'abonner</string>
|
||||||
<string name="action_mute">Masquer</string>
|
<string name="action_mute">Masquer</string>
|
||||||
<string name="unlimited">Illimité</string>
|
<string name="unlimited">Illimité</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">Mo</string>
|
<string name="mb">Mo</string>
|
||||||
<string name="gb">Go</string>
|
<string name="gb">Go</string>
|
||||||
<string name="total_video_quota">Quota vidéo total</string>
|
<string name="total_video_quota">Quota vidéo total</string>
|
||||||
@ -276,7 +279,7 @@
|
|||||||
<string name="report_account">Signaler le compte</string>
|
<string name="report_account">Signaler le compte</string>
|
||||||
<string-array name="settings_video_mode">
|
<string-array name="settings_video_mode">
|
||||||
<item>Normal</item>
|
<item>Normal</item>
|
||||||
<item>Torrent</item>
|
<item>Navigateur</item>
|
||||||
<item>Magnet</item>
|
<item>Magnet</item>
|
||||||
<item>Torrent</item>
|
<item>Torrent</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
@ -346,4 +349,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
||||||
<string name="set_video_language">Filtre de langue</string>
|
<string name="set_video_language">Filtre de langue</string>
|
||||||
<string name="set_video_language_description">Filtrer les vidéos avec différentes langues</string>
|
<string name="set_video_language_description">Filtrer les vidéos avec différentes langues</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -131,6 +131,9 @@
|
|||||||
<string name="action_follow">Iscriviti</string>
|
<string name="action_follow">Iscriviti</string>
|
||||||
<string name="action_mute">Silenzia</string>
|
<string name="action_mute">Silenzia</string>
|
||||||
<string name="unlimited">Illimitato</string>
|
<string name="unlimited">Illimitato</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Total video quota</string>
|
||||||
@ -346,4 +349,12 @@
|
|||||||
<string name="set_video_minimize_description">Ridurre al minimo le dimensioni dei video quando l\'applicazione è in background (Android N+)</string>
|
<string name="set_video_minimize_description">Ridurre al minimo le dimensioni dei video quando l\'applicazione è in background (Android N+)</string>
|
||||||
<string name="set_video_language">Filtro per le lingue</string>
|
<string name="set_video_language">Filtro per le lingue</string>
|
||||||
<string name="set_video_language_description">Filtra video con lingue diverse</string>
|
<string name="set_video_language_description">Filtra video con lingue diverse</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -130,6 +130,9 @@
|
|||||||
<string name="action_follow">Subscribe</string>
|
<string name="action_follow">Subscribe</string>
|
||||||
<string name="action_mute">ミュート</string>
|
<string name="action_mute">ミュート</string>
|
||||||
<string name="unlimited">Unlimited</string>
|
<string name="unlimited">Unlimited</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Total video quota</string>
|
||||||
@ -345,4 +348,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
||||||
<string name="set_video_language">Language filter</string>
|
<string name="set_video_language">Language filter</string>
|
||||||
<string name="set_video_language_description">Filter videos with different languages</string>
|
<string name="set_video_language_description">Filter videos with different languages</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -130,6 +130,9 @@
|
|||||||
<string name="action_follow">Subscribe</string>
|
<string name="action_follow">Subscribe</string>
|
||||||
<string name="action_mute">뮤트</string>
|
<string name="action_mute">뮤트</string>
|
||||||
<string name="unlimited">Unlimited</string>
|
<string name="unlimited">Unlimited</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Total video quota</string>
|
||||||
@ -345,4 +348,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
||||||
<string name="set_video_language">Language filter</string>
|
<string name="set_video_language">Language filter</string>
|
||||||
<string name="set_video_language_description">Filter videos with different languages</string>
|
<string name="set_video_language_description">Filter videos with different languages</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
<string name="set_cast">Enable Chromecast (beta)</string>
|
<string name="set_cast">Chromecast (beta) inschakelen</string>
|
||||||
<string name="please_wait">Please wait</string>
|
<string name="please_wait">Even geduld aub</string>
|
||||||
<string name="set_cast_description">Allow to discover Chromecast devices on the network.</string>
|
<string name="set_cast_description">Detecteren van Chromecast apparaten op het netwerk toestaan.</string>
|
||||||
<string name="set_video_in_list">Video lijst</string>
|
<string name="set_video_in_list">Videos in lijst</string>
|
||||||
<string name="set_video_in_list_description">Wijzig de lay-out voor het weergeven van video\'s in een lijst</string>
|
<string name="set_video_in_list_description">Wijzig de lay-out voor het weergeven van video\'s in een lijst</string>
|
||||||
<string name="no_instances">Geen instanties !</string>
|
<string name="no_instances">Geen instanties !</string>
|
||||||
<string name="show_more">Meer weergeven</string>
|
<string name="show_more">Meer weergeven</string>
|
||||||
<string name="show_less">Minder weergeven</string>
|
<string name="show_less">Minder weergeven</string>
|
||||||
<string name="cast">ChromeCast</string>
|
<string name="cast">ChromeCast</string>
|
||||||
<string name="chromecast_choice">ChromeCast choice</string>
|
<string name="chromecast_choice">ChromeCast keuze</string>
|
||||||
<string name="set_play_screen_lock">Schermvergrendeling</string>
|
<string name="set_play_screen_lock">Schermvergrendeling</string>
|
||||||
<string name="set_play_screen_lock_description">Video\'s laten doorspelen terwijl het scherm vergrendeld is</string>
|
<string name="set_play_screen_lock_description">Video\'s laten doorspelen terwijl het scherm vergrendeld is</string>
|
||||||
<string name="save">Opslaan</string>
|
<string name="save">Opslaan</string>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
<string name="set_autoplay_next_video">De volgende video automatisch afspelen</string>
|
<string name="set_autoplay_next_video">De volgende video automatisch afspelen</string>
|
||||||
<string name="set_autoplay_next_video_description">Wanneer een video eindigt, begin dan met de volgende voorgestelde video.</string>
|
<string name="set_autoplay_next_video_description">Wanneer een video eindigt, begin dan met de volgende voorgestelde video.</string>
|
||||||
<string name="add_public_reply">Voeg een openbaar antwoord toe</string>
|
<string name="add_public_reply">Voeg een openbaar antwoord toe</string>
|
||||||
<string name="originally_published">Originally published</string>
|
<string name="originally_published">Oorspronkelijk gepubliceerd op</string>
|
||||||
<string name="activity">Activiteit</string>
|
<string name="activity">Activiteit</string>
|
||||||
<string name="app">App</string>
|
<string name="app">App</string>
|
||||||
<string name="notif_new_video">Nieuwe video uit uw abonnementen</string>
|
<string name="notif_new_video">Nieuwe video uit uw abonnementen</string>
|
||||||
@ -87,9 +87,9 @@
|
|||||||
<item>6 uren</item>
|
<item>6 uren</item>
|
||||||
<item>12 uren</item>
|
<item>12 uren</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string name="_retry">Retry</string>
|
<string name="_retry">Opnieuw proberen</string>
|
||||||
<string name="refresh_token_failed">Token refresh failed!</string>
|
<string name="refresh_token_failed">Token vernieuwen mislukt!</string>
|
||||||
<string name="refresh_token_failed_message">You can retry this action or simply disconnect the current account</string>
|
<string name="refresh_token_failed_message">U kunt deze actie opnieuw uitproberen of het huidige account gewoon loskoppelen</string>
|
||||||
<string name="yes">Ja</string>
|
<string name="yes">Ja</string>
|
||||||
<string name="no">Geen</string>
|
<string name="no">Geen</string>
|
||||||
<string name="cancel">Annuleren</string>
|
<string name="cancel">Annuleren</string>
|
||||||
@ -128,15 +128,18 @@
|
|||||||
<string name="toast_error_loading_account">Er ging wat mis tijdens het omschakelen van accounts!</string>
|
<string name="toast_error_loading_account">Er ging wat mis tijdens het omschakelen van accounts!</string>
|
||||||
<string name="toast_error_search">Er ging wat mis tijdens het zoeken!</string>
|
<string name="toast_error_search">Er ging wat mis tijdens het zoeken!</string>
|
||||||
<string name="nothing_to_do">Er valt niets te doen</string>
|
<string name="nothing_to_do">Er valt niets te doen</string>
|
||||||
<string name="action_follow">Subscribe</string>
|
<string name="action_follow">Abonneren</string>
|
||||||
<string name="action_mute">Negeren</string>
|
<string name="action_mute">Negeren</string>
|
||||||
<string name="unlimited">Unlimited</string>
|
<string name="unlimited">Onbeperkt</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Totaal videoquotum</string>
|
||||||
<string name="daily_video_quota">Daily video quota</string>
|
<string name="daily_video_quota">Dagelijks videoquotum</string>
|
||||||
<string name="nsfw_title_warning">Mature or explicit content</string>
|
<string name="nsfw_title_warning">Expliciete inhoud, of inhoud voor volwassenen</string>
|
||||||
<string name="nsfw_message_warning">This video contains mature or explicit content. Are you sure you want to watch it?</string>
|
<string name="nsfw_message_warning">Deze video bevat volwassen of expliciete inhoud. Weet u zeker dat u deze wilt bekijken?</string>
|
||||||
<string name="search">Zoek</string>
|
<string name="search">Zoek</string>
|
||||||
<string name="delete">Verwijderen</string>
|
<string name="delete">Verwijderen</string>
|
||||||
<string name="action_lists_confirm_delete">Weet je zeker dat je deze lijst definitief wilt verwijderen?</string>
|
<string name="action_lists_confirm_delete">Weet je zeker dat je deze lijst definitief wilt verwijderen?</string>
|
||||||
@ -236,10 +239,10 @@
|
|||||||
<string name="send_comment">Reactie versturen</string>
|
<string name="send_comment">Reactie versturen</string>
|
||||||
<string name="all">Alle</string>
|
<string name="all">Alle</string>
|
||||||
<!-- end languages -->
|
<!-- end languages -->
|
||||||
<string name="playback_speed">Playback speed</string>
|
<string name="playback_speed">Afspeelsnelheid</string>
|
||||||
<string name="normal">Normaal</string>
|
<string name="normal">Normaal</string>
|
||||||
<string name="delete_history">Delete videos history</string>
|
<string name="delete_history">Videogeschiedenis verwijderen</string>
|
||||||
<string name="delete_history_confirm">Are you sure you want to delete all your videos history?</string>
|
<string name="delete_history_confirm">Weet je zeker dat je al je video geschiedenis wil verwijderen?</string>
|
||||||
<string name="export_list">Exporteren</string>
|
<string name="export_list">Exporteren</string>
|
||||||
<string name="import_list">Importeren</string>
|
<string name="import_list">Importeren</string>
|
||||||
<string name="export_notification_title">Export succesvol!</string>
|
<string name="export_notification_title">Export succesvol!</string>
|
||||||
@ -296,7 +299,7 @@
|
|||||||
<string name="agreement_check_peertube">Ik ben minstens 16 jaar oud en ga akkoord met de %1$s van dit geval</string>
|
<string name="agreement_check_peertube">Ik ben minstens 16 jaar oud en ga akkoord met de %1$s van dit geval</string>
|
||||||
<string name="edit_profile">Profiel bewerken</string>
|
<string name="edit_profile">Profiel bewerken</string>
|
||||||
<string name="make_an_action">Maak een actie</string>
|
<string name="make_an_action">Maak een actie</string>
|
||||||
<string name="action_unfollow">Unsubscribe</string>
|
<string name="action_unfollow">Abonnement beëindigen</string>
|
||||||
<string name="display_nsfw_videos">Gevoelige video\'s weergeven</string>
|
<string name="display_nsfw_videos">Gevoelige video\'s weergeven</string>
|
||||||
<string name="fullscreen">Volledig scherm</string>
|
<string name="fullscreen">Volledig scherm</string>
|
||||||
<string name="bookmark_peertube_empty">Er zijn geen video\'s in uw favorieten!</string>
|
<string name="bookmark_peertube_empty">Er zijn geen video\'s in uw favorieten!</string>
|
||||||
@ -346,4 +349,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimaliseer de grootte van de video\'s als de app op de achtergrond staat (Android N+)</string>
|
<string name="set_video_minimize_description">Minimaliseer de grootte van de video\'s als de app op de achtergrond staat (Android N+)</string>
|
||||||
<string name="set_video_language">Taalfilter</string>
|
<string name="set_video_language">Taalfilter</string>
|
||||||
<string name="set_video_language_description">Filtervideo\'s met verschillende talen</string>
|
<string name="set_video_language_description">Filtervideo\'s met verschillende talen</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">Deze live is nog niet gestart!</string>
|
||||||
|
<string name="remote_account">Account van een ander netwerk!</string>
|
||||||
|
<string name="instance_not_availabe">Instantie is niet beschikbaar!</string>
|
||||||
|
<string name="max_tag_size">De video mag niet meer dan 5 tags hebben!</string>
|
||||||
|
<string name="watermark">Watermerk</string>
|
||||||
|
<string name="toast_code_error">Er is een fout opgetreden! De instantie gaf geen autorisatiecode terug!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> extern account verbonden met de app.\n\nU kunt doorgaan naar bepaalde acties.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -133,6 +133,9 @@
|
|||||||
<string name="action_follow">Subskrybuj</string>
|
<string name="action_follow">Subskrybuj</string>
|
||||||
<string name="action_mute">Wycisz</string>
|
<string name="action_mute">Wycisz</string>
|
||||||
<string name="unlimited">Bez ograniczeń</string>
|
<string name="unlimited">Bez ograniczeń</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Całkowity limit filmów</string>
|
<string name="total_video_quota">Całkowity limit filmów</string>
|
||||||
@ -348,4 +351,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimalizacja rozmiaru filmów, gdy aplikacja znajduje się w tle (Android N+)</string>
|
<string name="set_video_minimize_description">Minimalizacja rozmiaru filmów, gdy aplikacja znajduje się w tle (Android N+)</string>
|
||||||
<string name="set_video_language">Filtr językowy</string>
|
<string name="set_video_language">Filtr językowy</string>
|
||||||
<string name="set_video_language_description">Filtrowanie filmów w różnych językach</string>
|
<string name="set_video_language_description">Filtrowanie filmów w różnych językach</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -131,6 +131,9 @@
|
|||||||
<string name="action_follow">Subscribe</string>
|
<string name="action_follow">Subscribe</string>
|
||||||
<string name="action_mute">Silenciar</string>
|
<string name="action_mute">Silenciar</string>
|
||||||
<string name="unlimited">Unlimited</string>
|
<string name="unlimited">Unlimited</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Total video quota</string>
|
||||||
@ -346,4 +349,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
||||||
<string name="set_video_language">Language filter</string>
|
<string name="set_video_language">Language filter</string>
|
||||||
<string name="set_video_language_description">Filter videos with different languages</string>
|
<string name="set_video_language_description">Filter videos with different languages</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -132,6 +132,9 @@
|
|||||||
<string name="action_follow">Subscribe</string>
|
<string name="action_follow">Subscribe</string>
|
||||||
<string name="action_mute">Mod silențios</string>
|
<string name="action_mute">Mod silențios</string>
|
||||||
<string name="unlimited">Unlimited</string>
|
<string name="unlimited">Unlimited</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Total video quota</string>
|
||||||
@ -347,4 +350,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
||||||
<string name="set_video_language">Language filter</string>
|
<string name="set_video_language">Language filter</string>
|
||||||
<string name="set_video_language_description">Filter videos with different languages</string>
|
<string name="set_video_language_description">Filter videos with different languages</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
<string name="set_cast">Enable Chromecast (beta)</string>
|
<string name="set_cast">Включить Chromecast (бета-версия)</string>
|
||||||
<string name="please_wait">Please wait</string>
|
<string name="please_wait">Пожалуйста подождите</string>
|
||||||
<string name="set_cast_description">Allow to discover Chromecast devices on the network.</string>
|
<string name="set_cast_description">Позволяет обнаружить устройства Chromecast в сети.</string>
|
||||||
<string name="set_video_in_list">Видео в списке</string>
|
<string name="set_video_in_list">Видео в списке</string>
|
||||||
<string name="set_video_in_list_description">Изменить расположение для отображения видео в списке</string>
|
<string name="set_video_in_list_description">Изменить расположение для отображения видео в списке</string>
|
||||||
<string name="no_instances">Нет экземпляров !</string>
|
<string name="no_instances">Нет экземпляров !</string>
|
||||||
<string name="show_more">Показать еще</string>
|
<string name="show_more">Показать еще</string>
|
||||||
<string name="show_less">Показать меньше</string>
|
<string name="show_less">Показать меньше</string>
|
||||||
<string name="cast">ChromeCast</string>
|
<string name="cast">ChromeCast</string>
|
||||||
<string name="chromecast_choice">ChromeCast choice</string>
|
<string name="chromecast_choice">Выбор ChromeCast</string>
|
||||||
<string name="set_play_screen_lock">Блокировка экрана</string>
|
<string name="set_play_screen_lock">Блокировка экрана</string>
|
||||||
<string name="set_play_screen_lock_description">Продолжать воспроизведение видео, когда экран заблокирован</string>
|
<string name="set_play_screen_lock_description">Продолжать воспроизведение видео, когда экран заблокирован</string>
|
||||||
<string name="save">Сохранить</string>
|
<string name="save">Сохранить</string>
|
||||||
@ -133,6 +133,9 @@
|
|||||||
<string name="action_follow">Подписка</string>
|
<string name="action_follow">Подписка</string>
|
||||||
<string name="action_mute">Игнорировать</string>
|
<string name="action_mute">Игнорировать</string>
|
||||||
<string name="unlimited">Без ограничений</string>
|
<string name="unlimited">Без ограничений</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">МБ</string>
|
<string name="mb">МБ</string>
|
||||||
<string name="gb">ГБ</string>
|
<string name="gb">ГБ</string>
|
||||||
<string name="total_video_quota">Общая квота видео</string>
|
<string name="total_video_quota">Общая квота видео</string>
|
||||||
@ -348,4 +351,12 @@
|
|||||||
<string name="set_video_minimize_description">Уменьшить размер видео, когда приложение находится в фоновом режиме (Android N+)</string>
|
<string name="set_video_minimize_description">Уменьшить размер видео, когда приложение находится в фоновом режиме (Android N+)</string>
|
||||||
<string name="set_video_language">Добавить языковой фильтр</string>
|
<string name="set_video_language">Добавить языковой фильтр</string>
|
||||||
<string name="set_video_language_description">Фильтровать видео с разными языками</string>
|
<string name="set_video_language_description">Фильтровать видео с разными языками</string>
|
||||||
|
<string name="live">Прямой эфир</string>
|
||||||
|
<string name="live_not_started">Этот прямой эфир ещё не начался!</string>
|
||||||
|
<string name="remote_account">Аккаунт из другой сети!</string>
|
||||||
|
<string name="instance_not_availabe">Экземпляр недоступен!</string>
|
||||||
|
<string name="max_tag_size">На видео не должно быть более 5 тегов!</string>
|
||||||
|
<string name="watermark">Водяной знак</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -131,6 +131,9 @@
|
|||||||
<string name="action_follow">Subscribe</string>
|
<string name="action_follow">Subscribe</string>
|
||||||
<string name="action_mute">Tysta</string>
|
<string name="action_mute">Tysta</string>
|
||||||
<string name="unlimited">Unlimited</string>
|
<string name="unlimited">Unlimited</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Total video quota</string>
|
||||||
@ -346,4 +349,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
||||||
<string name="set_video_language">Language filter</string>
|
<string name="set_video_language">Language filter</string>
|
||||||
<string name="set_video_language_description">Filter videos with different languages</string>
|
<string name="set_video_language_description">Filter videos with different languages</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -130,6 +130,9 @@
|
|||||||
<string name="action_follow">Subscribe</string>
|
<string name="action_follow">Subscribe</string>
|
||||||
<string name="action_mute">静言</string>
|
<string name="action_mute">静言</string>
|
||||||
<string name="unlimited">Unlimited</string>
|
<string name="unlimited">Unlimited</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Total video quota</string>
|
||||||
@ -344,4 +347,12 @@
|
|||||||
<string name="set_video_minimize_description">当处于后台播放时,最小化视频(仅适用于 Android N 以及之后的版本)</string>
|
<string name="set_video_minimize_description">当处于后台播放时,最小化视频(仅适用于 Android N 以及之后的版本)</string>
|
||||||
<string name="set_video_language">语言筛选</string>
|
<string name="set_video_language">语言筛选</string>
|
||||||
<string name="set_video_language_description">筛选其他语言的视频</string>
|
<string name="set_video_language_description">筛选其他语言的视频</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -130,6 +130,9 @@
|
|||||||
<string name="action_follow">Subscribe</string>
|
<string name="action_follow">Subscribe</string>
|
||||||
<string name="action_mute">靜音</string>
|
<string name="action_mute">靜音</string>
|
||||||
<string name="unlimited">Unlimited</string>
|
<string name="unlimited">Unlimited</string>
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Total video quota</string>
|
||||||
@ -345,4 +348,12 @@
|
|||||||
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
<string name="set_video_minimize_description">Minimize videos size when the app is in background (Android N+)</string>
|
||||||
<string name="set_video_language">Language filter</string>
|
<string name="set_video_language">Language filter</string>
|
||||||
<string name="set_video_language_description">Filter videos with different languages</string>
|
<string name="set_video_language_description">Filter videos with different languages</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -170,6 +170,10 @@
|
|||||||
<string name="action_mute">Mute</string>
|
<string name="action_mute">Mute</string>
|
||||||
|
|
||||||
<string name="unlimited">Unlimited</string>
|
<string name="unlimited">Unlimited</string>
|
||||||
|
|
||||||
|
<string name="peers">%1$d Peers</string>
|
||||||
|
<string name="b">B</string>
|
||||||
|
<string name="kb">KB</string>
|
||||||
<string name="mb">MB</string>
|
<string name="mb">MB</string>
|
||||||
<string name="gb">GB</string>
|
<string name="gb">GB</string>
|
||||||
<string name="total_video_quota">Total video quota</string>
|
<string name="total_video_quota">Total video quota</string>
|
||||||
@ -443,4 +447,13 @@
|
|||||||
|
|
||||||
<string name="set_video_language">Language filter</string>
|
<string name="set_video_language">Language filter</string>
|
||||||
<string name="set_video_language_description">Filter videos with different languages</string>
|
<string name="set_video_language_description">Filter videos with different languages</string>
|
||||||
|
<string name="live">Live</string>
|
||||||
|
<string name="live_not_started">This live has not started!</string>
|
||||||
|
<string name="remote_account">Account from another network!</string>
|
||||||
|
<string name="instance_not_availabe">Instance is not available!</string>
|
||||||
|
<string name="max_tag_size">The video should not have more than 5 tags!</string>
|
||||||
|
<string name="watermark">Watermark</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -7,6 +7,8 @@
|
|||||||
<color name="tag_color">#bb864692</color>
|
<color name="tag_color">#bb864692</color>
|
||||||
<color name="tag_color_text">#FAFAFA</color>
|
<color name="tag_color_text">#FAFAFA</color>
|
||||||
<color name="positive_thumbs">#2b90d9</color>
|
<color name="positive_thumbs">#2b90d9</color>
|
||||||
|
<color name="favorite">#ca8f04</color>
|
||||||
|
<color name="bookmark">#795548</color>
|
||||||
<color name="negative_thumbs">#F44336</color>
|
<color name="negative_thumbs">#F44336</color>
|
||||||
<color name="backgroundDark">#DD000000</color>
|
<color name="backgroundDark">#DD000000</color>
|
||||||
<color name="red_1">#F44336</color>
|
<color name="red_1">#F44336</color>
|
||||||
|
@ -9,6 +9,8 @@ buildscript {
|
|||||||
classpath 'com.android.tools.build:gradle:4.1.1'
|
classpath 'com.android.tools.build:gradle:4.1.1'
|
||||||
def nav_version = "2.3.0"
|
def nav_version = "2.3.0"
|
||||||
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
|
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
|
||||||
|
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
|
||||||
|
classpath 'de.undercouch:gradle-download-task:4.0.4'
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,15 @@ files:
|
|||||||
two_letters_code:
|
two_letters_code:
|
||||||
zh-TW: zh-rTW
|
zh-TW: zh-rTW
|
||||||
zh-CN: zh-rCN
|
zh-CN: zh-rCN
|
||||||
- source: /app/src/fdroid_full/fastlane/metadata/android/en-US/full_description.txt
|
- source: /src/fdroid_full/fastlane/metadata/android/en-US/full_description.txt
|
||||||
translation: /app/src/fdroid_full/fastlane/metadata/android/%two_letters_code%/%original_file_name%
|
translation: /src/fdroid_full/fastlane/metadata/android/%two_letters_code%/%original_file_name%
|
||||||
#update_option: update_without_changes
|
#update_option: update_without_changes
|
||||||
languages_mapping:
|
languages_mapping:
|
||||||
two_letters_code:
|
two_letters_code:
|
||||||
zh-TW: zh-rTW
|
zh-TW: zh-rTW
|
||||||
zh-CN: zh-rCN
|
zh-CN: zh-rCN
|
||||||
- source: /app/src/fdroid_full/fastlane/metadata/android/en-US/short_description.txt
|
- source: /src/fdroid_full/fastlane/metadata/android/en-US/short_description.txt
|
||||||
translation: /app/src/fdroid_full/fastlane/metadata/android/%two_letters_code%/%original_file_name%
|
translation: /src/fdroid_full/fastlane/metadata/android/%two_letters_code%/%original_file_name%
|
||||||
#update_option: update_without_changes
|
#update_option: update_without_changes
|
||||||
languages_mapping:
|
languages_mapping:
|
||||||
two_letters_code:
|
two_letters_code:
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
|
include ':torrentStream'
|
||||||
include ':app'
|
include ':app'
|
||||||
rootProject.name = "Fedilab Tube"
|
rootProject.name = "Fedilab Tube"
|
@ -0,0 +1,13 @@
|
|||||||
|
Fixes some issues on 1.10.0 (Crashes when adding a playlist + bad behavior when subscribing to remote accounts)
|
||||||
|
|
||||||
|
Added:
|
||||||
|
- Chromecast support (default disabled)
|
||||||
|
- Detect start time in URLs
|
||||||
|
|
||||||
|
Fixed:
|
||||||
|
- Typo
|
||||||
|
- Comment feature when logged out
|
||||||
|
- Full-screen breaks
|
||||||
|
- Crashes with the download button on live streams
|
||||||
|
- Jumps with full-screen and vertical videos
|
||||||
|
- Abuse report notifications clickable
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 132 KiB |
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |