Release notes + fix a bad behavior when adding a Mastodon account from a Peertube one

This commit is contained in:
Thomas 2023-01-27 11:36:25 +01:00
parent 96abece6da
commit 554335aa6e
6 changed files with 33 additions and 8 deletions

View file

@ -623,11 +623,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
BaseMainActivity.currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, 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) {
ActivityResultLauncher<String> permissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
@ -649,6 +645,13 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
} catch (DBException e) {
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 (currentAccount != null && currentAccount.mastodon_account == null && currentAccount.peertube_account == null) {
OkHttpClient okHttpClient = new OkHttpClient.Builder()

View file

@ -15,6 +15,8 @@ package app.fedilab.android.activities;
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_SOFTWARE;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
@ -70,6 +72,7 @@ public class LoginActivity extends BaseActivity {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_USER_TOKEN, account.token);
editor.putString(PREF_USER_SOFTWARE, BaseMainActivity.api.name());
editor.commit();
//The user is now authenticated, it will be redirected to MainActivity
Runnable myRunnable = () -> {

View file

@ -905,7 +905,7 @@ public class Helper {
if (newAccount == null) {
editor.putString(PREF_USER_TOKEN, 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.commit();
Intent loginActivity = new Intent(activity, LoginActivity.class);

View file

@ -72,6 +72,7 @@ import java.util.regex.Pattern;
import app.fedilab.android.BuildConfig;
import app.fedilab.android.R;
import app.fedilab.android.activities.AboutActivity;
import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.activities.PeertubeBaseMainActivity;
import app.fedilab.android.databinding.ActivityMainPeertubeBinding;
import app.fedilab.android.databinding.NavHeaderMainBinding;
@ -203,9 +204,16 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
} catch (DBException e) {
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 (currentAccount != null && currentAccount.mastodon_account == null && currentAccount.peertube_account == null) {
if (currentAccount != null && currentAccount.peertube_account == null) {
try {
userMe = new RetrofitPeertubeAPI(PeertubeMainActivity.this, currentInstance, currentToken).verifyCredentials();
currentAccount.peertube_account = userMe.getAccount();
@ -213,6 +221,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
e.printStackTrace();
}
}
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
headerMainBinding.accountAcc.setText(String.format("%s@%s", currentAccount.peertube_account.getUsername(), currentAccount.instance));

View file

@ -17,6 +17,7 @@ package app.fedilab.android.peertube.helper;
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_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.dialogStyle;
import static app.fedilab.android.peertube.activities.PeertubeMainActivity.typeOfConnection;
@ -575,7 +576,7 @@ public class Helper {
editor.putString(CLIENT_SECRET, null);
editor.putString(PREF_USER_ID, null);
editor.putString(PREF_USER_INSTANCE, null);
// editor.putString(PREF_USER_SOFTWARE, null);
editor.putString(PREF_USER_SOFTWARE, null);
editor.apply();
Intent loginActivity = new Intent(activity, PeertubeMainActivity.class);
activity.startActivity(loginActivity);

View file

@ -0,0 +1,9 @@
Changed:
- Peertube support
Changed:
- Cross actions with two accounts display a dialog
Fixed:
- Fix crashes