Commit 58beccea by Thomas Krex

- code kommentiert und aufgeräumt

-shape-klassen strukturiert
parent 5cd2ac8a
eclipse.preferences.version=1
encoding//src/tttclient/core/Constants.java=ISO-8859-1
encoding//src/tttclient/core/GraphicsContext.java=UTF-8
encoding//src/tttclient/messages/HighlightAnnotation.java=UTF-8
encoding//src/tttclient/messages/annotations/HighlightAnnotation.java=UTF-8
......@@ -322,36 +322,37 @@ int id abs__submit_area 0x7f04002f
int id abs__textButton 0x7f040013
int id abs__title 0x7f04001b
int id abs__up 0x7f04000b
int id action_settings 0x7f040047
int id add 0x7f040046
int id action_settings 0x7f040048
int id add 0x7f040047
int id button_paste 0x7f04003f
int id button_save 0x7f04003e
int id checkBox1 0x7f04003b
int id connect_btn 0x7f04003a
int id disableHome 0x7f040009
int id edit_query 0x7f040026
int id empty 0x7f040041
int id extend 0x7f04004a
int id feedDetailsLv 0x7f040042
int id feed_list 0x7f040040
int id empty 0x7f040042
int id extend 0x7f04004b
int id feedDetailsLv 0x7f040043
int id feed_list 0x7f040041
int id homeAsUp 0x7f040006
int id indexScrollView 0x7f040033
int id itemTitle 0x7f040044
int id itemTitle 0x7f040045
int id listMode 0x7f040002
int id next 0x7f040049
int id next 0x7f04004a
int id normal 0x7f040001
int id playerView_extended 0x7f040034
int id playerView_fullscreen 0x7f040036
int id port_tx 0x7f040039
int id progressBar 0x7f040043
int id progressBar 0x7f040044
int id scrollView1 0x7f040035
int id search 0x7f040048
int id search 0x7f040049
int id server_tx 0x7f040038
int id showCustom 0x7f040008
int id showHome 0x7f040005
int id showTitle 0x7f040007
int id statusIcon 0x7f040045
int id statusIcon 0x7f040046
int id tabMode 0x7f040003
int id textView1 0x7f04003f
int id textView1 0x7f040040
int id tx_name 0x7f04003d
int id tx_url 0x7f04003c
int id useLogo 0x7f040004
......@@ -409,18 +410,21 @@ int string abs__searchview_description_voice 0x7f09000c
int string abs__shareactionprovider_share_with 0x7f090006
int string abs__shareactionprovider_share_with_application 0x7f090007
int string action_settings 0x7f09000e
int string add_feed 0x7f09001e
int string add_feed 0x7f09001f
int string app_name 0x7f09000d
int string cancel 0x7f090018
int string confirm_download 0x7f090016
int string connect 0x7f090011
int string delete 0x7f09001d
int string delete 0x7f09001e
int string delete_feed 0x7f09001c
int string delete_lecture 0x7f09001d
int string deleted 0x7f09001b
int string hello_world 0x7f09000f
int string inet_needed 0x7f090019
int string multicast 0x7f090015
int string not_found 0x7f09001a
int string parse_fail_message 0x7f090021
int string parse_fail_title 0x7f090020
int string port 0x7f090013
int string prompt_title 0x7f090014
int string server_adresse 0x7f090012
......
......@@ -14,24 +14,36 @@
android:ems="10"
android:hint="Url" />
<EditText
android:id="@+id/tx_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="23dp"
android:ems="10"
android:hint="Name" />
<Button
android:id="@+id/button_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/tx_url"
android:layout_centerHorizontal="true"
android:layout_marginRight="52dp"
android:layout_marginTop="32dp"
android:background="@android:color/transparent"
android:text="Save" />
<EditText
android:id="@+id/tx_name"
android:layout_width="match_parent"
<Button
android:id="@+id/button_paste"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button_save"
android:layout_alignBottom="@+id/button_save"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="23dp"
android:ems="10"
android:hint="Name" />
android:layout_marginLeft="58dp"
android:background="@android:color/transparent"
android:text="Paste URL" />
</RelativeLayout>
\ No newline at end of file
......@@ -17,7 +17,10 @@
<string name="not_found">File was not found</string>
<string name="deleted">File was deleted</string>
<string name="delete_feed">Do you want to delete this feed? All Lectures saved on this devices will be deleted</string>
<string name="delete_lecture"> Do you want to delete this lecture from your devices?</string>
<string name="delete">Delete</string>
<string name="add_feed">Add a new Feed</string>
<string name="parse_fail_title">Connection Failed!!!</string>
<string name="parse_fail_message">Please make sure that the URL is correct and reachable</string>
</resources>
\ No newline at end of file
......@@ -3,12 +3,16 @@ package tttclient.activities;
import tttclient.models.Feed;
import tttclient.models.FeedDbManager;
import tttclient.models.FeedItemDbManager;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ClipData;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.database.Cursor;
import android.os.Build;
import android.os.Bundle;
import android.os.Vibrator;
import android.util.Log;
......@@ -30,6 +34,17 @@ import com.actionbarsherlock.view.MenuItem;
import de.tum.in.tttclient.R;
/**
*
* @author Thomas Krex
*
* Activity for adding and Displaying Feeds. This class uses the
* FeedDbManger to store feeds and a Listview to display them.
*
* @see FeedDbManager, Feed
*
*
*/
public class FeedActivity extends SherlockActivity implements
OnItemClickListener, OnItemLongClickListener {
......@@ -41,13 +56,14 @@ public class FeedActivity extends SherlockActivity implements
EditText nameTxt;
private int feedId;
private Vibrator myVib;
private ListView feedLv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.feed_activity);
myVib = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);
ListView feedList = (ListView) findViewById(R.id.feed_list);
feedLv = (ListView) findViewById(R.id.feed_list);
FeedDbManager fManager = new FeedDbManager(this);
Cursor cursor = fManager.getAllFromDB();
......@@ -57,33 +73,75 @@ public class FeedActivity extends SherlockActivity implements
FeedDbManager.COLUMN_FEEDURL }, new int[] {
android.R.id.text1, android.R.id.text2 });
feedList.setAdapter(adapter);
feedLv.setAdapter(adapter);
View empty = findViewById(R.id.empty);
feedList.setEmptyView(empty);
feedList.setOnItemClickListener(this);
feedList.setOnItemLongClickListener(this);
feedLv.setEmptyView(empty);
feedLv.setOnItemClickListener(this);
feedLv.setOnItemLongClickListener(this);
// initializing Dialog for adding Feeds
addDialog = new Dialog(this);
addDialog.setContentView(R.layout.dialog_feeds);
urlTxt = (EditText) addDialog.findViewById(R.id.tx_url);
nameTxt = (EditText) addDialog.findViewById(R.id.tx_name);
addDialog.setTitle(R.string.add_feed);
addDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
// emptying textfields after canceling dialog
urlTxt.setText("");
nameTxt.setText("");
}
});
// Button for pasting Url from the clipboard into the textfield
Button pasteButton = (Button) addDialog.findViewById(R.id.button_paste);
pasteButton.setOnClickListener(new OnClickListener() {
/**
* handles Click on "Paste URL" Button
*/
@SuppressLint("NewApi")
@Override
public void onClick(View v) {
// ClipBoardManager moved from android.text to android.content.
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
if (!clipboard.hasPrimaryClip()) {
Toast.makeText(getApplicationContext(),
"no URL in clipboard", Toast.LENGTH_SHORT)
.show();
} else {
ClipData.Item item = clipboard.getPrimaryClip()
.getItemAt(0);
CharSequence pasteText = item.getText();
urlTxt.setText(pasteText);
}
} else {
// pasting for ANdroid Gingerbread
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
if (!clipboard.hasText())
Toast.makeText(getApplicationContext(),
"no URL in clipboard", Toast.LENGTH_SHORT)
.show();
else {
urlTxt.setText(clipboard.getText());
}
}
}
});
Button saveButton = (Button) addDialog.findViewById(R.id.button_save);
saveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// name has to contains of at least one character
String name = nameTxt.getText().toString();
if (name.isEmpty()) {
Toast.makeText(getApplicationContext(),
......@@ -92,9 +150,8 @@ public class FeedActivity extends SherlockActivity implements
return;
}
// TODO validate url
String url = urlTxt.getText().toString();
// validate url
if (!URLUtil.isValidUrl(url)) {
Toast.makeText(getApplicationContext(),
"Please insert a valid Url", Toast.LENGTH_LONG)
......@@ -102,7 +159,8 @@ public class FeedActivity extends SherlockActivity implements
return;
}
// delete all whitespaces from ulr before inserting into the
// database
url.replaceAll("\\s+", "");
Feed feed = new Feed(name, url);
......@@ -116,21 +174,23 @@ public class FeedActivity extends SherlockActivity implements
}
// refresh list
adapter.changeCursor(fm.getAllFromDB());
// clear textfields of dialog
nameTxt.setText("");
urlTxt.setText("");
// close dialog
addDialog.dismiss();
}
});
Intent intent = getIntent();
String action = intent.getAction();
if (Intent.ACTION_VIEW.equals(action)) {
Log.d("IntentFIlter", intent.getDataString());
urlTxt.setText(intent.getDataString());
addDialog.show();
// Intent intent = getIntent();
// String action = intent.getAction();
// if (Intent.ACTION_VIEW.equals(action)) {
// Log.d("IntentFIlter", intent.getDataString());
// urlTxt.setText(intent.getDataString());
// addDialog.show();
}
// }
}
......@@ -163,13 +223,13 @@ public class FeedActivity extends SherlockActivity implements
.getColumnIndex(FeedDbManager.COLUMN_FEEDURL));
feedName = c.getString(c.getColumnIndex(FeedDbManager.COLUMN_NAME));
feedId = c.getInt(c.getColumnIndex("_id"));
}
Feed feed = new Feed(feedId, feedName, feedUrl);
Intent intent = new Intent(this, FeedDetailActivity.class);
intent.putExtra("feedUrl", feedUrl);
intent.putExtra("name", feedName);
intent.putExtra("id", feedId);
startActivity(intent);
// send Feed to FeedDetailsActivity for displaying items
Intent intent = new Intent(this, FeedDetailActivity.class);
intent.putExtra("feed", feed);
startActivity(intent);
}
}
@Override
......@@ -178,6 +238,7 @@ public class FeedActivity extends SherlockActivity implements
if (id == -1) {
return false;
}
// haptic feedback for longclick
myVib.vibrate(50);
// confirm delete
......@@ -198,6 +259,7 @@ public class FeedActivity extends SherlockActivity implements
adapter.changeCursor(fm.getAllFromDB());
}
};
// show alert dialog to get confirmed delete process
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.delete_feed);
builder.setPositiveButton(R.string.delete, listener);
......
......@@ -11,6 +11,12 @@ import com.actionbarsherlock.app.SherlockActivity;
import de.tum.in.tttclient.R;
/**
* Starting Screen of the App
*
* @author Thomas Krex
*
*/
public class MainActivity extends SherlockActivity {
@Override
......@@ -31,50 +37,5 @@ public class MainActivity extends SherlockActivity {
}
});
// Button connectButton = (Button)
// findViewById(R.id.liveChannel_button);
// connectButton.setOnClickListener(new OnClickListener() {
//
// @Override
// public void onClick(View v) {
// // get prompts.xml view
//
// Dialog dialog = new Dialog(MainActivity.this);
// dialog.setTitle(getString(R.string.prompt_title));
// dialog.setContentView(R.layout.dialog_connect);
//
// final EditText severInput = (EditText) dialog
// .findViewById(R.id.server_tx);
// final EditText portInput = (EditText) dialog
// .findViewById(R.id.port_tx);
// final Button connectButton = (Button) dialog
// .findViewById(R.id.connect_btn);
// final CheckBox checkBox = (CheckBox) dialog
// .findViewById(R.id.checkBox1);
//
// connectButton.setOnClickListener(new OnClickListener() {
//
// @Override
// public void onClick(View v) {
// try {
// InetAddress serverAdress = InetAddress
// .getByName(severInput.getText().toString());
// } catch (UnknownHostException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// int port = Integer.parseInt(portInput.getText()
// .toString());
//
// final boolean multicast = checkBox.isChecked();
//
// }
// });
//
// dialog.show();
//
// }
// });
}
}
package tttclient.activities;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class MySurfaceView extends SurfaceView implements
SurfaceHolder.Callback {
private final SurfaceHolder sh;
private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Canvas canvas;
public MySurfaceView(Context context) {
super(context);
sh = getHolder();
sh.addCallback(this);
paint.setColor(Color.BLUE);
paint.setStyle(Style.FILL);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// Canvas canvas = sh.lockCanvas();
// canvas.drawColor(Color.WHITE);
// canvas.drawCircle(100, 200, 50, paint);
// sh.unlockCanvasAndPost(canvas);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub
}
public void drawRec(int x, int y, int w, int h, Paint p) {
canvas = sh.lockCanvas();
canvas.drawRect(new Rect(x, y, x + w, y + h), p);
sh.unlockCanvasAndPost(canvas);
}
}
......@@ -31,6 +31,16 @@ import com.actionbarsherlock.widget.SearchView.OnQueryTextListener;
import de.tum.in.tttclient.R;
/**
* Activity for the replay of the recordings. Here is done much initializing
* work. All objects are passed to the recording class, that controls the
* replay. The MediaController delegates the task to the recording object
*
*
*
* @author Thomas Krex
*
*/
public class PlayerActivity extends SherlockActivity implements
MediaPlayerControl {
static final int LAYOUT_MODE_FULL = 0;
......@@ -64,12 +74,13 @@ public class PlayerActivity extends SherlockActivity implements
final File tttFile = new File(filePath + "/" + fileName + ".ttt");
File audioFile = new File(filePath + "/" + fileName + ".mp3");
// audioPlayer for controlling mp3-file
audioPlayer = MediaPlayer.create(this, Uri.fromFile(audioFile));
// creates a MediaController without fastforward and rewind buttons
audioController = new MediaController(this, false);
audioController.setMediaPlayer(this);
// show dialog parse ttt-File
final ProgressDialog dialog = new ProgressDialog(PlayerActivity.this);
dialog.setTitle("Please Wait");
dialog.setMessage("Prepare File ...");
......@@ -77,6 +88,11 @@ public class PlayerActivity extends SherlockActivity implements
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
/**
* asynchronous task for creating the recording object. prevents ui from
* being stucked, while reading messages and creating thumbnails
*/
AsyncTask<Void, Void, Void> initTask = new AsyncTask<Void, Void, Void>() {
@Override
......@@ -96,6 +112,11 @@ public class PlayerActivity extends SherlockActivity implements
" bits/pixel "
+ recording.getProtocolPreferences().bitsPerPixel);
/*
* create listeners for prev/next buttons of mediaController
* task are delegated to recordind object
*/
OnClickListener prevListener = new OnClickListener() {
@Override
......@@ -112,6 +133,7 @@ public class PlayerActivity extends SherlockActivity implements
}
};
// set the listeners
audioController.setPrevNextListeners(nextListener,
prevListener);
......@@ -126,8 +148,9 @@ public class PlayerActivity extends SherlockActivity implements
@Override
protected void onPostExecute(Void result) {
// close dialog
dialog.dismiss();
// show control bar
audioController.show(5000);
}
......@@ -136,17 +159,52 @@ public class PlayerActivity extends SherlockActivity implements
}
@Override
protected void onPause() {
recording.pause();
super.onPause();
}
@Override
public void onBackPressed() {
super.onBackPressed();
recording.close();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (audioController != null)
audioController.show();
return true;
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.d("PlayerActivity", "onDestroy");
recording.stop();
recording = null;
audioPlayer.release();
}
/*******************************************************************************************************************
* Delegating Search *
******************************************************************************************************************/
// delegates search to index and updates the view
public void search(String word) {
if (recording.getIndex() != null)
recording.getIndex().search(word);
// update display if recording is not playing
// if (!recording.isPlaying())
// updates the image after searching
recording.graphicsContext().updateView(false);
}
/*******************************************************************************************************************
* Methods of MediaPlayerControl *
******************************************************************************************************************/
@Override
public boolean canPause() {
return true;
......@@ -212,30 +270,9 @@ public class PlayerActivity extends SherlockActivity implements
}
@Override
protected void onPause() {
recording.pause();
super.onPause();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (audioController != null)
audioController.show();
return false;
}