forked from mirrors/Fedilab
Release notes + fix a bad behavior when adding a Mastodon account from a Peertube one
This commit is contained in:
parent
96abece6da
commit
554335aa6e
6 changed files with 33 additions and 8 deletions
|
@ -623,11 +623,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
BaseMainActivity.currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
|
BaseMainActivity.currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
|
||||||
}
|
}
|
||||||
String software = sharedpreferences.getString(PREF_USER_SOFTWARE, null);
|
String software = sharedpreferences.getString(PREF_USER_SOFTWARE, null);
|
||||||
if (software != null && software.equalsIgnoreCase("peertube")) {
|
|
||||||
startActivity(new Intent(this, PeertubeMainActivity.class));
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
ActivityResultLauncher<String> permissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
|
ActivityResultLauncher<String> permissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
|
||||||
|
@ -649,6 +645,13 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
} catch (DBException e) {
|
} catch (DBException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
if (currentAccount != null && currentAccount.peertube_account != null) {
|
||||||
|
//It is a peertube user
|
||||||
|
Intent myIntent = new Intent(this, PeertubeMainActivity.class);
|
||||||
|
startActivity(myIntent);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
//If the attached account is null, the app will fetch remote instance to get up-to-date values
|
//If the attached account is null, the app will fetch remote instance to get up-to-date values
|
||||||
if (currentAccount != null && currentAccount.mastodon_account == null && currentAccount.peertube_account == null) {
|
if (currentAccount != null && currentAccount.mastodon_account == null && currentAccount.peertube_account == null) {
|
||||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||||
|
|
|
@ -15,6 +15,8 @@ package app.fedilab.android.activities;
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
|
||||||
|
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_SOFTWARE;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -70,6 +72,7 @@ public class LoginActivity extends BaseActivity {
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_USER_TOKEN, account.token);
|
editor.putString(Helper.PREF_USER_TOKEN, account.token);
|
||||||
|
editor.putString(PREF_USER_SOFTWARE, BaseMainActivity.api.name());
|
||||||
editor.commit();
|
editor.commit();
|
||||||
//The user is now authenticated, it will be redirected to MainActivity
|
//The user is now authenticated, it will be redirected to MainActivity
|
||||||
Runnable myRunnable = () -> {
|
Runnable myRunnable = () -> {
|
||||||
|
|
|
@ -905,7 +905,7 @@ public class Helper {
|
||||||
if (newAccount == null) {
|
if (newAccount == null) {
|
||||||
editor.putString(PREF_USER_TOKEN, null);
|
editor.putString(PREF_USER_TOKEN, null);
|
||||||
editor.putString(PREF_USER_INSTANCE, null);
|
editor.putString(PREF_USER_INSTANCE, null);
|
||||||
// editor.putString(PREF_USER_SOFTWARE, null);
|
editor.putString(PREF_USER_SOFTWARE, null);
|
||||||
editor.putString(PREF_USER_ID, null);
|
editor.putString(PREF_USER_ID, null);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
Intent loginActivity = new Intent(activity, LoginActivity.class);
|
Intent loginActivity = new Intent(activity, LoginActivity.class);
|
||||||
|
|
|
@ -72,6 +72,7 @@ import java.util.regex.Pattern;
|
||||||
import app.fedilab.android.BuildConfig;
|
import app.fedilab.android.BuildConfig;
|
||||||
import app.fedilab.android.R;
|
import app.fedilab.android.R;
|
||||||
import app.fedilab.android.activities.AboutActivity;
|
import app.fedilab.android.activities.AboutActivity;
|
||||||
|
import app.fedilab.android.activities.MainActivity;
|
||||||
import app.fedilab.android.activities.PeertubeBaseMainActivity;
|
import app.fedilab.android.activities.PeertubeBaseMainActivity;
|
||||||
import app.fedilab.android.databinding.ActivityMainPeertubeBinding;
|
import app.fedilab.android.databinding.ActivityMainPeertubeBinding;
|
||||||
import app.fedilab.android.databinding.NavHeaderMainBinding;
|
import app.fedilab.android.databinding.NavHeaderMainBinding;
|
||||||
|
@ -203,9 +204,16 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
||||||
} catch (DBException e) {
|
} catch (DBException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
if (currentAccount != null && currentAccount.mastodon_account != null) {
|
||||||
|
//It is a Mastodon User
|
||||||
|
Intent myIntent = new Intent(PeertubeMainActivity.this, MainActivity.class);
|
||||||
|
startActivity(myIntent);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//If the attached account is null, the app will fetch remote instance to get up-to-date values
|
//If the attached account is null, the app will fetch remote instance to get up-to-date values
|
||||||
if (currentAccount != null && currentAccount.mastodon_account == null && currentAccount.peertube_account == null) {
|
if (currentAccount != null && currentAccount.peertube_account == null) {
|
||||||
try {
|
try {
|
||||||
userMe = new RetrofitPeertubeAPI(PeertubeMainActivity.this, currentInstance, currentToken).verifyCredentials();
|
userMe = new RetrofitPeertubeAPI(PeertubeMainActivity.this, currentInstance, currentToken).verifyCredentials();
|
||||||
currentAccount.peertube_account = userMe.getAccount();
|
currentAccount.peertube_account = userMe.getAccount();
|
||||||
|
@ -213,6 +221,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> {
|
Runnable myRunnable = () -> {
|
||||||
headerMainBinding.accountAcc.setText(String.format("%s@%s", currentAccount.peertube_account.getUsername(), currentAccount.instance));
|
headerMainBinding.accountAcc.setText(String.format("%s@%s", currentAccount.peertube_account.getUsername(), currentAccount.instance));
|
||||||
|
|
|
@ -17,6 +17,7 @@ package app.fedilab.android.peertube.helper;
|
||||||
import static android.content.Context.DOWNLOAD_SERVICE;
|
import static android.content.Context.DOWNLOAD_SERVICE;
|
||||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID;
|
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID;
|
||||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE;
|
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE;
|
||||||
|
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_SOFTWARE;
|
||||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN;
|
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN;
|
||||||
import static app.fedilab.android.mastodon.helper.Helper.dialogStyle;
|
import static app.fedilab.android.mastodon.helper.Helper.dialogStyle;
|
||||||
import static app.fedilab.android.peertube.activities.PeertubeMainActivity.typeOfConnection;
|
import static app.fedilab.android.peertube.activities.PeertubeMainActivity.typeOfConnection;
|
||||||
|
@ -575,7 +576,7 @@ public class Helper {
|
||||||
editor.putString(CLIENT_SECRET, null);
|
editor.putString(CLIENT_SECRET, null);
|
||||||
editor.putString(PREF_USER_ID, null);
|
editor.putString(PREF_USER_ID, null);
|
||||||
editor.putString(PREF_USER_INSTANCE, null);
|
editor.putString(PREF_USER_INSTANCE, null);
|
||||||
// editor.putString(PREF_USER_SOFTWARE, null);
|
editor.putString(PREF_USER_SOFTWARE, null);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
Intent loginActivity = new Intent(activity, PeertubeMainActivity.class);
|
Intent loginActivity = new Intent(activity, PeertubeMainActivity.class);
|
||||||
activity.startActivity(loginActivity);
|
activity.startActivity(loginActivity);
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
Changed:
|
||||||
|
- Peertube support
|
||||||
|
|
||||||
|
Changed:
|
||||||
|
- Cross actions with two accounts display a dialog
|
||||||
|
|
||||||
|
Fixed:
|
||||||
|
|
||||||
|
- Fix crashes
|
Loading…
Reference in a new issue