mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-15 16:39:37 +00:00
Check for primary account / drafts / archive
This commit is contained in:
parent
8dd3d1ef85
commit
a96e9d07fb
4 changed files with 87 additions and 17 deletions
|
@ -83,6 +83,16 @@ public interface DaoFolder {
|
||||||
" GROUP BY folder.id")
|
" GROUP BY folder.id")
|
||||||
LiveData<List<TupleFolderEx>> liveUnified();
|
LiveData<List<TupleFolderEx>> liveUnified();
|
||||||
|
|
||||||
|
@Query("SELECT folder.* FROM folder" +
|
||||||
|
" JOIN account ON account.id = folder.account" +
|
||||||
|
" WHERE `primary` AND type = '" + EntityFolder.DRAFTS + "'")
|
||||||
|
LiveData<EntityFolder> livePrimaryDrafts();
|
||||||
|
|
||||||
|
@Query("SELECT folder.* FROM folder" +
|
||||||
|
" JOIN account ON account.id = folder.account" +
|
||||||
|
" WHERE `primary` AND type = '" + EntityFolder.ARCHIVE + "'")
|
||||||
|
LiveData<EntityFolder> livePrimaryArchive();
|
||||||
|
|
||||||
@Query("SELECT folder.* FROM folder" +
|
@Query("SELECT folder.* FROM folder" +
|
||||||
" JOIN account ON account.id = folder.account" +
|
" JOIN account ON account.id = folder.account" +
|
||||||
" WHERE folder.type = '" + EntityFolder.DRAFTS + "'" +
|
" WHERE folder.type = '" + EntityFolder.DRAFTS + "'" +
|
||||||
|
@ -117,7 +127,6 @@ public interface DaoFolder {
|
||||||
" WHERE account = :account AND type = :type")
|
" WHERE account = :account AND type = :type")
|
||||||
EntityFolder getFolderByType(long account, String type);
|
EntityFolder getFolderByType(long account, String type);
|
||||||
|
|
||||||
// For debug/crash info
|
|
||||||
@Query("SELECT folder.* FROM folder" +
|
@Query("SELECT folder.* FROM folder" +
|
||||||
" JOIN account ON account.id = folder.account" +
|
" JOIN account ON account.id = folder.account" +
|
||||||
" WHERE `primary` AND type = '" + EntityFolder.DRAFTS + "'")
|
" WHERE `primary` AND type = '" + EntityFolder.DRAFTS + "'")
|
||||||
|
|
|
@ -962,7 +962,8 @@ public class FragmentAccount extends FragmentEx {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLoaded(Bundle args, EntityAccount primary) {
|
protected void onLoaded(Bundle args, EntityAccount primary) {
|
||||||
cbPrimary.setChecked(primary == null);
|
if (primary == null)
|
||||||
|
cbPrimary.setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -81,6 +81,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
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.LiveData;
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
|
|
||||||
import static android.app.Activity.RESULT_OK;
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
@ -92,6 +93,8 @@ public class FragmentSetup extends FragmentEx {
|
||||||
|
|
||||||
private Button btnAccount;
|
private Button btnAccount;
|
||||||
private TextView tvAccountDone;
|
private TextView tvAccountDone;
|
||||||
|
private TextView tvNoPrimaryDrafts;
|
||||||
|
private TextView tvNoPrimaryArchive;
|
||||||
|
|
||||||
private Button btnIdentity;
|
private Button btnIdentity;
|
||||||
private TextView tvIdentityDone;
|
private TextView tvIdentityDone;
|
||||||
|
@ -135,6 +138,8 @@ public class FragmentSetup extends FragmentEx {
|
||||||
|
|
||||||
btnAccount = view.findViewById(R.id.btnAccount);
|
btnAccount = view.findViewById(R.id.btnAccount);
|
||||||
tvAccountDone = view.findViewById(R.id.tvAccountDone);
|
tvAccountDone = view.findViewById(R.id.tvAccountDone);
|
||||||
|
tvNoPrimaryDrafts = view.findViewById(R.id.tvNoPrimaryDrafts);
|
||||||
|
tvNoPrimaryArchive = view.findViewById(R.id.tvNoPrimaryArchive);
|
||||||
|
|
||||||
btnIdentity = view.findViewById(R.id.btnIdentity);
|
btnIdentity = view.findViewById(R.id.btnIdentity);
|
||||||
tvIdentityDone = view.findViewById(R.id.tvIdentityDone);
|
tvIdentityDone = view.findViewById(R.id.tvIdentityDone);
|
||||||
|
@ -281,6 +286,8 @@ public class FragmentSetup extends FragmentEx {
|
||||||
|
|
||||||
tvAccountDone.setText(null);
|
tvAccountDone.setText(null);
|
||||||
tvAccountDone.setCompoundDrawables(null, null, null, null);
|
tvAccountDone.setCompoundDrawables(null, null, null, null);
|
||||||
|
tvNoPrimaryDrafts.setVisibility(View.GONE);
|
||||||
|
tvNoPrimaryArchive.setVisibility(View.GONE);
|
||||||
|
|
||||||
btnIdentity.setEnabled(false);
|
btnIdentity.setEnabled(false);
|
||||||
tvIdentityDone.setText(null);
|
tvIdentityDone.setText(null);
|
||||||
|
@ -345,15 +352,44 @@ public class FragmentSetup extends FragmentEx {
|
||||||
PackageManager pm = getContext().getPackageManager();
|
PackageManager pm = getContext().getPackageManager();
|
||||||
ibHelp.setVisibility(getIntentHelp().resolveActivity(pm) == null ? View.GONE : View.VISIBLE);
|
ibHelp.setVisibility(getIntentHelp().resolveActivity(pm) == null ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
DB db = DB.getInstance(getContext());
|
final DB db = DB.getInstance(getContext());
|
||||||
|
|
||||||
db.account().liveAccounts(true).observe(getViewLifecycleOwner(), new Observer<List<EntityAccount>>() {
|
db.account().liveAccounts(true).observe(getViewLifecycleOwner(), new Observer<List<EntityAccount>>() {
|
||||||
|
private boolean done = false;
|
||||||
|
private LiveData<EntityFolder> livePrimaryDrafts = null;
|
||||||
|
private LiveData<EntityFolder> livePrimaryArchive = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<EntityAccount> accounts) {
|
public void onChanged(@Nullable List<EntityAccount> accounts) {
|
||||||
boolean done = (accounts != null && accounts.size() > 0);
|
done = (accounts != null && accounts.size() > 0);
|
||||||
|
|
||||||
btnIdentity.setEnabled(done);
|
btnIdentity.setEnabled(done);
|
||||||
tvAccountDone.setText(done ? R.string.title_setup_done : R.string.title_setup_to_do);
|
tvAccountDone.setText(done ? R.string.title_setup_done : R.string.title_setup_to_do);
|
||||||
tvAccountDone.setCompoundDrawablesWithIntrinsicBounds(done ? check : null, null, null, null);
|
tvAccountDone.setCompoundDrawablesWithIntrinsicBounds(done ? check : null, null, null, null);
|
||||||
|
|
||||||
|
if (livePrimaryDrafts == null)
|
||||||
|
livePrimaryDrafts = db.folder().livePrimaryDrafts();
|
||||||
|
else
|
||||||
|
livePrimaryDrafts.removeObservers(getViewLifecycleOwner());
|
||||||
|
|
||||||
|
if (livePrimaryArchive == null)
|
||||||
|
livePrimaryArchive = db.folder().livePrimaryDrafts();
|
||||||
|
else
|
||||||
|
livePrimaryArchive.removeObservers(getViewLifecycleOwner());
|
||||||
|
|
||||||
|
livePrimaryDrafts.observe(getViewLifecycleOwner(), new Observer<EntityFolder>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(EntityFolder drafts) {
|
||||||
|
tvNoPrimaryDrafts.setVisibility(done && drafts == null ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
livePrimaryArchive.observe(getViewLifecycleOwner(), new Observer<EntityFolder>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(EntityFolder archive) {
|
||||||
|
tvNoPrimaryArchive.setVisibility(done && archive == null ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,38 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvAccount" />
|
app:layout_constraintTop_toBottomOf="@id/tvAccount" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvNoPrimaryDrafts"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/title_no_primary_drafts"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
android:textColor="?attr/colorWarning"
|
||||||
|
android:textIsSelectable="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvAccountDone" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvNoPrimaryArchive"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/title_no_primary_archive"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
android:textColor="?attr/colorWarning"
|
||||||
|
android:textIsSelectable="true"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvNoPrimaryDrafts" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/vSeparatorAccount"
|
android:id="@+id/vSeparatorAccount"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginTop="9dp"
|
android:layout_marginTop="12dp"
|
||||||
android:background="?attr/colorSeparator"
|
android:background="?attr/colorSeparator"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvAccountDone" />
|
app:layout_constraintTop_toBottomOf="@id/tvNoPrimaryArchive" />
|
||||||
|
|
||||||
<!-- identity -->
|
<!-- identity -->
|
||||||
|
|
||||||
|
@ -69,7 +93,7 @@
|
||||||
android:id="@+id/btnIdentity"
|
android:id="@+id/btnIdentity"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="9dp"
|
android:layout_marginTop="12dp"
|
||||||
android:text="@string/title_setup_identity"
|
android:text="@string/title_setup_identity"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
@ -101,7 +125,7 @@
|
||||||
android:id="@+id/vSeparatorIdentity"
|
android:id="@+id/vSeparatorIdentity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginTop="9dp"
|
android:layout_marginTop="12dp"
|
||||||
android:background="?attr/colorSeparator"
|
android:background="?attr/colorSeparator"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvIdentityDone" />
|
app:layout_constraintTop_toBottomOf="@id/tvIdentityDone" />
|
||||||
|
@ -112,7 +136,7 @@
|
||||||
android:id="@+id/btnPermissions"
|
android:id="@+id/btnPermissions"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="9dp"
|
android:layout_marginTop="12dp"
|
||||||
android:text="@string/title_setup_permissions"
|
android:text="@string/title_setup_permissions"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
@ -144,7 +168,7 @@
|
||||||
android:id="@+id/vSeparatorPermissions"
|
android:id="@+id/vSeparatorPermissions"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginTop="9dp"
|
android:layout_marginTop="12dp"
|
||||||
android:background="?attr/colorSeparator"
|
android:background="?attr/colorSeparator"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvPermissionsDone" />
|
app:layout_constraintTop_toBottomOf="@id/tvPermissionsDone" />
|
||||||
|
@ -155,7 +179,7 @@
|
||||||
android:id="@+id/btnDoze"
|
android:id="@+id/btnDoze"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="9dp"
|
android:layout_marginTop="12dp"
|
||||||
android:text="@string/title_setup_doze"
|
android:text="@string/title_setup_doze"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
@ -190,7 +214,7 @@
|
||||||
style="?android:attr/buttonStyleSmall"
|
style="?android:attr/buttonStyleSmall"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="9dp"
|
android:layout_marginTop="12dp"
|
||||||
android:minWidth="0dp"
|
android:minWidth="0dp"
|
||||||
android:minHeight="0dp"
|
android:minHeight="0dp"
|
||||||
android:text="@string/title_setup_data"
|
android:text="@string/title_setup_data"
|
||||||
|
@ -202,7 +226,7 @@
|
||||||
android:id="@+id/vSeparatorDoze"
|
android:id="@+id/vSeparatorDoze"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginTop="9dp"
|
android:layout_marginTop="12dp"
|
||||||
android:background="?attr/colorSeparator"
|
android:background="?attr/colorSeparator"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btnData" />
|
app:layout_constraintTop_toBottomOf="@id/btnData" />
|
||||||
|
@ -211,7 +235,7 @@
|
||||||
android:id="@+id/btnNotifications"
|
android:id="@+id/btnNotifications"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="9dp"
|
android:layout_marginTop="12dp"
|
||||||
android:text="@string/title_setup_notifications"
|
android:text="@string/title_setup_notifications"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
@ -221,7 +245,7 @@
|
||||||
android:id="@+id/tbDarkTheme"
|
android:id="@+id/tbDarkTheme"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="18dp"
|
android:layout_marginTop="12dp"
|
||||||
android:textOff="@string/title_setup_dark_theme"
|
android:textOff="@string/title_setup_dark_theme"
|
||||||
android:textOn="@string/title_setup_light_theme"
|
android:textOn="@string/title_setup_light_theme"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
@ -232,7 +256,7 @@
|
||||||
android:id="@+id/cbBlackTheme"
|
android:id="@+id/cbBlackTheme"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="9dp"
|
android:layout_marginTop="6dp"
|
||||||
android:text="@string/title_setup_black_background"
|
android:text="@string/title_setup_black_background"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
@ -243,7 +267,7 @@
|
||||||
style="?android:attr/buttonStyleSmall"
|
style="?android:attr/buttonStyleSmall"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="18dp"
|
android:layout_marginTop="12dp"
|
||||||
android:minWidth="0dp"
|
android:minWidth="0dp"
|
||||||
android:minHeight="0dp"
|
android:minHeight="0dp"
|
||||||
android:text="@string/title_advanced"
|
android:text="@string/title_advanced"
|
||||||
|
|
Loading…
Add table
Reference in a new issue