use of com.codename1.charts.compat.Paint in project CodenameOne by codenameone.
the class FlipTransition method initTransition.
@Override
public void initTransition() {
flipState = 0f;
transitionState = STATE_MOVE_AWAY;
zNear = 1600;
zFar = zNear + 3000;
Component source = getSource();
Component destination = getDestination();
int w = source.getWidth();
int h = source.getHeight();
// improper replace() calls, this may still be valid and shouldn't fail
if (w <= 0 || h <= 0) {
return;
}
sourceBuffer = createMutableImage(source.getWidth(), source.getHeight());
paint(sourceBuffer.getGraphics(), source, -source.getAbsoluteX(), -source.getAbsoluteY());
destBuffer = createMutableImage(destination.getWidth(), destination.getHeight());
paint(destBuffer.getGraphics(), destination, -destination.getAbsoluteX(), -destination.getAbsoluteY());
if (source instanceof Form) {
setBgColor(0);
}
motion = Motion.createLinearMotion(0, 100, duration);
motion.start();
}
use of com.codename1.charts.compat.Paint in project CodenameOne by codenameone.
the class AndroidImplementation method captureAudio.
public void captureAudio(final ActionListener response) {
if (!checkForPermission(Manifest.permission.RECORD_AUDIO, "This is required to record the audio")) {
return;
}
try {
final Form current = Display.getInstance().getCurrent();
final File temp = File.createTempFile("mtmp", ".3gpp");
temp.deleteOnExit();
if (recorder != null) {
recorder.release();
}
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_WB);
recorder.setOutputFile(temp.getAbsolutePath());
final Form recording = new Form("Recording");
recording.setTransitionInAnimator(CommonTransitions.createEmpty());
recording.setTransitionOutAnimator(CommonTransitions.createEmpty());
recording.setLayout(new BorderLayout());
recorder.prepare();
recorder.start();
final Label time = new Label("00:00");
time.getAllStyles().setAlignment(Component.CENTER);
Font f = Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_LARGE);
f = f.derive(getDisplayHeight() / 10, Font.STYLE_PLAIN);
time.getAllStyles().setFont(f);
recording.addComponent(BorderLayout.CENTER, time);
recording.registerAnimated(new Animation() {
long current = System.currentTimeMillis();
long zero = current;
int sec = 0;
public boolean animate() {
long now = System.currentTimeMillis();
if (now - current > 1000) {
current = now;
sec++;
return true;
}
return false;
}
public void paint(Graphics g) {
int seconds = sec % 60;
int minutes = sec / 60;
String secStr = seconds < 10 ? "0" + seconds : "" + seconds;
String minStr = minutes < 10 ? "0" + minutes : "" + minutes;
String txt = minStr + ":" + secStr;
time.setText(txt);
}
});
Container south = new Container(new com.codename1.ui.layouts.GridLayout(1, 2));
Command cancel = new Command("Cancel") {
@Override
public void actionPerformed(ActionEvent evt) {
if (recorder != null) {
recorder.stop();
recorder.release();
recorder = null;
}
current.showBack();
response.actionPerformed(null);
}
};
recording.setBackCommand(cancel);
south.add(new com.codename1.ui.Button(cancel));
south.add(new com.codename1.ui.Button(new Command("Save") {
@Override
public void actionPerformed(ActionEvent evt) {
if (recorder != null) {
recorder.stop();
recorder.release();
recorder = null;
}
current.showBack();
response.actionPerformed(new ActionEvent(temp.getAbsolutePath()));
}
}));
recording.addComponent(BorderLayout.SOUTH, south);
recording.show();
} catch (IOException ex) {
ex.printStackTrace();
throw new RuntimeException("failed to start audio recording");
}
}
use of com.codename1.charts.compat.Paint in project CodenameOne by codenameone.
the class AndroidImplementation method init.
@Override
public void init(Object m) {
if (m instanceof CodenameOneActivity) {
setContext(null);
setActivity((CodenameOneActivity) m);
} else {
setActivity(null);
setContext((Context) m);
}
instance = this;
if (getActivity() != null && getActivity().hasUI()) {
if (!hasActionBar()) {
try {
getActivity().requestWindowFeature(Window.FEATURE_NO_TITLE);
} catch (Exception e) {
// Log.d("Codename One", "No idea why this throws a Runtime Error", e);
}
} else {
getActivity().invalidateOptionsMenu();
try {
getActivity().requestWindowFeature(Window.FEATURE_ACTION_BAR);
getActivity().requestWindowFeature(Window.FEATURE_PROGRESS);
if (android.os.Build.VERSION.SDK_INT >= 21) {
// WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
getActivity().getWindow().addFlags(-2147483648);
}
} catch (Exception e) {
// Log.d("Codename One", "No idea why this throws a Runtime Error", e);
}
NotifyActionBar notify = new NotifyActionBar(getActivity(), false);
notify.run();
}
if (statusBarHidden) {
getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
getActivity().getWindow().setStatusBarColor(android.graphics.Color.TRANSPARENT);
}
if (Display.getInstance().getProperty("StatusbarHidden", "").equals("true")) {
getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
if (Display.getInstance().getProperty("KeepScreenOn", "").equals("true")) {
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
if (Display.getInstance().getProperty("DisableScreenshots", "").equals("true")) {
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
if (m instanceof CodenameOneActivity) {
((CodenameOneActivity) m).setDefaultIntentResultListener(this);
((CodenameOneActivity) m).setIntentResultListener(this);
}
/**
* translate our default font height depending on the screen density.
* this is required for new high resolution devices. otherwise
* everything looks awfully small.
*
* we use our default font height value of 16 and go from there. i
* thought about using new Paint().getTextSize() for this value but if
* some new version of android suddenly returns values already tranlated
* to the screen then we might end up with too large fonts. the
* documentation is not very precise on that.
*/
final int defaultFontPixelHeight = 16;
this.defaultFontHeight = this.translatePixelForDPI(defaultFontPixelHeight);
this.defaultFont = (CodenameOneTextPaint) ((NativeFont) this.createFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM)).font;
Display.getInstance().setTransitionYield(-1);
initSurface();
/**
* devices are extremely sensitive so dragging should start a little
* later than suggested by default implementation.
*/
this.setDragStartPercentage(1);
VirtualKeyboardInterface vkb = new AndroidKeyboard(this);
Display.getInstance().registerVirtualKeyboard(vkb);
Display.getInstance().setDefaultVirtualKeyboard(vkb);
InPlaceEditView.endEdit();
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
if (nativePeers.size() > 0) {
for (int i = 0; i < nativePeers.size(); i++) {
((AndroidImplementation.AndroidPeer) nativePeers.elementAt(i)).init();
}
}
} else {
/**
* translate our default font height depending on the screen density.
* this is required for new high resolution devices. otherwise
* everything looks awfully small.
*
* we use our default font height value of 16 and go from there. i
* thought about using new Paint().getTextSize() for this value but if
* some new version of android suddenly returns values already tranlated
* to the screen then we might end up with too large fonts. the
* documentation is not very precise on that.
*/
final int defaultFontPixelHeight = 16;
this.defaultFontHeight = this.translatePixelForDPI(defaultFontPixelHeight);
this.defaultFont = (CodenameOneTextPaint) ((NativeFont) this.createFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM)).font;
}
HttpURLConnection.setFollowRedirects(false);
CookieHandler.setDefault(null);
}
use of com.codename1.charts.compat.Paint in project CodenameOne by codenameone.
the class ResetableTextWatcher method startEditing.
/**
* Start editing the given text-area
* This method is executed on the UI thread, so UI manipulation is safe here.
* @param activity Current running activity
* @param textArea The TextAreaData instance that wraps the CN1 TextArea that our internal EditText needs to overlap. We use
* a TextAreaData so that the text area properties can be accessed off the EDT safely.
* @param codenameOneInputType One of the input type constants in com.codename1.ui.TextArea
* @param initialText The text that appears in the Codename One text are before the call to startEditing
* @param isEditedFieldSwitch if true, then special case for async edit mode - the native editing is already active, no need to show
* native field, just change the connected field
*/
private synchronized void startEditing(Activity activity, TextAreaData textArea, String initialText, int codenameOneInputType, final boolean isEditedFieldSwitch) {
int txty = lastTextAreaY = textArea.getAbsoluteY() + textArea.getScrollY();
int txtx = lastTextAreaX = textArea.getAbsoluteX() + textArea.getScrollX();
lastTextAreaWidth = textArea.getWidth();
lastTextAreaHeight = textArea.getHeight();
int paddingTop = 0;
int paddingLeft = textArea.paddingLeft;
int paddingRight = textArea.paddingRight;
int paddingBottom = textArea.paddingBottom;
if (textArea.isTextField) {
switch(textArea.getVerticalAlignment()) {
case Component.BOTTOM:
paddingTop = textArea.getHeight() - textArea.paddingBottom - textArea.fontHeight;
break;
case Component.CENTER:
paddingTop = textArea.getHeight() / 2 - textArea.fontHeight / 2;
break;
default:
paddingTop = textArea.paddingTop;
break;
}
} else {
paddingTop = textArea.paddingTop;
}
int id = activity.getResources().getIdentifier("cn1Style", "attr", activity.getApplicationInfo().packageName);
if (!isEditedFieldSwitch) {
mEditText = new EditView(activity, textArea.textArea, this, id);
} else {
mEditText.switchToTextArea(textArea.textArea);
}
if (textArea.getClientProperty("blockCopyPaste") != null || Display.getInstance().getProperty("blockCopyPaste", "false").equals("true")) {
// The code below is taken from this stackoverflow answer: http://stackoverflow.com/a/22756538/756809
if (android.os.Build.VERSION.SDK_INT < 11) {
mEditText.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
menu.clear();
}
});
} else {
mEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
public void onDestroyActionMode(ActionMode mode) {
}
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
return false;
}
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
});
}
} else if (isEditedFieldSwitch) {
// reset copy-paste protection
if (android.os.Build.VERSION.SDK_INT < 11) {
mEditText.setOnCreateContextMenuListener(null);
} else {
mEditText.setCustomSelectionActionModeCallback(null);
}
}
if (!isEditedFieldSwitch) {
mEditText.addTextChangedListener(mEditText.mTextWatcher);
}
mEditText.setBackgroundDrawable(null);
mEditText.setFocusableInTouchMode(true);
mEditLayoutParams = new FrameLayout.LayoutParams(0, 0);
// Set the appropriate gravity so that the left and top margins will be
// taken into account
mEditLayoutParams.gravity = Gravity.LEFT | Gravity.TOP;
mEditLayoutParams.setMargins(txtx, txty, 0, 0);
mEditLayoutParams.width = textArea.getWidth();
mEditLayoutParams.height = textArea.getHeight();
mEditText.setLayoutParams(mEditLayoutParams);
if (textArea.isRTL()) {
mEditText.setGravity(Gravity.RIGHT | Gravity.TOP);
} else {
mEditText.setGravity(Gravity.LEFT | Gravity.TOP);
}
mEditText.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
Component nextDown = textArea.nextDown;
boolean imeOptionTaken = true;
int ime = EditorInfo.IME_FLAG_NO_EXTRACT_UI;
if (textArea.isSingleLineTextArea()) {
if (textArea.getClientProperty("searchField") != null) {
mEditText.setImeOptions(ime | EditorInfo.IME_ACTION_SEARCH);
} else {
if (textArea.getClientProperty("sendButton") != null) {
mEditText.setImeOptions(ime | EditorInfo.IME_ACTION_SEND);
} else {
if (textArea.getClientProperty("goButton") != null) {
mEditText.setImeOptions(ime | EditorInfo.IME_ACTION_GO);
} else {
if (textArea.isTextField && textArea.getDoneListener() != null) {
mEditText.setImeOptions(ime | EditorInfo.IME_ACTION_DONE);
} else if (nextDown != null && nextDown instanceof TextArea && ((TextArea) nextDown).isEditable() && ((TextArea) nextDown).isEnabled()) {
mEditText.setImeOptions(ime | EditorInfo.IME_ACTION_NEXT);
} else {
mEditText.setImeOptions(ime | EditorInfo.IME_ACTION_DONE);
imeOptionTaken = false;
}
}
}
}
}
mEditText.setSingleLine(textArea.isSingleLineTextArea());
mEditText.setAdapter((ArrayAdapter<String>) null);
mEditText.setText(initialText);
if (!textArea.isSingleLineTextArea() && textArea.textArea.isGrowByContent() && textArea.textArea.getGrowLimit() > -1) {
defaultMaxLines = mEditText.getMaxLines();
mEditText.setMaxLines(textArea.textArea.getGrowLimit());
}
if (textArea.nativeHintBool && textArea.getHint() != null) {
mEditText.setHint(textArea.getHint());
}
if (!isEditedFieldSwitch) {
addView(mEditText, mEditLayoutParams);
}
invalidate();
setVisibility(VISIBLE);
bringToFront();
mEditText.requestFocus();
Object nativeFont = textArea.nativeFont;
if (nativeFont == null) {
nativeFont = impl.getDefaultFont();
}
Paint p = (Paint) ((AndroidImplementation.NativeFont) nativeFont).font;
mEditText.setTypeface(p.getTypeface());
mEditText.setTextScaleX(p.getTextScaleX());
mEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, p.getTextSize());
int fgColor = textArea.fgColor;
mEditText.setTextColor(Color.rgb(fgColor >> 16, (fgColor & 0x00ff00) >> 8, (fgColor & 0x0000ff)));
boolean password = false;
if ((codenameOneInputType & TextArea.PASSWORD) == TextArea.PASSWORD) {
codenameOneInputType = codenameOneInputType ^ TextArea.PASSWORD;
password = true;
}
if (textArea.isSingleLineTextArea()) {
mEditText.setInputType(getAndroidInputType(codenameOneInputType));
// if not ime was explicity requested and this is a single line textfield of type ANY add the emoji keyboard.
if (!imeOptionTaken && codenameOneInputType == TextArea.ANY) {
mEditText.setInputType(getAndroidInputType(codenameOneInputType) | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
}
if (Display.getInstance().getProperty("andAddComma", "false").equals("true") && (codenameOneInputType & TextArea.DECIMAL) == TextArea.DECIMAL) {
defaultKeyListener = mEditText.getKeyListener();
mEditText.setKeyListener(DigitsKeyListener.getInstance("0123456789.,"));
}
}
if (password) {
int type = mInputTypeMap.get(codenameOneInputType, InputType.TYPE_CLASS_TEXT);
if ((type & InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) == InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) {
type = type ^ InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
}
// turn off suggestions for passwords
mEditText.setInputType(type | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
mEditText.setTransformationMethod(new MyPasswordTransformationMethod());
}
int maxLength = textArea.maxSize;
InputFilter[] FilterArray = new InputFilter[1];
FilterArray[0] = new InputFilter.LengthFilter(maxLength);
mEditText.setFilters(FilterArray);
mEditText.setSelection(mEditText.getText().length());
showVirtualKeyboard(true);
if (Boolean.FALSE.equals(textArea.getClientProperty("android.cursorVisible"))) {
// This provides an imperfect workaround for this issue:
// https://github.com/codenameone/CodenameOne/issues/2317
// Blinking cursor causes text to disappear on some versions of android
// Can't seem to find how to detect whether device is affected, so
// just providing a client property to disable the blinking cursor
// on a particular text field.
mEditText.setCursorVisible(false);
}
/*
// Leaving this hack here for posterity. It seems that this manually
// blinking cursor causes the paste menu to disappear
// https://github.com/codenameone/CodenameOne/issues/2147
// Removing the hack below, fixes this issue. And in the test device
// I'm using the blinking of text doesn't seem to occur, so perhaps
// it was fixed via other means. Test device:
// Name: Samsung Galaxy S3 (T-Mobile)
// OS: 4.3
// Manufacturer: Samsung
// Model: 4.3
// Chipset: armeabi-v7a 1512MHz
// Memory: 16000000000
// Heap: 256000000
// Display: 720 x 1280
//
// UPDATE Feb. 13, 2018:
// This issue seems to be still present in some devices, but it isn't clear even
// how to detect it.
// Issue reported and reproduced here https://github.com/codenameone/CodenameOne/issues/2317
// Issue has been observed in a Virtual Box installation with 5.1.1, but
// cannot be reproduced in a Nexus 5 running 5.1.1.
//
if (Build.VERSION.SDK_INT < 21) {
// HACK!!! On Android 4.4, it seems that the natural blinking cursor
// causes text to disappear when it blinks. Manually blinking the
// cursor seems to work around this issue, so that's what we do here.
// This issue is described here: http://stackoverflow.com/questions/41305052/textfields-content-disappears-during-typing?noredirect=1#comment69977316_41305052
mEditText.setCursorVisible(false);
final boolean[] cursorVisible = new boolean[]{false};
if (cursorTimer != null) {
cursorTimer.cancel();
}
cursorTimer = new Timer();
cursorTimerTask = new TimerTask() {
public void run() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
EditView v = mEditText;
if (v != null) {
cursorVisible[0] = !cursorVisible[0];
v.setCursorVisible(cursorVisible[0]);
}
}
});
}
};
cursorTimer.schedule(cursorTimerTask, 100, 500);
}
*/
}
use of com.codename1.charts.compat.Paint in project CodenameOne by codenameone.
the class AndroidGraphics method paintComponentBackground.
public void paintComponentBackground(int x, int y, int width, int height, Style s) {
if (width <= 0 || height <= 0) {
return;
}
canvas.save();
applyTransform();
Image bgImageOrig = s.getBgImage();
try {
if (bgImageOrig == null) {
if (s.getBackgroundType() >= Style.BACKGROUND_GRADIENT_LINEAR_VERTICAL) {
drawGradientBackground(s, x, y, width, height);
// canvas.restore();
return;
}
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
// canvas.restore();
return;
} else {
int iW = bgImageOrig.getWidth();
int iH = bgImageOrig.getHeight();
Object bgImage = bgImageOrig.getImage();
switch(s.getBackgroundType()) {
case Style.BACKGROUND_NONE:
if (s.getBgTransparency() != 0) {
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
}
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_SCALED:
drawImageImpl(bgImage, x, y, width, height);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_SCALED_FILL:
float r = Math.max(((float) width) / ((float) iW), ((float) height) / ((float) iH));
int bwidth = (int) (((float) iW) * r);
int bheight = (int) (((float) iH) * r);
drawImageImpl(bgImage, x + (width - bwidth) / 2, y + (height - bheight) / 2, bwidth, bheight);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_SCALED_FIT:
if (s.getBgTransparency() != 0) {
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
}
float r2 = Math.min(((float) width) / ((float) iW), ((float) height) / ((float) iH));
int awidth = (int) (((float) iW) * r2);
int aheight = (int) (((float) iH) * r2);
drawImageImpl(bgImage, x + (width - awidth) / 2, y + (height - aheight) / 2, awidth, aheight);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_TILE_BOTH:
tileImageImpl(bgImage, x, y, width, height);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_TOP:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
tileImageImpl(bgImage, x, y, width, iH);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_CENTER:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
tileImageImpl(bgImage, x, y + (height / 2 - iH / 2), width, iH);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_BOTTOM:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
tileImageImpl(bgImage, x, y + (height - iH), width, iH);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_LEFT:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
for (int yPos = 0; yPos <= height; yPos += iH) {
canvas.drawBitmap((Bitmap) bgImage, x, y + yPos, paint);
}
canvas.restore();
return;
case Style.BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_CENTER:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
for (int yPos = 0; yPos <= height; yPos += iH) {
canvas.drawBitmap((Bitmap) bgImage, x + (width / 2 - iW / 2), y + yPos, paint);
}
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_RIGHT:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
for (int yPos = 0; yPos <= height; yPos += iH) {
canvas.drawBitmap((Bitmap) bgImage, x + width - iW, y + yPos, paint);
}
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_ALIGNED_TOP:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
canvas.drawBitmap((Bitmap) bgImage, x + (width / 2 - iW / 2), y, paint);
canvas.restore();
return;
case Style.BACKGROUND_IMAGE_ALIGNED_BOTTOM:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
canvas.drawBitmap((Bitmap) bgImage, x + (width / 2 - iW / 2), y + (height - iH), paint);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_ALIGNED_LEFT:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
canvas.drawBitmap((Bitmap) bgImage, x, y + (height / 2 - iH / 2), paint);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_ALIGNED_RIGHT:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
canvas.drawBitmap((Bitmap) bgImage, x + width - iW, y + (height / 2 - iH / 2), paint);
canvas.restore();
return;
case Style.BACKGROUND_IMAGE_ALIGNED_CENTER:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
canvas.drawBitmap((Bitmap) bgImage, x + (width / 2 - iW / 2), y + (height / 2 - iH / 2), paint);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_ALIGNED_TOP_LEFT:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
canvas.drawBitmap((Bitmap) bgImage, x, y, paint);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_ALIGNED_TOP_RIGHT:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
canvas.drawBitmap((Bitmap) bgImage, x + width - iW, y, paint);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_ALIGNED_BOTTOM_LEFT:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
canvas.drawBitmap((Bitmap) bgImage, x, y + (height - iH), paint);
// canvas.restore();
return;
case Style.BACKGROUND_IMAGE_ALIGNED_BOTTOM_RIGHT:
setColor(s.getBgColor());
fillRectImpl(x, y, width, height, s.getBgTransparency());
canvas.drawBitmap((Bitmap) bgImage, x + width - iW, y + (height - iH), paint);
// canvas.restore();
return;
case Style.BACKGROUND_GRADIENT_LINEAR_HORIZONTAL:
case Style.BACKGROUND_GRADIENT_LINEAR_VERTICAL:
case Style.BACKGROUND_GRADIENT_RADIAL:
drawGradientBackground(s, x, y, width, height);
// canvas.restore();
return;
}
}
} finally {
unapplyTransform();
canvas.restore();
}
}
Aggregations