Commit 60096c4b authored by Thomas Krex's avatar Thomas Krex
Browse files

actiobar sherlock hinzugefügt -> kompatibel zu android 2.3.3

parent be157c0e
......@@ -5,8 +5,7 @@ import java.io.IOException;
import tttclient.services.DownloadService;
import tttclient.ttt.Recording;
import android.annotation.TargetApi;
import android.app.Activity;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.media.MediaPlayer;
import android.net.Uri;
......@@ -14,22 +13,27 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.MediaController.MediaPlayerControl;
import android.widget.ScrollView;
import android.widget.SearchView;
import android.widget.SearchView.OnQueryTextListener;
import android.widget.ViewSwitcher;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.widget.SearchView;
import com.actionbarsherlock.widget.SearchView.OnQueryTextListener;
import de.tum.in.tttclient.R;
public class PlayerActivity extends Activity implements MediaPlayerControl {
public class PlayerActivity extends SherlockActivity implements
MediaPlayerControl {
public String fileName;
public String filePath;
......@@ -41,11 +45,11 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
private MediaController audioController;
private SearchView searchView;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player_main);
scrollView = (ScrollView) findViewById(R.id.indexScrollView);
switcher = (ViewSwitcher) findViewById(R.id.viewSwitcher);
......@@ -217,13 +221,17 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
audioPlayer.release();
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressLint("NewApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.player_menu, menu);
MenuItem item = menu.findItem(R.id.search);
searchView = (SearchView) item.getActionView();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
searchView.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN
| EditorInfo.IME_ACTION_NEXT);
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
......@@ -235,7 +243,7 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
@Override
public boolean onQueryTextChange(String newText) {
// search(newText);
search(newText);
return true;
}
});
......
......@@ -27,8 +27,8 @@ package tttclient.messages.annotations;
import java.io.DataInputStream;
import java.io.IOException;
import tttclient.shapes.StrokedPath;
import tttclient.ttt.Constants;
import tttclient.ttt.StrokedPath;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
......
......@@ -27,8 +27,8 @@ package tttclient.messages.annotations;
import java.io.DataInputStream;
import java.io.IOException;
import tttclient.shapes.StrokedRect;
import tttclient.ttt.Constants;
import tttclient.ttt.StrokedRect;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
......
......@@ -113,9 +113,6 @@ public class FeedItemDbManager {
c.close();
}
// c = db.rawQuery("SELECT last_insert_rowid()", null);
// c.moveToNext();
}
public void deleteTable() {
......
......@@ -103,7 +103,6 @@ public class ParseService extends IntentService {
@Override
public void start(Attributes attributes) {
feedItem.setLength(attributes.getValue(LENGTH));
Log.d("Parser", "length: " + attributes.getValue(LENGTH));
}
});
......
......@@ -22,14 +22,14 @@
*
* Author: Peter Ziewer, TU Munich, Germany - ziewer@in.tum.de
*/
package tttclient.ttt;
package tttclient.shapes;
import android.graphics.RectF;
public class ColoredShape {
int color;
RectF rectangle;
boolean filled;
public int color;
public RectF rectangle;
public boolean filled;
public ColoredShape(int color, RectF rectangle, boolean filled) {
this.color = color;
......
package tttclient.ttt;
package tttclient.shapes;
import android.graphics.Canvas;
import android.graphics.Paint.Cap;
......
package tttclient.ttt;
package tttclient.shapes;
import android.graphics.Canvas;
import android.graphics.Paint.Cap;
......
package tttclient.ttt;
package tttclient.shapes;
import android.graphics.Paint;
import android.graphics.Paint.Cap;
......
......@@ -440,7 +440,7 @@ public class Index {
* @return
* @throws IOException
*/
final public static double THUMBNAIL_SCALE_FACTOR = 0.3;
final public static double THUMBNAIL_SCALE_FACTOR = 0.25;
public boolean createScreenshots() throws IOException {
......@@ -695,9 +695,22 @@ public class Index {
if (index.get(i).contains(searchword))
search_index.add(index.get(i));
Log.d("search", "number of hits: " + search_index.size());
highlightSearchResultsOnThumbnails();
// force repaint to highlight results
}
public void nextSearchResult() {
int time = recording.getTime();
for (int i = 0; i < search_index.size(); i++) {
// found - set player to index with next search result
if (search_index.get(i).getTimestamp() > time) {
recording.setTime(search_index.get(i).getTimestamp(), true);
break;
}
// reached end of recording - start from beginning
if (i == search_index.size() - 1)
recording.setTime(search_index.get(0).getTimestamp(), true);
}
}
......
......@@ -6,6 +6,7 @@ import java.util.ArrayList;
import tttclient.messages.annotations.Annotation;
import tttclient.messages.annotations.HighlightAnnotation;
import tttclient.shapes.ColoredShape;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
......
......@@ -22,17 +22,21 @@
*
* Author: Peter Ziewer, TU Munich, Germany - ziewer@in.tum.de
*/
package tttclient.messages;
package tttclient.ttt;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.util.ArrayList;
import tttclient.messages.CursorMessage;
import tttclient.messages.CursorPositionMessage;
import tttclient.messages.FramebufferUpdateMessage;
import tttclient.messages.HextileMessage;
import tttclient.messages.Message;
import tttclient.messages.WhiteboardMessage;
import tttclient.messages.annotations.Annotation;
import tttclient.messages.annotations.DeleteAllAnnotation;
import tttclient.ttt.Constants;
import tttclient.ttt.Recording;
import android.graphics.Rect;
import android.util.Log;
......@@ -349,75 +353,222 @@ public class Messages {
// set next message for run loop
recording.next_message = newNext != -1 ? newNext : 0;
Log.d("Messages", "setting recording next message to " + newNext);
}
}
/*******************************************************************************************************************
* Statistics * //
******************************************************************************************************************/
// public void statistics() {
// int[] encoding_count = new int[256];
//
// for (int i = 0; i < messages.size(); i++) {
// Message message = messages.get(i);
// encoding_count[message.getEncoding()]++;
// }
//
// // output
// String[] encoding = new String[256];
// for (int i = 0; i < encoding.length; i++)
// encoding[i] = "Unknown [" + i + "]";
//
// encoding[Constants.EncodingTTTCursorPosition] = "CursorPosition";
// encoding[Constants.EncodingTTTXCursor] = "XCursor";
// encoding[Constants.EncodingTTTRichCursor] = "RichCursor";
// encoding[Constants.EncodingFlagUpdate] = "Update FILTER";
// encoding[Constants.EncodingFlagTimestamp] = "Timestamp FILTER";
// encoding[Constants.AnnotationRectangle] = "Rectangle";
// encoding[Constants.AnnotationLine] = "Line";
// encoding[Constants.AnnotationFreehand] = "Free";
// encoding[Constants.AnnotationHighlight] = "Highlight";
// encoding[Constants.AnnotationImage] = "Image"; // MODMSG
// encoding[Constants.AnnotationText] = "Text"; // MODMSG
// encoding[Constants.AnnotationDelete] = "Delete";
// encoding[Constants.AnnotationDeleteAll] = "Delete all";
// encoding[Constants.EncodingRecording] = "Recording FILTER";
// encoding[Constants.EncodingRaw] = "Raw";
// encoding[Constants.EncodingCopyRect] = "CopyRect";
// encoding[Constants.EncodingRRE] = "RRE";
// encoding[Constants.EncodingCoRRE] = "CoRRE";
// encoding[Constants.EncodingHextile] = "Hextile";
// encoding[Constants.EncodingZlib] = "Zlib";
// encoding[Constants.EncodingTight] = "Tight";
// encoding[Constants.EncodingWhiteboard] = "BlankPage";
//
// System.out.println();
// System.out.println("STATISTICS:");
// System.out.println();
// System.out.println("Qty:\tEncoding:");
// for (int i = 0; i < encoding.length; i++) {
// if (encoding_count[i] > 0)
// Log.d("statistic", " " + encoding_count[i] + "\t "
// + encoding[i]);
// }
// System.out.println();
// int annotations = encoding_count[Constants.AnnotationRectangle]
// + encoding_count[Constants.AnnotationLine]
// + encoding_count[Constants.AnnotationFreehand]
// + encoding_count[Constants.AnnotationHighlight]
// + encoding_count[Constants.AnnotationDelete]
// + encoding_count[Constants.AnnotationDeleteAll];
// System.out.println(" " + annotations + "\t annotations");
// System.out.println();
// }
//
// // TODO: more checks
// public void checkDuration(int duration) {
// if (messages.get(messages.size() - 1).getTimestamp() < duration) {
// System.out.println("expand duration of desktop recording");
// // messages.add(new DeleteAllAnnotation(duration));
// }
// }
// }
synchronized public void setTime_full_frame_check_regarding_stripes(int time) {
// long t = System.currentTimeMillis();
// if not set newly, this causes a call of stop() in run() because end
// of recording reached
int newNext = messages.size();
int totalCounter = 0;
ArrayList<Message> collected = new ArrayList<Message>();
// graphicsContext.memGraphics.setColor(Color.MAGENTA);
// graphicsContext.memGraphics.fillRect(0, 0, prefs.framebufferWidth,
// prefs.framebufferHeight);
boolean covered = false;
boolean whiteboard = !containsWhiteboard;
boolean cursor = !containsCursorMessages;
boolean cursorPosition = !containsCursorMessages;
boolean deleteAll = !containsAnnotations;
// a little preview (500msec) can be useful to get a more complete frame
// because framebuffer updates or annotations on whiteboard can be
// delayed
// TODO: verify if always better in pause mode
// TODO: verify if useful if not in pause mode
if (recording.paused())
time += 500;
for (int i = messages.size() - 1; i >= 0; i--) {
Message message = messages.get(i);
// skip future
if (message.getTimestamp() > time) {
newNext = i;
continue;
}
totalCounter++;
// find latest cursor
// NOTE: Cursor(Positions)Messages are FrameBufferUpdateMessages,
// but do not cover desktop
if (message instanceof CursorMessage) {
if (!cursor) {
// add at beginning
collected.add(0, message);
// mark as finished
cursor = true;
}
} else if (message instanceof CursorPositionMessage) {
if (!cursorPosition) {
// add at beginning
collected.add(0, message);
// mark as finished
cursorPosition = true;
}
}
// find latest whiteboard status
else if (message instanceof WhiteboardMessage) {
if (!whiteboard) {
// add at beginning
collected.add(0, message);
// mark as finished
whiteboard = true;
// TODO: think about following optimazation
// does not work for continous playback after whiteboard,
// because offscreen image is not updated
// // if whiteboard is enabled, previous framebufferupdates
// are irrelevant
// if (((WhiteboardMessage) message).isWhiteboardEnabled())
// coveredCounter = full;
}
}
// message is part of keyframe, because it covers unset pixels
else if (message instanceof FramebufferUpdateMessage) {
if (!covered) {
if (message.getTimestamp() > time - 125000)
// within 2 minutes
// add at beginning
collected.add(0, message);
else
// any pixel should be covered by stripes now
covered = true;
}
}
// all annotation since last deleteAll
else if (message instanceof Annotation) {
if (!deleteAll) {
// add at beginning
collected.add(0, message);
// if deleteAll all previous annotations are irrelevant
deleteAll = message instanceof DeleteAllAnnotation;
}
}
// add all other messages
else {
// add at beginning
collected.add(0, message);
}
// finished if gathered everything needed for keyframe or if reached
// current playback time
if (i == recording.next_message
|| (covered && deleteAll && cursor && cursorPosition && whiteboard))
break;
// clear whiteboard at beginning
if (i == 0 && !whiteboard)
collected.add(
0,
new WhiteboardMessage(0, 0, recording
.getProtocolPreferences()));
// clear annotations at beginning
if (i == 0 && !deleteAll)
collected.add(0, new DeleteAllAnnotation(0));
}
// t = System.currentTimeMillis() - t;
// System.out.println("Keyframe computation: "+Constants.getStringFromTime((int)
// t));
// t = System.currentTimeMillis();
// now paint collected messages (keyframe)
for (int i = 0; i < collected.size(); i++) {
// System.out.println(collected.get(i));
collected.get(i).paint(recording.graphicsContext());
}
// set next message for run loop
recording.next_message = newNext != -1 ? newNext : 0;
// t = System.currentTimeMillis() - t;
// System.out.print("\t" + Constants.getStringFromTime((int) t));
// System.out.println("\t"+collected.size() + "\t(" + totalCounter +
// ")\t"
// + Constants.getStringFromTime(time - collected.get(0).getTimestamp())
// + " "
// + ((collected.size() > 0 && time - collected.get(0).getTimestamp() >
// 120000)) + "\t- ");
}
/*******************************************************************************************************************
* Statistics * //
******************************************************************************************************************/
public void statistics() {
int[] encoding_count = new int[256];
for (int i = 0; i < messages.size(); i++) {
Message message = messages.get(i);
encoding_count[message.getEncoding()]++;
}
// output
String[] encoding = new String[256];
for (int i = 0; i < encoding.length; i++)
encoding[i] = "Unknown [" + i + "]";
encoding[Constants.EncodingTTTCursorPosition] = "CursorPosition";
encoding[Constants.EncodingTTTXCursor] = "XCursor";
encoding[Constants.EncodingTTTRichCursor] = "RichCursor";
encoding[Constants.EncodingFlagUpdate] = "Update FILTER";
encoding[Constants.EncodingFlagTimestamp] = "Timestamp FILTER";
encoding[Constants.AnnotationRectangle] = "Rectangle";
encoding[Constants.AnnotationLine] = "Line";
encoding[Constants.AnnotationFreehand] = "Free";
encoding[Constants.AnnotationHighlight] = "Highlight";
encoding[Constants.AnnotationImage] = "Image"; // MODMSG
encoding[Constants.AnnotationText] = "Text"; // MODMSG
encoding[Constants.AnnotationDelete] = "Delete";
encoding[Constants.AnnotationDeleteAll] = "Delete all";
encoding[Constants.EncodingRecording] = "Recording FILTER";
encoding[Constants.EncodingRaw] = "Raw";
encoding[Constants.EncodingCopyRect] = "CopyRect";
encoding[Constants.EncodingRRE] = "RRE";
encoding[Constants.EncodingCoRRE] = "CoRRE";
encoding[Constants.EncodingHextile] = "Hextile";
encoding[Constants.EncodingZlib] = "Zlib";
encoding[Constants.EncodingTight] = "Tight";
encoding[Constants.EncodingWhiteboard] = "BlankPage";
System.out.println();
System.out.println("STATISTICS:");
System.out.println();
System.out.println("Qty:\tEncoding:");
for (int i = 0; i < encoding.length; i++) {
if (encoding_count[i] > 0)
Log.d("statistic", " " + encoding_count[i] + "\t "
+ encoding[i]);
}
System.out.println();
int annotations = encoding_count[Constants.AnnotationRectangle]
+ encoding_count[Constants.AnnotationLine]
+ encoding_count[Constants.AnnotationFreehand]
+ encoding_count[Constants.AnnotationHighlight]
+ encoding_count[Constants.AnnotationDelete]
+ encoding_count[Constants.AnnotationDeleteAll];
System.out.println(" " + annotations + "\t annotations");
System.out.println();
}
// TODO: more checks
public void checkDuration(int duration) {
if (messages.get(messages.size() - 1).getTimestamp() < duration) {
System.out.println("expand duration of desktop recording");
// messages.add(new DeleteAllAnnotation(duration));
}
}
}
......@@ -35,8 +35,6 @@ import java.util.zip.InflaterInputStream;
import tttclient.messages.Message;
import tttclient.messages.MessageProducerAdapter;
import tttclient.messages.Messages;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
......@@ -119,6 +117,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
}
graphicsContext.enableRefresh(true);
setTime(0, true);
messages.statistics();
}
void read(File file) throws IOException {
......@@ -452,13 +451,12 @@ public class Recording extends MessageProducerAdapter implements Runnable {
return layout;
}
@SuppressLint("NewApi")
View addTitle(int number) {
TextView title = new TextView(context);
title.setText(String.valueOf(number + 1));
title.setTextAppearance(context, android.R.style.TextAppearance_Large);
title.setTextColor(Color.BLACK);
title.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
// title.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
return title;
}
......@@ -538,6 +536,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// paint offscreen
messages.setTime_full_frame_check(time);
// messages.setTime_full_frame_check_regarding_stripes(time);
if (refresh) {
// focusCurrentIndexEntry(time);
......
......@@ -28,6 +28,7 @@ import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import tttclient.shapes.ColoredShape;
import android.graphics.Color;
import android.graphics.RectF;
......
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