diff options
author | Unpublished <unpublished@gmx.net> | 2021-02-28 14:37:18 +0300 |
---|---|---|
committer | Unpublished <unpublished@gmx.net> | 2021-02-28 14:38:13 +0300 |
commit | 99d3687aaf554440fb7754a4d52675d3900c36dc (patch) | |
tree | 8bd3804117d637bd7a7a9a32035ffc2197298182 /News-Android-App/src/main/java | |
parent | 56dd0f631cec1f1c63d1981a9b3dcc4be68f6c00 (diff) |
Allow installing dev build next to release build
Signed-off-by: Unpublished <unpublished@gmx.net>
Diffstat (limited to 'News-Android-App/src/main/java')
3 files changed, 21 insertions, 12 deletions
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java index d20d16a9..d627a4f1 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java @@ -400,8 +400,9 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements boolean isAccountThere = false; Account[] accounts = mAccountManager.getAccounts(); + String accountType = AccountGeneral.getAccountType(this); for (Account account : accounts) { - if (account.type.intern().equals(AccountGeneral.ACCOUNT_TYPE)) { + if (account.type.intern().equals(accountType)) { isAccountThere = true; } } @@ -409,7 +410,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements //If the account is not in the Android Account Manager if (!isAccountThere) { //Then add the new account - Account account = new Account(getString(R.string.app_name), AccountGeneral.ACCOUNT_TYPE); + Account account = new Account(getString(R.string.app_name), accountType); mAccountManager.addAccountExplicitly(account, "", new Bundle()); SyncIntervalSelectorActivity.setAccountSyncInterval(this, mPrefs); @@ -679,8 +680,9 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements AccountManager mAccountManager = AccountManager.get(this); Account[] accounts = mAccountManager.getAccounts(); for(Account acc : accounts) { - if (acc.type.equals(AccountGeneral.ACCOUNT_TYPE)) { - ContentResolver.requestSync(acc, AccountGeneral.ACCOUNT_TYPE, accBundle); + String accountType = AccountGeneral.getAccountType(this); + if (acc.type.equals(accountType)) { + ContentResolver.requestSync(acc, accountType, accBundle); } } //http://stackoverflow.com/questions/5253858/why-does-contentresolver-requestsync-not-trigger-a-sync diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SyncIntervalSelectorActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SyncIntervalSelectorActivity.java index 3a363d7b..fb85288d 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SyncIntervalSelectorActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SyncIntervalSelectorActivity.java @@ -95,21 +95,22 @@ public class SyncIntervalSelectorActivity extends AppCompatActivity { int minutes = mPrefs.getInt(SYNC_INTERVAL_IN_MINUTES_STRING, 1440); AccountManager mAccountManager = AccountManager.get(context); - Account[] accounts = mAccountManager.getAccountsByType(AccountGeneral.ACCOUNT_TYPE); + String accountType = AccountGeneral.getAccountType(context); + Account[] accounts = mAccountManager.getAccountsByType(accountType); for (Account account : accounts) { if (minutes != 0) { long SYNC_INTERVAL = minutes * SECONDS_PER_MINUTE; - ContentResolver.setSyncAutomatically(account, AccountGeneral.ACCOUNT_TYPE, true); + ContentResolver.setSyncAutomatically(account, accountType, true); Bundle bundle = new Bundle(); ContentResolver.addPeriodicSync( account, - AccountGeneral.ACCOUNT_TYPE, + accountType, bundle, SYNC_INTERVAL); } else { - ContentResolver.setSyncAutomatically(account, AccountGeneral.ACCOUNT_TYPE, false); + ContentResolver.setSyncAutomatically(account, accountType, false); } } } diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/authentication/AccountGeneral.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/authentication/AccountGeneral.java index 81b3902a..f8d2734d 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/authentication/AccountGeneral.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/authentication/AccountGeneral.java @@ -1,10 +1,10 @@ package de.luhmer.owncloudnewsreader.authentication; +import android.content.Context; + +import de.luhmer.owncloudnewsreader.R; + public class AccountGeneral { - /** - * Account type id - */ - public static final String ACCOUNT_TYPE = "de.luhmer.owncloudnewsreader"; /** * Account name @@ -21,4 +21,10 @@ public class AccountGeneral { public static final String AUTHTOKEN_TYPE_FULL_ACCESS = "Full access"; public static final String AUTHTOKEN_TYPE_FULL_ACCESS_LABEL = "Full access to an Nextcloud News account"; + /** + * Account type id + */ + public static String getAccountType(Context context) { + return context.getString(R.string.account_type); + } } |