fix(auth): use BuildType depended redirect uri

This commit is contained in:
FineFindus 2023-04-09 15:46:30 +02:00
parent 7615723d4f
commit a59587eb62
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
3 changed files with 16 additions and 2 deletions

View File

@ -5,6 +5,7 @@ plugins {
android { android {
compileSdk 33 compileSdk 33
defaultConfig { defaultConfig {
manifestPlaceholders = [oAuthScheme:"moshidon-android-auth"]
archivesBaseName = "moshidon" archivesBaseName = "moshidon"
applicationId "org.joinmastodon.android.moshinda" applicationId "org.joinmastodon.android.moshinda"
minSdk 23 minSdk 23
@ -34,6 +35,7 @@ android {
debuggable true debuggable true
versionNameSuffix '-debug' versionNameSuffix '-debug'
applicationIdSuffix '.debug' applicationIdSuffix '.debug'
manifestPlaceholders = [oAuthScheme:"moshidon-android-debug-auth"]
} }
githubRelease{ githubRelease{
initWith release initWith release
@ -43,6 +45,7 @@ android {
versionNameSuffix '-nightly' versionNameSuffix '-nightly'
applicationIdSuffix '.nightly' applicationIdSuffix '.nightly'
signingConfig signingConfigs.nightly signingConfig signingConfigs.nightly
manifestPlaceholders = [oAuthScheme:"moshidon-android-nightly-auth"]
} }
playRelease{ playRelease{
initWith release initWith release

View File

@ -41,7 +41,7 @@
<action android:name="android.intent.action.VIEW"/> <action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/> <category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="moshidon-android-auth" android:host="callback"/> <data android:scheme="${oAuthScheme}" android:host="callback"/>
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".ExternalShareActivity" android:exported="true" android:configChanges="orientation|screenSize" android:windowSoftInputMode="adjustResize" <activity android:name=".ExternalShareActivity" android:exported="true" android:configChanges="orientation|screenSize" android:windowSoftInputMode="adjustResize"

View File

@ -65,7 +65,7 @@ import me.grishka.appkit.api.ErrorResponse;
public class AccountSessionManager{ public class AccountSessionManager{
private static final String TAG="AccountSessionManager"; private static final String TAG="AccountSessionManager";
public static final String SCOPE="read write follow push"; public static final String SCOPE="read write follow push";
public static final String REDIRECT_URI="moshidon-android-auth://callback"; public static final String REDIRECT_URI = getRedirectURI();
private static final AccountSessionManager instance=new AccountSessionManager(); private static final AccountSessionManager instance=new AccountSessionManager();
@ -84,6 +84,17 @@ public class AccountSessionManager{
return instance; return instance;
} }
public static String getRedirectURI() {
StringBuilder builder = new StringBuilder();
builder.append("moshidon-android-");
if (BuildConfig.BUILD_TYPE.equals("debug") || BuildConfig.BUILD_TYPE.equals("nightly")) {
builder.append(BuildConfig.BUILD_TYPE);
builder.append('-');
}
builder.append("auth://callback");
return builder.toString();
}
private AccountSessionManager(){ private AccountSessionManager(){
prefs=MastodonApp.context.getSharedPreferences("account_manager", Context.MODE_PRIVATE); prefs=MastodonApp.context.getSharedPreferences("account_manager", Context.MODE_PRIVATE);
File file=new File(MastodonApp.context.getFilesDir(), "accounts.json"); File file=new File(MastodonApp.context.getFilesDir(), "accounts.json");