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

problem mit gc ist aufgetreten und wieder verschwunden, durch weglassen des...

problem mit gc ist aufgetreten und wieder verschwunden, durch weglassen des counters beim abtasten der amplitude.
parent 93491d56
......@@ -4,4 +4,5 @@ encoding//src/tttrec/connections/Connection.java=UTF-8
encoding//src/tttrec/connections/RFBConnection.java=UTF-8
encoding//src/tttrec/core/RfbProtocol.java=UTF-8
encoding//src/tttrec/messages/FreehandAnnotation.java=UTF-8
encoding//src/tttrec/messages/HextileMessage.java=UTF-8
encoding//src/tttrec/recording/Recorder.java=UTF-8
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<shape>
<corners android:radius="8dp" />
<gradient
android:endColor="#000000"
android:startColor="#000000" />
<stroke
android:width="1dp"
android:color="#FFFFFF" />
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="8dp" />
<gradient
android:endColor="#FF0000"
android:startColor="#00FF00" />
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
......@@ -54,9 +54,18 @@
android:id="@+id/chronometer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:text="Chronometer"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:max="150"
android:progressDrawable="@drawable/progressbar" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
......
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".Start_session"
>
tools:context=".Start_session" >
<!-- Login progress -->
......@@ -37,8 +34,7 @@
<ScrollView
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:layout_height="match_parent" >
<LinearLayout
style="@style/LoginFormContainer"
......@@ -67,24 +63,22 @@
android:layout_height="wrap_content"
android:orientation="horizontal" >
<AutoCompleteTextView
<AutoCompleteTextView
android:id="@+id/ip_address"
android:layout_width="0dip"
android:layout_weight="2"
android:layout_height="wrap_content"
android:layout_weight="2"
android:hint="@string/prompt_ip"
android:inputType="date"
android:digits="0123456789."
android:maxLines="1"
android:singleLine="true" />
<EditText
android:id="@+id/port"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:hint="@string/prompt_port"
android:layout_weight="1"
android:digits="0123456789"
android:hint="@string/prompt_port"
android:inputType="number"
android:maxLines="1"
android:singleLine="true" />
......
package com.example.tttrecorderandroid;
import java.util.List;
import tttrec.core.RfbProtocol;
import tttrec.customviews.AnnotationView;
import tttrec.customviews.ScaleAwareImageView;
import tttrec.interaction.AnnotationCanvasTouchListener;
import tttrec.interaction.InteractionManager;
import tttrec.messages.Annotation;
import tttrec.recording.AudioRecorder;
import tttrec.util.MyColorPickerDialog;
import tttrec.util.ReconnectDialog;
import android.app.Activity;
......@@ -21,6 +20,8 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.GestureDetector;
......@@ -31,15 +32,16 @@ import android.view.View.OnTouchListener;
import android.view.ViewTreeObserver;
import android.widget.Chronometer;
import android.widget.ImageButton;
import android.widget.ProgressBar;
public class MainActivity extends Activity {
private static final String DEBUG_TAG = "MainActivity";
private TTTRecorderAndroid tttRec;
private InteractionManager im;
private GestureDetector gestureDetector;
private List<ImageButton> colourButtons;
private ProgressBar mProgressBar;
private Chronometer timer;
private Handler levelHandler;
private ReconnectDialog rDialog;
private MyColorPickerDialog colorDialog;
......@@ -47,12 +49,9 @@ public class MainActivity extends Activity {
private ImageButton highlightAnnotationButton;
private ImageButton colorPickerButton;
// TODO remove Android
AnnotationView annotationView;
ScaleAwareImageView imgV;
// // TODO testing
// private int screenHeight = 100;
private final OnTouchListener mTouchListener2 = new OnTouchListener() {
@Override
......@@ -75,21 +74,13 @@ public class MainActivity extends Activity {
highlightAnnotationButton = (ImageButton) findViewById(R.id.SelectHighlight);
colorPickerButton = (ImageButton) findViewById(R.id.colorPickerButton);
highlightAnnotationButton.setAlpha(0.4f);
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
// colourButtons = createColorButtonList();
// ImageButton b = (ImageButton) findViewById(R.id.colour_button_red);
// b.setScaleType(ScaleType.CENTER);
// b.getBackground().setColorFilter(0xe0f47521,
// PorterDuff.Mode.SRC_ATOP);
// compute the actual space for a view
// TODO remove Android
annotationView = (AnnotationView) findViewById(R.id.annotationView);
imgV = (ScaleAwareImageView) findViewById(R.id.vncImageView);
imgV.setOnTouchListener(mTouchListener2);
// View Tree Observer is used to measure the height of the ImageView
ViewTreeObserver vto = imgV.getViewTreeObserver();
vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
......@@ -104,8 +95,20 @@ public class MainActivity extends Activity {
}
});
tttRec = new TTTRecorderAndroid(annotationView, imgV, new Handler(),
getApplicationContext());
// Handler receives the level of the recorded audio from the class
// AudioRecorder
levelHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
if (msg.what == AudioRecorder.LEVEL_MSG) {
int level = msg.arg1;
mProgressBar.setProgress(level);
}
}
};
tttRec = new TTTRecorderAndroid(annotationView, imgV, levelHandler,
new Handler(Looper.getMainLooper()), getApplicationContext());
Thread t = new Thread(tttRec);
t.start();
......@@ -137,18 +140,6 @@ public class MainActivity extends Activity {
connectionReceiver);
}
// private List<ImageButton> createColorButtonList() {
// List<ImageButton> result = new ArrayList<ImageButton>();
// result.add((ImageButton) findViewById(R.id.colour_button_yellow));
// result.add((ImageButton) findViewById(R.id.colour_button_black));
// result.add((ImageButton) findViewById(R.id.colour_button_blue));
// result.add((ImageButton) findViewById(R.id.colour_button_green));
// result.add((ImageButton) findViewById(R.id.colour_button_red));
//
// return result;
// }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
......@@ -172,26 +163,6 @@ public class MainActivity extends Activity {
* @param view
* View The clicked Button
*/
// public void colourSelected(View view) {
//
// ImageButton ib = (ImageButton) view;
//
// for (ImageButton b : colourButtons) {
// if (ib.getId() == (b.getId())) {
// b.setScaleType(ScaleType.CENTER);
// b.getBackground().setColorFilter(0xe0f47521,
// PorterDuff.Mode.SRC_ATOP);
// b.invalidate();
// } else {
// b.setScaleType(ScaleType.CENTER_CROP);
// b.getBackground().clearColorFilter();
// b.invalidate();
//
// }
// }
//
// im.onColourSelected((ImageButton) view);
// }
public void annotationModeSelected(View view) {
......@@ -221,6 +192,7 @@ public class MainActivity extends Activity {
if (recording) {
im.stopRecording();
timer.stop();
mProgressBar.setProgress(0);
annotationView.recording = false;
b.setImageResource(R.drawable.record);
......@@ -286,6 +258,9 @@ public class MainActivity extends Activity {
}
/**
* stops the recording, releases memory and terminates the activity
*/
public void exitActivity() {
if (recording) {
im.stopRecording();
......@@ -374,11 +349,25 @@ public class MainActivity extends Activity {
}
/**
* Handles interaction with the ColorPicker ImageButton in the toolbar. Open
* the ColorPickerDialog;
*
* @param view
*/
public void openColorPicker(View view) {
colorDialog.show();
}
/**
* Handles the click on the different ImageButtons of the ColorPickerDialog.
* Forwards the corresponding color to the interaction manager and sets the
* icon of the ColorPicker ImageButton
*
* @param view
* The ImageButton for choosing the color
*/
public void onColorSelected(View view) {
int viewId = view.getId();
......
......@@ -17,6 +17,7 @@ import android.view.View;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
/**
* Activity which displays a login screen to the user, offering registration as
......@@ -41,6 +42,7 @@ public class Start_session extends Activity {
protected EditText mPortView;
protected EditText mPasswordView;
private static LectureProfile profil;
protected AlertDialog connectionFailedDialog;
private View mConnectionFormView;
......@@ -93,6 +95,13 @@ public class Start_session extends Activity {
new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!checkUserInput())
return;
profil = new LectureProfile(mLectureView.getText()
.toString());
profil.setTeacher(mTeacherView.getText().toString());
showProgress(true);
mAuthTask = new UserLoginTask();
mAuthTask.execute((Void) null);
......@@ -153,8 +162,8 @@ public class Start_session extends Activity {
protected Byte doInBackground(Void... params) {
// TODO: attempt authentication against a network service.
return TTTRecorderAndroid.establishConnection(mIPView.getText()
.toString(), Integer.parseInt(mPortView.getText()
return TTTRecorderAndroid.establishConnection(profil, mIPView
.getText().toString(), Integer.parseInt(mPortView.getText()
.toString()), mPasswordView.getText().toString());
}
......@@ -194,4 +203,31 @@ public class Start_session extends Activity {
showProgress(false);
}
}
public boolean checkUserInput() {
if (mLectureView.getText().toString().matches("")) {
Toast.makeText(getApplicationContext(),
"Please enter the title of the Lecture", Toast.LENGTH_LONG)
.show();
return false;
} else if (mTeacherView.getText().toString().matches("")) {
Toast.makeText(getApplicationContext(),
"Please enter the name of the teacher ", Toast.LENGTH_LONG)
.show();
return false;
} else if (mIPView.getText().toString().matches("")) {
Toast.makeText(getApplicationContext(),
"Please enter the hostname/adresse of the VNC-Server",
Toast.LENGTH_LONG).show();
return false;
} else if (mPortView.getText().toString().matches("")) {
Toast.makeText(getApplicationContext(),
"Please enter the open port of the VNC-Server",
Toast.LENGTH_LONG).show();
return false;
} else
return true;
}
}
......@@ -36,8 +36,9 @@ public class TTTRecorderAndroid implements Runnable {
// TODO Move to Graphics Context
private final AnnotationView annotationView;
private static LectureProfile lectureProfil;
private final Handler uiThreadHandler;
private final Handler levelHandler;
private final Context context;
private Recorder recorder;
......@@ -131,7 +132,9 @@ public class TTTRecorderAndroid implements Runnable {
};
public TTTRecorderAndroid(AnnotationView annotationView,
ScaleAwareImageView imgv, Handler uiThreadHandler, Context context) {
ScaleAwareImageView imgv, Handler levelHandler,
Handler uiThreadHandler, Context context) {
this.levelHandler = levelHandler;
this.uiThreadHandler = uiThreadHandler;
this.annotationView = annotationView;
this.imgv = imgv;
......@@ -150,9 +153,10 @@ public class TTTRecorderAndroid implements Runnable {
* @param password
* password for the vnc server
*/
public static byte establishConnection(String address, int port,
String password) {
public static byte establishConnection(LectureProfile profil,
String address, int port, String password) {
lectureProfil = profil;
InetAddress serverAddress = null;
try {
......@@ -187,6 +191,7 @@ public class TTTRecorderAndroid implements Runnable {
*/
public void updateView(final Bitmap bmp) {
// uiThreadHandler.post(new Runnable() {
uiThreadHandler.post(new Runnable() {
@Override
......@@ -202,8 +207,8 @@ public class TTTRecorderAndroid implements Runnable {
* updates the imageView by calling invalidate(). The bitmap is changed in
* GraphicsContext.
*/
public void updateView() {
uiThreadHandler.post(updateViewTask);
public void updateImageView() {
imgv.postInvalidate();
}
/***
......@@ -211,16 +216,16 @@ public class TTTRecorderAndroid implements Runnable {
* changed in GraphicsContext.
*/
public void updateAnnotationView() {
uiThreadHandler.post(updateAnnotationTask);
annotationView.postInvalidate();
}
public void startRecording() {
// TODO do via User input
LectureProfile lp = new LectureProfile("TestLecture");
lp.setTeacher("Bob");
// LectureProfile lp = new LectureProfile("TestLecture");
// lp.setTeacher("Bob");
try {
recorder = new Recorder(rfbProtocol, lp);
recorder = new Recorder(rfbProtocol, lectureProfil, levelHandler);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
......
......@@ -39,7 +39,7 @@ public abstract class GraphicsContext extends Observable {
public void updateScaledBitmap() {
tttrec.updateView();
tttrec.updateImageView();
}
......
......@@ -2,7 +2,7 @@ package tttrec.interaction;
import tttrec.interaction.ClientToServer.Key;
import tttrec.messages.Annotation;
import tttrec.util.ColorPickerDialog.OnColorChangedListener;
import tttrec.util.MyColorPickerDialog.OnColorChangedListener;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
......@@ -75,34 +75,6 @@ public class InteractionManager extends GestureDetector.SimpleOnGestureListener
tttRec.clearAllAnnotations();
}
// public void onColourSelected(ImageButton colourButton) {
//
// {
// switch (colourButton.getId()) {
// case R.id.colour_button_red:
// currentAnnotationcolor = Annotation.Red;
// break;
// case R.id.colour_button_black:
// currentAnnotationcolor = Annotation.Black;
// break;
// case R.id.colour_button_blue:
// currentAnnotationcolor = Annotation.Blue;
// break;
// case R.id.colour_button_green:
// currentAnnotationcolor = Annotation.Green;
// break;
// case R.id.colour_button_yellow:
// currentAnnotationcolor = Annotation.Yellow;
// break;
// default:
// // shouldn't happen, where did that button come from?
// break;
// }
//
// }
//
// }
public void onColorSelected(int color) {
currentAnnotationcolor = color;
}
......
// TeleTeachingTool - Presentation Recording With Automated Indexing
//
// Copyright (C) 2003-2008 Peter Ziewer - Technische Universit�t M�nchen
// Copyright (C) 2003-2008 Peter Ziewer - Technische Universit���t M���nchen
//
// This file is part of TeleTeachingTool.
//
......@@ -30,243 +30,254 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Random;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import tttrec.core.Constants;
import tttrec.core.GraphicsContext;
import android.graphics.Paint;
public class HextileMessage extends FramebufferUpdateMessage {
// reading from stream is easier then reading from byte array
private ByteArrayInputStream byteArrayInputStream;
private DataInputStream is;
// constructor
public HextileMessage(int timestamp, int x, int y, int width, int height, byte[] data) {
super(timestamp, x, y, width, height);
// encoded message data without header
this.data = data;
// create streams to read data
// NOTE: don't use buffered streams, because this will lead to heavy memory usage;
byteArrayInputStream = new ByteArrayInputStream(this.data);
is = new DataInputStream(byteArrayInputStream);
}
// read from TTT input stream
public HextileMessage(int timestamp, DataInputStream in, int size) throws IOException {
this(timestamp, in.readShort(), in.readShort(), in.readShort(), in.readShort(), FramebufferUpdateMessage
.readBytes(in, size - 8));
}
// constructor - reading message from RFB input stream and directly draw rectangle to graphics context
public HextileMessage(int timestamp, int x, int y, int width, int height, GraphicsContext graphicsContext,
DataInputStream is) throws IOException {
this(timestamp, x, y, width, height,
handleAndBufferHextileRect(graphicsContext, is, x, y, width, height, false));
}
public int getEncoding() {
return Constants.EncodingHextile;
}
static private byte[] handleAndBufferHextileRect(GraphicsContext graphicsContext, DataInputStream is, int x, int y,
int w, int h, boolean updateFlag) throws IOException {
// create buffer
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
DataOutputStream buffer = new DataOutputStream(new BufferedOutputStream(byteArrayOutputStream));
// handle
handleHextileRect(graphicsContext, is, buffer, x, y, w, h, updateFlag);
// write buffer
buffer.flush();
return byteArrayOutputStream.toByteArray();
}
// These colors should be kept between handleHextileSubrect() calls.
static private void handleHextileRect(GraphicsContext graphicsContext, DataInputStream is, DataOutputStream os,
int x, int y, int w, int h, boolean updateFlag) throws IOException {
// scan hextiles
for (int ty = y; ty < y + h; ty += 16) {
int th = 16;
if (y + h - ty < 16)
th = y + h - ty;
for (int tx = x; tx < x + w; tx += 16) {
int tw = 16;
if (x + w - tx < 16)
tw = x + w - tx;
handleHextileSubrect(graphicsContext, is, os, tx, ty, tw, th, updateFlag);
}
}
graphicsContext.refresh(x, y, w, h);
}
// Handle one tile in the Hextile-encoded data.
static private void handleHextileSubrect(GraphicsContext graphicsContext, DataInputStream is, DataOutputStream os,
int tx, int ty, int tw, int th, boolean updateFlag) throws IOException {
int subencoding = is.readUnsignedByte();
// buffering
if (os != null)
os.writeByte(subencoding);
// Is it a raw-encoded sub-rectangle?
if ((subencoding & Constants.HextileRaw) != 0) {
handleRawRect(graphicsContext, is, os, tx, ty, tw, th);