mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-25 01:06:04 +00:00
Use sliders for FFSend properties
This commit is contained in:
parent
61ad85eed7
commit
4ba04ca05f
3 changed files with 75 additions and 37 deletions
|
@ -28,7 +28,6 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
|
@ -40,6 +39,7 @@ import android.view.View;
|
|||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -64,8 +64,10 @@ public class FragmentDialogInsertLink extends FragmentDialogBase {
|
|||
private EditText etTitle;
|
||||
private Button btnUpload;
|
||||
private ProgressBar pbUpload;
|
||||
private EditText etDlimit;
|
||||
private EditText etTlimit;
|
||||
private TextView tvDLimit;
|
||||
private SeekBar sbDLimit;
|
||||
private TextView tvTLimit;
|
||||
private SeekBar sbTLimit;
|
||||
|
||||
private static final int METADATA_CONNECT_TIMEOUT = 10 * 1000; // milliseconds
|
||||
private static final int METADATA_READ_TIMEOUT = 15 * 1000; // milliseconds
|
||||
|
@ -94,8 +96,10 @@ public class FragmentDialogInsertLink extends FragmentDialogBase {
|
|||
final ProgressBar pbWait = view.findViewById(R.id.pbWait);
|
||||
btnUpload = view.findViewById(R.id.btnUpload);
|
||||
pbUpload = view.findViewById(R.id.pbUpload);
|
||||
etDlimit = view.findViewById(R.id.etDlimit);
|
||||
etTlimit = view.findViewById(R.id.etTlimit);
|
||||
tvDLimit = view.findViewById(R.id.tvDLimit);
|
||||
sbDLimit = view.findViewById(R.id.sbDLimit);
|
||||
tvTLimit = view.findViewById(R.id.tvTLimit);
|
||||
sbTLimit = view.findViewById(R.id.sbTLimit);
|
||||
Group grpUpload = view.findViewById(R.id.grpUpload);
|
||||
|
||||
etLink.addTextChangedListener(new TextWatcher() {
|
||||
|
@ -254,6 +258,40 @@ public class FragmentDialogInsertLink extends FragmentDialogBase {
|
|||
}
|
||||
});
|
||||
|
||||
sbDLimit.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
tvDLimit.setText(getString(R.string.title_style_link_ffsend_dlimit, progress));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
|
||||
sbTLimit.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
tvTLimit.setText(getString(R.string.title_style_link_ffsend_tlimit, progress));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
String link = (uri == null ? "https://" : uri.toString());
|
||||
etLink.setText(link);
|
||||
|
@ -263,8 +301,8 @@ public class FragmentDialogInsertLink extends FragmentDialogBase {
|
|||
etTitle.setText(savedInstanceState.getString("fair:text"));
|
||||
}
|
||||
|
||||
etDlimit.setHint(Integer.toString(FFSend.FF_DEFAULT_DLIMIT));
|
||||
etTlimit.setHint(Integer.toString(FFSend.FF_DEFAULT_TLIMIT));
|
||||
sbDLimit.setProgress(FFSend.FF_DEFAULT_DLIMIT);
|
||||
sbTLimit.setProgress(FFSend.FF_DEFAULT_TLIMIT);
|
||||
|
||||
pbWait.setVisibility(View.GONE);
|
||||
pbUpload.setVisibility(View.GONE);
|
||||
|
@ -309,31 +347,31 @@ public class FragmentDialogInsertLink extends FragmentDialogBase {
|
|||
private void onFFSend(Uri uri) {
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable("uri", uri);
|
||||
args.putString("dlimit", etDlimit.getText().toString());
|
||||
args.putString("tlimit", etTlimit.getText().toString());
|
||||
args.putInt("dlimit", sbDLimit.getProgress());
|
||||
args.putInt("tlimit", sbTLimit.getProgress());
|
||||
|
||||
new SimpleTask<String>() {
|
||||
@Override
|
||||
protected void onPreExecute(Bundle args) {
|
||||
btnUpload.setEnabled(false);
|
||||
etDlimit.setEnabled(false);
|
||||
etTlimit.setEnabled(false);
|
||||
sbDLimit.setEnabled(false);
|
||||
sbTLimit.setEnabled(false);
|
||||
pbUpload.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bundle args) {
|
||||
btnUpload.setEnabled(true);
|
||||
etDlimit.setEnabled(true);
|
||||
etTlimit.setEnabled(true);
|
||||
sbDLimit.setEnabled(true);
|
||||
sbTLimit.setEnabled(true);
|
||||
pbUpload.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String onExecute(Context context, Bundle args) throws Throwable {
|
||||
Uri uri = args.getParcelable("uri");
|
||||
String _dlimit = args.getString("dlimit");
|
||||
String _tlimit = args.getString("tlimit");
|
||||
int dlimit = args.getInt("dlimit");
|
||||
int tlimit = args.getInt("tlimit");
|
||||
|
||||
if (uri == null)
|
||||
throw new FileNotFoundException("uri");
|
||||
|
@ -345,8 +383,10 @@ public class FragmentDialogInsertLink extends FragmentDialogBase {
|
|||
if (dfile == null)
|
||||
throw new FileNotFoundException("dfile");
|
||||
|
||||
int dlimit = (TextUtils.isEmpty(_dlimit) ? FFSend.FF_DEFAULT_DLIMIT : Integer.parseInt(_dlimit));
|
||||
int tlimit = (TextUtils.isEmpty(_tlimit) ? FFSend.FF_DEFAULT_TLIMIT : Integer.parseInt(_tlimit));
|
||||
if (dlimit == 0)
|
||||
dlimit = FFSend.FF_DEFAULT_DLIMIT;
|
||||
if (tlimit == 0)
|
||||
tlimit = FFSend.FF_DEFAULT_TLIMIT;
|
||||
|
||||
args.putString("title", dfile.getName());
|
||||
|
||||
|
|
|
@ -139,20 +139,19 @@
|
|||
android:id="@+id/tvDLimit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:labelFor="@+id/etDlimit"
|
||||
android:layout_marginTop="6dp"
|
||||
android:labelFor="@+id/sbDLimit"
|
||||
android:text="@string/title_style_link_ffsend_dlimit"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnUpload" />
|
||||
|
||||
<eu.faircode.email.EditTextPlain
|
||||
android:id="@+id/etDlimit"
|
||||
<SeekBar
|
||||
android:id="@+id/sbDLimit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
android:maxLength="3"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:max="100"
|
||||
android:min="0"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDLimit" />
|
||||
|
@ -161,20 +160,19 @@
|
|||
android:id="@+id/tvTLimit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:labelFor="@+id/etTlimit"
|
||||
android:layout_marginTop="6dp"
|
||||
android:labelFor="@+id/sbTLimit"
|
||||
android:text="@string/title_style_link_ffsend_tlimit"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etDlimit" />
|
||||
app:layout_constraintTop_toBottomOf="@id/sbDLimit" />
|
||||
|
||||
<eu.faircode.email.EditTextPlain
|
||||
android:id="@+id/etTlimit"
|
||||
<SeekBar
|
||||
android:id="@+id/sbTLimit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
android:maxLength="3"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:max="240"
|
||||
android:min="0"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvTLimit" />
|
||||
|
@ -183,6 +181,6 @@
|
|||
android:id="@+id/grpUpload"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="btnUpload,tvDLimit,etDlimit,tvTLimit,etTlimit" />
|
||||
app:constraint_referenced_ids="btnUpload,tvDLimit,sbDLimit,tvTLimit,sbTLimit" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</eu.faircode.email.ScrollViewEx>
|
|
@ -1420,8 +1420,8 @@
|
|||
<string name="title_style_link_metadata">Fetch title</string>
|
||||
<string name="title_style_link_metadata_remark">This will fetch the title at the entered address</string>
|
||||
<string name="title_style_link_ffsend" translatable="false">FFSend</string>
|
||||
<string name="title_style_link_ffsend_dlimit" translatable="false">Download limit (count)</string>
|
||||
<string name="title_style_link_ffsend_tlimit" translatable="false">Time limit (hours)</string>
|
||||
<string name="title_style_link_ffsend_dlimit" translatable="false">Download limit (%1$d x)</string>
|
||||
<string name="title_style_link_ffsend_tlimit" translatable="false">Time limit (%1$d hours)</string>
|
||||
|
||||
<string name="title_add_image">Add image</string>
|
||||
<string name="title_add_image_inline">Insert</string>
|
||||
|
|
Loading…
Reference in a new issue