From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / android / project / xscreensaver / src / org / jwz / xscreensaver / XScreenSaverActivity.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.Activity;
21 import android.app.WallpaperManager;
22 import android.content.ComponentName;
23 import android.content.Intent;
24 import android.os.Build;
25 import android.os.Bundle;
26 import android.view.View;
27 import android.provider.Settings;
28
29 public class XScreenSaverActivity extends Activity
30   implements View.OnClickListener {
31
32   @Override
33   protected void onCreate(Bundle savedInstanceState) {
34     super.onCreate(savedInstanceState);
35     // openList();
36     setContentView(R.layout.activity_xscreensaver);
37
38     findViewById(R.id.apply_wallpaper).setOnClickListener(this);
39     findViewById(R.id.apply_daydream).setOnClickListener(this);
40   }
41
42   @Override
43   public void onClick(View v) {
44     switch (v.getId()) {
45     case R.id.apply_wallpaper:
46       startActivity(new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER));
47       break;
48
49     case R.id.apply_daydream:
50       String action;
51       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
52         action = Settings.ACTION_DREAM_SETTINGS;
53       } else {
54         action = Settings.ACTION_DISPLAY_SETTINGS;
55       }
56       startActivity(new Intent(action));
57       break;
58     }
59   }
60 }