use of com.klinker.android.launcher.api.ResourceHelper in project Talon-for-Twitter by klinker24.
the class ImageUtils method getBiggerCircle.
public static Bitmap getBiggerCircle(Bitmap currentImage, Context context) {
int scale = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 400, context.getResources().getDisplayMetrics());
Bitmap bitmap;
if (currentImage.getWidth() >= currentImage.getHeight()) {
bitmap = Bitmap.createBitmap(currentImage, currentImage.getWidth() / 2 - currentImage.getHeight() / 2, 0, currentImage.getHeight(), currentImage.getHeight());
} else {
bitmap = Bitmap.createBitmap(currentImage, 0, currentImage.getHeight() / 2 - currentImage.getWidth() / 2, currentImage.getWidth(), currentImage.getWidth());
}
Bitmap output;
try {
output = Bitmap.createBitmap(scale, scale, Bitmap.Config.ARGB_8888);
} catch (OutOfMemoryError e) {
return null;
}
Canvas canvas = new Canvas(output);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
Rect rect = new Rect(0, 0, scale, scale);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
canvas.drawCircle(scale / 2, scale / 2, (scale / 2) - (scale / 25), paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
try {
canvas.drawBitmap(bitmap, null, rect, paint);
} catch (Exception e) {
// bitmap is null i guess
}
ResourceHelper helper = new ResourceHelper(context, "com.klinker.android.twitter");
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(helper.getDimension("contact_picture_border"));
try {
TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.circle_border });
int resource = a.getResourceId(0, 0);
a.recycle();
paint.setColor(context.getResources().getColor(resource));
} catch (Exception e) {
paint.setColor(helper.getColor("circle_outline_dark"));
}
canvas.drawCircle(scale / 2, scale / 2, (scale / 2) - (scale / 25), paint);
return output;
}
use of com.klinker.android.launcher.api.ResourceHelper in project Talon-for-Twitter by klinker24.
the class ImageUtils method getCircle.
public static Bitmap getCircle(Bitmap currentImage, Context context) {
int scale = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96, context.getResources().getDisplayMetrics());
Bitmap bitmap;
if (currentImage == null) {
return null;
}
if (currentImage.getWidth() >= currentImage.getHeight()) {
bitmap = Bitmap.createBitmap(currentImage, currentImage.getWidth() / 2 - currentImage.getHeight() / 2, 0, currentImage.getHeight(), currentImage.getHeight());
} else {
bitmap = Bitmap.createBitmap(currentImage, 0, currentImage.getHeight() / 2 - currentImage.getWidth() / 2, currentImage.getWidth(), currentImage.getWidth());
}
Bitmap output;
try {
output = Bitmap.createBitmap(scale, scale, Bitmap.Config.ARGB_8888);
} catch (OutOfMemoryError e) {
return null;
}
Canvas canvas = new Canvas(output);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
Rect rect = new Rect(0, 0, scale, scale);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
canvas.drawCircle(scale / 2, scale / 2, (scale / 2) - (scale / 25), paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
try {
canvas.drawBitmap(bitmap, null, rect, paint);
} catch (Exception e) {
// bitmap is null i guess
}
ResourceHelper helper = new ResourceHelper(context, "com.klinker.android.twitter");
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(helper.getDimension("contact_picture_border"));
try {
TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.circle_border });
int resource = a.getResourceId(0, 0);
a.recycle();
paint.setColor(context.getResources().getColor(resource));
} catch (Exception e) {
paint.setColor(helper.getColor("circle_outline_dark"));
}
canvas.drawCircle(scale / 2, scale / 2, (scale / 2) - (scale / 25), paint);
return output;
}
use of com.klinker.android.launcher.api.ResourceHelper in project Talon-for-Twitter by klinker24.
the class FullScreenSwipeRefreshLayout method onLayout.
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
final int width = getMeasuredWidth();
final int height = getMeasuredHeight();
ResourceHelper helper = new ResourceHelper(getContext(), "com.klinker.android.twitter");
if (Build.VERSION.SDK_INT > 18 && AppSettings.getInstance(getContext()).uiExtras && (getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE || helper.getBoolean("isTablet")) && !MainActivity.isPopup) {
// action bar plus the status bar
translation = Utils.getStatusBarHeight(getContext()) + Utils.getActionBarHeight(getContext());
} else {
// just the action bar
translation = Utils.getActionBarHeight(getContext());
}
try {
int immersive = android.provider.Settings.System.getInt(getContext().getContentResolver(), "immersive_mode");
if (immersive == 1) {
mImmersive = true;
}
} catch (Exception e) {
}
statusTranslation = Utils.getStatusBarHeight(getContext());
actionBarTranslation = Utils.getActionBarHeight(getContext());
mProgressBar.setBounds(0, 0, width, mProgressBarHeight);
if (getChildCount() == 0) {
return;
}
final View child = getChildAt(0);
final int childLeft = getPaddingLeft();
final int childTop = mCurrentTargetOffsetTop + getPaddingTop();
final int childWidth = width - getPaddingLeft() - getPaddingRight();
final int childHeight = height - getPaddingTop() - getPaddingBottom();
child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
}
use of com.klinker.android.launcher.api.ResourceHelper in project Talon-for-Twitter by klinker24.
the class ImageUtils method getSizedCircle.
public static Bitmap getSizedCircle(Bitmap currentImage, Context context, int dp) {
int scale = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics());
if (currentImage == null) {
return null;
}
if (currentImage.getWidth() >= currentImage.getHeight()) {
currentImage = Bitmap.createBitmap(currentImage, currentImage.getWidth() / 2 - currentImage.getHeight() / 2, 0, currentImage.getHeight(), currentImage.getHeight());
} else {
currentImage = Bitmap.createBitmap(currentImage, 0, currentImage.getHeight() / 2 - currentImage.getWidth() / 2, currentImage.getWidth(), currentImage.getWidth());
}
Bitmap output;
try {
output = Bitmap.createBitmap(scale, scale, Bitmap.Config.ARGB_8888);
} catch (OutOfMemoryError e) {
return null;
}
Canvas canvas = new Canvas(output);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
Rect rect = new Rect(0, 0, scale, scale);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
canvas.drawCircle(scale / 2, scale / 2, (scale / 2) - (scale / 25), paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
try {
canvas.drawBitmap(currentImage, null, rect, paint);
} catch (Exception e) {
// bitmap is null i guess
}
ResourceHelper helper = new ResourceHelper(context, "com.klinker.android.twitter");
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(helper.getDimension("contact_picture_border"));
try {
TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.circle_border });
int resource = a.getResourceId(0, 0);
a.recycle();
paint.setColor(context.getResources().getColor(resource));
} catch (Exception e) {
paint.setColor(helper.getColor("circle_outline_dark"));
}
canvas.drawCircle(scale / 2, scale / 2, (scale / 2) - (scale / 25), paint);
return resizeImage(context, output, dp);
}
Aggregations