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());
}
}
......
This diff is collapsed.
package tttclient.ttt;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import tttclient.messages.Annotation;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageButton;
public class IndexEntry extends ImageButton {
......@@ -12,15 +15,13 @@ public class IndexEntry extends ImageButton {
private final Index index;
private Bitmap thumbnail;
private String title = "";
private final String searchbase_of_page;
private String searchbase_of_page;
private ArrayList<SearchBaseEntry> words;
private ArrayList<Annotation> annotations;
private boolean hasThumbnail = false;
// private ArrayList<SearchBaseEntry> words;
// private Index index;
public IndexEntry(Context context, Index index, String title,
public IndexEntry(Context context, final Index index, String title,
int timestamp, String searchableText, Bitmap thumbnail) {
super(context);
this.index = index;
......@@ -28,6 +29,15 @@ public class IndexEntry extends ImageButton {
this.title = title;
this.searchbase_of_page = searchableText;
this.thumbnail = thumbnail;
this.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
index.getRecording().setTime(IndexEntry.this.timestamp, true);
}
});
}
public IndexEntry(Context context, Index index) {
......@@ -70,4 +80,83 @@ public class IndexEntry extends ImageButton {
return hasThumbnail;
}
// read words and coordinates for this index
public void readSearchbase(DataInputStream in, double ratio)
throws IOException {
// TODO: maybe compare or overwrite
ArrayList<SearchBaseEntry> words = new ArrayList<SearchBaseEntry>();
int number_of_words = in.readShort();
for (int i = 0; i < number_of_words; i++)
words.add(SearchBaseEntry.read(in, ratio));
// now set words
// NOTE: setting all at once will update searchbase of Index Extension
// (used for backward compatibility)
setSearchbase(words);
}
// set ASCII searchbase
public void setSearchbase(String searchbase) {
// TODO: umlaut reduction
this.searchbase_of_page = searchbase;
}
// set searchbase with per word coordinates (from XML)
public void setSearchbase(ArrayList<SearchBaseEntry> words) {
this.words = words;
// overwrite searchbase string for page
String page_string = "";
for (int i = 0; i < words.size(); i++)
page_string += words.get(i).searchText + " ";
setSearchbase(page_string);
}
// perform search
// public boolean contains(String searchword) {
// // empty search
// if (searchword == null || searchword.equals("")) {
// results.clear();
// return false;
// }
//
// // ASCII searchbase
// if (words == null)
// return searchbase_of_page.toLowerCase().indexOf(
// searchword.toLowerCase()) >= 0;
//
// // XML searchbase
// else
// return getSearchResults(searchword);
// }
private final ArrayList<ColoredShape> results = new ArrayList<ColoredShape>();
// // perform advanced search (XML searchbase with coordinates)
// private boolean getSearchResults(String searchword) {
// results.clear();
//
// if (words != null) {
// for (int i = 0; i < words.size(); i++)
// words.get(i).contains(searchword, results);
// }
//
// // any result found?
// return results.size() > 0;
// }
// public void highlightSearchResults() {
// if (results != null)
// for (int i = 0; i < results.size(); i++) {
// ColoredShape shape = results.get(i);
// g.setColor(shape.color);
// if (shape.filled)
// g.fill(shape.shape);
// else
// g.draw(shape.shape);
// }
// }
}
This diff is collapsed.
// 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 08.09.2005
*
* Author: Peter Ziewer, TU Munich, Germany - ziewer@in.tum.de
*/
package tttclient.ttt;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import android.graphics.Color;
/**
* @author ziewer
*
* To change the template for this generated type comment go to
* Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
*/
public class SearchBaseEntry {
// character widths for dynamic underlining
static int[] widths = new int[256];
// static {
// // choose standard font (proportions will be similar for other fonts)
// Font f = new Font("Serif", Font.PLAIN, 16);
// FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(f);
//
// // determine size of printable characters (all others will be zero)
// for (char c = 32; c < 127; c++)
// widths[c] = metrics.charWidth(c);
// for (char c = 161; c < 256; c++)
// widths[c] = metrics.charWidth(c);
// }
private final int x, y, width, height;
// TODO: maybe ratio should be handled in index
private double ratio = 1;
double getRatio() {
return ratio;
}
String searchText = "";
String searchTextOriginal = "";
public SearchBaseEntry(String searchtext, int x, int y, int width,
int height, double ratio) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.ratio = ratio;
this.searchTextOriginal = searchtext;
this.searchText = Constants.reduce(searchtext);
}
// for highlighting search results
static int borderSize = 6;
static int highlighColor = Color.argb(64, Color.red(Color.CYAN),
Color.green(Color.CYAN), Color.blue(Color.CYAN));
static int underlineColor = Color.RED;
static int borderColor = Color.argb(192, Color.red(Color.RED),
Color.green(Color.RED), Color.blue(Color.RED));
// TODO: return value not used / think about naming of method
// adds words from searchbase containing searchword to resultss
// public boolean contains(String searchword, ArrayList<ColoredShape>
// results) {
// // System.out.println(searchText);
// if (searchText.indexOf(Constants.reduce(searchword)) >= 0) {
//
// // highlight search results
// if (results != null) {
// // NOTE: explicit round to avoid java drawing bug (different
// // rounding if color is transparent)
// Rect rectangle = new Rect((int) (getX() - borderSize),
// (int) (getY() - borderSize),
// (int) (getWidth() + 2 * borderSize),
// (int) (getHeight() + 2 * borderSize));
//
// // highlight
// results.add(new ColoredShape(highlighColor, rectangle, true));
//
// // border
// results.add(new ColoredShape(borderColor, rectangle, false));
//
// // underline results
// boolean fixedSize = false;
// if (fixedSize) {
// // using fixed sized font
// // TODO: use character specific letter size - variable sized
// // font
// double sizeOfLetter = (getWidth()) / searchText.length();
// int indexOf = -1;
// // System.out.println("\"" + result.searchText + "\"");
// while (-1 != (indexOf = searchText.indexOf(searchword,
// indexOf + 1))) {
// // System.out.println(indexOf + "\t" + sizeOfLetter +
// // "\t" + (result.right - result.left));
// results.add(new ColoredShape(underlineColor, new Rect(
// getX() + sizeOfLetter * indexOf, getY()
// + getHeight() + borderSize - 2,
// sizeOfLetter * (searchword.length()), 4), true));
// }
//
// // TODO: only for testing - remove
// // letter ticks
// if (!false)
// for (int j = 0; j <= searchText.length(); j++) {
// results.add(new ColoredShape(underlineColor,
// new Line2D.Double(
// getX() + j * sizeOfLetter, getY()
// + getHeight() - 3, getX()
// + j * sizeOfLetter, getY()
// + getHeight() + 3), false));
// }
// } else {