Loading app/src/main/java/app/fedilab/android/BaseMainActivity.java +8 −5 Original line number Diff line number Diff line Loading @@ -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 -> { Loading @@ -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() Loading app/src/main/java/app/fedilab/android/activities/LoginActivity.java +3 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 = () -> { Loading app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java +10 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading @@ -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)); Loading app/src/main/java/app/fedilab/android/peertube/helper/Helper.java +2 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading
app/src/main/java/app/fedilab/android/BaseMainActivity.java +8 −5 Original line number Diff line number Diff line Loading @@ -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 -> { Loading @@ -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() Loading
app/src/main/java/app/fedilab/android/activities/LoginActivity.java +3 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 = () -> { Loading
app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading
app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java +10 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading @@ -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)); Loading
app/src/main/java/app/fedilab/android/peertube/helper/Helper.java +2 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading