mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #1315 from deltachat/tweak-progress-dialog
add margin between progress-bar and dialog when there are not buttons
This commit is contained in:
@@ -1,52 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guidelineTop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintGuide_begin="16dp" />
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guidelineStart"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_begin="16dp" />
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guidelineEnd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_end="16dp" />
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:indeterminate="true" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/text"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="@id/guidelineStart"
|
||||
app:layout_constraintTop_toTopOf="@id/guidelineTop" />
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@id/guidelineEnd"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toEndOf="@id/progressBar"
|
||||
app:layout_constraintTop_toTopOf="@id/guidelineTop" />
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<androidx.legacy.widget.Space
|
||||
android:id="@+id/noButtonsSpacer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="16dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -356,6 +356,7 @@
|
||||
<string name="add_account">Add account</string>
|
||||
<string name="delete_account">Delete account</string>
|
||||
<string name="delete_account_ask">Are you sure you want to delete your account data?</string>
|
||||
<string name="switching_account">Switching account…</string>
|
||||
|
||||
<!-- share and forward messages -->
|
||||
<!-- Translators: Title shown above a chat/contact list; the user selects the recipient of the messages he wants to forward to -->
|
||||
|
||||
@@ -184,7 +184,7 @@ public class AccountManager {
|
||||
|
||||
Account prevAccount = maybeGetAccount(new File(activity.getFilesDir(), prevDbName));
|
||||
if (prevAccount!=null) {
|
||||
new SwitchAccountAsyncTask(activity, R.string.switch_account, prevAccount, inCreationDbName).execute();
|
||||
new SwitchAccountAsyncTask(activity, R.string.switching_account, prevAccount, inCreationDbName).execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ public class AccountManager {
|
||||
private final @Nullable String deleteDbName;
|
||||
|
||||
public SwitchAccountAsyncTask(Activity activity, int title, @Nullable Account destAccount, @Nullable String deleteDbName) {
|
||||
super(activity, title, R.string.one_moment);
|
||||
super(activity, null, activity.getString(title));
|
||||
this.activityWeakReference = new WeakReference<>(activity);
|
||||
this.destAccount = destAccount;
|
||||
this.deleteDbName = deleteDbName;
|
||||
@@ -284,11 +284,11 @@ public class AccountManager {
|
||||
.setSingleChoiceItems(menu.toArray(new String[menu.size()]), presel, (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
if (which==addAccount) {
|
||||
new SwitchAccountAsyncTask(activity, R.string.add_account, null, null).execute();
|
||||
new SwitchAccountAsyncTask(activity, R.string.one_moment, null, null).execute();
|
||||
} else { // switch account
|
||||
Account account = accounts.get(which);
|
||||
if (!account.isCurrent()) {
|
||||
new SwitchAccountAsyncTask(activity, R.string.switch_account, account, null).execute();
|
||||
new SwitchAccountAsyncTask(activity, R.string.switching_account, account, null).execute();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms.util.views;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
@@ -7,6 +8,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -38,9 +40,22 @@ public class ProgressDialog extends AlertDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isButtonVisible(int which) {
|
||||
Button button = getButton(which);
|
||||
if (button==null) {
|
||||
return false;
|
||||
}
|
||||
return button.getVisibility()==View.VISIBLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
|
||||
if (isButtonVisible(Dialog.BUTTON_POSITIVE) || isButtonVisible(Dialog.BUTTON_NEGATIVE) || isButtonVisible(Dialog.BUTTON_NEUTRAL)) {
|
||||
findViewById(R.id.noButtonsSpacer).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
progressBar = findViewById(R.id.progressBar);
|
||||
textView = findViewById(R.id.text);
|
||||
setupProgressBar();
|
||||
|
||||
Reference in New Issue
Block a user