fixes for prefs
This commit is contained in:
parent
4714a8542a
commit
8e60686d7b
@ -9,7 +9,7 @@
|
|||||||
<string name="p_drag_distance_key">org.solovyev.android.calculator.DragButtonCalibrationActivity_distance</string>
|
<string name="p_drag_distance_key">org.solovyev.android.calculator.DragButtonCalibrationActivity_distance</string>
|
||||||
<string name="p_drag_distance">15;350</string>
|
<string name="p_drag_distance">15;350</string>
|
||||||
<string name="p_drag_angle_key">org.solovyev.android.calculator.DragButtonCalibrationActivity_angle</string>
|
<string name="p_drag_angle_key">org.solovyev.android.calculator.DragButtonCalibrationActivity_angle</string>
|
||||||
<string name="p_drag_angle">130;180</string>
|
<string name="p_drag_angle">0;45</string>
|
||||||
<string name="p_drag_duration_key">org.solovyev.android.calculator.DragButtonCalibrationActivity_duration</string>
|
<string name="p_drag_duration_key">org.solovyev.android.calculator.DragButtonCalibrationActivity_duration</string>
|
||||||
<string name="p_drag_duration">40;2500</string>
|
<string name="p_drag_duration">40;2500</string>
|
||||||
</resources>
|
</resources>
|
@ -13,26 +13,26 @@
|
|||||||
a:max="60"/>
|
a:max="60"/>
|
||||||
|
|
||||||
|
|
||||||
<org.solovyev.android.view.prefs.IntegerRangeSeekBarPreference
|
<org.solovyev.android.view.prefs.FloatRangeSeekBarPreference
|
||||||
a:key="@string/p_drag_distance_key"
|
a:key="@string/p_drag_distance_key"
|
||||||
a:title="Distance of drag event"
|
a:title="Distance of drag event"
|
||||||
a:text=" pxs"
|
a:text=" pxs"
|
||||||
a:defaultValue="@string/p_drag_distance"
|
a:defaultValue="15;350"
|
||||||
range:boundaries="10;500"/>
|
range:boundaries="10;500"/>
|
||||||
|
|
||||||
<org.solovyev.android.view.prefs.IntegerRangeSeekBarPreference
|
<org.solovyev.android.view.prefs.FloatRangeSeekBarPreference
|
||||||
a:key="@string/p_drag_duration_key"
|
a:key="@string/p_drag_duration_key"
|
||||||
a:title="Duration of drag event"
|
a:title="Duration of drag event"
|
||||||
a:text=" ms"
|
a:text=" ms"
|
||||||
a:defaultValue="@string/p_drag_duration"
|
a:defaultValue="40;2500"
|
||||||
range:boundaries="5;4000"/>
|
range:boundaries="5;4000"/>
|
||||||
|
|
||||||
<org.solovyev.android.view.prefs.IntegerRangeSeekBarPreference
|
<org.solovyev.android.view.prefs.FloatRangeSeekBarPreference
|
||||||
a:key="@string/p_drag_angle_key"
|
a:key="@string/p_drag_angle_key"
|
||||||
a:title="Angle of drag event"
|
a:title="Angle of drag event"
|
||||||
a:text=" degrees"
|
a:text=" degrees"
|
||||||
a:defaultValue="@string/p_drag_angle"
|
a:defaultValue="0;45"
|
||||||
range:boundaries="100;180"/>
|
range:boundaries="0;45"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
@ -6,10 +6,7 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.*;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.ClipboardManager;
|
import android.text.ClipboardManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -20,7 +17,7 @@ import android.widget.TextView;
|
|||||||
import bsh.EvalError;
|
import bsh.EvalError;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.solovyev.android.view.*;
|
import org.solovyev.android.view.FontSizeAdjuster;
|
||||||
import org.solovyev.android.view.widgets.*;
|
import org.solovyev.android.view.widgets.*;
|
||||||
import org.solovyev.common.utils.Announcer;
|
import org.solovyev.common.utils.Announcer;
|
||||||
import org.solovyev.common.utils.history.HistoryAction;
|
import org.solovyev.common.utils.history.HistoryAction;
|
||||||
@ -28,7 +25,7 @@ import org.solovyev.common.utils.history.HistoryAction;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
public class CalculatorActivity extends Activity implements FontSizeAdjuster {
|
public class CalculatorActivity extends Activity implements FontSizeAdjuster, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
private static final int HVGA_WIDTH_PIXELS = 320;
|
private static final int HVGA_WIDTH_PIXELS = 320;
|
||||||
|
|
||||||
@ -99,8 +96,7 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
|
||||||
if (DragButtonCalibrationActivity.INTENT_ACTION.equals(intent.getAction())) {
|
if (DragButtonCalibrationActivity.INTENT_ACTION.equals(intent.getAction())) {
|
||||||
final DragButtonCalibrationActivity.Preferences preferences = DragButtonCalibrationActivity.getPreferences(CalculatorActivity.this);
|
dpclRegister.announce().onDragPreferencesChange(DragButtonCalibrationActivity.getPreferences(CalculatorActivity.this));
|
||||||
dpclRegister.announce().onDragPreferencesChange(preferences);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -233,4 +229,9 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster {
|
|||||||
float ratio = (float) h / HVGA_WIDTH_PIXELS;
|
float ratio = (float) h / HVGA_WIDTH_PIXELS;
|
||||||
view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontPixelSize * ratio);
|
view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontPixelSize * ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
|
||||||
|
dpclRegister.announce().onDragPreferencesChange(DragButtonCalibrationActivity.getPreferences(CalculatorActivity.this));
|
||||||
|
}
|
||||||
}
|
}
|
@ -248,12 +248,17 @@ public class DragButtonCalibrationActivity extends Activity {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Interval<Float> transformInterval(@NotNull PreferenceType preferenceType, @NotNull DragDirection dragDirection, @NotNull Interval<Float> interval) {
|
private static Interval<Float> transformInterval(@NotNull PreferenceType preferenceType, @NotNull DragDirection dragDirection, @NotNull Interval<Float> interval) {
|
||||||
if ( preferenceType == PreferenceType.angle && dragDirection == DragDirection.down ) {
|
if (preferenceType == PreferenceType.angle) {
|
||||||
final Float leftBorder = interval.getLeftBorder();
|
final Float leftBorder = interval.getLeftBorder();
|
||||||
final Float rightBorder = interval.getRightBorder();
|
final Float rightBorder = interval.getRightBorder();
|
||||||
|
|
||||||
interval.setLeftBorder(180f - rightBorder);
|
if (dragDirection == DragDirection.up) {
|
||||||
interval.setRightBorder(180f - leftBorder);
|
interval.setLeftBorder(180f - rightBorder);
|
||||||
|
interval.setRightBorder(180f - leftBorder);
|
||||||
|
} else if (dragDirection == DragDirection.left || dragDirection == DragDirection.right) {
|
||||||
|
interval.setLeftBorder(90f - rightBorder / 2);
|
||||||
|
interval.setRightBorder(90f + leftBorder / 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return interval;
|
return interval;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
package org.solovyev.common;
|
package org.solovyev.common;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.solovyev.common.utils.*;
|
import org.solovyev.common.utils.*;
|
||||||
@ -34,6 +35,7 @@ public abstract class AbstractIntervalMapper<T> implements Mapper<Interval<T>> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Interval<T> parseValue(@Nullable String s) throws IllegalArgumentException {
|
public Interval<T> parseValue(@Nullable String s) throws IllegalArgumentException {
|
||||||
|
Log.d(AbstractIntervalMapper.class.getName(), "Parsing: " + s);
|
||||||
final List<T> list = CollectionsUtils.split(s, ";", getParser());
|
final List<T> list = CollectionsUtils.split(s, ";", getParser());
|
||||||
|
|
||||||
assert list.size() == 2;
|
assert list.size() == 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user