Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
Torkild Retvedt authored and Torkild Retvedt committed Sep 21, 2010
0 parents commit 92b66b8
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="bin"/>
</classpath>
33 changes: 33 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Trommelyd</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
15 changes: 15 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="no.trommelyd.android"
android:versionCode="1" android:versionName="0.1">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".trommelyd"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
</manifest>
11 changes: 11 additions & 0 deletions default.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-3
Binary file added res/drawable/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/tromme_post.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/tromme_pre.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions res/drawable/trommebutton.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="true"
android:state_pressed="false"
android:drawable="@drawable/tromme_pre" />
<item
android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/tromme_post" />
<item
android:state_focused="false"
android:state_pressed="true"
android:drawable="@drawable/tromme_post" />
<item
android:drawable="@drawable/tromme_pre" />
</selector>
14 changes: 14 additions & 0 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#6a6a6a">

<ImageView
android:id="@+id/TrommelydButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/trommebutton"
android:layout_centerInParent="true"
android:clickable="true" />
</RelativeLayout>
Binary file added res/raw/trommelyd.wav
Binary file not shown.
5 changes: 5 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">Trommelyd</string>
</resources>
68 changes: 68 additions & 0 deletions src/no/trommelyd/android/trommelyd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package no.trommelyd.android;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class trommelyd extends Activity {

private volatile MediaPlayer trommelydPlayer;

// Event handler for button click
private OnClickListener trommelydButtonListener = new OnClickListener() {
public void onClick(View v) {
if (trommelydPlayer.isPlaying()) {
trommelydPlayer.seekTo(0);
} else {
trommelydPlayer.start();
}
}
};

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
//this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

// main layout
setContentView(R.layout.main);

// Capture our button from layout
ImageView trommelydButton = (ImageView)findViewById(R.id.TrommelydButton);

// Register the onClick listener with the implementation above
if (trommelydButton != null)
trommelydButton.setOnClickListener(trommelydButtonListener);

trommelydPlayer = MediaPlayer.create(getBaseContext(), R.raw.trommelyd);

// when playback is complete, prepare for next play
trommelydPlayer.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
mp.stop();
mp.prepareAsync();
}
});

// when media is prepared, make sure position is correct
trommelydPlayer.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.seekTo(0);
}
});
}

}

0 comments on commit 92b66b8

Please sign in to comment.