Commit 00b9fb47 authored by Thomas Krex's avatar Thomas Krex
Browse files

scrollview scrollt zum aktuellen index entry

-trick ist die position des parent abzufragen
parent 5c8642b3
...@@ -95,8 +95,7 @@ public class PlayerActivity extends Activity implements MediaPlayerControl { ...@@ -95,8 +95,7 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {
try { try {
recording = new Recording(getApplicationContext(), tttFile, recording = new Recording(getApplicationContext(), tttFile,
audioPlayer, imgV, surfaceView, scrollView, audioPlayer, imgV, scrollView);
screenWidth, screenHeight);
OnClickListener prevListener = new OnClickListener() { OnClickListener prevListener = new OnClickListener() {
...@@ -307,21 +306,21 @@ public class PlayerActivity extends Activity implements MediaPlayerControl { ...@@ -307,21 +306,21 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
} }
void switchSurface(int index) { // void switchSurface(int index) {
if (index == 0) { // if (index == 0) {
surfaceView.setVisibility(View.INVISIBLE); // surfaceView.setVisibility(View.INVISIBLE);
surfaceView = (SurfaceView) findViewById(R.id.playerView_fullscreen); // surfaceView = (SurfaceView) findViewById(R.id.playerView_fullscreen);
recording.graphicsContext().setSurfaceView(surfaceView); // recording.graphicsContext().setSurfaceView(surfaceView);
// recording.focusCurrentIndexEntry(recording.getLastIndexFired() - // // recording.focusCurrentIndexEntry(recording.getLastIndexFired() -
// 1); // // 1);
switcher.setDisplayedChild(0); // switcher.setDisplayedChild(0);
} // }
if (index == 1) { // if (index == 1) {
surfaceView.setVisibility(View.INVISIBLE); // surfaceView.setVisibility(View.INVISIBLE);
surfaceView = (SurfaceView) findViewById(R.id.playerView_extended); // surfaceView = (SurfaceView) findViewById(R.id.playerView_extended);
recording.graphicsContext().setSurfaceView(surfaceView); // recording.graphicsContext().setSurfaceView(surfaceView);
recording.graphicsContext().updateOverlay(); // recording.graphicsContext().updateOverlay();
} // }
} // }
} }
...@@ -20,9 +20,8 @@ import android.media.Image; ...@@ -20,9 +20,8 @@ import android.media.Image;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log; import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
@SuppressLint("NewApi") @SuppressLint("NewApi")
public class GraphicsContext implements MessageConsumer { public class GraphicsContext implements MessageConsumer {
...@@ -39,16 +38,12 @@ public class GraphicsContext implements MessageConsumer { ...@@ -39,16 +38,12 @@ public class GraphicsContext implements MessageConsumer {
private final BitmapContainer bitmapContainer; private final BitmapContainer bitmapContainer;
private final Canvas canvas; private final Canvas canvas;
private ImageView imgView; private ImageView imgView;
private SurfaceView overlay;
private SurfaceHolder sHolder;
private boolean refreshEnabled = false; private boolean refreshEnabled = false;
private final MessageProducer producer; private final MessageProducer producer;
private final ProtocolPreferences prefs; private final ProtocolPreferences prefs;
private final Recording recording; private final Recording recording;
private final double scaleFactorX;
private final double scaleFactorY;
private final int screenWidth;
private final int screenHeight;
private final byte[] hextile_bg_encoded; private final byte[] hextile_bg_encoded;
private final byte[] hextile_fg_encoded; private final byte[] hextile_fg_encoded;
private final int[] pixels; private final int[] pixels;
...@@ -57,25 +52,13 @@ public class GraphicsContext implements MessageConsumer { ...@@ -57,25 +52,13 @@ public class GraphicsContext implements MessageConsumer {
return recording; return recording;
} }
public GraphicsContext(ImageView imgV, SurfaceView surfaceView, public GraphicsContext(ImageView imgV, Recording record) {
Recording record, int width, int height) {
setImageView(imgV); setImageView(imgV);
this.producer = record; this.producer = record;
this.recording = record; this.recording = record;
producer.addMessageConsumer(this); producer.addMessageConsumer(this);
this.prefs = record.getProtocolPreferences(); this.prefs = record.getProtocolPreferences();
// // init SurfaceView
// setSurfaceView(surfaceView);
//
// compute scale factor
this.screenWidth = width;
this.screenHeight = height;
scaleFactorX = width / prefs.framebufferWidth;
scaleFactorY = height / prefs.framebufferHeight;
this.bitmapContainer = new BitmapContainer(Bitmap.createBitmap( this.bitmapContainer = new BitmapContainer(Bitmap.createBitmap(
prefs.framebufferWidth, prefs.framebufferHeight, prefs.framebufferWidth, prefs.framebufferHeight,
Config.ARGB_8888)); Config.ARGB_8888));
...@@ -96,9 +79,6 @@ public class GraphicsContext implements MessageConsumer { ...@@ -96,9 +79,6 @@ public class GraphicsContext implements MessageConsumer {
// Gets the image task from the incoming Message object. // Gets the image task from the incoming Message object.
Bitmap bitmap = (Bitmap) inputMessage.obj; Bitmap bitmap = (Bitmap) inputMessage.obj;
// TODO
// updateOverlay();
paintAnnotations(canvas); paintAnnotations(canvas);
recording.highlightSearchResults(canvas); recording.highlightSearchResults(canvas);
...@@ -113,19 +93,23 @@ public class GraphicsContext implements MessageConsumer { ...@@ -113,19 +93,23 @@ public class GraphicsContext implements MessageConsumer {
// Gets the image task from the incoming Message object. // Gets the image task from the incoming Message object.
int indexNumber = inputMessage.arg1; int indexNumber = inputMessage.arg1;
int color = inputMessage.arg2; int color = inputMessage.arg2;
recording.getIndex().get(indexNumber - 1) IndexEntry entry = recording.getIndex().get(indexNumber - 1);
.setBackgroundColor(color); entry.setBackgroundColor(color);
LinearLayout parent = (LinearLayout) entry.getParent();
recording.getIndexViewer().scrollTo(0,
parent.getTop() - parent.getHeight() / 2);
} }
}; };
} }
public void setSurfaceView(SurfaceView surfaceView) { // public void setSurfaceView(SurfaceView surfaceView) {
this.overlay = surfaceView; // this.overlay = surfaceView;
overlay.setZOrderOnTop(true); // overlay.setZOrderOnTop(true);
sHolder = overlay.getHolder(); // sHolder = overlay.getHolder();
sHolder.setFixedSize(prefs.framebufferWidth, prefs.framebufferHeight); // sHolder.setFixedSize(prefs.framebufferWidth, prefs.framebufferHeight);
//
} // }
public static void fillRect(int[] array, Rect r, int color, int screenWidth) { public static void fillRect(int[] array, Rect r, int color, int screenWidth) {
int x = r.left; int x = r.left;
...@@ -166,17 +150,17 @@ public class GraphicsContext implements MessageConsumer { ...@@ -166,17 +150,17 @@ public class GraphicsContext implements MessageConsumer {
} }
} }
public void updateOverlay() { // public void updateOverlay() {
//
Canvas canvas = sHolder.lockCanvas(); // Canvas canvas = sHolder.lockCanvas();
if (canvas != null) { // if (canvas != null) {
canvas.drawBitmap(bitmapContainer.getBimap(), 0, 0, null); // canvas.drawBitmap(bitmapContainer.getBimap(), 0, 0, null);
paintAnnotations(canvas); // paintAnnotations(canvas);
recording.highlightSearchResults(canvas); // recording.highlightSearchResults(canvas);
sHolder.unlockCanvasAndPost(canvas); // sHolder.unlockCanvasAndPost(canvas);
} // }
//
} // }
public void enableRefresh(boolean refresh) { public void enableRefresh(boolean refresh) {
this.refreshEnabled = refresh; this.refreshEnabled = refresh;
......
...@@ -43,7 +43,6 @@ import android.graphics.Color; ...@@ -43,7 +43,6 @@ import android.graphics.Color;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.util.Log; import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.SurfaceView;
import android.view.View; import android.view.View;
import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView; import android.widget.ImageView;
...@@ -60,7 +59,7 @@ public class Recording extends MessageProducerAdapter implements Runnable { ...@@ -60,7 +59,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
private final Index index; private final Index index;
private final Context context; private final Context context;
private ScrollView indexViewer; private final ScrollView indexViewer;
private File tttFile; private File tttFile;
public Messages getMessages() { public Messages getMessages() {
...@@ -84,8 +83,7 @@ public class Recording extends MessageProducerAdapter implements Runnable { ...@@ -84,8 +83,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
} }
public Recording(Context context, File tttFile, MediaPlayer audioPlayer, public Recording(Context context, File tttFile, MediaPlayer audioPlayer,
ImageView imgV, SurfaceView surfaceView, ScrollView scrollView, ImageView imgV, ScrollView scrollView) throws IOException {
int screenWidth, int screenHeight) throws IOException {
// read // read
this.context = context; this.context = context;
this.indexViewer = scrollView; this.indexViewer = scrollView;
...@@ -98,8 +96,7 @@ public class Recording extends MessageProducerAdapter implements Runnable { ...@@ -98,8 +96,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// read messages + extensions // read messages + extensions
read(tttFile); read(tttFile);
graphicsContext = new GraphicsContext(imgV, surfaceView, this, graphicsContext = new GraphicsContext(imgV, this);
screenWidth, screenHeight);
if (!index.isValid()) if (!index.isValid())
index.computeIndex(); index.computeIndex();
...@@ -113,26 +110,25 @@ public class Recording extends MessageProducerAdapter implements Runnable { ...@@ -113,26 +110,25 @@ public class Recording extends MessageProducerAdapter implements Runnable {
int audio_duration = audioPlayer.getDuration(); int audio_duration = audioPlayer.getDuration();
int max_duration = Math.max(audio_duration, desktop_duration); int max_duration = Math.max(audio_duration, desktop_duration);
// int desktop_diff = desktop_duration - max_duration;
// int audio_diff = audio_duration - max_duration;
// calculate replay factor for badly synced audio recordings (audio
// too short)
desktop_replay_factor = 1; desktop_replay_factor = 1;
if (audio_duration > 0) { if (audio_duration > 0) {
desktop_replay_factor = (double) audio_duration / max_duration; desktop_replay_factor = (double) audio_duration / max_duration;
// audioPlayer.set(1 / desktop_replay_factor);
} }
// messages.checkDuration(audioPlayer.getDuration());
} }
graphicsContext.enableRefresh(true); graphicsContext.enableRefresh(true);
setTime(0, true); setTime(0, true);
} }
public void setIndexViewer(ScrollView scrollView) { // public void setIndexViewer(ScrollView scrollView) {
this.indexViewer = scrollView; // this.indexViewer = scrollView;
// }
public ScrollView getIndexViewer() {
return indexViewer;
} }
void read(File file) throws IOException { void read(File file) throws IOException {
......
Supports Markdown
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