mirror of https://github.com/M66B/FairEmail.git
Shortcut has accounts
This commit is contained in:
parent
16b1552bc2
commit
794f1840a7
|
@ -50,21 +50,32 @@ public class ActivityMain extends AppCompatActivity implements FragmentManager.O
|
||||||
|
|
||||||
if (prefs.getBoolean("eula", false)) {
|
if (prefs.getBoolean("eula", false)) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
new SimpleTask<List<EntityAccount>>() {
|
|
||||||
|
new SimpleTask<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
protected List<EntityAccount> onExecute(Context context, Bundle args) {
|
protected Boolean onExecute(Context context, Bundle args) {
|
||||||
return DB.getInstance(context).account().getSynchronizingAccounts();
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
if (prefs.getBoolean("has_accounts", false))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
DB db = DB.getInstance(context);
|
||||||
|
List<EntityAccount> accounts = db.account().getSynchronizingAccounts();
|
||||||
|
boolean hasAccounts = (accounts != null && accounts.size() > 0);
|
||||||
|
|
||||||
|
prefs.edit().putBoolean("has_accounts", hasAccounts).apply();
|
||||||
|
|
||||||
|
return hasAccounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onExecuted(Bundle args, List<EntityAccount> accounts) {
|
protected void onExecuted(Bundle args, Boolean hasAccounts) {
|
||||||
if (accounts == null || accounts.size() == 0)
|
if (hasAccounts) {
|
||||||
startActivity(new Intent(ActivityMain.this, ActivitySetup.class));
|
|
||||||
else {
|
|
||||||
startActivity(new Intent(ActivityMain.this, ActivityView.class));
|
startActivity(new Intent(ActivityMain.this, ActivityView.class));
|
||||||
ServiceSynchronize.boot(ActivityMain.this);
|
ServiceSynchronize.boot(ActivityMain.this);
|
||||||
ServiceSend.boot(ActivityMain.this);
|
ServiceSend.boot(ActivityMain.this);
|
||||||
}
|
} else
|
||||||
|
startActivity(new Intent(ActivityMain.this, ActivitySetup.class));
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
|
@ -47,6 +48,7 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -270,6 +272,7 @@ public class FragmentSetup extends FragmentBase {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
final DB db = DB.getInstance(getContext());
|
final DB db = DB.getInstance(getContext());
|
||||||
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
|
||||||
db.account().liveSynchronizingAccounts().observe(getViewLifecycleOwner(), new Observer<List<EntityAccount>>() {
|
db.account().liveSynchronizingAccounts().observe(getViewLifecycleOwner(), new Observer<List<EntityAccount>>() {
|
||||||
private boolean done = false;
|
private boolean done = false;
|
||||||
|
@ -286,6 +289,8 @@ public class FragmentSetup extends FragmentBase {
|
||||||
|
|
||||||
btnIdentity.setEnabled(done);
|
btnIdentity.setEnabled(done);
|
||||||
btnInbox.setEnabled(done);
|
btnInbox.setEnabled(done);
|
||||||
|
|
||||||
|
prefs.edit().putBoolean("has_accounts", done).apply();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue