Browse Source

Undo move to archive/trash

Fixes #92
main
M66B 6 years ago
parent
commit
f4086ecbb3
6 changed files with 153 additions and 81 deletions
  1. BIN
      .idea/caches/build_file_checksums.ser
  2. +1
    -1
      .idea/misc.xml
  3. +2
    -0
      app/build.gradle
  4. +70
    -6
      app/src/main/java/eu/faircode/email/FragmentMessages.java
  5. +79
    -74
      app/src/main/res/layout/fragment_messages.xml
  6. +1
    -0
      app/src/main/res/values/strings.xml

BIN
.idea/caches/build_file_checksums.ser View File


+ 1
- 1
.idea/misc.xml View File

@ -30,7 +30,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">


+ 2
- 0
app/build.gradle View File

@ -87,6 +87,8 @@ dependencies {
implementation "androidx.browser:browser:$androidx_version"
implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
implementation "androidx.coordinatorlayout:coordinatorlayout:1.0.0-alpha1"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"


+ 70
- 6
app/src/main/java/eu/faircode/email/FragmentMessages.java View File

@ -25,6 +25,7 @@ import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
@ -218,6 +219,7 @@ public class FragmentMessages extends FragmentEx {
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityMessage message = db.message().getMessage(id);
EntityFolder folder = db.folder().getFolder(message.folder);
@ -231,24 +233,86 @@ public class FragmentMessages extends FragmentEx {
}
db.message().setMessageUiHide(message.id, true);
EntityOperation.queue(db, message, EntityOperation.MOVE, target.id);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
EntityOperation.process(context);
Log.i(Helper.TAG, "Move id=" + id + " target=" + target);
return target.name;
}
@Override
protected void onLoaded(Bundle args, String folder) {
Snackbar.make(
protected void onLoaded(final Bundle args, final String target) {
final Snackbar snackbar = Snackbar.make(
view,
getString(R.string.title_moving, Helper.localizeFolderName(getContext(), folder)),
Snackbar.LENGTH_SHORT).show();
getString(R.string.title_moving, Helper.localizeFolderName(getContext(), target)),
Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.title_undo, new View.OnClickListener() {
@Override
public void onClick(View v) {
snackbar.dismiss();
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
long id = args.getLong("id");
Log.i(Helper.TAG, "Undo move id=" + id);
DB.getInstance(context).message().setMessageUiHide(id, false);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
super.onException(args, ex);
}
}.load(FragmentMessages.this, args);
}
});
snackbar.show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (snackbar.isShown()) {
snackbar.dismiss();
args.putString("target", target);
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
String target = args.getString("target");
Log.i(Helper.TAG, "Moving id=" + id + " target=" + target);
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityMessage message = db.message().getMessage(id);
EntityFolder folder = db.folder().getFolderByName(message.account, target);
EntityOperation.queue(db, message, EntityOperation.MOVE, folder.id);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
EntityOperation.process(context);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
super.onException(args, ex);
}
}.load(FragmentMessages.this, args);
}
}
}, 5000);
}
@Override


+ 79
- 74
app/src/main/res/layout/fragment_messages.xml View File

@ -1,76 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ActivityView">
<TextView
android:id="@+id/tvNoEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_no_messages"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvHintActions"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:gravity="center_vertical"
android:minHeight="33dp"
android:text="@string/title_hint_message_actions"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toStartOf="@+id/ibHintActions"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvNoEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_no_messages"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/ibHintActions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/baseline_close_24"
app:layout_constraintBottom_toBottomOf="@id/tvHintActions"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/tvHintActions" />
<TextView
android:id="@+id/tvHintActions"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:gravity="center_vertical"
android:minHeight="33dp"
android:text="@string/title_hint_message_actions"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toStartOf="@+id/ibHintActions"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/vSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="6dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHintActions" />
<ImageButton
android:id="@+id/ibHintActions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/baseline_close_24"
app:layout_constraintBottom_toBottomOf="@id/tvHintActions"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/tvHintActions" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvFolder"
android:layout_width="0dp"
android:layout_height="0dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparator" />
<View
android:id="@+id/vSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="6dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHintActions" />
<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" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvFolder"
android:layout_width="0dp"
android:layout_height="0dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparator" />
<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" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpHintActions"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="tvHintActions,ibHintActions,vSeparator" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpReady"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="rvFolder" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
@ -83,16 +100,4 @@
app:backgroundTint="?attr/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpHintActions"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="tvHintActions,ibHintActions,vSeparator" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpReady"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="rvFolder" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

+ 1
- 0
app/src/main/res/values/strings.xml View File

@ -221,6 +221,7 @@
<string name="title_issue">Do you have a question or problem?</string>
<string name="title_yes">Yes</string>
<string name="title_no">No</string>
<string name="title_undo">Undo</string>
<string name="title_pro_feature">This is a pro feature</string>
<string name="title_pro_list">List of pro features</string>


Loading…
Cancel
Save