Cloud sync: improvements

pull/212/head
M66B 2 years ago
parent 763d385fc2
commit f56dfef612

@ -217,18 +217,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
btnActivate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
String user = prefs.getString("cloud_user", null);
Intent intent = new Intent(Intent.ACTION_SEND)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.setType("text/plain")
.putExtra(Intent.EXTRA_EMAIL, new String[]{BuildConfig.CLOUD_EMAIL})
.putExtra(Intent.EXTRA_SUBJECT, CloudSync.getCloudUser(user))
.putExtra(Intent.EXTRA_TEXT, "Activate");
v.getContext().startActivity(intent);
} catch (Throwable ex) {
Log.e(ex);
}
onCloudActivate();
}
});
@ -1522,6 +1511,24 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
cloud(args);
}
private void onCloudActivate() {
try {
final Context context = getContext();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String user = prefs.getString("cloud_user", null);
Intent intent = new Intent(Intent.ACTION_SEND)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.setType("text/plain")
.putExtra(Intent.EXTRA_EMAIL, new String[]{BuildConfig.CLOUD_EMAIL})
.putExtra(Intent.EXTRA_SUBJECT, CloudSync.getCloudUser(user))
.putExtra(Intent.EXTRA_TEXT, "Activate");
startActivity(intent);
} catch (Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}
private void onCloudSync() {
Bundle args = new Bundle();
args.putString("command", "sync");
@ -1541,14 +1548,22 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
new SimpleTask<Void>() {
@Override
protected void onPreExecute(Bundle args) {
Helper.setViewsEnabled(cardCloud, false);
prefs.edit().putBoolean("cloud_busy", true).apply();
Helper.setViewsEnabled(cardCloud, false);
}
@Override
protected void onPostExecute(Bundle args) {
Helper.setViewsEnabled(cardCloud, true);
prefs.edit().putBoolean("cloud_busy", false).apply();
Helper.setViewsEnabled(cardCloud, true);
view.post(new Runnable() {
@Override
public void run() {
view.scrollTo(0, cardCloud.getBottom());
}
});
WorkerSync.init(getContext());
}
@ -1560,7 +1575,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
try {
CloudSync.execute(context, command, true);
} catch (SecurityException ex) {
command = "logout";
prefs.edit().remove("cloud_password").apply();
throw ex;
} finally {
if ("logout".equals(command) || "wipe".equals(command)) {
@ -1585,13 +1600,6 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
@Override
protected void onExecuted(Bundle args, Void data) {
prefs.edit().putBoolean("cloud_activated", true).apply();
view.post(new Runnable() {
@Override
public void run() {
view.scrollTo(0, cardCloud.getTop());
}
});
}
@Override

@ -328,13 +328,25 @@
android:id="@+id/tvLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginTop="12dp"
android:text="username"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRegister" />
<TextView
android:id="@+id/tvActivateRemark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_cloud_activate_remark"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLogin" />
<Button
android:id="@+id/btnActivate"
android:layout_width="wrap_content"
@ -351,19 +363,7 @@
android:textStyle="bold"
app:drawableTint="?attr/colorInfoForeground"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLogin" />
<TextView
android:id="@+id/tvActivateRemark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="@string/title_advanced_cloud_activate_remark"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnActivate" />
app:layout_constraintTop_toBottomOf="@id/tvActivateRemark" />
<TextView
android:id="@+id/tvAccountRemark"
@ -375,7 +375,7 @@
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvActivateRemark" />
app:layout_constraintTop_toBottomOf="@id/btnActivate" />
<CheckBox
android:id="@+id/cbSend"

@ -990,6 +990,7 @@
<string name="title_advanced_cloud_invalid" translatable="false">Invalid username or password</string>
<string name="title_advanced_cloud_activate" translatable="false">Activate</string>
<string name="title_advanced_cloud_activate_remark" translatable="false">
Cloud sync needs to be activated by sending an email.
Please use the same email address you used to activate the pro features.
The cloud account and the email address will not be linked.
</string>

Loading…
Cancel
Save