• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.dreams.bummer;
18 
19 import android.graphics.Color;
20 import android.service.dreams.Dream;
21 import android.view.View;
22 import android.view.ViewGroup;
23 import android.widget.FrameLayout;
24 
25 public class Bummer extends Dream {
26     public static final int MOVE = 1;
27 
28     public static final int DELAY = 1000; // ms
29 
30     public String message = "Bummer!";
31     public int color = Color.WHITE;
32     public float size = 20.0f;
33 
34     private FrameLayout mFrame;
35     private BummerView mApology;
36 
37     @Override
onStart()38     public void onStart() {
39         mFrame = new FrameLayout(this);
40         mFrame.setLayoutParams(new ViewGroup.LayoutParams(
41                 ViewGroup.LayoutParams.MATCH_PARENT,
42                 ViewGroup.LayoutParams.MATCH_PARENT
43                 ));
44 
45         mApology = new BummerView(this);
46         mApology.setText(message);
47         mApology.setTextColor(color);
48         mApology.setTextSize(size);
49         mApology.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.stat_sys_warning, 0, 0,
50                 0);
51         mApology.setCompoundDrawablePadding(8);
52         mApology.setAlpha(0.5f);
53 
54         final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
55                 ViewGroup.LayoutParams.WRAP_CONTENT,
56                 ViewGroup.LayoutParams.WRAP_CONTENT
57                 );
58         mApology.setVisibility(View.INVISIBLE);
59         mFrame.addView(mApology, lp);
60 
61         setContentView(mFrame);
62     }
63 
64 }
65