Skip to content

Commit

Permalink
Added watermak to week view
Browse files Browse the repository at this point in the history
  • Loading branch information
jush committed Sep 17, 2011
1 parent c37372b commit a9130d6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion AndroidManifest.xml
Expand Up @@ -11,7 +11,8 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/CalendarTheme">
android:theme="@style/CalendarTheme"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Binary file added res/drawable/background_vg_android.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/org/androidaalto/bookingroom/view/WeekView.java
Expand Up @@ -35,6 +35,7 @@
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
Expand Down Expand Up @@ -584,6 +585,22 @@ protected void onDraw(Canvas viewCanvas) {
drawFixedAreas(viewCanvas);
}

private void copyWartermarkToCanvas(Canvas canvas) {
Bitmap watermark = BitmapFactory.decodeResource(mResources,
R.drawable.background_vg_android);
Rect src = mSrcRect;
src.top = 0;
src.left = 0;
src.bottom = watermark.getHeight();
src.right = watermark.getWidth();
Rect dst = mDestRect;
dst.top = mBitmapHeight/2 - watermark.getHeight()/2;
dst.bottom = mBitmapHeight/2 + watermark.getHeight()/2;
dst.left = mNavigationWidth;
dst.right = mViewWidth - 2 * mNavigationWidth;
canvas.drawBitmap(watermark, src, dst, null);
}

private void clearEntireView(Canvas canvas) {
Paint p = mPaint;
Rect r = mRect;
Expand Down Expand Up @@ -1167,6 +1184,7 @@ private void clearViewBackground(Rect r, Canvas canvas, Paint p) {
r.left = 0;
r.right = mViewWidth;
canvas.drawRect(r, p);
copyWartermarkToCanvas(canvas);
}

private void remeasure(int width, int height) {
Expand Down

0 comments on commit a9130d6

Please sign in to comment.