-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathLibVisual.java
More file actions
285 lines (226 loc) · 8.14 KB
/
LibVisual.java
File metadata and controls
285 lines (226 loc) · 8.14 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/* Libvisual - The audio visualisation framework.
*
* Copyright (C) 2004-2006 Dennis Smit <ds@nerds-incorporated.org>
* Copyright (C) 2012 Daniel Hiepler <daniel-lva@niftylight.de>
*
* Authors: Dennis Smit <ds@nerds-incorporated.org>
* Daniel Hiepler <daniel-lva@niftylight.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.libvisual.android;
import android.app.Activity;
import android.os.Bundle;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Window;
import android.widget.TextView;
/**
* @todo
* mic input
* scaling
* actor/input/morph classes
* GL View
*/
public class LibVisual extends Activity
{
public static VisActor curActor;
public static VisInput curInput;
public static VisMorph curMorph;
public static VisBin curBin;
private final static String TAG = "LibVisual";
private LibVisualSettings s;
private LibVisualView v;
private String defaultDoMorph;
private String defaultMorph;
private String defaultActor;
private String defaultInput;
private Boolean doMorph;
/* implementend by liblvclient.so */
private static native boolean init();
private static native void deinit();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle state)
{
super.onCreate(state);
/* hide titlebar */
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
/* create new settings-object */
s = new LibVisualSettings(this);
/* initialize libvisual */
init();
/* do morph when changing actors? */
defaultDoMorph = getString(R.string.default_do_morph);
doMorph = s.getBoolean("prefs_do_morph", (defaultDoMorph == "true" ?
true :
false));
/* morph plugin */
defaultMorph = getString(R.string.default_plugin_morph);
String prefMorph = s.getString("prefs_morph", defaultMorph);
curMorph = new VisMorph(prefMorph);
/* input plugin */
defaultInput = getString(R.string.default_plugin_input);
String prefInput = s.getString("prefs_input", defaultInput);
curInput = new VisInput(prefInput);
/* actor plugin */
defaultActor = getString(R.string.default_plugin_actor);
String prefActor = s.getString("prefs_actor", defaultActor);
curActor = new VisActor(prefActor);
/* create bin */
curBin = new VisBin();
/* set depth of bin */
curBin.setSupportedDepth(VisVideo.VISUAL_VIDEO_DEPTH_ALL);
curBin.setPreferredDepth(VisVideo.VISUAL_VIDEO_DEPTH_32BIT);
/* create new LibVisualBitmapView */
v = new LibVisualBitmapView(this);
/* set our LibVisualBitmapView as contentView */
setContentView(v);
}
/** called by OS when this activity becomes active again */
@Override
public void onResume()
{
super.onResume();
Log.i(TAG, "onResume()");
/* screen dimming */
v.setScreenDimming();
/* do-morph */
doMorph = s.getBoolean("prefs_do_morph", (defaultDoMorph == "true" ?
true :
false));
/* morph changed? */
String newMorphName = s.getString("prefs_morph", defaultMorph);
if(!curMorph.plugin.getPlugname().equals(newMorphName))
{
Log.i(TAG, "Changing morph (\""+curMorph.plugin.getPlugname()+"\" -> \""+newMorphName+"\")");
curBin.setMorph(newMorphName);
curMorph = curBin.getMorph();
}
/* actor changed? */
String newActorName = s.getString("prefs_actor", defaultActor);
if(!curActor.plugin.getPlugname().equals(newActorName))
{
Log.i(TAG, "Changing actor (\""+curActor.plugin.getPlugname()+"\" -> \""+newActorName+"\")");
/* do morph? */
if(doMorph)
{
/* enable morph */
}
else
{
/* disable morph */
}
/* switch actor */
curBin.switchActor(newActorName);
/* get new actor */
curActor = curBin.getActor();
}
/* input changed? */
}
/** orientation changed */
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
}
/** options menu */
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.libvisual, menu);
return true;
}
/** item from options menu selected */
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
/* About App */
case R.id.about_libvisual_android:
{
startActivity(new Intent(this, LibVisualAboutApp.class));
return true;
}
/* About Lib */
case R.id.about_libvisual:
{
startActivity(new Intent(this, LibVisualAboutLib.class));
return true;
}
/* About actor */
case R.id.about_actor:
{
startActivity(new Intent(this, LibVisualAboutActor.class));
return true;
}
/* About input */
case R.id.about_input:
{
startActivity(new Intent(this, LibVisualAboutInput.class));
return true;
}
/* About morph */
case R.id.about_morph:
{
startActivity(new Intent(this, LibVisualAboutMorph.class));
return true;
}
/* Preferences */
case R.id.settings:
{
startActivity(new Intent(this, LibVisualPreferences.class));
return true;
}
/* wtf? */
default:
{
Log.w(TAG, "Unhandled menu-item. This is a bug!");
break;
}
}
return false;
}
/* called when activity is destroyed */
@Override
public void onDestroy()
{
/* deinitialize libvisual */
deinit();
super.onDestroy();
}
/* load our native library */
static
{
try
{
System.loadLibrary("gnustl_shared");
System.loadLibrary("visual");
System.loadLibrary("lvclient");
}
catch(UnsatisfiedLinkError e)
{
Log.e(TAG, "Error while loading shared library: "+e.getMessage());
e.printStackTrace();
}
}
}