From http://www.jwz.org/xscreensaver/xscreensaver-5.35.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
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)
38       .setOnClickListener(new View.OnClickListener() {
39           @Override
40           public void onClick(View v) {
41               openList();
42           }
43       });
44
45   }
46
47   private void openList() {
48     Intent intent;
49     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
50         intent = new Intent(Settings.ACTION_DREAM_SETTINGS);
51     } else {
52         intent = new Intent(Settings.ACTION_DISPLAY_SETTINGS);
53     }
54     startActivity(intent);
55   }
56
57 }