diff --git a/build.gradle b/build.gradle
index 8dab0f0c4..2d1288b32 100644
--- a/build.gradle
+++ b/build.gradle
@@ -121,6 +121,7 @@ dependencies {
debugCompile "com.facebook.stetho:stetho-timber:${STETHO_VERSION}@aar"
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
+ compile 'com.github.rey5137:material:1.2.4'
compile 'com.android.support:multidex:1.0.1'
compile 'com.nononsenseapps:filepicker:2.5.2'
compile "com.android.support:design:${SUPPORT_VERSION}"
diff --git a/src/main/java/org/tasks/dialogs/SeekBarDialog.java b/src/main/java/org/tasks/dialogs/SeekBarDialog.java
index 3dcd9a860..d25a1fa0c 100644
--- a/src/main/java/org/tasks/dialogs/SeekBarDialog.java
+++ b/src/main/java/org/tasks/dialogs/SeekBarDialog.java
@@ -4,13 +4,12 @@ import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
-import android.icu.text.NumberFormat;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
-import android.widget.SeekBar;
-import android.widget.TextView;
+
+import com.rey.material.widget.Slider;
import org.tasks.R;
import org.tasks.injection.DialogFragmentComponent;
@@ -24,56 +23,48 @@ import butterknife.ButterKnife;
public class SeekBarDialog extends InjectingDialogFragment {
- private static final String EXTRA_MIN_VALUE = "extra_min_value";
- private static final String EXTRA_MAX_VALUE = "extra_max_value";
+ private static final String EXTRA_LAYOUT = "extra_layout";
private static final String EXTRA_INITIAL_VALUE = "extra_initial_value";
+
public static final String EXTRA_VALUE = "extra_value";
- public static SeekBarDialog newSeekBarDialog(int minValue, int maxValue, int initial) {
+ public static SeekBarDialog newSeekBarDialog(int layout, int initial) {
SeekBarDialog dialog = new SeekBarDialog();
Bundle args = new Bundle();
- args.putInt(EXTRA_MIN_VALUE, minValue);
- args.putInt(EXTRA_MAX_VALUE, maxValue);
+ args.putInt(EXTRA_LAYOUT, layout);
dialog.setArguments(args);
dialog.initial = initial;
return dialog;
}
- @BindView(R.id.seekbar) SeekBar seekBar;
- @BindView(R.id.min) TextView min;
- @BindView(R.id.max) TextView max;
+ @BindView(R.id.slider) Slider slider;
@Inject DialogBuilder dialogBuilder;
@Inject Theme theme;
- private int minValue;
- private int maxValue;
private int initial;
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
- LayoutInflater layoutInflater = theme.getLayoutInflater(getContext());
- View view = layoutInflater.inflate(R.layout.dialog_seekbar, null);
- ButterKnife.bind(this, view);
-
Bundle arguments = getArguments();
if (savedInstanceState != null) {
initial = savedInstanceState.getInt(EXTRA_INITIAL_VALUE);
}
- minValue = arguments.getInt(EXTRA_MIN_VALUE);
- maxValue = arguments.getInt(EXTRA_MAX_VALUE);
- min.setText(NumberFormat.getIntegerInstance().format(minValue));
- max.setText(NumberFormat.getIntegerInstance().format(maxValue));
- seekBar.setMax(maxValue - minValue);
- seekBar.setProgress(initial);
+ int layout = arguments.getInt(EXTRA_LAYOUT);
+
+ LayoutInflater layoutInflater = theme.getLayoutInflater(getContext());
+ View view = layoutInflater.inflate(layout, null);
+ ButterKnife.bind(this, view);
+
+ slider.setValue(initial, true);
return dialogBuilder.newDialog()
.setView(view)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, new Intent() {{
- putExtra(EXTRA_VALUE, seekBar.getProgress() + minValue);
+ putExtra(EXTRA_VALUE, slider.getValue());
}});
}
})
@@ -85,7 +76,7 @@ public class SeekBarDialog extends InjectingDialogFragment {
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- outState.putInt(EXTRA_INITIAL_VALUE, seekBar.getProgress());
+ outState.putInt(EXTRA_INITIAL_VALUE, slider.getValue());
}
@Override
diff --git a/src/main/java/org/tasks/widget/WidgetConfigDialog.java b/src/main/java/org/tasks/widget/WidgetConfigDialog.java
index a5083675e..a80fed382 100644
--- a/src/main/java/org/tasks/widget/WidgetConfigDialog.java
+++ b/src/main/java/org/tasks/widget/WidgetConfigDialog.java
@@ -182,7 +182,7 @@ public class WidgetConfigDialog extends InjectingDialogFragment {
@OnClick(R.id.widget_opacity)
public void showOpacitySlider() {
- SeekBarDialog seekBarDialog = newSeekBarDialog(0, 100, opacityPercentage);
+ SeekBarDialog seekBarDialog = newSeekBarDialog(R.layout.dialog_opacity_seekbar, opacityPercentage);
seekBarDialog.setTargetFragment(this, REQUEST_OPACITY);
seekBarDialog.show(getChildFragmentManager(), FRAG_TAG_SEEKBAR);
}
diff --git a/src/main/res/layout/dialog_opacity_seekbar.xml b/src/main/res/layout/dialog_opacity_seekbar.xml
new file mode 100644
index 000000000..0d8d28450
--- /dev/null
+++ b/src/main/res/layout/dialog_opacity_seekbar.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/res/layout/dialog_seekbar.xml b/src/main/res/layout/dialog_seekbar.xml
deleted file mode 100644
index c08024e08..000000000
--- a/src/main/res/layout/dialog_seekbar.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file