Some fixes
This commit is contained in:
parent
d5f394dfea
commit
edbe65593b
|
@ -68,7 +68,7 @@ assembleDebug:
|
|||
cache:
|
||||
key: "${CI_COMMIT_TAG}"
|
||||
paths:
|
||||
- app/build/outputs/apk/fdroid_peertube_apps_educ/debug/app-fdroid_peertube_apps_educ-debug.apk
|
||||
- app/build/outputs/apk/fdroid_acad/debug/app-fdroid_acad-debug.apk
|
||||
- app/build/outputs/apk/fdroid_full/debug/app-fdroid_full-debug.apk
|
||||
policy: push
|
||||
script:
|
||||
|
@ -76,11 +76,11 @@ assembleDebug:
|
|||
|
||||
# Basic android and gradle stuff
|
||||
# Check linting
|
||||
lintfdroid_peertube_apps_educDebug:
|
||||
lintfdroid_acadDebug:
|
||||
interruptible: true
|
||||
stage: build
|
||||
script:
|
||||
- ./gradlew -Pci --console=plain :app:lintfdroid_peertube_apps_educDebug -PbuildDir=lint
|
||||
- ./gradlew -Pci --console=plain :app:lintfdroid_acadDebug -PbuildDir=lint
|
||||
except:
|
||||
- tags
|
||||
|
||||
|
@ -110,7 +110,7 @@ putApkOnTags:
|
|||
cache:
|
||||
key: "${CI_COMMIT_TAG}"
|
||||
paths:
|
||||
- app/build/outputs/apk/fdroid_peertube_apps_educ/debug/app-fdroid_peertube_apps_educ-debug.apk
|
||||
- app/build/outputs/apk/fdroid_acad/debug/app-fdroid_acad-debug.apk
|
||||
- app/build/outputs/apk/fdroid_full/debug/app-fdroid_full-debug.apk
|
||||
policy: pull
|
||||
script:
|
||||
|
@ -120,11 +120,11 @@ putApkOnTags:
|
|||
- 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 HEADER="Private-Token: ${GITLAB_API_TOKEN}"'
|
||||
- export acadUrl="${NC_DOWNLOAD_URL}app-fdroid_peertube_apps_educ-debug.apk"
|
||||
- export acadUrl="${NC_DOWNLOAD_URL}app-fdroid_acad-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}" -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_peertube_apps_educ/debug/app-fdroid_peertube_apps_educ-debug.apk "${NC_UPLOAD_URL}/app-fdroid_peertube_apps_educ-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"'
|
||||
- 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="PUT"; echo -e "${description}\n\n[Get the acad version](${acadUrl})\n\n[Get the full version](${fullUrl})" > /tmp/text; fi
|
||||
|
|
|
@ -42,7 +42,7 @@ android {
|
|||
}
|
||||
//boolean full_instances if set to false means TubeAcad
|
||||
productFlavors {
|
||||
fdroid_peertube_apps_educ {
|
||||
fdroid_acad {
|
||||
applicationId "app.fedilab.fedilabtube"
|
||||
resValue "string", "app_name", "TubeAcad"
|
||||
resValue "string", "app_id", "app.fedilab.fedilabtube"
|
||||
|
@ -57,7 +57,7 @@ android {
|
|||
buildConfigField "int", "cast_enabled", "0"
|
||||
buildConfigField "int", "default_theme", "2"
|
||||
}
|
||||
google_peertube_apps_educ {
|
||||
google_acad {
|
||||
applicationId "app.fedilab.fedilabtube"
|
||||
resValue "string", "app_name", "TubeAcad"
|
||||
resValue "string", "app_id", "app.fedilab.fedilabtube"
|
||||
|
@ -68,8 +68,8 @@ android {
|
|||
buildConfigField "boolean", "sepia_search", "false"
|
||||
buildConfigField "boolean", "instance_switcher", "true"
|
||||
buildConfigField "boolean", "allow_remote_connections", "false"
|
||||
buildConfigField "boolean", "google_cast_lib", "false"
|
||||
buildConfigField "int", "cast_enabled", "0"
|
||||
buildConfigField "boolean", "google_cast_lib", "true"
|
||||
buildConfigField "int", "cast_enabled", "1"
|
||||
buildConfigField "int", "default_theme", "2"
|
||||
}
|
||||
fdroid_full {
|
||||
|
@ -135,13 +135,14 @@ android {
|
|||
}
|
||||
|
||||
sourceSets {
|
||||
fdroid_peertube_apps_educ {
|
||||
|
||||
fdroid_acad {
|
||||
res.srcDirs = ['src/main/res', 'src/acad/res', 'src/no_google_cast_lib/res']
|
||||
java.srcDirs = ['src/main/java', 'src/acad/java', 'src/no_google_donation/java', 'src/no_google_cast_lib/java']
|
||||
}
|
||||
google_peertube_apps_educ {
|
||||
google_acad {
|
||||
res.srcDirs = ['src/main/res', 'src/acad/res', 'src/no_google_cast_lib/res']
|
||||
java.srcDirs = ['src/main/java', 'src/acad/java', 'src/no_google_donation/java', 'src/no_google_cast_lib/java']
|
||||
java.srcDirs = ['src/main/java', 'src/acad/java', 'src/no_google_donation/java', 'src/google_cast_lib/java']
|
||||
}
|
||||
fdroid_full {
|
||||
res.srcDirs = ['src/main/res', 'src/full/res', 'src/no_google_cast_lib/res']
|
||||
|
@ -221,23 +222,23 @@ dependencies {
|
|||
|
||||
//************ MATOMO --> acad instances only **************//
|
||||
|
||||
fdroid_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2'
|
||||
google_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2'
|
||||
fdroid_acadImplementation 'org.matomo.sdk:tracker:4.1.2'
|
||||
google_acadImplementation 'org.matomo.sdk:tracker:4.1.2'
|
||||
|
||||
//************ CAST **************///
|
||||
|
||||
//---> Google libs (google_full + bittube)
|
||||
google_acadImplementation "androidx.mediarouter:mediarouter:1.2.1"
|
||||
google_acadImplementation 'com.google.android.gms:play-services-cast-framework:19.0.0'
|
||||
google_fullImplementation "androidx.mediarouter:mediarouter:1.2.1"
|
||||
google_fullImplementation 'com.google.android.gms:play-services-cast-framework:19.0.0'
|
||||
bittubeImplementation "androidx.mediarouter:mediarouter:1.2.1"
|
||||
bittubeImplementation 'com.google.android.gms:play-services-cast-framework:19.0.0'
|
||||
|
||||
//----> Other flavors
|
||||
fdroid_peertube_apps_educImplementation 'su.litvak.chromecast:api-v2:0.11.3'
|
||||
fdroid_peertube_apps_educImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
|
||||
fdroid_peertube_apps_educImplementation 'org.slf4j:slf4j-simple:1.7.30'
|
||||
google_peertube_apps_educImplementation 'su.litvak.chromecast:api-v2:0.11.3'
|
||||
google_peertube_apps_educImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
|
||||
google_peertube_apps_educImplementation 'org.slf4j:slf4j-simple:1.7.30'
|
||||
fdroid_acadImplementation 'su.litvak.chromecast:api-v2:0.11.3'
|
||||
fdroid_acadImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
|
||||
fdroid_acadImplementation 'org.slf4j:slf4j-simple:1.7.30'
|
||||
fdroid_fullImplementation 'su.litvak.chromecast:api-v2:0.11.3'
|
||||
fdroid_fullImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
|
||||
fdroid_fullImplementation 'org.slf4j:slf4j-simple:1.7.30'
|
||||
|
|
|
@ -27,16 +27,15 @@
|
|||
android:host="*"
|
||||
android:pathPrefix="/videos/watch/"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".PeertubeActivity" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".expandedcontrols.ExpandedControlsActivity"
|
||||
android:theme="@style/AppThemeNoActionBar"
|
||||
|
||||
/>
|
||||
|
||||
<meta-data
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.text.SpannableString;
|
|||
import android.text.Spanned;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -37,17 +38,16 @@ import androidx.core.content.ContextCompat;
|
|||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.fedilabtube.client.mastodon.RetrofitMastodonAPI;
|
||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.fedilabtube.client.entities.AcadInstances;
|
||||
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.client.entities.WellKnownNodeinfo;
|
||||
import app.fedilab.fedilabtube.client.mastodon.RetrofitMastodonAPI;
|
||||
import app.fedilab.fedilabtube.databinding.ActivityLoginBinding;
|
||||
import app.fedilab.fedilabtube.helper.Helper;
|
||||
import app.fedilab.fedilabtube.helper.HelperAcadInstance;
|
||||
|
@ -120,16 +120,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
if (!BuildConfig.full_instances) {
|
||||
binding.loginUid.setOnFocusChangeListener((v, hasFocus) -> {
|
||||
if (!hasFocus) {
|
||||
if (binding.loginUid.getText() != null && android.util.Patterns.EMAIL_ADDRESS.matcher(binding.loginUid.getText().toString().trim()).matches()) {
|
||||
String[] emailArray = binding.loginUid.getText().toString().split("@");
|
||||
if (emailArray.length > 1) {
|
||||
binding.loginButton.callOnClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
binding.loginUidContainer.setVisibility(View.GONE);
|
||||
binding.loginPasswdContainer.setVisibility(View.GONE);
|
||||
binding.loginInstanceContainer.setVisibility(View.GONE);
|
||||
|
@ -137,24 +128,24 @@ public class LoginActivity extends AppCompatActivity {
|
|||
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()];
|
||||
|
||||
List<AcadInstances> acadInstances = AcadInstances.getInstances();
|
||||
String[] academiesKey = new String[acadInstances.size()];
|
||||
String[] academiesValue = new String[acadInstances.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) {
|
||||
for (AcadInstances ac : acadInstances) {
|
||||
academiesKey[i] = ac.getName();
|
||||
academiesValue[i] = ac.getUrl();
|
||||
Log.v(Helper.TAG, "url 1: " + ac.getUrl());
|
||||
Log.v(Helper.TAG, "url 2: " + acad);
|
||||
if (ac.getUrl().compareTo(acad) == 0) {
|
||||
position = i;
|
||||
Log.v(Helper.TAG, "ok: " + position);
|
||||
}
|
||||
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);
|
||||
|
@ -162,6 +153,17 @@ public class LoginActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
acadInstance = academiesValue[position];
|
||||
if (acadInstances.get(position).isOpenId()) {
|
||||
binding.loginUidContainer.setVisibility(View.GONE);
|
||||
binding.loginPasswdContainer.setVisibility(View.GONE);
|
||||
binding.loginInstanceContainer.setVisibility(View.GONE);
|
||||
binding.createAnAccountPeertube.setVisibility(View.GONE);
|
||||
} else {
|
||||
binding.loginUidContainer.setVisibility(View.VISIBLE);
|
||||
binding.loginPasswdContainer.setVisibility(View.VISIBLE);
|
||||
binding.loginInstanceContainer.setVisibility(View.GONE);
|
||||
binding.createAnAccountPeertube.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -169,6 +171,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||
|
||||
}
|
||||
});
|
||||
binding.instancePicker.setSelection(position, true);
|
||||
}
|
||||
if (BuildConfig.allow_remote_connections) {
|
||||
binding.loginInstance.setOnFocusChangeListener((v, hasFocus) -> {
|
||||
|
@ -196,7 +199,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
binding.loginButton.setOnClickListener(v -> {
|
||||
if (!BuildConfig.full_instances) {
|
||||
if (!BuildConfig.full_instances && AcadInstances.isOpenId(acadInstance)) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Oauth oauth = new RetrofitPeertubeAPI(LoginActivity.this, acadInstance, null).oauthClient(null, null, null, null);
|
||||
|
@ -275,7 +278,6 @@ public class LoginActivity extends AppCompatActivity {
|
|||
return;
|
||||
}
|
||||
String finalInstance = instance;
|
||||
if (BuildConfig.full_instances) {
|
||||
new Thread(() -> {
|
||||
WellKnownNodeinfo.NodeInfo instanceNodeInfo = null;
|
||||
if (BuildConfig.allow_remote_connections) {
|
||||
|
@ -284,7 +286,6 @@ public class LoginActivity extends AppCompatActivity {
|
|||
connectToFediverse(finalInstance, instanceNodeInfo);
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -49,11 +49,8 @@ import com.kobakei.ratethisapp.RateThisApp;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -62,6 +59,7 @@ import java.util.regex.Pattern;
|
|||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
||||
import app.fedilab.fedilabtube.client.data.InstanceData;
|
||||
import app.fedilab.fedilabtube.client.entities.AcadInstances;
|
||||
import app.fedilab.fedilabtube.client.entities.Error;
|
||||
import app.fedilab.fedilabtube.client.entities.OauthParams;
|
||||
import app.fedilab.fedilabtube.client.entities.PeertubeInformation;
|
||||
|
@ -496,9 +494,9 @@ public class MainActivity extends BaseMainActivity {
|
|||
MenuItem settingsItem = menu.findItem(R.id.action_settings);
|
||||
MenuItem sepiaSearchItem = menu.findItem(R.id.action_sepia_search);
|
||||
MenuItem incognitoItem = menu.findItem(R.id.action_incognito);
|
||||
MenuItem instanceItem = menu.findItem(R.id.action_change_instance);
|
||||
MenuItem accountItem = menu.findItem(R.id.action_account);
|
||||
MenuItem donateItem = menu.findItem(R.id.action_donate);
|
||||
MenuItem changeInstanceItem = menu.findItem(R.id.action_change_instance);
|
||||
|
||||
FrameLayout rootView = (FrameLayout) accountItem.getActionView();
|
||||
|
||||
|
@ -512,24 +510,15 @@ public class MainActivity extends BaseMainActivity {
|
|||
redCircle.setVisibility(View.GONE);
|
||||
}
|
||||
TooltipCompat.setTooltipText(accountItem.getActionView(), getText(R.string.account));
|
||||
if (BuildConfig.full_instances && BuildConfig.google_restriction) {
|
||||
if (BuildConfig.FLAVOR.compareTo("google_full") == 0) {
|
||||
donateItem.setVisible(true);
|
||||
}
|
||||
|
||||
if (BuildConfig.surfing_mode && ((Helper.isLoggedIn(MainActivity.this) && typeOfConnection == NORMAL) || typeOfConnection == SURFING)) {
|
||||
binding.instances.setVisibility(View.VISIBLE);
|
||||
binding.instances.setOnClickListener(null);
|
||||
binding.instances.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(MainActivity.this, ManageInstancesActivity.class);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
|
||||
});
|
||||
} else {
|
||||
binding.instances.setVisibility(View.GONE);
|
||||
if (!BuildConfig.instance_switcher) {
|
||||
changeInstanceItem.setVisible(false);
|
||||
}
|
||||
switch (typeOfConnection) {
|
||||
case UNKNOWN:
|
||||
instanceItem.setVisible(false);
|
||||
accountItem.setVisible(false);
|
||||
uploadItem.setVisible(false);
|
||||
myVideosItem.setVisible(false);
|
||||
|
@ -543,7 +532,9 @@ public class MainActivity extends BaseMainActivity {
|
|||
case NORMAL:
|
||||
accountItem.setVisible(true);
|
||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||
instanceItem.setVisible(false);
|
||||
if (!BuildConfig.full_instances) {
|
||||
changeInstanceItem.setVisible(false);
|
||||
}
|
||||
uploadItem.setVisible(true);
|
||||
myVideosItem.setVisible(true);
|
||||
playslistItem.setVisible(true);
|
||||
|
@ -555,7 +546,6 @@ public class MainActivity extends BaseMainActivity {
|
|||
boolean checked = sharedpreferences.getBoolean(getString(R.string.set_store_in_history), true);
|
||||
incognitoItem.setChecked(checked);
|
||||
} else {
|
||||
instanceItem.setVisible(true);
|
||||
uploadItem.setVisible(false);
|
||||
myVideosItem.setVisible(false);
|
||||
playslistItem.setVisible(!BuildConfig.full_instances);
|
||||
|
@ -566,7 +556,6 @@ public class MainActivity extends BaseMainActivity {
|
|||
}
|
||||
break;
|
||||
case SURFING:
|
||||
instanceItem.setVisible(false);
|
||||
accountItem.setVisible(true);
|
||||
uploadItem.setVisible(false);
|
||||
myVideosItem.setVisible(false);
|
||||
|
@ -578,9 +567,6 @@ public class MainActivity extends BaseMainActivity {
|
|||
break;
|
||||
}
|
||||
|
||||
if (!BuildConfig.instance_switcher) {
|
||||
instanceItem.setVisible(false);
|
||||
}
|
||||
|
||||
if (!BuildConfig.sepia_search) {
|
||||
sepiaSearchItem.setVisible(false);
|
||||
|
@ -624,7 +610,9 @@ public class MainActivity extends BaseMainActivity {
|
|||
String action = "TIMELINE";
|
||||
if (item.getItemId() == R.id.action_change_instance) {
|
||||
if (BuildConfig.full_instances) {
|
||||
showRadioButtonDialogFullInstances(MainActivity.this, false);
|
||||
Intent intent = new Intent(MainActivity.this, ManageInstancesActivity.class);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
|
||||
} else {
|
||||
showRadioButtonDialog();
|
||||
}
|
||||
|
@ -738,21 +726,19 @@ public class MainActivity extends BaseMainActivity {
|
|||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String acad = HelperInstance.getLiveInstance(MainActivity.this);
|
||||
int i = 0;
|
||||
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()];
|
||||
List<AcadInstances> acadInstances = AcadInstances.getInstances();
|
||||
String[] academiesKey = new String[acadInstances.size()];
|
||||
String[] academiesValue = new String[acadInstances.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) {
|
||||
for (AcadInstances ac : acadInstances) {
|
||||
academiesKey[i] = ac.getName();
|
||||
academiesValue[i] = ac.getUrl();
|
||||
if (ac.getUrl().compareTo(acad) == 0) {
|
||||
position = i;
|
||||
}
|
||||
it.remove();
|
||||
i++;
|
||||
}
|
||||
|
||||
alt_bld.setSingleChoiceItems(academiesKey, position, (dialog, item) -> {
|
||||
String newInstance = academiesValue[item];
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
package app.fedilab.fedilabtube.client.entities;
|
||||
/* 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 java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import app.fedilab.fedilabtube.helper.HelperAcadInstance;
|
||||
|
||||
public class AcadInstances {
|
||||
|
||||
private String name;
|
||||
private String url;
|
||||
private boolean openId;
|
||||
|
||||
public static boolean isOpenId(String domain) {
|
||||
List<AcadInstances> instances = getInstances();
|
||||
for (AcadInstances acadInstance : instances) {
|
||||
if (acadInstance.getUrl().compareTo(domain) == 0) {
|
||||
return acadInstance.isOpenId();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<AcadInstances> getInstances() {
|
||||
List<AcadInstances> acadInstances = new ArrayList<>();
|
||||
|
||||
for (String academie : HelperAcadInstance.academies) {
|
||||
AcadInstances acadInstance = new AcadInstances();
|
||||
acadInstance.name = academie;
|
||||
acadInstance.openId = !Arrays.asList(HelperAcadInstance.notOpenId).contains(academie);
|
||||
acadInstance.url = getPeertubeUrl(academie);
|
||||
acadInstances.add(acadInstance);
|
||||
}
|
||||
HashMap<String, String> instancesMap = new HashMap<>(HelperAcadInstance.instances_themes);
|
||||
Iterator<Map.Entry<String, String>> it = instancesMap.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, String> pair = it.next();
|
||||
AcadInstances acadInstance = new AcadInstances();
|
||||
acadInstance.name = pair.getKey();
|
||||
acadInstance.openId = true;
|
||||
acadInstance.url = pair.getValue();
|
||||
acadInstances.add(acadInstance);
|
||||
it.remove();
|
||||
}
|
||||
return acadInstances;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the peertube URL depending of the academic domain name
|
||||
*
|
||||
* @param acad String academic domain name
|
||||
* @return String the peertube URL
|
||||
*/
|
||||
private static String getPeertubeUrl(String 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";
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public boolean isOpenId() {
|
||||
return openId;
|
||||
}
|
||||
|
||||
}
|
|
@ -32,6 +32,64 @@ public class HelperAcadInstance {
|
|||
public static String SUBSCRIPTIONS = "ABONNEMENTS";
|
||||
public static String MYVIDEOS = "VIDEOS";
|
||||
|
||||
|
||||
public static String[] notOpenId = {
|
||||
"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",
|
||||
"ac-lille.fr",
|
||||
"ac-limoges.fr",
|
||||
"ac-lyon.fr",
|
||||
"ac-mayotte.fr",
|
||||
"ac-montpellier.fr",
|
||||
"ac-nancy.fr",
|
||||
"ac-nantes.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[] 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"
|
||||
};
|
||||
|
||||
|
||||
//List of available emails
|
||||
public static String[] valideEmails = {
|
||||
"ac-aix-marseille.fr",
|
||||
|
@ -71,10 +129,11 @@ public class HelperAcadInstance {
|
|||
"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");
|
||||
//TODO: remove comments when instances will be available
|
||||
/* 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");
|
||||
|
@ -83,7 +142,7 @@ public class HelperAcadInstance {
|
|||
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");
|
||||
is.put("Cycle 3", "tube-cycle-3.apps.education.fr");*/
|
||||
instances_themes = Collections.unmodifiableMap(is);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,8 @@ public class HelperInstance {
|
|||
* @param context Context
|
||||
* @return String domain instance
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public static String getLiveInstance(Context context) {
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String acad;
|
||||
if (BuildConfig.FLAVOR.compareTo("fdroid_full") == 0 || BuildConfig.FLAVOR.compareTo("google_full") == 0) {
|
||||
return sharedpreferences.getString(Helper.PREF_INSTANCE, getDefaultInstance());
|
||||
} else if (BuildConfig.FLAVOR.compareTo("bittube") == 0) {
|
||||
|
@ -41,13 +39,15 @@ public class HelperInstance {
|
|||
} else if (BuildConfig.FLAVOR.compareTo("queermotion") == 0) {
|
||||
return sharedpreferences.getString(Helper.PREF_INSTANCE, "queermotion.org");
|
||||
} else {
|
||||
acad = sharedpreferences.getString(Helper.PREF_INSTANCE, "tube-institutionnelle.apps.education.fr");
|
||||
if (acad == null) {
|
||||
acad = "tube-institutionnelle.apps.education.fr";
|
||||
}
|
||||
return acad;
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, "tube.ac-lyon.fr");
|
||||
if (!instance.startsWith("tube")) {
|
||||
return "tube.ac-lyon.fr";
|
||||
} else {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a default instance host name depending of the device locale
|
||||
|
|
|
@ -81,6 +81,34 @@
|
|||
|
||||
</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_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/instance_picker_title" />
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/barrierTop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="bottom"
|
||||
app:constraint_referenced_ids="instance_picker, login_instance_container" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/login_uid_container"
|
||||
android:layout_width="0dp"
|
||||
|
@ -88,7 +116,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/login_instance_container">
|
||||
app:layout_constraintTop_toBottomOf="@id/barrierTop">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/login_uid"
|
||||
|
@ -121,27 +149,7 @@
|
|||
</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"
|
||||
|
|
|
@ -44,16 +44,6 @@
|
|||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
android:fitsSystemWindows="true"
|
||||
>
|
||||
<ImageView
|
||||
android:id="@+id/instances"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_baseline_public_24"
|
||||
android:layout_gravity="start"
|
||||
android:contentDescription="@string/instance_choice"
|
||||
android:layout_marginEnd="5dp"
|
||||
app:tint="?attr/colorAccent" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -9,17 +9,16 @@
|
|||
android:title="@string/search"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
app:showAsAction="always|collapseActionView" />
|
||||
<item
|
||||
android:id="@+id/action_change_instance"
|
||||
android:icon="@drawable/ic_baseline_track_changes_24"
|
||||
android:title="@string/change_instance"
|
||||
android:visible="false"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_account"
|
||||
app:actionLayout="@layout/counter_account_icon"
|
||||
android:title="@string/account"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_change_instance"
|
||||
android:icon="@drawable/ic_baseline_track_changes_24"
|
||||
android:title="@string/change_instance"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_playlist"
|
||||
android:icon="@drawable/ic_baseline_playlist_play_24"
|
||||
|
|
Loading…
Reference in New Issue