Commit c383e05a authored by Thomas Krex's avatar Thomas Krex

versuch mit eigenem surfaceviewk

parent 7c8554e4
......@@ -2,7 +2,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
android:orientation="horizontal"
android:weightSum="3" >
<ScrollView
android:id="@+id/indexScrollView"
......@@ -18,12 +19,12 @@
<LinearLayout
android:id="@+id/surfaceContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="@android:color/black"
android:gravity="center" >
<SurfaceView
<tttclient.activities.MySurfaceView
android:id="@+id/playerView_extended"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
......
......@@ -15,8 +15,16 @@ public class MySurfaceView extends SurfaceView implements
sHolder = getHolder();
sHolder.addCallback(this);
sHolder.setFormat(PixelFormat.RGBA_4444);
}
// @Override
// protected void onLayout(boolean changed, int left, int top, int right,
// int bottom) {
// // TODO Auto-generated method stub
// super.onLayout(changed, left, top, right, bottom);
// }
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
......@@ -39,9 +47,4 @@ public class MySurfaceView extends SurfaceView implements
}
@Override
public SurfaceHolder getHolder() {
return sHolder;
}
}
......@@ -15,7 +15,6 @@ import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder.Callback;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
......@@ -38,7 +37,7 @@ import com.actionbarsherlock.widget.SearchView.OnQueryTextListener;
import de.tum.in.tttclient.R;
public class PlayerActivity extends SherlockActivity implements
MediaPlayerControl, Callback {
MediaPlayerControl {
final public static int FULLSCREEN_MODE = 0;
final public static int EXTENDED_MODE = 1;
public String fileName;
......@@ -53,7 +52,7 @@ public class PlayerActivity extends SherlockActivity implements
private MediaController audioController;
private LinearLayout container;
private SearchView searchView;
private SurfaceView surfaceView;
private MySurfaceView surfaceView;
private SurfaceHolder mHolder;
LayoutParams fullParams;
LayoutParams extendedParams;
......@@ -81,19 +80,77 @@ public class PlayerActivity extends SherlockActivity implements
audioController = new MediaController(this);
audioController.setMediaPlayer(this);
audioController.setHorizontalScrollBarEnabled(false);
dialog = new ProgressDialog(PlayerActivity.this);
dialog.setTitle("Please Wait");
dialog.setMessage("Prepare File ...");
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
scrollView = (ScrollView) findViewById(R.id.indexScrollView);
container = (LinearLayout) findViewById(R.id.surfaceContainer);
surfaceView = (SurfaceView) findViewById(R.id.playerView_extended);
surfaceView.setZOrderMediaOverlay(true);
surfaceView = (MySurfaceView) findViewById(R.id.playerView_extended);
mHolder = surfaceView.getHolder();
mHolder.addCallback(this);
scrollView = (ScrollView) findViewById(R.id.indexScrollView);
fullParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.MATCH_PARENT);
extendedParams = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
AsyncTask<Void, Void, Void> initTask = new AsyncTask<Void, Void, Void>() {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
dialog.show();
}
@Override
protected Void doInBackground(Void... params) {
try {
recording = new Recording(getApplicationContext(), tttFile,
audioPlayer, surfaceView, mHolder, scrollView);
OnClickListener prevListener = new OnClickListener() {
@Override
public void onClick(View v) {
recording.previous();
}
};
OnClickListener nextListener = new OnClickListener() {
@Override
public void onClick(View v) {
recording.next();
}
};
audioController.setPrevNextListeners(nextListener,
prevListener);
audioController.setAnchorView((LinearLayout) surfaceView
.getParent());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
dialog.dismiss();
surfaceView.setSize(
recording.getProtocolPreferences().framebufferWidth,
recording.getProtocolPreferences().framebufferHeight);
}
};
initTask.execute();
}
......@@ -222,7 +279,7 @@ public class PlayerActivity extends SherlockActivity implements
return true;
}
boolean isExtendend = false;
boolean isExtendend = true;
@Override
public boolean onOptionsItemSelected(MenuItem item) {
......@@ -263,19 +320,23 @@ public class PlayerActivity extends SherlockActivity implements
// hide ScrollView
scrollView.setVisibility(View.GONE);
surfaceView.setLayoutParams(fullParams);
// container.recomputeViewAttributes(surfaceView);
container.recomputeViewAttributes(surfaceView);
}
// extended View
if (index == 1) {
scrollView.setVisibility(View.VISIBLE);
surfaceView.setLayoutParams(extendedParams);
container.recomputeViewAttributes(surfaceView);
}
if (recording != null) {
// mHolder.setSizeFromLayout();
// mHolder.setFixedSize(
// recording.getProtocolPreferences().framebufferWidth,
// recording.getProtocolPreferences().framebufferHeight);
// if (recording.graphicsContext() != null) {
// recording.graphicsContext().setHolder(mHolder);
// }
}
// if (recording != null)
// surfaceView.getHolder().setFixedSize(
// recording.getProtocolPreferences().framebufferWidth,
// recording.getProtocolPreferences().framebufferHeight);
}
@Override
......@@ -289,95 +350,8 @@ public class PlayerActivity extends SherlockActivity implements
return surfaceView;
}
public void setSurfaceView(SurfaceView surfaceView) {
public void setSurfaceView(MySurfaceView surfaceView) {
this.surfaceView = surfaceView;
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
if (recording != null) {
holder.setFixedSize(
recording.getProtocolPreferences().framebufferWidth,
recording.getProtocolPreferences().framebufferHeight);
if (recording.graphicsContext() != null) {
recording.graphicsContext().setHolder(holder);
}
}
}
@Override
public void surfaceCreated(final SurfaceHolder holder) {
AsyncTask<Void, Void, Void> initTask = new AsyncTask<Void, Void, Void>() {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
dialog = new ProgressDialog(PlayerActivity.this);
dialog.setTitle("Please Wait");
dialog.setMessage("Prepare File ...");
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.show();
}
@Override
protected Void doInBackground(Void... params) {
try {
recording = new Recording(getApplicationContext(), tttFile,
audioPlayer, surfaceView, mHolder, scrollView);
OnClickListener prevListener = new OnClickListener() {
@Override
public void onClick(View v) {
recording.previous();
}
};
OnClickListener nextListener = new OnClickListener() {
@Override
public void onClick(View v) {
recording.next();
}
};
audioController.setPrevNextListeners(nextListener,
prevListener);
audioController.setAnchorView((LinearLayout) container
.getParent());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
dialog.dismiss();
holder.setFixedSize(
recording.getProtocolPreferences().framebufferWidth,
recording.getProtocolPreferences().framebufferHeight);
recording.graphicsContext().setHolder(holder);
holder.setKeepScreenOn(true);
}
};
initTask.execute();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub
}
}
......@@ -2,6 +2,7 @@ package tttclient.core;
import java.util.ArrayList;
import tttclient.activities.MySurfaceView;
import tttclient.messages.Annotation;
import tttclient.messages.CursorMessage;
import tttclient.messages.CursorPositionMessage;
......@@ -22,7 +23,6 @@ import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.LinearLayout;
@SuppressLint("NewApi")
......@@ -38,8 +38,8 @@ public class GraphicsContext implements MessageConsumer {
private final Handler scrollHandler;
private final BitmapContainer bitmapContainer;
private SurfaceView surfaceView;
private SurfaceHolder holder;
private MySurfaceView surfaceView;
private final SurfaceHolder holder;
private boolean refreshEnabled = false;
private final MessageProducer producer;
......@@ -65,10 +65,10 @@ public class GraphicsContext implements MessageConsumer {
}
}
public GraphicsContext(SurfaceView imgV, final SurfaceHolder holder,
public GraphicsContext(MySurfaceView imgV, final SurfaceHolder holder,
Recording record) {
setImageView(imgV);
this.setHolder(holder);
this.holder = holder;
this.producer = record;
this.recording = record;
......@@ -99,22 +99,6 @@ public class GraphicsContext implements MessageConsumer {
// paintWhiteboard();
// paintAnnotations();
// recording.highlightSearchResults(canvas);
// Thread paintThread = new Thread(new Runnable() {
//
// @Override
// public void run() {
// try {
//
paintCanvas(holder);
//
// } catch (OutOfMemoryError e) {
//
// }
//
// }
// });
// paintThread.start();
}
};
......@@ -182,14 +166,13 @@ public class GraphicsContext implements MessageConsumer {
if (canvas != null) {
canvas.drawBitmap(pixels, 0,
recording.getProtocolPreferences().framebufferWidth, 0, 0,
recording.getProtocolPreferences().framebufferWidth,
recording.getProtocolPreferences().framebufferHeight,
false, null);
if (isWhiteboardEnabled())
paintWhiteboard(canvas);
else
canvas.drawBitmap(pixels, 0,
recording.getProtocolPreferences().framebufferWidth, 0,
0, recording.getProtocolPreferences().framebufferWidth,
recording.getProtocolPreferences().framebufferHeight,
false, null);
paintAnnotations(canvas);
recording.highlightSearchResults(canvas);
......@@ -207,7 +190,7 @@ public class GraphicsContext implements MessageConsumer {
return refreshEnabled;
}
public void setImageView(SurfaceView imgV) {
public void setImageView(MySurfaceView imgV) {
this.surfaceView = imgV;
// test TODO
// imgView.setWillNotCacheDrawing(true);
......@@ -241,24 +224,21 @@ public class GraphicsContext implements MessageConsumer {
// draw Canvas on current Bitmap
public void updateView() {
if (refreshEnabled) {
android.os.Message message = viewHandler.obtainMessage(0, pixels);
message.sendToTarget();
// Thread paintThread = new Thread(new Runnable() {
//
// @Override
// public void run() {
//
// paintCanvas();
//
// }
// });
// try {
// paintThread.start();
// } catch (OutOfMemoryError e) {
//
// }
//
// }
Thread paintThread = new Thread(new Runnable() {
@Override
public void run() {
try {
paintCanvas(holder);
} catch (OutOfMemoryError e) {
}
}
});
paintThread.start();
}
}
......@@ -266,22 +246,23 @@ public class GraphicsContext implements MessageConsumer {
// set new Bitmap
public void updateView(final int[] pixel) {
if (refreshEnabled) {
android.os.Message message = viewHandler.obtainMessage(0, pixel);
message.sendToTarget();
// Thread paintThread = new Thread(new Runnable() {
//
// @Override
// public void run() {
//
// paintCanvas();
//
// }
// });
// try {
// paintThread.start();
// } catch (OutOfMemoryError e) {
//
// }
// android.os.Message message = viewHandler.obtainMessage(0, pixel);
// message.sendToTarget();
Thread paintThread = new Thread(new Runnable() {
@Override
public void run() {
try {
paintCanvas(holder);
} catch (OutOfMemoryError e) {
}
}
});
paintThread.start();
}
}
......@@ -334,7 +315,7 @@ public class GraphicsContext implements MessageConsumer {
// if recording is adjusting, messages are not painted one by one but
// only the final image
if (!recording.adjusting) {
if (refreshEnabled) {
// bitmapContainer.getBimap().setPixels(pixels,
// x + y * prefs.framebufferWidth, prefs.framebufferWidth, x,
// y, w, h);
......@@ -418,18 +399,15 @@ public class GraphicsContext implements MessageConsumer {
// show blank page if whiteboard activated
if (isWhiteboardEnabled()) {
int[] whitePixels = new int[(int) (prefs.framebufferWidth * IndexEntry.THUMBNAIL_SCALE_FACTOR)
* (int) (prefs.framebufferWidth * IndexEntry.THUMBNAIL_SCALE_FACTOR)];
int[] whitePixels = new int[prefs.framebufferWidth
* prefs.framebufferWidth];
for (int i = 0; i < whitePixels.length; i++) {
whitePixels[i] = Color.WHITE;
}
Bitmap whiteboard = Bitmap
.createBitmap(
whitePixels,
(int) (prefs.framebufferWidth * IndexEntry.THUMBNAIL_SCALE_FACTOR),
(int) (prefs.framebufferHeight * IndexEntry.THUMBNAIL_SCALE_FACTOR),
Config.ARGB_4444);
Bitmap whiteboard = Bitmap.createBitmap(whitePixels,
prefs.framebufferWidth, prefs.framebufferHeight,
Config.ARGB_4444);
return whiteboard;
} else {
......@@ -577,8 +555,4 @@ public class GraphicsContext implements MessageConsumer {
return holder;
}
public void setHolder(SurfaceHolder holder) {
this.holder = holder;
}
}
\ No newline at end of file
......@@ -33,6 +33,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.zip.InflaterInputStream;
import tttclient.activities.MySurfaceView;
import tttclient.messages.Message;
import tttclient.messages.MessageProducerAdapter;
import android.content.Context;
......@@ -44,7 +45,6 @@ import android.os.Looper;
import android.util.Log;
import android.view.Gravity;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
......@@ -84,7 +84,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
}
public Recording(Context context, File tttFile, MediaPlayer audioPlayer,
SurfaceView surface, SurfaceHolder holder, ScrollView scrollView)
MySurfaceView surface, SurfaceHolder holder, ScrollView scrollView)
throws IOException {
// read
this.context = context;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment