Browse Source

Added folder spinner

main
M66B 6 years ago
parent
commit
261913d8b9
4 changed files with 30 additions and 2 deletions
  1. +2
    -1
      app/src/main/java/eu/faircode/email/FragmentAccount.java
  2. +14
    -0
      app/src/main/java/eu/faircode/email/FragmentFolder.java
  3. +1
    -0
      app/src/main/java/eu/faircode/email/FragmentIdentity.java
  4. +13
    -1
      app/src/main/res/layout/fragment_folder.xml

+ 2
- 1
app/src/main/java/eu/faircode/email/FragmentAccount.java View File

@ -69,6 +69,7 @@ public class FragmentAccount extends Fragment {
private CheckBox cbSynchronize; private CheckBox cbSynchronize;
private Button btnOk; private Button btnOk;
private ProgressBar pbCheck; private ProgressBar pbCheck;
// TODO: loading spinner
static final int DEFAULT_INBOX_SYNC = 30; static final int DEFAULT_INBOX_SYNC = 30;
static final int DEFAULT_STANDARD_SYNC = 7; static final int DEFAULT_STANDARD_SYNC = 7;
@ -296,7 +297,7 @@ public class FragmentAccount extends Fragment {
folders.add(0, inbox); folders.add(0, inbox);
for (EntityFolder folder : folders) for (EntityFolder folder : folders)
if (db.folder().getFolder(account.id, folder.name) == null) {
if (db.folder().getFolderByName(account.id, folder.name) == null) {
folder.account = account.id; folder.account = account.id;
Log.i(Helper.TAG, "Creating folder=" + folder.name + " (" + folder.type + ")"); Log.i(Helper.TAG, "Creating folder=" + folder.name + " (" + folder.type + ")");
folder.id = db.folder().insertFolder(folder); folder.id = db.folder().insertFolder(folder);


+ 14
- 0
app/src/main/java/eu/faircode/email/FragmentFolder.java View File

@ -24,6 +24,7 @@ import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.constraint.Group;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager; import android.support.v4.app.LoaderManager;
import android.support.v4.content.AsyncTaskLoader; import android.support.v4.content.AsyncTaskLoader;
@ -37,12 +38,15 @@ import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast; import android.widget.Toast;
public class FragmentFolder extends Fragment { public class FragmentFolder extends Fragment {
private CheckBox cbSynchronize; private CheckBox cbSynchronize;
private EditText etAfter; private EditText etAfter;
private Button btnOk; private Button btnOk;
private ProgressBar pbWait;
private Group grpReady;
@Override @Override
@Nullable @Nullable
@ -57,6 +61,8 @@ public class FragmentFolder extends Fragment {
cbSynchronize = view.findViewById(R.id.cbSynchronize); cbSynchronize = view.findViewById(R.id.cbSynchronize);
etAfter = view.findViewById(R.id.etAfter); etAfter = view.findViewById(R.id.etAfter);
btnOk = view.findViewById(R.id.btnOk); btnOk = view.findViewById(R.id.btnOk);
pbWait = view.findViewById(R.id.pbWait);
grpReady = view.findViewById(R.id.grpReady);
btnOk.setOnClickListener(new View.OnClickListener() { btnOk.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -72,6 +78,11 @@ public class FragmentFolder extends Fragment {
} }
}); });
// Initialize
grpReady.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE);
// Observe
DB.getInstance(getContext()).folder().liveFolder(id).observe(this, new Observer<EntityFolder>() { DB.getInstance(getContext()).folder().liveFolder(id).observe(this, new Observer<EntityFolder>() {
@Override @Override
public void onChanged(@Nullable EntityFolder folder) { public void onChanged(@Nullable EntityFolder folder) {
@ -79,6 +90,9 @@ public class FragmentFolder extends Fragment {
cbSynchronize.setChecked(folder.synchronize); cbSynchronize.setChecked(folder.synchronize);
etAfter.setText(Integer.toString(folder.after)); etAfter.setText(Integer.toString(folder.after));
} }
pbWait.setVisibility(View.GONE);
grpReady.setVisibility(View.VISIBLE);
} }
}); });


+ 1
- 0
app/src/main/java/eu/faircode/email/FragmentIdentity.java View File

@ -70,6 +70,7 @@ public class FragmentIdentity extends Fragment {
private CheckBox cbSynchronize; private CheckBox cbSynchronize;
private Button btnOk; private Button btnOk;
private ProgressBar pbCheck; private ProgressBar pbCheck;
// TODO: loading spinner
@Override @Override
@Nullable @Nullable


+ 13
- 1
app/src/main/res/layout/fragment_folder.xml View File

@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical" android:orientation="vertical"
tools:context=".ActivityView"> tools:context=".ActivityView">
@ -52,10 +53,21 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etAfter" /> app:layout_constraintTop_toBottomOf="@id/etAfter" />
<ProgressBar
android:id="@+id/pbWait"
style="@style/Base.Widget.AppCompat.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.Group <android.support.constraint.Group
android:id="@+id/grpReady" android:id="@+id/grpReady"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:constraint_referenced_ids="cbSynchronize,etAfter,btnOk" />
app:constraint_referenced_ids="cbSynchronize,tvAfter,etAfter,btnOk" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
</ScrollView> </ScrollView>

Loading…
Cancel
Save