From f0eaceb8a42d3aa39c507e6cdfd929b7070b4254 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 13 Sep 2020 19:20:04 +0200 Subject: [PATCH] apply flavors --- app/build.gradle | 33 ++- app/src/{main => acad}/res/values/strings.xml | 2 +- app/src/full/res/values/strings.xml | 204 ++++++++++++++++++ app/src/main/AndroidManifest.xml | 8 +- .../fedilab/fedilabtube/LoginActivity.java | 53 +++-- .../app/fedilab/fedilabtube/MainActivity.java | 50 ++++- .../fedilabtube/PeertubeRegisterActivity.java | 31 ++- .../fedilabtube/client/PeertubeAPI.java | 51 +++++ .../client/entities/InstanceNodeInfo.java | 137 ++++++++++++ .../fedilabtube/client/entities/NodeInfo.java | 37 ++++ .../fragment/DisplayPlaylistsFragment.java | 1 - .../fedilab/fedilabtube/helper/Helper.java | 23 +- app/src/main/res/drawable/colored_border.xml | 13 -- app/src/main/res/drawable/default_banner.xml | 10 - .../drawable/ic_baseline_arrow_back_24.xml | 10 - .../ic_baseline_arrow_forward_ios_24.xml | 10 - .../drawable/ic_baseline_arrow_white_24.xml | 10 - .../res/drawable/ic_baseline_close_24.xml | 10 - .../res/drawable/ic_dashboard_black_24dp.xml | 9 - .../res/drawable/ic_launcher_background.xml | 170 --------------- .../drawable/ic_notifications_black_24dp.xml | 9 - app/src/main/res/drawable/ic_user_minus.xml | 9 - app/src/main/res/drawable/ic_user_plus.xml | 10 - app/src/main/res/layout/activity_account.xml | 1 - app/src/main/res/layout/activity_login.xml | 22 +- .../main/res/layout/activity_playlists.xml | 1 - .../res/layout/activity_register_peertube.xml | 32 ++- .../main/res/layout/activity_show_account.xml | 3 - app/src/main/res/layout/activity_webview.xml | 1 - .../res/layout/activity_webview_connect.xml | 1 - .../layout/drawer_peertube_notification.xml | 1 - .../res/layout/exo_playback_control_view.xml | 125 ----------- app/src/main/res/layout/fragment_accounts.xml | 83 ------- .../layout/fragment_peertube_favourites.xml | 58 ----- .../res/layout/fragment_peertube_settings.xml | 67 ------ app/src/main/res/layout/simple_bar.xml | 53 ----- .../main/res/navigation/mobile_navigation.xml | 13 +- .../mobile_navigation_connected.xml | 1 - app/src/main/res/values-sw600dp/dimens.xml | 1 - app/src/main/res/values/dimens.xml | 6 - app/src/main/res/values/styles.xml | 6 - 41 files changed, 631 insertions(+), 744 deletions(-) rename app/src/{main => acad}/res/values/strings.xml (99%) create mode 100644 app/src/full/res/values/strings.xml create mode 100644 app/src/main/java/app/fedilab/fedilabtube/client/entities/InstanceNodeInfo.java create mode 100644 app/src/main/java/app/fedilab/fedilabtube/client/entities/NodeInfo.java delete mode 100644 app/src/main/res/drawable/colored_border.xml delete mode 100644 app/src/main/res/drawable/default_banner.xml delete mode 100644 app/src/main/res/drawable/ic_baseline_arrow_back_24.xml delete mode 100644 app/src/main/res/drawable/ic_baseline_arrow_forward_ios_24.xml delete mode 100644 app/src/main/res/drawable/ic_baseline_arrow_white_24.xml delete mode 100644 app/src/main/res/drawable/ic_baseline_close_24.xml delete mode 100644 app/src/main/res/drawable/ic_dashboard_black_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_launcher_background.xml delete mode 100644 app/src/main/res/drawable/ic_notifications_black_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_user_minus.xml delete mode 100644 app/src/main/res/drawable/ic_user_plus.xml delete mode 100644 app/src/main/res/layout/exo_playback_control_view.xml delete mode 100644 app/src/main/res/layout/fragment_accounts.xml delete mode 100644 app/src/main/res/layout/fragment_peertube_favourites.xml delete mode 100644 app/src/main/res/layout/fragment_peertube_settings.xml delete mode 100644 app/src/main/res/layout/simple_bar.xml diff --git a/app/build.gradle b/app/build.gradle index 5fc5908..cea73f1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,19 +34,38 @@ android { productFlavors { fdroid_acad { applicationId "app.fedilab.fedilabtube" - buildConfigField "string", "version", "fdroid_acad" - } - fdroid_full { - applicationId "app.fedilab.tubelab" - buildConfigField "string", "version", "fdroid_full" + buildConfigField "String", "version", "\"fdroid_acad\"" + buildConfigField "boolean", "full_instances", "false" } google_acad { applicationId "app.fedilab.fedilabtube" - buildConfigField "string", "version", "google_acad" + buildConfigField "String", "version", "\"google_acad\"" + buildConfigField "boolean", "full_instances", "false" + } + fdroid_full { + applicationId "app.fedilab.tubelab" + buildConfigField "String", "version", "\"fdroid_full\"" + buildConfigField "boolean", "full_instances", "true" } google_full { applicationId "app.fedilab.tubelab" - buildConfigField "string", "version", "google_full" + buildConfigField "String", "version", "\"google_full\"" + buildConfigField "boolean", "full_instances", "true" + } + } + + sourceSets { + fdroid_acad { + res.srcDirs = ['src/main/res', 'src/acad/res'] + } + google_acad { + res.srcDirs = ['src/main/res', 'src/acad/res'] + } + fdroid_full { + res.srcDirs = ['src/main/res', 'src/full/res'] + } + google_full { + res.srcDirs = ['src/main/res', 'src/full/res'] } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/acad/res/values/strings.xml similarity index 99% rename from app/src/main/res/values/strings.xml rename to app/src/acad/res/values/strings.xml index e56c866..982d699 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/acad/res/values/strings.xml @@ -211,4 +211,4 @@ Afficher la liste Supprimer la liste de lecture Modifier - \ No newline at end of file + diff --git a/app/src/full/res/values/strings.xml b/app/src/full/res/values/strings.xml new file mode 100644 index 0000000..b5a99b0 --- /dev/null +++ b/app/src/full/res/values/strings.xml @@ -0,0 +1,204 @@ + + Tubelab + Home + Discover + Notifications + Recently added + Trending + Most liked + Oops! An error occurred! + + No videos! + Favicon + Open with + + Close + Upload + Image preview + Select the file to upload + + Channel + Videos + Channels + + Yes + No + Cancel + Download + Profile picture + Update video + + + %d s + %d m + %d h + %d d + %s views + + Instance host + Uploading, please wait… + The video has been uploaded! + Upload cancelled! + Tap here to edit the video data. + + An error occurred while selecting the media! + + Download %1$s + + + Privacy + Logout + Login + + + Password + Email + Tags + + Validate + Share with + Shared via Fedilab + User name + + Settings + Are you sure you want to logout @%1$s@%2$s? + + Following + Followers + Unable to get client id! + An error occurred while switching between accounts! + An error occurred while searching! + No action can be taken + + + Follow + + Mute + + Search + Delete + + + Are you sure you want to permanently delete this list? + Delete list + + + Be the first to leave a comment on this video with the top right button! + + Comments are not enabled on this video! + Pick up a resolution + The video has been added to bookmarks! + The video has been removed from bookmarks! + + Information + Logo of the application + + + + Subscriptions + + Delete a comment + Are you sure to delete this comment? + Mode for videos + + My videos + Title + License + Category + Language + This video contains mature or explicit content + Enable video comments + + Description + The video has been updated! + + + Register an account + Email address + Preview + Change preview + Name + Display more + No channels! + Some explanations about your report… + Report video + Report + Pickup another instance + History + Edit + + set_video_mode_choice + Allows to change mode for playing videos (default, streaming or via a browser). + + + Delete video + Are you sure to delete this video? + No videos to display! + Share + %1$s commented your video %2$s]]> + %1$s is following your channel %2$s]]> + %1$s is following your account]]> + + %1$s has been published]]> + %1$s succeeded]]> + %1$s failed]]> + %1$s published a new video: %2$s]]> + %1$s has been blacklisted]]> + %1$s has been unblacklisted]]> + Add a public comment + Send comment + All + + + Playlists + Display name + You don\'t have any playlists. Tap on the \"+\" icon to add a new playlist + You must provide a display name! + The channel is required when the playlist is public. + Create a playlist + There is nothing in this playlist yet. + Confirm password + I agree to %1$s and %2$s + server rules + terms of service + Sign up + Please, fill all the fields! + Passwords don\'t match! + The email doesn\'t seem to be valid! + You will be sent a confirmation e-mail + Use at least 8 characters + Password should contain at least 8 characters + Username should only contain letters, numbers and underscores + Account created! + + Your account has been created!\n\n + Think to validate your email within the 48 next hours.\n\n + You can now connect your account by writing %1$s in the first field and tap on Connect.\n\n + Important: If your instance required validation, you will receive an email once it is validated! + + Account + Report account + + + Webview + Direct stream + + + + Do you want to unfollow this account? + + + Title for the video + Join Peertube + I am at least 16 years old and agree to the %1$s of this instance + Edit profile + Make an action + + + Unfollow + + Display sensitive videos + Fullscreen + There are no videos in your favourites! + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cd7115f..9fdcec9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -54,7 +54,7 @@ android:name=".AccountActivity" android:configChanges="orientation|screenSize" android:label="@string/app_name" - android:windowSoftInputMode="stateAlwaysHidden"/> + android:windowSoftInputMode="stateAlwaysHidden" /> - + android:windowSoftInputMode="stateAlwaysHidden"> - + android:windowSoftInputMode="stateAlwaysHidden"> 1 && !Arrays.asList(Helper.valideEmails).contains(emailArray[1])) { - Toasty.error(LoginActivity.this, getString(R.string.email_error_domain, emailArray[1])).show(); - return; - } - String host = emailArray[1]; - String instance = Helper.getPeertubeUrl(host); - final HashMap parameters = new HashMap<>(); + + connectionButton.setEnabled(false); - - try { - instance = URLEncoder.encode(instance, "utf-8"); - } catch (UnsupportedEncodingException e) { - Toasty.error(LoginActivity.this, getString(R.string.client_error), Toast.LENGTH_LONG).show(); + final HashMap parameters = new HashMap<>(); + String instance, host; + if (!BuildConfig.full_instances) { + String[] emailArray = login_uid.getText().toString().split("@"); + if (emailArray.length > 1 && !Arrays.asList(Helper.valideEmails).contains(emailArray[1])) { + Toasty.error(LoginActivity.this, getString(R.string.email_error_domain, emailArray[1])).show(); + return; + } + host = emailArray[1]; + instance = Helper.getPeertubeUrl(host); + } else { + if (login_instance == null || login_instance.getText() == null || login_instance.getText().toString().trim().length() == 0) { + Toasty.error(LoginActivity.this, getString(R.string.instance_fails)).show(); + return; + } + instance = host = login_instance.getText().toString(); } - if (Arrays.asList(Helper.openid).contains(host)) { - String finalInstance = instance; + if (Arrays.asList(Helper.openid).contains(host) || !BuildConfig.full_instances) { new Thread(() -> { try { actionToken = "/api/v1/oauth-clients/local"; - String response = new HttpsConnection(LoginActivity.this).get("https://" + finalInstance + actionToken, 30, null, null); + String response = new HttpsConnection(LoginActivity.this).get("https://" + instance + actionToken, 30, null, null); if (response == null) { runOnUiThread(() -> { connectionButton.setEnabled(true); @@ -192,11 +204,10 @@ public class LoginActivity extends AppCompatActivity { parameters.put(Helper.REDIRECT_URIS, Helper.REDIRECT_CONTENT); parameters.put(Helper.SCOPES, Helper.OAUTH_SCOPES_PEERTUBE); parameters.put(Helper.WEBSITE, Helper.WEBSITE_VALUE); - String finalInstance = instance; new Thread(() -> { try { actionToken = "/api/v1/oauth-clients/local"; - String response = new HttpsConnection(LoginActivity.this).get("https://" + finalInstance + actionToken, 30, parameters, null); + String response = new HttpsConnection(LoginActivity.this).get("https://" + instance + actionToken, 30, parameters, null); if (response == null) { runOnUiThread(() -> { connectionButton.setEnabled(true); @@ -231,7 +242,7 @@ public class LoginActivity extends AppCompatActivity { parameters.put("scope", "user"); String oauthUrl = "/api/v1/users/token"; try { - String responseLogin = new HttpsConnection(LoginActivity.this).post("https://" + finalInstance + oauthUrl, 30, parameters, null); + String responseLogin = new HttpsConnection(LoginActivity.this).post("https://" + instance + oauthUrl, 30, parameters, null); proceedLogin(responseLogin, host); } catch (final Exception e) { parameters.clear(); @@ -250,7 +261,7 @@ public class LoginActivity extends AppCompatActivity { } parameters.put("scope", "user"); try { - String responseLogin = new HttpsConnection(LoginActivity.this).post("https://" + finalInstance + oauthUrl, 30, parameters, null); + String responseLogin = new HttpsConnection(LoginActivity.this).post("https://" + instance + oauthUrl, 30, parameters, null); proceedLogin(responseLogin, host); } catch (final Exception e2) { e2.printStackTrace(); diff --git a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java index 7bfb67b..594e6ac 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java @@ -22,6 +22,9 @@ import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.Toast; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; @@ -43,11 +46,13 @@ import java.util.LinkedHashMap; import app.fedilab.fedilabtube.client.HttpsConnection; import app.fedilab.fedilabtube.client.PeertubeAPI; import app.fedilab.fedilabtube.client.entities.Account; +import app.fedilab.fedilabtube.client.entities.InstanceNodeInfo; import app.fedilab.fedilabtube.client.entities.PeertubeInformation; import app.fedilab.fedilabtube.helper.Helper; import app.fedilab.fedilabtube.sqlite.AccountDAO; import app.fedilab.fedilabtube.sqlite.Sqlite; import app.fedilab.fedilabtube.viewmodel.FeedsVM; +import es.dmoral.toasty.Toasty; import static app.fedilab.fedilabtube.helper.Helper.academies; @@ -173,7 +178,11 @@ public class MainActivity extends AppCompatActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_change_instance) { - showRadioButtonDialog(); + if (BuildConfig.full_instances) { + showRadioButtonDialogFullInstances(); + } else { + showRadioButtonDialog(); + } return true; } else if (item.getItemId() == R.id.action_account) { Intent intent; @@ -249,4 +258,43 @@ public class MainActivity extends AppCompatActivity { AlertDialog alert = alt_bld.create(); alert.show(); } + + @SuppressLint("ApplySharedPref") + private void showRadioButtonDialogFullInstances() { + final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); + alt_bld.setTitle(R.string.instance_choice); + String instance = Helper.getLiveInstance(MainActivity.this); + final EditText input = new EditText(MainActivity.this); + LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT); + input.setLayoutParams(lp); + alt_bld.setView(input); + input.setText(instance); + alt_bld.setPositiveButton(R.string.validate, + (dialog, which) -> new Thread(() -> { + try { + String newInstance = input.getText().toString().trim(); + InstanceNodeInfo instanceNodeInfo = new PeertubeAPI(MainActivity.this).displayNodeInfo(newInstance); + if (instanceNodeInfo.getName() != null && instanceNodeInfo.getName().trim().toLowerCase().compareTo("peertube") == 0) { + SharedPreferences.Editor editor = sharedpreferences.edit(); + editor.putString(Helper.PREF_INSTANCE, newInstance); + editor.commit(); + runOnUiThread(() -> { + dialog.dismiss(); + recreate(); + }); + } else { + runOnUiThread(() -> Toasty.error(MainActivity.this, getString(R.string.not_valide_instance), Toast.LENGTH_LONG).show()); + } + } catch (Exception e) { + e.printStackTrace(); + } + + }).start()); + alt_bld.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); + AlertDialog alert = alt_bld.create(); + alert.show(); + } } \ No newline at end of file diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeRegisterActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeRegisterActivity.java index 7bee622..f84f5ce 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeRegisterActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeRegisterActivity.java @@ -30,6 +30,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import com.google.android.material.textfield.TextInputEditText; +import com.google.android.material.textfield.TextInputLayout; import java.util.Arrays; import java.util.regex.Matcher; @@ -58,13 +59,19 @@ public class PeertubeRegisterActivity extends AppCompatActivity { getSupportActionBar().setDisplayHomeAsUpEnabled(true); signup = findViewById(R.id.signup); + + TextInputLayout login_instance_container = findViewById(R.id.login_instance_container); TextInputEditText username = findViewById(R.id.username); TextInputEditText email = findViewById(R.id.email); TextInputEditText password = findViewById(R.id.password); TextInputEditText password_confirm = findViewById(R.id.password_confirm); + TextInputEditText login_instance = findViewById(R.id.login_instance); CheckBox agreement = findViewById(R.id.agreement); error_message = findViewById(R.id.error_message); + if (BuildConfig.full_instances) { + login_instance_container.setVisibility(View.VISIBLE); + } username.setOnFocusChangeListener((view, focused) -> { if (!focused && username.getText() != null) { @@ -134,8 +141,13 @@ public class PeertubeRegisterActivity extends AppCompatActivity { } signup.setEnabled(false); - String host = emailArray[1]; - instance = Helper.getPeertubeUrl(host); + if (BuildConfig.full_instances) { + instance = login_instance.getText().toString(); + } else { + String host = emailArray[1]; + instance = Helper.getPeertubeUrl(host); + } + AccountCreation accountCreation = new AccountCreation(); accountCreation.setEmail(email.getText().toString().trim()); accountCreation.setPassword(password.getText().toString().trim()); @@ -193,10 +205,17 @@ public class PeertubeRegisterActivity extends AppCompatActivity { TextView agreement_text = findViewById(R.id.agreement_text); String tos = getString(R.string.tos); String serverrules = getString(R.string.server_rules); - String content_agreement = getString(R.string.agreement_check, - "" + serverrules + "", - "" + tos + "" - ); + String content_agreement; + if (BuildConfig.full_instances) { + content_agreement = getString(R.string.agreement_check_peertube, + "" + tos + "" + ); + } else { + content_agreement = getString(R.string.agreement_check, + "" + serverrules + "", + "" + tos + "" + ); + } agreement_text.setMovementMethod(LinkMovementMethod.getInstance()); agreement_text.setText(Html.fromHtml(content_agreement)); setTitle(R.string.create_an_account); diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java index 686ffb1..1a6b4b7 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java @@ -48,6 +48,8 @@ import app.fedilab.fedilabtube.client.entities.AccountCreation; import app.fedilab.fedilabtube.client.entities.ChannelCreation; import app.fedilab.fedilabtube.client.entities.Error; import app.fedilab.fedilabtube.client.entities.Instance; +import app.fedilab.fedilabtube.client.entities.InstanceNodeInfo; +import app.fedilab.fedilabtube.client.entities.NodeInfo; import app.fedilab.fedilabtube.client.entities.Peertube; import app.fedilab.fedilabtube.client.entities.PeertubeAccountNotification; import app.fedilab.fedilabtube.client.entities.PeertubeActorFollow; @@ -2091,6 +2093,55 @@ public class PeertubeAPI { return accounts; } + public InstanceNodeInfo displayNodeInfo(String domain) { + if (domain == null) { + return null; + } + String response; + InstanceNodeInfo instanceNodeInfo = new InstanceNodeInfo(); + if (domain.startsWith("http://")) { + domain = domain.replace("http://", ""); + } + if (domain.startsWith("https://")) { + domain = domain.replace("https://", ""); + } + try { + response = new HttpsConnection(context).get("https://" + domain + "/.well-known/nodeinfo", 30, null, null); + JSONArray jsonArray = new JSONObject(response).getJSONArray("links"); + ArrayList nodeInfos = new ArrayList<>(); + try { + int i = 0; + while (i < jsonArray.length()) { + + JSONObject resobj = jsonArray.getJSONObject(i); + NodeInfo nodeInfo = new NodeInfo(); + nodeInfo.setHref(resobj.getString("href")); + nodeInfo.setRel(resobj.getString("rel")); + i++; + nodeInfos.add(nodeInfo); + } + if (nodeInfos.size() > 0) { + NodeInfo nodeInfo = nodeInfos.get(nodeInfos.size() - 1); + response = new HttpsConnection(context).get(nodeInfo.getHref(), 30, null, null); + JSONObject resobj = new JSONObject(response); + JSONObject jsonObject = resobj.getJSONObject("software"); + String name = jsonObject.getString("name").toUpperCase(); + if (name.compareTo("CORGIDON") == 0) { + name = "MASTODON"; + } + instanceNodeInfo.setName(name); + instanceNodeInfo.setVersion(jsonObject.getString("version")); + instanceNodeInfo.setOpenRegistrations(resobj.getBoolean("openRegistrations")); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } catch (IOException | JSONException | NoSuchAlgorithmException | KeyManagementException | HttpsConnection.HttpsConnectionException e) { + e.printStackTrace(); + } + return instanceNodeInfo; + } + /** * Set the error message * diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/InstanceNodeInfo.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/InstanceNodeInfo.java new file mode 100644 index 0000000..adefab2 --- /dev/null +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/InstanceNodeInfo.java @@ -0,0 +1,137 @@ +package app.fedilab.fedilabtube.client.entities; + +/* 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 . */ +@SuppressWarnings("unused") +public class InstanceNodeInfo { + + private String name; + private String title; + private String version; + private boolean openRegistrations; + private boolean connectionError; + private int numberOfUsers = 0; + private int numberOfPosts = 0; + private int numberOfInstance = 0; + private String staffAccountStr; + private Account staffAccount; + private String nodeName; + private String nodeDescription; + private String thumbnail; + + 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; + } + + public boolean isOpenRegistrations() { + return openRegistrations; + } + + public void setOpenRegistrations(boolean openRegistrations) { + this.openRegistrations = openRegistrations; + } + + public boolean isConnectionError() { + return connectionError; + } + + public void setConnectionError(boolean connectionError) { + this.connectionError = connectionError; + } + + public int getNumberOfUsers() { + return numberOfUsers; + } + + public void setNumberOfUsers(int numberOfUsers) { + this.numberOfUsers = numberOfUsers; + } + + public int getNumberOfPosts() { + return numberOfPosts; + } + + public void setNumberOfPosts(int numberOfPosts) { + this.numberOfPosts = numberOfPosts; + } + + public String getStaffAccountStr() { + return staffAccountStr; + } + + public void setStaffAccountStr(String staffAccountStr) { + this.staffAccountStr = staffAccountStr; + } + + public Account getStaffAccount() { + return staffAccount; + } + + public void setStaffAccount(Account staffAccount) { + this.staffAccount = staffAccount; + } + + public String getNodeName() { + return nodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + public String getNodeDescription() { + return nodeDescription; + } + + public void setNodeDescription(String nodeDescription) { + this.nodeDescription = nodeDescription; + } + + public String getThumbnail() { + return thumbnail; + } + + public void setThumbnail(String thumbnail) { + this.thumbnail = thumbnail; + } + + public int getNumberOfInstance() { + return numberOfInstance; + } + + public void setNumberOfInstance(int numberOfInstance) { + this.numberOfInstance = numberOfInstance; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } +} diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/NodeInfo.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/NodeInfo.java new file mode 100644 index 0000000..56a6a52 --- /dev/null +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/NodeInfo.java @@ -0,0 +1,37 @@ +package app.fedilab.fedilabtube.client.entities; + +/* 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 . */ +@SuppressWarnings("unused") +public class NodeInfo { + private String rel; + private String href; + + public String getRel() { + return rel; + } + + public void setRel(String rel) { + this.rel = rel; + } + + public String getHref() { + return href; + } + + public void setHref(String href) { + this.href = href; + } +} diff --git a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayPlaylistsFragment.java b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayPlaylistsFragment.java index ac2fe3b..f43afd5 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayPlaylistsFragment.java +++ b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayPlaylistsFragment.java @@ -38,7 +38,6 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; import com.google.android.material.floatingactionbutton.FloatingActionButton; diff --git a/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java b/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java index 1c235eb..a15bbf1 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java +++ b/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java @@ -56,6 +56,7 @@ import java.util.Locale; import java.util.TimeZone; import java.util.regex.Pattern; +import app.fedilab.fedilabtube.BuildConfig; import app.fedilab.fedilabtube.MainActivity; import app.fedilab.fedilabtube.R; import app.fedilab.fedilabtube.WebviewActivity; @@ -209,6 +210,9 @@ public class Helper { */ 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) { @@ -241,14 +245,19 @@ public class Helper { */ public static String getLiveInstance(Context context) { final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); - String acad = sharedpreferences.getString(Helper.PREF_INSTANCE, "tube.ac-lyon.fr"); - if (acad == null) { - acad = "tube.ac-lyon.fr"; - } - if (acad.startsWith("tube-")) { - return acad; + String acad; + if (BuildConfig.full_instances) { + return sharedpreferences.getString(Helper.PREF_INSTANCE, "peertube.social"); } else { - return getPeertubeUrl(acad); + acad = sharedpreferences.getString(Helper.PREF_INSTANCE, "tube.ac-lyon.fr"); + if (acad == null) { + acad = "tube.ac-lyon.fr"; + } + if (acad.startsWith("tube-")) { + return acad; + } else { + return getPeertubeUrl(acad); + } } } diff --git a/app/src/main/res/drawable/colored_border.xml b/app/src/main/res/drawable/colored_border.xml deleted file mode 100644 index 320a81e..0000000 --- a/app/src/main/res/drawable/colored_border.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/default_banner.xml b/app/src/main/res/drawable/default_banner.xml deleted file mode 100644 index 2324a79..0000000 --- a/app/src/main/res/drawable/default_banner.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_baseline_arrow_back_24.xml b/app/src/main/res/drawable/ic_baseline_arrow_back_24.xml deleted file mode 100644 index c9d2255..0000000 --- a/app/src/main/res/drawable/ic_baseline_arrow_back_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_baseline_arrow_forward_ios_24.xml b/app/src/main/res/drawable/ic_baseline_arrow_forward_ios_24.xml deleted file mode 100644 index edd53d2..0000000 --- a/app/src/main/res/drawable/ic_baseline_arrow_forward_ios_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_baseline_arrow_white_24.xml b/app/src/main/res/drawable/ic_baseline_arrow_white_24.xml deleted file mode 100644 index 5d09b98..0000000 --- a/app/src/main/res/drawable/ic_baseline_arrow_white_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_baseline_close_24.xml b/app/src/main/res/drawable/ic_baseline_close_24.xml deleted file mode 100644 index d5d2297..0000000 --- a/app/src/main/res/drawable/ic_baseline_close_24.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_dashboard_black_24dp.xml b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml deleted file mode 100644 index 46fc8de..0000000 --- a/app/src/main/res/drawable/ic_dashboard_black_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9..0000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/ic_notifications_black_24dp.xml b/app/src/main/res/drawable/ic_notifications_black_24dp.xml deleted file mode 100644 index 78b75c3..0000000 --- a/app/src/main/res/drawable/ic_notifications_black_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_user_minus.xml b/app/src/main/res/drawable/ic_user_minus.xml deleted file mode 100644 index 07f4851..0000000 --- a/app/src/main/res/drawable/ic_user_minus.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_user_plus.xml b/app/src/main/res/drawable/ic_user_plus.xml deleted file mode 100644 index d3db0c3..0000000 --- a/app/src/main/res/drawable/ic_user_plus.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml index 135dbdf..1b2c595 100644 --- a/app/src/main/res/layout/activity_account.xml +++ b/app/src/main/res/layout/activity_account.xml @@ -23,7 +23,6 @@ tools:context=".AccountActivity"> @@ -72,13 +71,32 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + + + + + app:layout_constraintTop_toBottomOf="@id/login_instance_container"> diff --git a/app/src/main/res/layout/activity_register_peertube.xml b/app/src/main/res/layout/activity_register_peertube.xml index 8e270d4..8eea78b 100644 --- a/app/src/main/res/layout/activity_register_peertube.xml +++ b/app/src/main/res/layout/activity_register_peertube.xml @@ -33,7 +33,6 @@ android:orientation="horizontal"> + + + + + + + + + + @@ -83,7 +105,6 @@ @@ -96,7 +117,6 @@ android:text="@string/email" /> @@ -121,7 +141,6 @@ android:text="@string/password" /> @@ -149,7 +168,6 @@ diff --git a/app/src/main/res/layout/activity_show_account.xml b/app/src/main/res/layout/activity_show_account.xml index cf4be13..212d12a 100644 --- a/app/src/main/res/layout/activity_show_account.xml +++ b/app/src/main/res/layout/activity_show_account.xml @@ -23,7 +23,6 @@ tools:context=".ShowAccountActivity">