mirror of https://github.com/tasks/tasks
Misc cleanup
parent
47d38374de
commit
75f3c509da
@ -1,55 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2012 Todoroo Inc
|
||||
*
|
||||
* See the file "LICENSE" for the full license governing this code.
|
||||
*/
|
||||
package com.todoroo.andlib.utility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* Helper class for reading and writing SharedPreferences
|
||||
*
|
||||
* @author Tim Su <tim@todoroo.com>
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class Preferences {
|
||||
|
||||
private static SharedPreferences preferences = null;
|
||||
|
||||
/** Get preferences object from the context */
|
||||
private static SharedPreferences getPrefs(Context context) {
|
||||
if(preferences != null) {
|
||||
return preferences;
|
||||
}
|
||||
|
||||
context = context.getApplicationContext();
|
||||
try {
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
// try writing
|
||||
preferences.edit().commit();
|
||||
|
||||
} catch (Exception e) {
|
||||
Timber.e(e, e.getMessage());
|
||||
String alternate = "preferences" + android.os.Process.myUid(); //$NON-NLS-1$
|
||||
preferences = context.getSharedPreferences(alternate, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
return preferences;
|
||||
}
|
||||
|
||||
public static boolean getBoolean(Context context, int keyResources, boolean defValue) {
|
||||
try {
|
||||
return getPrefs(context).getBoolean(context.getString(keyResources), defValue);
|
||||
} catch (ClassCastException e) {
|
||||
Timber.e(e, e.getMessage());
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2012 Todoroo Inc
|
||||
*
|
||||
* See the file "LICENSE" for the full license governing this code.
|
||||
*/
|
||||
package com.todoroo.astrid.ui;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.graphics.drawable.shapes.RoundRectShape;
|
||||
import android.graphics.drawable.shapes.Shape;
|
||||
|
||||
public class CustomBorderDrawable extends ShapeDrawable {
|
||||
private final Paint fillpaint, strokepaint;
|
||||
private final float strokeWidth;
|
||||
|
||||
public CustomBorderDrawable(Shape s, int fill, int stroke, int strokeWidth) {
|
||||
super(s);
|
||||
fillpaint = new Paint(this.getPaint());
|
||||
fillpaint.setColor(fill);
|
||||
strokepaint = new Paint(fillpaint);
|
||||
strokepaint.setStyle(Paint.Style.STROKE);
|
||||
strokepaint.setStrokeWidth(strokeWidth);
|
||||
strokepaint.setColor(stroke);
|
||||
this.strokeWidth = strokeWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Shape shape, Canvas canvas, Paint paint) {
|
||||
shape.resize(canvas.getClipBounds().right,
|
||||
canvas.getClipBounds().bottom);
|
||||
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.setRectToRect(new RectF(0, 0, canvas.getClipBounds().right,
|
||||
canvas.getClipBounds().bottom),
|
||||
new RectF(strokeWidth/2, strokeWidth/2, canvas.getClipBounds().right - strokeWidth/2,
|
||||
canvas.getClipBounds().bottom - strokeWidth/2),
|
||||
Matrix.ScaleToFit.FILL);
|
||||
canvas.concat(matrix);
|
||||
|
||||
shape.draw(canvas, fillpaint);
|
||||
shape.draw(canvas, strokepaint);
|
||||
}
|
||||
|
||||
public static StateListDrawable customButton(int tl, int tr, int br, int bl, int onColor, int offColor, int borderColor, int strokeWidth) {
|
||||
Shape shape = new RoundRectShape(new float[] { tl, tl, tr, tr, br, br, bl, bl}, null, null);
|
||||
ShapeDrawable sdOn = new CustomBorderDrawable(shape, onColor, borderColor, strokeWidth);
|
||||
ShapeDrawable sdOff = new CustomBorderDrawable(shape, offColor, borderColor, strokeWidth);
|
||||
|
||||
StateListDrawable stld = new StateListDrawable();
|
||||
stld.addState(new int[] { android.R.attr.state_pressed }, sdOn);
|
||||
stld.addState(new int[] { android.R.attr.state_checked }, sdOn);
|
||||
stld.addState(new int[] { android.R.attr.state_enabled }, sdOff);
|
||||
return stld;
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.todoroo.astrid.ui;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
|
||||
public class EditDialogOkBackground {
|
||||
|
||||
public static StateListDrawable getBg(int colorValue) {
|
||||
final Paint p = new Paint();
|
||||
p.setColor(Color.GRAY);
|
||||
Drawable d = new Drawable() {
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
//
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
//
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.OPAQUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
Rect r = canvas.getClipBounds();
|
||||
canvas.drawLine(r.left, r.top, r.right, r.top, p);
|
||||
}
|
||||
};
|
||||
|
||||
ColorDrawable color = new ColorDrawable(colorValue);
|
||||
|
||||
StateListDrawable stld = new StateListDrawable();
|
||||
stld.addState(new int[] { android.R.attr.state_pressed }, color);
|
||||
stld.addState(new int[] { android.R.attr.state_enabled }, d);
|
||||
return stld;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue