Commit 18f4ba66 by Thomas Krex

Internetverbindung wird für services abgefragt

parent 00b9fb47
eclipse.preferences.version=1
encoding//src/tttclient/messages/annotations/HighlightAnnotation.java=UTF-8
encoding//src/tttclient/ttt/Constants.java=ISO-8859-1
encoding//src/tttclient/ttt/GraphicsContext.java=UTF-8
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
package="de.tum.in.tttclient"
android:versionCode="1"
android:versionName="1.0" >
......@@ -8,6 +8,7 @@
</uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk
android:minSdkVersion="9"
......@@ -15,7 +16,7 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:icon="@drawable/ttt24"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
package="de.tum.in.tttclient"
android:versionCode="1"
android:versionName="1.0" >
......@@ -8,6 +8,7 @@
</uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk
android:minSdkVersion="9"
......@@ -15,7 +16,7 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:icon="@drawable/ttt24"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
......
# cache for current jar dependency. DO NOT EDIT.
# format is <lastModified> <length> <SHA-1> <path>
# Encoding is UTF-8
/** Automatically generated file. DO NOT MODIFY */
package com.example.test;
public final class BuildConfig {
public final static boolean DEBUG = true;
}
\ No newline at end of file
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.example.test;
public final class R {
public static final class attr {
}
public static final class dimen {
/** Default screen margins, per the Android Design guidelines.
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
*/
public static final int activity_horizontal_margin=0x7f040000;
public static final int activity_vertical_margin=0x7f040001;
}
public static final class drawable {
public static final int checked_icon=0x7f020000;
public static final int ic_launcher=0x7f020001;
public static final int my_border=0x7f020002;
public static final int selected_index_border=0x7f020003;
public static final int unchecked_icon=0x7f020004;
}
public static final class id {
public static final int action_settings=0x7f080015;
public static final int add=0x7f080014;
public static final int button_save=0x7f08000e;
public static final int checkBox1=0x7f08000b;
public static final int connect_btn=0x7f08000a;
public static final int extend=0x7f080017;
public static final int feedDetailsLv=0x7f080010;
public static final int feed_list=0x7f08000f;
public static final int indexScrollView=0x7f080003;
public static final int itemTitle=0x7f080012;
public static final int liveChannel_button=0x7f080002;
public static final int playerView_extended=0x7f080004;
public static final int playerView_fullscreen=0x7f080006;
public static final int port_tx=0x7f080009;
public static final int progressBar=0x7f080011;
public static final int scrollView1=0x7f080005;
public static final int search=0x7f080016;
public static final int server_tx=0x7f080008;
public static final int statusIcon=0x7f080013;
public static final int test_button=0x7f080000;
public static final int tx_name=0x7f08000d;
public static final int tx_url=0x7f08000c;
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_extended=0x7f030001;
public static final int activity_player_fullscreen_overlay=0x7f030002;
public static final int activity_player_main=0x7f030003;
public static final int dialog_connect=0x7f030004;
public static final int dialog_feeds=0x7f030005;
public static final int feed_activity=0x7f030006;
public static final int feed_details_activity=0x7f030007;
public static final int list_feeditems=0x7f030008;
}
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 connect=0x7f050004;
public static final int hello_world=0x7f050002;
public static final int multicast=0x7f050008;
public static final int port=0x7f050006;
public static final int prompt_title=0x7f050007;
public static final int server_adresse=0x7f050005;
public static final int wait=0x7f050003;
}
public static final class style {
/**
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
API 11 theme customizations can go here.
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
API 14 theme customizations can go here.
*/
public static final int AppBaseTheme=0x7f060000;
/** Application theme.
All customizations that are NOT specific to a particular API-level can go here.
*/
public static final int AppTheme=0x7f060001;
}
}
......@@ -9,24 +9,6 @@
tools:context=".MainActivity" >
<Button
android:id="@+id/test_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/watch_button"
android:layout_centerHorizontal="true"
android:layout_marginTop="72dp"
android:text="Test" />
<Button
android:id="@+id/liveChannel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="34dp"
android:text="Feedback Channel" />
<Button
android:id="@+id/watch_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
......@@ -3,6 +3,8 @@
<item
android:id="@+id/add"
android:icon="@android:drawable/ic_input_add"
android:showAsAction="always"
android:title="addFeed">
</item>
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">test</string>
<string name="app_name">TTTClient</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="wait">Please Wait. Reading File</string>
......
......@@ -21,8 +21,7 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import com.example.test.R;
import de.tum.in.tttclient.R;
public class FeedActivity extends Activity implements OnItemClickListener,
OnItemLongClickListener {
......
......@@ -20,6 +20,8 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;
......@@ -33,8 +35,7 @@ import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.Toast;
import com.example.test.R;
import de.tum.in.tttclient.R;
public class FeedDetailActivity extends Activity implements
OnItemClickListener, OnItemLongClickListener {
......@@ -160,7 +161,11 @@ public class FeedDetailActivity extends Activity implements
intent.putExtra(Consts.SERVICE_ID, Consts.PARSE_SERVICE_ID);
intent.putExtra(ParseService.URL_STRING, feedUrl);
startService(intent);
if (isNetworkAvailable())
startService(intent);
else
Toast.makeText(getApplicationContext(),
"Internet Connection needed", Toast.LENGTH_LONG).show();
}
......@@ -228,15 +233,19 @@ public class FeedDetailActivity extends Activity implements
public void startDownloadService() {
progressDialog.show();
Intent intent = new Intent(this, DownloadService.class);
intent.putExtra(DownloadService.FILE_NAME, title);
intent.putExtra(DownloadService.FILE_URL, link);
intent.putExtra(DownloadService.PROGRESS_RECEIVER,
new DownloadReceiver(new Handler()));
if (isNetworkAvailable()) {
progressDialog.show();
Intent intent = new Intent(this, DownloadService.class);
intent.putExtra(DownloadService.FILE_NAME, title);
intent.putExtra(DownloadService.FILE_URL, link);
intent.putExtra(DownloadService.PROGRESS_RECEIVER,
new DownloadReceiver(new Handler()));
// Start download service
startService(intent);
// Start download service
startService(intent);
} else
Toast.makeText(getApplicationContext(),
"Internet Connection needed", Toast.LENGTH_LONG).show();
}
......@@ -311,6 +320,13 @@ public class FeedDetailActivity extends Activity implements
return false;
}
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager
.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
public class DownloadReceiver extends ResultReceiver {
public DownloadReceiver(Handler handler) {
......
package tttclient.activities;
import java.net.InetAddress;
import java.net.UnknownHostException;
import tttclient.services.DownloadService;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import com.example.test.R;
import de.tum.in.tttclient.R;
public class MainActivity extends Activity {
......@@ -35,65 +27,50 @@ public class MainActivity extends Activity {
}
});
Button testButton = (Button) findViewById(R.id.test_button);
testButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),
PlayerActivity.class);
intent.putExtra(DownloadService.FILE_NAME,
"Diskrete_Strukturen_2014_01_09");
intent.putExtra(DownloadService.FILE_PATH,
"/mnt/sdcard/ttt/Diskrete_Strukturen_2014_01_09");
startActivity(intent);
}
});
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();
}
});
// 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();
//
// }
// });
}
}
......@@ -14,12 +14,10 @@ import android.os.AsyncTask;
import android.os.Build;
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.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
......@@ -29,8 +27,7 @@ import android.widget.ScrollView;
import android.widget.SearchView;
import android.widget.SearchView.OnQueryTextListener;
import android.widget.ViewSwitcher;
import com.example.test.R;
import de.tum.in.tttclient.R;
public class PlayerActivity extends Activity implements MediaPlayerControl {
......@@ -42,9 +39,6 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
private Recording recording;
private MediaPlayer audioPlayer;
private MediaController audioController;
private SurfaceView surfaceView;
private int imgVHeight;
private int imgVWidth;
private SearchView searchView;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
......@@ -53,7 +47,6 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player_main);
scrollView = (ScrollView) findViewById(R.id.indexScrollView);
// surfaceView = (SurfaceView) findViewById(R.id.playerView_fullscreen);
switcher = (ViewSwitcher) findViewById(R.id.viewSwitcher);
......@@ -68,12 +61,6 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
File audioFile = new File(filePath + "/" + fileName + ".mp3");
audioPlayer = MediaPlayer.create(this, Uri.fromFile(audioFile));
Log.d("Player", " width: " + imgVWidth + " , height: " + imgVHeight);
Display display = getWindowManager().getDefaultDisplay();
final int screenWidth = display.getWidth(); // deprecated
final int screenHeight = display.getHeight(); // deprecated
audioController = new MediaController(this);
audioController.setMediaPlayer(this);
audioController.setHorizontalScrollBarEnabled(false);
......
......@@ -48,8 +48,19 @@ public class GraphicsContext implements MessageConsumer {
private final byte[] hextile_fg_encoded;
private final int[] pixels;
public Recording getRecording() {
return recording;
public static void fillRect(int[] array, Rect r, int color, int screenWidth) {
int x = r.left;
int y = r.top;
int w = r.width();
int h = r.height();
for (int i = y; i < y + h; i++) {
int offset = i * screenWidth + x;
for (int j = 0; j < w; j++) {
array[offset + j] = color;
}
}
}
public GraphicsContext(ImageView imgV, Recording record) {
......@@ -73,6 +84,9 @@ public class GraphicsContext implements MessageConsumer {
hextile_bg_encoded = new byte[prefs.bytesPerPixel];
hextile_fg_encoded = new byte[prefs.bytesPerPixel];
// hanlder do tasks, which has to be done in the UI-Thread
// Updating of ImageView
viewHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(android.os.Message inputMessage) {
......@@ -86,7 +100,7 @@ public class GraphicsContext implements MessageConsumer {
}
};
// Updating of ScrollView
scrollHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(android.os.Message inputMessage) {
......@@ -111,44 +125,29 @@ public class GraphicsContext implements MessageConsumer {
//
// }
public static void fillRect(int[] array, Rect r, int color, int screenWidth) {
int x = r.left;
int y = r.top;
int w = r.width();
int h = r.height();
for (int i = y; i < y + h; i++) {
int offset = i * screenWidth + x;
for (int j = 0; j < w; j++) {
array[offset + j] = color;
}
}
}
public static void borderRect(int[] array, Rect r, int color,
int screenWidth) {
int x = r.left;
int y = r.top;
int w = r.width();
int h = r.height();
for (int i = y; i < y + h; i++) {
int offset = i * screenWidth + x;
if (i == y || i == y + h - 1) {
for (int j = 0; j < w; j++) {
array[offset + j] = color;
}
} else {
for (int j = 0; j < w; j++) {
if (j == 0 || j == w - 1)
array[offset + j] = color;
}
}
}
}
// public static void borderRect(int[] array, Rect r, int color,
// int screenWidth) {
// int x = r.left;
// int y = r.top;
// int w = r.width();
// int h = r.height();
//
// for (int i = y; i < y + h; i++) {
// int offset = i * screenWidth + x;
// if (i == y || i == y + h - 1) {
// for (int j = 0; j < w; j++) {
//
// array[offset + j] = color;
// }
// } else {
// for (int j = 0; j < w; j++) {
// if (j == 0 || j == w - 1)
// array[offset + j] = color;
// }
//
// }
// }
// }
// public void updateOverlay() {
//
......@@ -184,6 +183,10 @@ public class GraphicsContext implements MessageConsumer {
return this.prefs;
}
public Recording getRecording() {
return recording;
}
public byte[] getHextile_bg_encoded() {
return hextile_bg_encoded;
}
......@@ -196,6 +199,7 @@ public class GraphicsContext implements MessageConsumer {
return this.scrollHandler;
}
// TODO welche Methoden werden wann benötigt
// draw Canvas on current Bitmap
public void updateCanvas() {
if (refreshEnabled) {
......@@ -272,7 +276,6 @@ public class GraphicsContext implements MessageConsumer {
bitmapContainer.getBimap().setPixels(pixels,
x + y * prefs.framebufferWidth, prefs.framebufferWidth, x,
y, w, h);
Rect change = new Rect(x, y, x + w, y + h);
// bitmapContainer.getBimap().setPixels(pixels, 0,
// prefs.framebufferWidth, 0, 0, prefs.framebufferWidth,
......@@ -376,8 +379,6 @@ public class GraphicsContext implements MessageConsumer {
}
// show desktop
return scaledScreenshot;
}
......
......@@ -122,15 +122,6 @@ public class Recording extends MessageProducerAdapter implements Runnable {
setTime(0, true);
}
// public void setIndexViewer(ScrollView scrollView) {
// this.indexViewer = scrollView;
// }
public ScrollView getIndexViewer() {
return indexViewer;
}
void read(File file) throws IOException {
DataInputStream in = new DataInputStream(new BufferedInputStream(
......@@ -157,9 +148,6 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// read body of recording
messages.readMessages(in);
// read search bases
// TODO: upercase ending??
// readSearchbaseFromFile();
}
@Override
......@@ -269,9 +257,6 @@ public class Recording extends MessageProducerAdapter implements Runnable {
parseExtensions();
// no original, but modified recording
if (extensions.size() > 0)
original = false;
}
private void parseExtensions() throws IOException {
......@@ -421,11 +406,6 @@ public class Recording extends MessageProducerAdapter implements Runnable {
next_message = next;
}
// public void highlightSearchResults(Canvas canvas) {
// index.highlightSearchResultsOfCurrentIndex(canvas);
//
// }
public void highlightSearchResults(Canvas canvas) {
// int[] pixelCopy = new int[graphicsContext().getPixels().length];
// System.arraycopy(graphicsContext().getPixels(), 0, pixelCopy, 0,
......@@ -435,11 +415,14 @@ public class Recording extends MessageProducerAdapter implements Runnable {
}
// /*******************************************************************************************************************
// * playback control *
// ******************************************************************************************************************/
//
private Thread thread;