fixes for prefs
This commit is contained in:
@@ -6,10 +6,7 @@
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.*;
|
||||
import android.os.Bundle;
|
||||
import android.text.ClipboardManager;
|
||||
import android.util.Log;
|
||||
@@ -20,7 +17,7 @@ import android.widget.TextView;
|
||||
import bsh.EvalError;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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.common.utils.Announcer;
|
||||
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.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;
|
||||
|
||||
@@ -99,8 +96,7 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
if (DragButtonCalibrationActivity.INTENT_ACTION.equals(intent.getAction())) {
|
||||
final DragButtonCalibrationActivity.Preferences preferences = DragButtonCalibrationActivity.getPreferences(CalculatorActivity.this);
|
||||
dpclRegister.announce().onDragPreferencesChange(preferences);
|
||||
dpclRegister.announce().onDragPreferencesChange(DragButtonCalibrationActivity.getPreferences(CalculatorActivity.this));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -233,4 +229,9 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster {
|
||||
float ratio = (float) h / HVGA_WIDTH_PIXELS;
|
||||
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
|
||||
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 rightBorder = interval.getRightBorder();
|
||||
|
||||
interval.setLeftBorder(180f - rightBorder);
|
||||
interval.setRightBorder(180f - leftBorder);
|
||||
if (dragDirection == DragDirection.up) {
|
||||
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;
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
package org.solovyev.common;
|
||||
|
||||
import android.util.Log;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.common.utils.*;
|
||||
@@ -34,6 +35,7 @@ public abstract class AbstractIntervalMapper<T> implements Mapper<Interval<T>> {
|
||||
|
||||
@Override
|
||||
public Interval<T> parseValue(@Nullable String s) throws IllegalArgumentException {
|
||||
Log.d(AbstractIntervalMapper.class.getName(), "Parsing: " + s);
|
||||
final List<T> list = CollectionsUtils.split(s, ";", getParser());
|
||||
|
||||
assert list.size() == 2;
|
||||
|
Reference in New Issue
Block a user