Commit b74b0cef authored by Thomas Krex's avatar Thomas Krex
Browse files

indexview in die Klasse index verschoben

parent 3a48ce9d
...@@ -369,7 +369,7 @@ public class FeedDetailActivity extends SherlockActivity implements ...@@ -369,7 +369,7 @@ public class FeedDetailActivity extends SherlockActivity implements
int progress = resultData.getInt("progress"); int progress = resultData.getInt("progress");
progressDialog.setMessage(progress + "% donwloaded"); progressDialog.setMessage(progress + "% downloaded");
} }
......
...@@ -65,9 +65,10 @@ public class PlayerActivity extends SherlockActivity implements ...@@ -65,9 +65,10 @@ public class PlayerActivity extends SherlockActivity implements
File audioFile = new File(filePath + "/" + fileName + ".mp3"); File audioFile = new File(filePath + "/" + fileName + ".mp3");
audioPlayer = MediaPlayer.create(this, Uri.fromFile(audioFile)); audioPlayer = MediaPlayer.create(this, Uri.fromFile(audioFile));
audioController = new MediaController(this); // creates a MediaController without fastforward and rewind buttons
audioController = new MediaController(this, false);
audioController.setMediaPlayer(this); audioController.setMediaPlayer(this);
audioController.setHorizontalScrollBarEnabled(false);
final ProgressDialog dialog = new ProgressDialog(PlayerActivity.this); final ProgressDialog dialog = new ProgressDialog(PlayerActivity.this);
dialog.setTitle("Please Wait"); dialog.setTitle("Please Wait");
dialog.setMessage("Prepare File ..."); dialog.setMessage("Prepare File ...");
...@@ -134,6 +135,7 @@ public class PlayerActivity extends SherlockActivity implements ...@@ -134,6 +135,7 @@ public class PlayerActivity extends SherlockActivity implements
} }
// delegates search to index and updates the view
public void search(String word) { public void search(String word) {
if (recording.getIndex() != null) if (recording.getIndex() != null)
recording.getIndex().search(word); recording.getIndex().search(word);
...@@ -231,28 +233,31 @@ public class PlayerActivity extends SherlockActivity implements ...@@ -231,28 +233,31 @@ public class PlayerActivity extends SherlockActivity implements
MenuInflater inflater = getSupportMenuInflater(); MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.player_menu, menu); inflater.inflate(R.menu.player_menu, menu);
MenuItem item = menu.findItem(R.id.search); MenuItem item = menu.findItem(R.id.search);
// set up search View in Actionbar
searchView = (SearchView) item.getActionView(); searchView = (SearchView) item.getActionView();
//
// for API level >14 you can hide fullscreen textfield when input is
// made
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
searchView.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN); searchView.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN);
// set up methods to react on user input
searchView.setOnQueryTextListener(new OnQueryTextListener() { searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override @Override
public boolean onQueryTextSubmit(String query) { public boolean onQueryTextSubmit(String query) {
// search(query); recording.getIndex().nextSearchResult();
// if (query.isEmpty())
// searchView.clearFocus();
// recording.getIndex().highlightSearchResultsOnThumbnails();
searchView.clearFocus(); searchView.clearFocus();
return true; return true;
} }
@Override @Override
public boolean onQueryTextChange(String newText) { public boolean onQueryTextChange(String newText) {
// search after String during the input
search(newText); search(newText);
recording.getIndex().highlightSearchResultsOnThumbnails(); // update thumbnail to mark new search results
recording.getIndex().updateThumbnails();
return true; return true;
} }
}); });
...@@ -266,11 +271,10 @@ public class PlayerActivity extends SherlockActivity implements ...@@ -266,11 +271,10 @@ public class PlayerActivity extends SherlockActivity implements
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection // Handle item selection
switch (item.getItemId()) { switch (item.getItemId()) {
// handle layout switch
case R.id.extend: case R.id.extend:
if (!isExtendend) { if (!isExtendend) {
switchLayout(1); switchLayout(1);
// switchSurface(1);
item.setIcon(getResources().getDrawable( item.setIcon(getResources().getDrawable(
R.drawable.ic_action_full_screen)); R.drawable.ic_action_full_screen));
isExtendend = true; isExtendend = true;
...@@ -284,6 +288,7 @@ public class PlayerActivity extends SherlockActivity implements ...@@ -284,6 +288,7 @@ public class PlayerActivity extends SherlockActivity implements
} }
return true; return true;
// go to next search result
case R.id.next: case R.id.next:
if (!searchView.getQuery().toString().isEmpty()) if (!searchView.getQuery().toString().isEmpty())
Log.d("Player", "next invoked"); Log.d("Player", "next invoked");
......
...@@ -3,8 +3,6 @@ package tttclient.core; ...@@ -3,8 +3,6 @@ package tttclient.core;
import java.util.ArrayList; import java.util.ArrayList;
import tttclient.messages.Annotation; import tttclient.messages.Annotation;
import tttclient.messages.CursorMessage;
import tttclient.messages.CursorPositionMessage;
import tttclient.messages.Message; import tttclient.messages.Message;
import tttclient.messages.MessageConsumer; import tttclient.messages.MessageConsumer;
import tttclient.messages.MessageProducer; import tttclient.messages.MessageProducer;
...@@ -17,23 +15,15 @@ import android.graphics.Canvas; ...@@ -17,23 +15,15 @@ import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Rect; import android.graphics.Rect;
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.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
@SuppressLint("NewApi") @SuppressLint("NewApi")
public class GraphicsContext implements MessageConsumer { public class GraphicsContext implements MessageConsumer {
static float SCALE_X_FULLSCREEN;
static float SCALE_Y_FULLSCREEN;
static float SCALE_X_EXTENDED;
static float SCALE_Y_EXTENDED;
private final Handler viewHandler; private final Handler viewHandler;
private final Handler scrollHandler;
private final BitmapContainer bitmapContainer; private final BitmapContainer bitmapContainer;
private ImageView imgView; private ImageView imgView;
...@@ -73,15 +63,12 @@ public class GraphicsContext implements MessageConsumer { ...@@ -73,15 +63,12 @@ public class GraphicsContext implements MessageConsumer {
prefs.framebufferWidth, prefs.framebufferHeight, prefs.framebufferWidth, prefs.framebufferHeight,
Config.ARGB_4444)); Config.ARGB_4444));
// canvas to Bitmap
this.pixels = bitmapContainer.getPixels(); this.pixels = bitmapContainer.getPixels();
hextile_bg_encoded = new byte[prefs.bytesPerPixel]; hextile_bg_encoded = new byte[prefs.bytesPerPixel];
hextile_fg_encoded = new byte[prefs.bytesPerPixel]; hextile_fg_encoded = new byte[prefs.bytesPerPixel];
// hanlder do tasks, which has to be done in the UI-Thread // Handler for Updating the ImageView
// Updating of ImageView
viewHandler = new Handler(Looper.getMainLooper()) { viewHandler = new Handler(Looper.getMainLooper()) {
@Override @Override
public void handleMessage(android.os.Message inputMessage) { public void handleMessage(android.os.Message inputMessage) {
...@@ -92,47 +79,9 @@ public class GraphicsContext implements MessageConsumer { ...@@ -92,47 +79,9 @@ public class GraphicsContext implements MessageConsumer {
} }
}; };
// Updating of ScrollView
scrollHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(android.os.Message inputMessage) {
// Gets the image task from the incoming Message object.
int indexNumber = inputMessage.arg1;
int color = inputMessage.arg2;
IndexEntry entry = recording.getIndex().get(indexNumber - 1);
entry.setBackgroundColor(color);
LinearLayout parent = (LinearLayout) entry.getParent();
recording.getIndexViewer().scrollTo(0,
parent.getTop() - parent.getHeight() / 2);
}
};
} }
// public static void borderRect(int[] array, Rect r, int color,
// int screenWidth) {
// int x = r.left;
// int y = r.top;
// int w = r.width();
// int h = r.height();
//
// for (int i = y; i < y + h; i++) {
// int offset = i * screenWidth + x;
// if (i == y || i == y + h - 1) {
// for (int j = 0; j < w; j++) {
//
// array[offset + j] = color;
// }
// } else {
// for (int j = 0; j < w; j++) {
// if (j == 0 || j == w - 1)
// array[offset + j] = color;
// }
//
// }
// }
// }
public void enableRefresh(boolean refresh) { public void enableRefresh(boolean refresh) {
this.refreshEnabled = refresh; this.refreshEnabled = refresh;
} }
...@@ -167,18 +116,10 @@ public class GraphicsContext implements MessageConsumer { ...@@ -167,18 +116,10 @@ public class GraphicsContext implements MessageConsumer {
return hextile_fg_encoded; return hextile_fg_encoded;
} }
public Handler getScrollHandler() { // painting is done here
return this.scrollHandler;
}
// TODO welche Methoden werden wann ben??tigt
// draw Canvas on current Bitmap
public void updateView() { public void updateView() {
if (refreshEnabled) { if (refreshEnabled) {
// Thread paintThread = new Thread(new Runnable() {
//
// @Override
// public void run() {
Bitmap bitmap = bitmapContainer.getBitmap(); Bitmap bitmap = bitmapContainer.getBitmap();
Canvas canvas = new Canvas(bitmap); Canvas canvas = new Canvas(bitmap);
...@@ -189,18 +130,6 @@ public class GraphicsContext implements MessageConsumer { ...@@ -189,18 +130,6 @@ public class GraphicsContext implements MessageConsumer {
android.os.Message message = viewHandler.obtainMessage(0, bitmap); android.os.Message message = viewHandler.obtainMessage(0, bitmap);
message.sendToTarget(); message.sendToTarget();
// }
// });
// paintThread.start();
}
}
// set new Bitmap
public void updateView(final Bitmap bitmap) {
if (refreshEnabled) {
android.os.Message message = viewHandler.obtainMessage(0, bitmap);
message.sendToTarget();
} }
} }
...@@ -222,34 +151,7 @@ public class GraphicsContext implements MessageConsumer { ...@@ -222,34 +151,7 @@ public class GraphicsContext implements MessageConsumer {
} }
// // used by hextile message
// public int decodeColor(byte[] colorField) {
// int color = 0;
// for (int i = 0, shift = 0; i < prefs.bytesPerPixel; i++, shift += 8) {
// color += (colorField[i] & 0xFF) << shift;
// }
//
// switch (prefs.bitsPerPixel) {
// case 16:
// if (prefs.bigEndian)
// // 16 bit big endian: swap bytes
// color = (color & 0xFF) << 8 | ((color & 0xFF00) >> 8);
// // case 8:
// // // use color table
// // return colors[color];
// // default:
// // // use default color
// // if (prefs.bigEndian) {
// // // 24 bit big endian: swap bytes
// // color = (color & 0xFF) << 24 | (color >> 8 & 0xFF) << 16
// // | (color >> 16 & 0xFF) << 8 | color >> 24 & 0xFF;
// // }
// // return new Color(color);
//
// }
// return color;
// }
public void setForeground(byte[] color, int offset) { public void setForeground(byte[] color, int offset) {
System.arraycopy(color, offset, hextile_fg_encoded, 0, System.arraycopy(color, offset, hextile_fg_encoded, 0,
prefs.bytesPerPixel); prefs.bytesPerPixel);
...@@ -275,9 +177,6 @@ public class GraphicsContext implements MessageConsumer { ...@@ -275,9 +177,6 @@ public class GraphicsContext implements MessageConsumer {
// if recording is adjusting, messages are not painted one by one but // if recording is adjusting, messages are not painted one by one but
// only the final image // only the final image
if (!recording.adjusting) { if (!recording.adjusting) {
// bitmapContainer.getCurBitmap().setPixels(pixels,
// x + y * prefs.framebufferWidth, prefs.framebufferWidth, x,
// y, w, h);
updateView(); updateView();
} }
...@@ -353,31 +252,23 @@ public class GraphicsContext implements MessageConsumer { ...@@ -353,31 +252,23 @@ public class GraphicsContext implements MessageConsumer {
} }
public Bitmap getScreenshotWithoutAnnotations() { public Bitmap createScreenshotWithoutAnnotations() {
// create new mutable bitmap // create new mutable bitmap
Bitmap screenshot = Bitmap.createBitmap(prefs.framebufferWidth, Bitmap screenshot = Bitmap.createBitmap(prefs.framebufferWidth,
prefs.framebufferHeight, Config.ARGB_4444); prefs.framebufferHeight, Config.ARGB_4444);
// show blank page if whiteboard activated // show blank page if whiteboard activated
if (isWhiteboardEnabled()) { if (isWhiteboardEnabled()) {
Log.d("Screenshot", "WhiteBoard enabled");
Canvas canvas = new Canvas(screenshot); Canvas canvas = new Canvas(screenshot);
canvas.drawColor(Color.WHITE); paintWhiteboard(canvas);
} else } else {
screenshot.setPixels(pixels, 0, prefs.framebufferWidth, 0, 0, screenshot.setPixels(pixels, 0, prefs.framebufferWidth, 0, 0,
prefs.framebufferWidth, prefs.framebufferHeight); prefs.framebufferWidth, prefs.framebufferHeight);
// Bitmap scaledScreenshot = Bitmap }
// .createScaledBitmap(
// screenshot,
// (int) (prefs.framebufferWidth *
// IndexEntry.THUMBNAIL_SCALE_FACTOR),
// (int) (prefs.framebufferHeight *
// IndexEntry.THUMBNAIL_SCALE_FACTOR),
// false);
// screenshot.recycle();
// System.gc();
return screenshot; return screenshot;
} }
...@@ -405,18 +296,9 @@ public class GraphicsContext implements MessageConsumer { ...@@ -405,18 +296,9 @@ public class GraphicsContext implements MessageConsumer {
return new WhiteboardMessage(0, whiteboardPage, prefs); return new WhiteboardMessage(0, whiteboardPage, prefs);
} }
// fill the canvas with white color and set the page number
public void paintWhiteboard(Canvas canvas) { public void paintWhiteboard(Canvas canvas) {
// int[] whitePixel = new int[prefs.framebufferHeight
// * prefs.framebufferWidth];
// for (int i = 0; i < whitePixel.length; i++) {
// whitePixel[i] = Color.WHITE;
// }
//
// bitmapContainer.getBimap().setPixels(whitePixel, 0,
// prefs.framebufferWidth, 0, 0, prefs.framebufferWidth,
// prefs.framebufferHeight);
canvas.drawColor(Color.WHITE); canvas.drawColor(Color.WHITE);
Paint p = new Paint(Color.BLACK); Paint p = new Paint(Color.BLACK);
...@@ -426,92 +308,4 @@ public class GraphicsContext implements MessageConsumer { ...@@ -426,92 +308,4 @@ public class GraphicsContext implements MessageConsumer {
} }
// ////////////////////////////////////////////////////////////////
// Cursor
// ////////////////////////////////////////////////////////////////
private boolean showSoftCursor;
public int[] softCursorPixels;
public Image softCursor;
public Bitmap softCursorSource;
public int cursorX, cursorY;
public int cursorWidth, cursorHeight;
public int hotX, hotY;
// Remove soft cursor, dispose resources.
// Moves soft cursor into a particular location.
synchronized public void softCursorMove(int x, int y) {
if (showSoftCursor) {
int old_cursorX = cursorX;
int old_cursorY = cursorY;
// set new position
cursorX = x;
cursorY = y;
// clear old and paint new cursor
// refresh(old_cursorX - hotX, old_cursorY - hotY, cursorWidth,
// cursorHeight);
// refresh(x - hotX, y - hotY, cursorWidth, cursorHeight);
updateView();
} else {
// just set new position
cursorX = x;
cursorY = y;
}
}
// Remove soft cursor, dispose resources.
synchronized public void softCursorFree() {
if (showSoftCursor) {
showSoftCursor = false;
softCursor = null;
softCursorSource = null;
softCursorPixels = null;
// refresh(cursorX - hotX, cursorY - hotY, cursorWidth,
// cursorHeight);
updateView();
}
}
public void showSoftCursor(boolean show) {
if (show) {
// show soft cursor (if available)
if (softCursor != null) {
showSoftCursor = true;
// refresh(cursorX - hotX, cursorY - hotY, cursorWidth,
// cursorHeight);
updateView();
;
}
} else {
// disable soft cursor
if (showSoftCursor) {
showSoftCursor = false;
// refresh(cursorX - hotX, cursorY - hotY, cursorWidth,
// cursorHeight);
updateView();
}
}
}
// updates for late comers and recorders
public Message getCurrentCursorPositionMessage() {
return new CursorPositionMessage(0, cursorX, cursorY);
}
// updates for late comers and recorders
private CursorMessage bufferedCursorMessage;
public void setCurrentCursorMessage(CursorMessage cursorMessage) {
bufferedCursorMessage = cursorMessage;
}
public Message getCurrentCursorMessage() {
return bufferedCursorMessage;
}
} }
\ No newline at end of file
...@@ -36,8 +36,17 @@ import tttclient.messages.WhiteboardMessage; ...@@ -36,8 +36,17 @@ import tttclient.messages.WhiteboardMessage;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Handler;
import android.os.Looper;
import android.util.Log; import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
public class Index { public class Index {
...@@ -54,6 +63,8 @@ public class Index { ...@@ -54,6 +63,8 @@ public class Index {
private Recording recording; private Recording recording;
private final Context context; private final Context context;
private final ScrollView indexViewer;
private final Handler scrollHandler;
int getWidth() { int getWidth() {
return recording.getProtocolPreferences().framebufferWidth; return recording.getProtocolPreferences().framebufferWidth;
...@@ -63,14 +74,26 @@ public class Index { ...@@ -63,14 +74,26 @@ public class Index {
return recording; return recording;
} }
public Index(Recording recording, Context context) {