Commit aec08a36 authored by Thomas Krex's avatar Thomas Krex

+ Umstellung auf Drawer Layout:

	Indexansicht kann durch swipe oder toggle in der Actionbar angezeigt werden. Dafür wurde eine neue Project Library hinzugefügt, da es Probleme zwischen der Sherlock Actionbar und dem 	ActionBarDrawerToggle gibt. App stürzt seltsamer Weise bei einem Icon für diesen Toggle ab. MediaController reagiert nicht bei Berührung des Bildschirms -> neuer OnClickListener für SurfaceView
parent f099e24e
......@@ -14,3 +14,4 @@
target=android-19
android.library=false
android.library.reference.1=../../Downloads/JakeWharton-ActionBarSherlock-5a15d92/actionbarsherlock
android.library.reference.2=../../Arbeit_workspace/DrawerToggleLibrary
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -4,26 +4,24 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<SurfaceView
android:id="@+id/playerView_fullscreen"
android:layout_width="wrap_content"
android:id="@+id/playerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"/>
</FrameLayout>
<!-- The navigation drawer -->
<!-- <ListView android:id="@+id/left_drawer" -->
<!-- android:layout_width="240dp" -->
<!-- android:layout_height="match_parent" -->
<!-- android:layout_gravity="start" -->
<!-- android:choiceMode="singleChoice" -->
<!-- android:divider="@android:color/transparent" -->
<!-- android:dividerHeight="0dp" -->
<!-- android:background="#111"/> -->
</LinearLayout>
</LinearLayout>
<ScrollView
android:id="@+id/indexScrollView"
......
......@@ -29,5 +29,7 @@
<color name="light_gray">#66bfbdbd</color>
<color name="trans_blue">#660063d2</color>
<color name="trans_black">#d1212427</color>
<string name="drawer_open">Open Index Navigation</string>
<string name="drawer_close">Close Index Navigation</string>
</resources>
\ No newline at end of file
......@@ -6,15 +6,17 @@ import java.io.IOException;
import tttclient.core.Recording;
import tttclient.services.DownloadService;
import android.app.ProgressDialog;
import android.content.res.Configuration;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.DrawerLayout.DrawerListener;
import android.view.ContextThemeWrapper;
import android.view.Display;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
......@@ -23,11 +25,10 @@ import android.view.inputmethod.EditorInfo;
import android.widget.LinearLayout;
import android.widget.MediaController;
import android.widget.MediaController.MediaPlayerControl;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.ViewSwitcher;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.app.ActionBarSherlockDrawerToggle;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
......@@ -46,37 +47,92 @@ import de.tum.in.tttclient.R;
* @author Thomas Krex
*
*/
public class PlayerActivity extends SherlockActivity implements
public class PlayerActivity extends SherlockFragmentActivity implements
MediaPlayerControl {
static final int LAYOUT_MODE_FULL = 0;
static final int LAYOUT_MODE_EXTENDED = 1;
public String fileName;
public String filePath;
private RelativeLayout parentView;
private LinearLayout content;
private LinearLayout container;
public SurfaceView surfaceView;
private SurfaceHolder sHolder;
private ViewSwitcher switcher;
private ScrollView scrollView;
private Recording recording;
private MediaPlayer audioPlayer;
private MediaController audioController;
private SearchView searchView;
private DrawerLayout mDrawerLayout;
private ActionBarSherlockDrawerToggle mDrawerToggle;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player_overlapping);
setContentView(R.layout.activity_player_navigation_drawer);
/*******************************************************************************************************************
* SetUp of DrawerToggle in ActionBar *
******************************************************************************************************************/
// TODO crash with other toggle icon
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = new ActionBarSherlockDrawerToggle(this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.drawable.ttt24, /* nav drawer icon to replace 'Up' caret */
R.string.drawer_open, /* "open drawer" description */
R.string.drawer_close /* "close drawer" description */
);
mDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerLayout.setDrawerListener(new DrawerListener() {
@Override
public void onDrawerStateChanged(int newState) {
mDrawerToggle.onDrawerStateChanged(newState);
}
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
mDrawerToggle.onDrawerSlide(drawerView, slideOffset);
}
@Override
public void onDrawerOpened(View drawerView) {
mDrawerToggle.onDrawerOpened(drawerView);
}
@Override
public void onDrawerClosed(View drawerView) {
mDrawerToggle.onDrawerClosed(drawerView);
}
});
// Set the drawer toggle as the DrawerListener
mDrawerLayout.setDrawerListener(mDrawerToggle);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
/*******************************************************************************************************************
* Main Initialization *
********************************************************************************************************************/
scrollView = (ScrollView) findViewById(R.id.indexScrollView);
// needed as anchor of the MediaController
parentView = (RelativeLayout) findViewById(R.id.parentView);
content = (LinearLayout) findViewById(R.id.content);
// container of SurfaceView
container = (LinearLayout) findViewById(R.id.container);
surfaceView = (SurfaceView) findViewById(R.id.playerView);
surfaceView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
audioController.show();
}
});
fileName = getIntent().getStringExtra(DownloadService.FILE_NAME);
setTitle(fileName);
filePath = getIntent().getStringExtra(DownloadService.FILE_PATH);
......@@ -148,7 +204,7 @@ public class PlayerActivity extends SherlockActivity implements
audioController.setPrevNextListeners(nextListener,
prevListener);
audioController.setAnchorView(parentView);
audioController.setAnchorView(content);
} catch (IOException e) {
// TODO Auto-generated catch block
......@@ -172,6 +228,13 @@ public class PlayerActivity extends SherlockActivity implements
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
mDrawerToggle.syncState();
}
@Override
protected void onPause() {
......@@ -195,6 +258,12 @@ public class PlayerActivity extends SherlockActivity implements
audioPlayer.release();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
mDrawerToggle.onConfigurationChanged(newConfig);
}
/*******************************************************************************************************************
* Methods of MediaPlayerControl *
******************************************************************************************************************/
......@@ -305,6 +374,10 @@ public class PlayerActivity extends SherlockActivity implements
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
switch (item.getItemId()) {
// handle layout switch
case R.id.extend:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment