summaryrefslogtreecommitdiff
path: root/android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java
blob: e8491251af75e7caea92c5b2bbb3193276ed178f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package org.libreoffice.impressremote;

import org.libreoffice.impressremote.communication.CommunicationService;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

public class BlankScreenFragment extends Fragment {

    CommunicationService mCommunicationService;

    public BlankScreenFragment(CommunicationService aCommunicationService) {
        mCommunicationService = aCommunicationService;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                    Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.fragment_blankscreen, container,
                        false);

        Bitmap aBitmap = mCommunicationService.getSlideShow().getImage(
                        mCommunicationService.getSlideShow().getCurrentSlide());

        // Process the image
        final int borderWidth = 8;

        Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
        p.setShadowLayer(borderWidth, 0, 0, Color.BLACK);

        RectF aRect = new RectF(borderWidth, borderWidth, borderWidth
                        + aBitmap.getWidth(), borderWidth + aBitmap.getHeight());
        Bitmap aOut = Bitmap.createBitmap(aBitmap.getWidth() + 2 * borderWidth,
                        aBitmap.getHeight() + 2 * borderWidth,
                        aBitmap.getConfig());
        Canvas canvas = new Canvas(aOut);
        canvas.drawColor(Color.TRANSPARENT);
        canvas.drawRect(aRect, p);
        canvas.drawBitmap(aBitmap, null, aRect, null);

        ImageView aImage = (ImageView) v
                        .findViewById(R.id.blankscreen_slidepreview);
        aImage.setImageBitmap(aOut);

        OnClickListener aListener = new OnClickListener() {

            @Override
            public void onClick(View v) {
                getFragmentManager().popBackStackImmediate();
            }

        };

        v.findViewById(R.id.blankscreen_slidepreview).setOnClickListener(
                        aListener);
        v.findViewById(R.id.blankscreen_return).setOnClickListener(aListener);
        mCommunicationService.getTransmitter().blankScreen();
        // TODO Auto-generated method stub
        return v;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        mCommunicationService.getTransmitter().resume();
    }
}