1209c1b7da49a2d1c4f84096ed9758641100880f
[xscreensaver] / android / xscreensaver / src / org / jwz / xscreensaver / Activity.java
1 /* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2  *
3  * xscreensaver, Copyright (c) 2016 Jamie Zawinski <jwz@jwz.org>
4  * and Dennis Sheil <dennis@panaceasupplies.com>
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation.  No representations are made about the suitability of this
11  * software for any purpose.  It is provided "as is" without express or 
12  * implied warranty.
13  *
14  * This is the XScreenSaver "application" that just brings up the
15  * Live Wallpaper preferences.
16  */
17
18 package org.jwz.xscreensaver;
19
20 import android.app.WallpaperManager;
21 import android.content.ComponentName;
22 import android.content.Intent;
23 import android.os.Build;
24 import android.os.Bundle;
25 import android.view.View;
26 import android.provider.Settings;
27
28 public class Activity extends android.app.Activity
29   implements View.OnClickListener {
30
31   @Override
32   protected void onCreate(Bundle savedInstanceState) {
33     super.onCreate(savedInstanceState);
34     // openList();
35     setContentView(R.layout.activity_xscreensaver);
36
37     findViewById(R.id.apply_wallpaper).setOnClickListener(this);
38     findViewById(R.id.apply_daydream).setOnClickListener(this);
39   }
40
41   @Override
42   public void onClick(View v) {
43     switch (v.getId()) {
44     case R.id.apply_wallpaper:
45       startActivity(new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER));
46       break;
47
48     case R.id.apply_daydream:
49       String action;
50       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
51         action = Settings.ACTION_DREAM_SETTINGS;
52       } else {
53         action = Settings.ACTION_DISPLAY_SETTINGS;
54       }
55       startActivity(new Intent(action));
56       break;
57     }
58   }
59 }