Commit d3abf1ff by Alisa Jung

meh zwischenstand, aber android studio ist abgeschmiert. hab paar activities gemacht.

parent c7a9c696
......@@ -23,4 +23,5 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
}
......@@ -15,6 +15,11 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ManagePlaylistsActivity"
android:label="@string/title_activity_manage_playlists"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".PlaylistEditor"></activity>
</application>
</manifest>
\ No newline at end of file
package com.soundapp.alisajung.ambientsounds;
import android.content.ContentResolver;
import android.content.Intent;
import android.database.Cursor;
import android.media.MediaPlayer;
import android.net.Uri;
......@@ -22,12 +23,23 @@ public class MainActivity extends AppCompatActivity {
private static final String TAG = "LOGTAG";
public void loadEditPlaylistsActivity(View view){
Log.d(TAG,"Button pressed");
Intent intent = new Intent(this, ManagePlaylistsActivity.class);
startActivity(intent);
}
public void stopAll(View view){
Log.d(TAG, "TODO: stop playing stuff.");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mediaList = (ListView) findViewById(R.id.medialist1);
/* mediaList = (ListView) findViewById(R.id.medialist1);
ContentResolver cr = getContentResolver();
mediaImporter = new MediaImporter(cr,mediaList, getApplicationContext());
......@@ -43,6 +55,6 @@ public class MainActivity extends AppCompatActivity {
});
loadMediaButton = (Button) findViewById(R.id.loadmedia);
loadMediaButton.setOnClickListener(mediaImporter);
loadMediaButton.setOnClickListener(mediaImporter);*/
}
}
package com.soundapp.alisajung.ambientsounds;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
public class ManagePlaylistsActivity extends AppCompatActivity {
public static int PLAYLIST_ADD = 0;
public static int PLAYLIST_EDIT = 1;
public static String EDIT_MODE = "editmode";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manage_playlists);
}
public void backToMainMenu(View view){
Log.d("Hallo", "Back To main Menu pressed");
finish();
}
public void addPlaylist(View view){
Log.d("Hallo", "TODO: Add Playlist");
Intent intent = new Intent(this, PlaylistEditor.class);
int message = PLAYLIST_ADD;
intent.putExtra(EDIT_MODE,PLAYLIST_ADD);
startActivity(intent);
}
}
package com.soundapp.alisajung.ambientsounds;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import java.io.IOException;
import java.util.ArrayList;
public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnItemClickListener {
private ContentResolver contentResolver;
private static String LOGTAG = "Media Importer";
private ListView mediaListView;
private Context context;
private ArrayList arrayListTitles;
private ArrayList<Long> arrayListIds;
private ArrayAdapter arrayAdapater;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_playlist_editor);
mediaListView = (ListView) findViewById(R.id.medialist1);
ContentResolver cr = getContentResolver();
Intent intent = getIntent();
int message = intent.getIntExtra(ManagePlaylistsActivity.EDIT_MODE,-1);
Log.d("Hilfe", "Test");
Log.d("Hilfe", "Message: " + message);
if (message == ManagePlaylistsActivity.PLAYLIST_ADD){
Log.d("Hilfe", "bla");
arrayListIds = new ArrayList<Long>();
Log.d("Hilfe", "bla4");
mediaListView.setOnItemClickListener(this);
Log.d("Hilfe", "bla5");
//loadMedia();
//Log.d("Hilfe", "bla3");
}
else if (message == ManagePlaylistsActivity.PLAYLIST_EDIT){
}
else{
Log.d("Hilfe", "FUCK FUCK FUCK "+message + " sollte " + ManagePlaylistsActivity.PLAYLIST_ADD);
}
}
private void loadMedia() {
Uri uri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
Cursor cursor = contentResolver.query(uri, null, null, null, null);
long lastid = 0;
if (cursor == null) {
Log.d(LOGTAG, "Cursor fail");
// query failed, handle error.
} else if (!cursor.moveToFirst()) {
Log.d(LOGTAG, "Curser move fist fail");
// no media on the device
} else {
Log.d(LOGTAG, "Stuff.");
arrayListTitles = new ArrayList();
arrayAdapater = new ArrayAdapter(context, android.R.layout.simple_list_item_1, arrayListTitles);
mediaListView.setAdapter(arrayAdapater);
int titleColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Media.TITLE);
int idColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Media._ID);
arrayListIds.clear();
arrayListTitles.clear();
do {
long thisId = cursor.getLong(idColumn);
String thisTitle = cursor.getString(titleColumn);
Log.d(LOGTAG, "Logging!" + thisTitle);
// ...process entry...
lastid = thisId;
arrayListTitles.add(thisTitle);
arrayListIds.add(thisId);
} while (cursor.moveToNext());
// playSongWithID(lastid);
}
}
public void playSongWithID(long id){
Log.d(LOGTAG, "Try playing ");
Uri contentUri = ContentUris.withAppendedId(
android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id);
MediaPlayer mMediaPlayer = new MediaPlayer();
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mMediaPlayer.setDataSource(context, contentUri);
} catch (IOException e) {
Log.d(LOGTAG, "Fail. mist.");
e.printStackTrace();
}
try {
mMediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mMediaPlayer.start();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
playSongWithID(arrayListIds.get(position));
}
}
......@@ -9,36 +9,31 @@
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.soundapp.alisajung.ambientsounds.MainActivity">
<TextView
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="toller text"
android:id="@+id/textView" />
android:id="@+id/medialist1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="58dp"
android:clickable="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Play Sample"
android:id="@+id/sampleButton1"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
android:text="Edit Lists"
android:id="@+id/editlists"
android:onClick="loadEditPlaylistsActivity"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Load Media"
android:id="@+id/loadmedia"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true" />
android:text="Stop all"
android:id="@+id/button5"
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/medialist1"
android:layout_below="@+id/sampleButton1"
android:onClick="stopAll"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="58dp"
android:clickable="true" />
android:layout_alignParentStart="true" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.soundapp.alisajung.ambientsounds.ManagePlaylistsActivity">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="@+id/button2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back"
android:id="@+id/button2"
android:onClick="backToMainMenu"
android:layout_alignTop="@+id/button3"
android:layout_alignRight="@+id/listView2"
android:layout_alignEnd="@+id/listView2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add List"
android:id="@+id/button3"
android:onClick="addPlaylist"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.soundapp.alisajung.ambientsounds.PlaylistEditor">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:text="Playlist_Name" />
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/medialist1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/editText" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Done"
android:id="@+id/button2"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete List"
android:id="@+id/button3"
android:layout_alignTop="@+id/button2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>
......@@ -2,4 +2,5 @@
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>
<resources>
<string name="app_name">AmbientSounds</string>
<string name="title_activity_manage_playlists">ManagePlaylistsActivity</string>
</resources>
......@@ -8,4 +8,13 @@
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
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