mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 01:39:18 +02:00
improve code
This commit is contained in:
parent
91e898ee96
commit
c6bbb0a524
3 changed files with 19 additions and 36 deletions
|
@ -42,4 +42,14 @@ public class DcAccounts {
|
|||
private native long getJsonrpcInstanceCPtr ();
|
||||
private native long getAccountCPtr (int accountId);
|
||||
private native long getSelectedAccountCPtr ();
|
||||
|
||||
public boolean isAllChatmail() {
|
||||
for (int accountId : getAll()) {
|
||||
DcContext dcContext = getAccount(accountId);
|
||||
if (!dcContext.isChatmail()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,18 +109,9 @@ public class DozeReminder {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean isAllChatmail() {
|
||||
for (int accountId : ApplicationContext.dcAccounts.getAll()) {
|
||||
DcContext context = ApplicationContext.dcAccounts.getAccount(accountId);
|
||||
if (!context.isChatmail()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isPushAvailableAndSufficient() {
|
||||
return isAllChatmail() && FcmReceiveService.getToken() != null;
|
||||
return ApplicationContext.dcAccounts.isAllChatmail()
|
||||
&& FcmReceiveService.getToken() != null;
|
||||
}
|
||||
|
||||
public static void maybeAskDirectly(Context context) {
|
||||
|
|
|
@ -214,36 +214,18 @@ public class Prefs {
|
|||
return result==null? null : Uri.parse(result);
|
||||
}
|
||||
|
||||
private static boolean isAllChatmail(Context context) {
|
||||
DcAccounts dcAccounts = DcHelper.getAccounts(context);
|
||||
for (int accountId : dcAccounts.getAll()) {
|
||||
DcContext dcContext = dcAccounts.getAccount(accountId);
|
||||
if (!dcContext.isChatmail()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean reliableService(Context context) {
|
||||
final String key = "pref_reliable_service";
|
||||
boolean value = false;
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (prefs.contains(key)) {
|
||||
try {
|
||||
value = getBooleanPreference(context, key, false);
|
||||
return prefs.getBoolean(key, true);
|
||||
} catch(Exception e) {}
|
||||
boolean value2;
|
||||
try {
|
||||
value2 = getBooleanPreference(context, key, !value);
|
||||
} catch(Exception e) {
|
||||
value2 = !value;
|
||||
}
|
||||
|
||||
// if the key was unset, then calculate default value
|
||||
if (value != value2) {
|
||||
value = FcmReceiveService.getToken() == null || !isAllChatmail(context);
|
||||
}
|
||||
|
||||
return value;
|
||||
return FcmReceiveService.getToken() == null
|
||||
|| !DcHelper.getAccounts(context).isAllChatmail();
|
||||
}
|
||||
|
||||
// vibrate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue