Commit 0323ee3d authored by Thomas Krex's avatar Thomas Krex

-wechsel zwischen fullscreen und extended view impelemntiert mit View

Switcher, entsprechendes Menü item hinzugefügt
parent 04a303bd
......@@ -22,40 +22,46 @@ public final class R {
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
public static final int my_border=0x7f020001;
}
public static final class id {
public static final int action_settings=0x7f08000e;
public static final int add=0x7f08000d;
public static final int button_save=0x7f080009;
public static final int feedDetailsLv=0x7f08000b;
public static final int feed_list=0x7f08000a;
public static final int action_settings=0x7f08000f;
public static final int add=0x7f08000e;
public static final int button_save=0x7f08000a;
public static final int extend=0x7f080010;
public static final int feedDetailsLv=0x7f08000c;
public static final int feed_list=0x7f08000b;
public static final int feedback_button=0x7f080002;
public static final int indexScrollView=0x7f080004;
public static final int playerView=0x7f080003;
public static final int playerView_extended=0x7f080005;
public static final int progressBar=0x7f08000c;
public static final int scrollView1=0x7f080006;
public static final int indexScrollView=0x7f080003;
public static final int playerView_extended=0x7f080004;
public static final int playerView_fullscreen=0x7f080006;
public static final int progressBar=0x7f08000d;
public static final int scrollView1=0x7f080005;
public static final int test_button=0x7f080000;
public static final int tx_name=0x7f080008;
public static final int tx_url=0x7f080007;
public static final int tx_name=0x7f080009;
public static final int tx_url=0x7f080008;
public static final int viewSwitcher=0x7f080007;
public static final int watch_button=0x7f080001;
}
public static final class layout {
public static final int activity_main=0x7f030000;
public static final int activity_player=0x7f030001;
public static final int activity_player_extended=0x7f030002;
public static final int dialog_feeds=0x7f030003;
public static final int feed_activity=0x7f030004;
public static final int feed_details_activity=0x7f030005;
public static final int activity_player_extended=0x7f030001;
public static final int activity_player_fullscreen=0x7f030002;
public static final int activity_player_main=0x7f030003;
public static final int dialog_feeds=0x7f030004;
public static final int feed_activity=0x7f030005;
public static final int feed_details_activity=0x7f030006;
}
public static final class menu {
public static final int feed_menu=0x7f070000;
public static final int main=0x7f070001;
public static final int player_menu=0x7f070002;
}
public static final class string {
public static final int action_settings=0x7f050001;
public static final int app_name=0x7f050000;
public static final int hello_world=0x7f050002;
public static final int wait=0x7f050003;
}
public static final class style {
/**
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<stroke
android:width="10dip"
android:color="@android:color/darker_gray" >
</stroke>
</shape>
\ No newline at end of file
......@@ -7,8 +7,9 @@
<ScrollView
android:id="@+id/indexScrollView"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_weight="3" >
android:layout_height="fill_parent"
android:layout_weight="3"
android:paddingLeft="5dip" >
</ScrollView>
<ImageView
......@@ -17,7 +18,9 @@
android:layout_height="match_parent"
android:layout_toRightOf="@+id/scrollView1"
android:layout_weight="5"
android:scaleType="fitXY"
android:background="@drawable/my_border"
android:padding="10dip"
android:scaleType="centerInside"
android:src="@drawable/ic_launcher" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/playerView"
android:id="@+id/playerView_fullscreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ViewSwitcher
android:id="@+id/viewSwitcher"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/playerView_fullscreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ScrollView
android:id="@+id/indexScrollView"
android:layout_width="200dp"
android:layout_height="fill_parent"
android:layout_weight="3"
android:paddingLeft="5dip" >
</ScrollView>
<ImageView
android:id="@+id/playerView_extended"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/scrollView1"
android:layout_weight="5"
android:background="@drawable/my_border"
android:padding="10dip"
android:scaleType="centerInside"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</ViewSwitcher>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/extend"
android:icon="@android:drawable/ic_input_add"
android:showAsAction="always">
</item>
</menu>
\ No newline at end of file
......@@ -4,5 +4,6 @@
<string name="app_name">test</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="wait">Please Wait. Reading File</string>
</resources>
......@@ -4,23 +4,24 @@ import java.io.File;
import java.io.IOException;
import tttclient.services.DownloadService;
import tttclient.ttt.IndexEntry;
import tttclient.ttt.Recording;
import android.app.Activity;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
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.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.MediaController;
import android.widget.MediaController.MediaPlayerControl;
import android.widget.ScrollView;
import android.widget.ViewSwitcher;
import com.example.test.R;
......@@ -29,6 +30,7 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
public String fileName;
public String filePath;
public ImageView imgV;
private ViewSwitcher switcher;
private ScrollView scrollView;
private Recording recording;
private MediaPlayer audioPlayer;
......@@ -39,11 +41,16 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player_extended);
imgV = (ImageView) findViewById(R.id.playerView_extended);
setContentView(R.layout.activity_player_main);
scrollView = (ScrollView) findViewById(R.id.indexScrollView);
switcher = (ViewSwitcher) findViewById(R.id.viewSwitcher);
// desfault fullscreen
imgV = (ImageView) findViewById(R.id.playerView_fullscreen);
// switchLayout(0);
fileName = getIntent().getStringExtra(DownloadService.FILE_NAME);
setTitle(fileName);
filePath = getIntent().getStringExtra(DownloadService.FILE_PATH);
File tttFile = new File(filePath + "/" + fileName + ".ttt");
......@@ -57,7 +64,7 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
int screenWidth = display.getWidth(); // deprecated
int screenHeight = display.getHeight(); // deprecated
recording = new Recording(getApplicationContext(), tttFile,
audioPlayer, imgV, screenWidth, screenHeight);
audioPlayer, imgV, scrollView, screenWidth, screenHeight);
} catch (IOException e) {
// TODO Auto-generated catch block
......@@ -89,8 +96,6 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
audioController.setAnchorView(imgV);
initScrollView();
}
@Override
......@@ -175,20 +180,57 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
audioPlayer.release();
}
public void initScrollView() {
LinearLayout layout = new LinearLayout(getApplicationContext());
layout.setBackgroundColor(Color.MAGENTA);
//
int length = recording.getIndex().size();
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.player_menu, menu);
return true;
}
boolean isExtendend = false;
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.extend:
if (!isExtendend) {
switchLayout(1);
item.setIcon(getResources().getDrawable(
android.R.drawable.ic_input_delete));
isExtendend = true;
} else if (isExtendend) {
switchLayout(0);
item.setIcon(getResources().getDrawable(
android.R.drawable.ic_input_add));
isExtendend = false;
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
void switchLayout(int index) {
// fullscreen
if (index == 0) {
imgV = (ImageView) findViewById(R.id.playerView_fullscreen);
recording.graphicsContext().setImageView(imgV);
switcher.setDisplayedChild(0);
for (int i = 0; i < length; i++) {
IndexEntry entry = recording.getIndex().get(i);
layout.addView(entry);
System.out.println("Index " + i + " has thumbnail "
+ entry.hasThumbnail());
}
// extended View
if (index == 1) {
imgV = (ImageView) findViewById(R.id.playerView_extended);
// recording.graphicsContext().refresh();
recording.graphicsContext().setImageView(imgV);
switcher.setDisplayedChild(1);
scrollView.addView(layout);
}
}
}
// TeleTeachingTool - Presentation Recording With Automated Indexing
//
// Copyright (C) 2003-2008 Peter Ziewer - Technische Universit?t M?nchen
//
// This file is part of TeleTeachingTool.
//
// TeleTeachingTool is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// TeleTeachingTool is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with TeleTeachingTool. If not, see <http://www.gnu.org/licenses/>.
/*
* Created on 23.02.2006
*
* Author: Peter Ziewer, TU Munich, Germany - ziewer@in.tum.de
*/
package tttclient.ttt;
import android.graphics.drawable.shapes.Shape;
public class ColoredShape {
int color;
Shape shape;
boolean filled;
public ColoredShape(int color, Shape shape, boolean filled) {
this.color = color;
this.shape = shape;
this.filled = filled;
}
}
......@@ -26,7 +26,7 @@ public class GraphicsContext implements MessageConsumer {
private Canvas scaledCanvas;
private final BitmapContainer bitmapContainer;
private Bitmap scaledBitmap;
private final ImageView imgView;
private ImageView imgView;
private boolean refreshEnabled = true;
private final MessageProducer producer;
private final ProtocolPreferences prefs;
......@@ -90,10 +90,10 @@ public class GraphicsContext implements MessageConsumer {
public void handleMessage(android.os.Message inputMessage) {
// Gets the image task from the incoming Message object.
Bitmap bitmap = (Bitmap) inputMessage.obj;
Bitmap.createScaledBitmap(bitmap, screenWidth, screenHeight,
true);
// Bitmap.createScaledBitmap(bitmap, screenWidth, screenHeight,
// true);
imgView.setImageBitmap(bitmap);
imgView.invalidate();
// imgView.invalidate();
}
};
......@@ -107,6 +107,10 @@ public class GraphicsContext implements MessageConsumer {
return refreshEnabled;
}
public void setImageView(ImageView imgV) {
this.imgView = imgV;
}
public int[] getPixels() {
return this.pixels;
}
......@@ -142,7 +146,6 @@ public class GraphicsContext implements MessageConsumer {
// }
public void updateView(final Bitmap bitmap) {
android.os.Message message = bitmapHandler.obtainMessage(0, bitmap);
message.sendToTarget();
}
......@@ -228,7 +231,8 @@ public class GraphicsContext implements MessageConsumer {
bitmapContainer.getBimap().setPixels(pixels,
x + y * prefs.framebufferWidth, prefs.framebufferWidth, x,
y, w, h);
updateView(bitmapContainer.getBimap());
if (refreshEnabled)
updateView(bitmapContainer.getBimap());
}
}
......
......@@ -45,9 +45,6 @@ public class Index {
public ArrayList<IndexEntry> index = new ArrayList<IndexEntry>();
ArrayList<IndexEntry> search_index = new ArrayList<IndexEntry>();
public int searchbaseFormatStored = NO_SEARCHBASE;
public int searchbaseFormat = NO_SEARCHBASE;
// //////////////////////////////////////////////////////////////////////////////////////////////////////////
// constructors
// //////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -59,6 +56,10 @@ public class Index {
return recording.getProtocolPreferences().framebufferWidth;
}
public Recording getRecording() {
return recording;
}
public Index(Recording recording, Context context) {
this.recording = recording;
this.context = context;
......@@ -290,43 +291,6 @@ public class Index {
index.add(new IndexEntry(context, this));
}
// // write index entries as extension
// public void writeIndexExtension(DataOutputStream out) throws IOException
// {
// if (index != null) {
// // buffer output to determine its length
// ByteArrayOutputStream byteArrayOutputStream = new
// ByteArrayOutputStream();
// DataOutputStream buffer = new DataOutputStream(
// byteArrayOutputStream);
//
// // header
// buffer.writeByte(Constants.EXTENSION_INDEX_TABLE);
// buffer.writeShort(index.size());
// // index table
// for (int i = 0; i < index.size(); i++) {
// IndexEntry indexEntry = index.get(i);
// // timestamp
// buffer.writeInt(indexEntry.getTimestamp());
// // title
// buffer.writeByte(indexEntry.getTitle().length());
// buffer.writeBytes(indexEntry.getTitle());
//
// // write searchbase text (if exist)
// String searchableText = indexEntry.getSearchbase();
// if (searchableText == null || searchableText.length() == 0)
// buffer.writeInt(0);
// else {
// searchbaseFormatStored = Index.XML_SEARCHBASE;
// // NOTE: String.length() not always equals
// // String.getBytes().length
// // depending on the system's character encoding (Umlauts may
// // fail)
// buffer.writeInt(searchableText.getBytes().length);
// buffer.write(searchableText.getBytes());
// }
//
// TODO bufferedImage in Bitmap transformieren
// read one image representing thumbnail
private void readThumbnail(DataInputStream in) throws IOException {
......@@ -346,31 +310,6 @@ public class Index {
}
}
// private void writeThumbnail(IndexEntry indexEntry, DataOutputStream out)
// throws IOException {
// // TODO: write annotated thumbnail for HTML script
//
// // write thumbnail image
// ImageIcon thumbnail = indexEntry.getThumbnail();
// if (thumbnail == null)
// // no thumbnail available
// out.writeInt(0);
// else {
// // buffer to determine size of image
// BufferedImage bufferedImage = new BufferedImage(
// thumbnail.getIconWidth(), thumbnail.getIconHeight(),
// BufferedImage.TYPE_INT_RGB);
// Graphics g = bufferedImage.createGraphics();
// g.drawImage(thumbnail.getImage(), 0, 0, null);
// ByteArrayOutputStream imageOut = new ByteArrayOutputStream();
// ImageIO.write(bufferedImage, "png", imageOut);
// imageOut.flush();
// // write size + image
// out.writeInt(imageOut.size());
// out.write(imageOut.toByteArray());
// }
// }
// ///////////////////////////////////////////
// thumbnail defaults
// ///////////////////////////////////////////
......@@ -548,22 +487,21 @@ public class Index {
// set time of index
IndexEntry indexEntry = index.get(i);
int timestamp = indexEntry.getTimestamp();
// for screenshots Bitmap hast to set but not the display
// for screenshots Bitmap has to set but not the display/audio
recording.setTime(timestamp, false);
// create screenshot
Bitmap screenshot = recording.graphicsContext()
.getScreenshotWithoutAnnotations();
Bitmap scaled = Bitmap
.createScaledBitmap(screenshot, screenshot.getWidth() / 5,
screenshot.getHeight() / 5, true);
// set thumbnail
// faster image scaling
// Image thumbnail = ScriptCreator.getScaledInstance(
// screenshot, recording.prefs.framebufferWidth
// / thumbnail_scale_factor,
// recording.prefs.framebufferHeight
// / thumbnail_scale_factor);
indexEntry.setThumbnail(screenshot);
indexEntry.setThumbnail(scaled);
}
......@@ -730,7 +668,7 @@ public class Index {
// set index
nowPlayingIndex_startingAtZero = i;
// recording.fireIndexChangedEvent(nowPlayingIndex_startingAtZero + 1);
recording.fireIndexChangedEvent(nowPlayingIndex_startingAtZero + 1);
}
public IndexEntry get(int i) {
......@@ -765,10 +703,12 @@ public class Index {
for (int i = 0; i < index.size(); i++)
if (index.get(i).getTimestamp() == timestamp) {
nowPlayingIndex_startingAtZero = i;
// index.get(i).setBackgroundColor(Color.RED);
// index.get
// fire event (index event starting at one)
// recording
// .fireIndexChangedEvent(nowPlayingIndex_startingAtZero + 1);
recording
.fireIndexChangedEvent(nowPlayingIndex_startingAtZero + 1);
// update search result highligting
// recording.graphicsContext().refresh();
......@@ -784,18 +724,18 @@ public class Index {
// final public static int ASCII_SEARCHBASE = 1;
// final public static int XML_SEARCHBASE = 2;
//
// // TOD:; visibility
// public int searchbaseFormatStored = NO_SEARCHBASE;
// public int searchbaseFormat = NO_SEARCHBASE;
//
// public int getSearchbaseFormat() {
// return searchbaseFormat;
// }
//
// public int getSearchbaseFormatStored() {
// return searchbaseFormatStored;