|
|
@ -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());
|
|
|
|
|
|
|
|
|
|
|
|