Use sliders for FFSend properties

pull/209/head
M66B 2 years ago
parent 61ad85eed7
commit 4ba04ca05f

@ -28,7 +28,6 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable; import android.text.Editable;
@ -40,6 +39,7 @@ import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -64,8 +64,10 @@ public class FragmentDialogInsertLink extends FragmentDialogBase {
private EditText etTitle; private EditText etTitle;
private Button btnUpload; private Button btnUpload;
private ProgressBar pbUpload; private ProgressBar pbUpload;
private EditText etDlimit; private TextView tvDLimit;
private EditText etTlimit; private SeekBar sbDLimit;
private TextView tvTLimit;
private SeekBar sbTLimit;
private static final int METADATA_CONNECT_TIMEOUT = 10 * 1000; // milliseconds private static final int METADATA_CONNECT_TIMEOUT = 10 * 1000; // milliseconds
private static final int METADATA_READ_TIMEOUT = 15 * 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); final ProgressBar pbWait = view.findViewById(R.id.pbWait);
btnUpload = view.findViewById(R.id.btnUpload); btnUpload = view.findViewById(R.id.btnUpload);
pbUpload = view.findViewById(R.id.pbUpload); pbUpload = view.findViewById(R.id.pbUpload);
etDlimit = view.findViewById(R.id.etDlimit); tvDLimit = view.findViewById(R.id.tvDLimit);
etTlimit = view.findViewById(R.id.etTlimit); 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); Group grpUpload = view.findViewById(R.id.grpUpload);
etLink.addTextChangedListener(new TextWatcher() { 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) { if (savedInstanceState == null) {
String link = (uri == null ? "https://" : uri.toString()); String link = (uri == null ? "https://" : uri.toString());
etLink.setText(link); etLink.setText(link);
@ -263,8 +301,8 @@ public class FragmentDialogInsertLink extends FragmentDialogBase {
etTitle.setText(savedInstanceState.getString("fair:text")); etTitle.setText(savedInstanceState.getString("fair:text"));
} }
etDlimit.setHint(Integer.toString(FFSend.FF_DEFAULT_DLIMIT)); sbDLimit.setProgress(FFSend.FF_DEFAULT_DLIMIT);
etTlimit.setHint(Integer.toString(FFSend.FF_DEFAULT_TLIMIT)); sbTLimit.setProgress(FFSend.FF_DEFAULT_TLIMIT);
pbWait.setVisibility(View.GONE); pbWait.setVisibility(View.GONE);
pbUpload.setVisibility(View.GONE); pbUpload.setVisibility(View.GONE);
@ -309,31 +347,31 @@ public class FragmentDialogInsertLink extends FragmentDialogBase {
private void onFFSend(Uri uri) { private void onFFSend(Uri uri) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putParcelable("uri", uri); args.putParcelable("uri", uri);
args.putString("dlimit", etDlimit.getText().toString()); args.putInt("dlimit", sbDLimit.getProgress());
args.putString("tlimit", etTlimit.getText().toString()); args.putInt("tlimit", sbTLimit.getProgress());
new SimpleTask<String>() { new SimpleTask<String>() {
@Override @Override
protected void onPreExecute(Bundle args) { protected void onPreExecute(Bundle args) {
btnUpload.setEnabled(false); btnUpload.setEnabled(false);
etDlimit.setEnabled(false); sbDLimit.setEnabled(false);
etTlimit.setEnabled(false); sbTLimit.setEnabled(false);
pbUpload.setVisibility(View.VISIBLE); pbUpload.setVisibility(View.VISIBLE);
} }
@Override @Override
protected void onPostExecute(Bundle args) { protected void onPostExecute(Bundle args) {
btnUpload.setEnabled(true); btnUpload.setEnabled(true);
etDlimit.setEnabled(true); sbDLimit.setEnabled(true);
etTlimit.setEnabled(true); sbTLimit.setEnabled(true);
pbUpload.setVisibility(View.GONE); pbUpload.setVisibility(View.GONE);
} }
@Override @Override
protected String onExecute(Context context, Bundle args) throws Throwable { protected String onExecute(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri"); Uri uri = args.getParcelable("uri");
String _dlimit = args.getString("dlimit"); int dlimit = args.getInt("dlimit");
String _tlimit = args.getString("tlimit"); int tlimit = args.getInt("tlimit");
if (uri == null) if (uri == null)
throw new FileNotFoundException("uri"); throw new FileNotFoundException("uri");
@ -345,8 +383,10 @@ public class FragmentDialogInsertLink extends FragmentDialogBase {
if (dfile == null) if (dfile == null)
throw new FileNotFoundException("dfile"); throw new FileNotFoundException("dfile");
int dlimit = (TextUtils.isEmpty(_dlimit) ? FFSend.FF_DEFAULT_DLIMIT : Integer.parseInt(_dlimit)); if (dlimit == 0)
int tlimit = (TextUtils.isEmpty(_tlimit) ? FFSend.FF_DEFAULT_TLIMIT : Integer.parseInt(_tlimit)); dlimit = FFSend.FF_DEFAULT_DLIMIT;
if (tlimit == 0)
tlimit = FFSend.FF_DEFAULT_TLIMIT;
args.putString("title", dfile.getName()); args.putString("title", dfile.getName());

@ -139,20 +139,19 @@
android:id="@+id/tvDLimit" android:id="@+id/tvDLimit"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="6dp"
android:labelFor="@+id/etDlimit" android:labelFor="@+id/sbDLimit"
android:text="@string/title_style_link_ffsend_dlimit" 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_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnUpload" /> app:layout_constraintTop_toBottomOf="@id/btnUpload" />
<eu.faircode.email.EditTextPlain <SeekBar
android:id="@+id/etDlimit" android:id="@+id/sbDLimit"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="number" android:max="100"
android:maxLength="3" android:min="0"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDLimit" /> app:layout_constraintTop_toBottomOf="@id/tvDLimit" />
@ -161,20 +160,19 @@
android:id="@+id/tvTLimit" android:id="@+id/tvTLimit"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="6dp"
android:labelFor="@+id/etTlimit" android:labelFor="@+id/sbTLimit"
android:text="@string/title_style_link_ffsend_tlimit" 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_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etDlimit" /> app:layout_constraintTop_toBottomOf="@id/sbDLimit" />
<eu.faircode.email.EditTextPlain <SeekBar
android:id="@+id/etTlimit" android:id="@+id/sbTLimit"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="number" android:max="240"
android:maxLength="3" android:min="0"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvTLimit" /> app:layout_constraintTop_toBottomOf="@id/tvTLimit" />
@ -183,6 +181,6 @@
android:id="@+id/grpUpload" android:id="@+id/grpUpload"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="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> </androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx> </eu.faircode.email.ScrollViewEx>

@ -1420,8 +1420,8 @@
<string name="title_style_link_metadata">Fetch title</string> <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_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" translatable="false">FFSend</string>
<string name="title_style_link_ffsend_dlimit" translatable="false">Download limit (count)</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 (hours)</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">Add image</string>
<string name="title_add_image_inline">Insert</string> <string name="title_add_image_inline">Insert</string>

Loading…
Cancel
Save