This commit is contained in:
2011-12-18 14:31:27 +00:00
parent 26ca75f4c1
commit 433ee4b734
24 changed files with 6878 additions and 0 deletions

8
AutoPlayer/.classpath Normal file
View File

@@ -0,0 +1,8 @@
<?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="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

40
AutoPlayer/.project Normal file
View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AutoPlayer</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>
<linkedResources>
<link>
<name>ExceptionHandlerLib_src</name>
<type>2</type>
<locationURI>_android_ExceptionHandlerLib_7d68b46a/src</locationURI>
</link>
</linkedResources>
</projectDescription>

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.TwentyCodes.android.AutoPlayer"
android:versionCode="3"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" >
</uses-permission>
<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
<activity
android:name=".AutoPlayerActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.TwentyCodes.android.exception.ExceptionReportActivity" >
</activity>
<receiver android:name="HeadPhoneReceiver" >
<intent-filter>
<action android:name="android.intent.action.HEADSET_PLUG" >
</action>
</intent-filter>
</receiver>
<receiver android:name="BootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" >
</action>
</intent-filter>
</receiver>
<service android:name="HeadphoneListenerService" >
</service>
<activity
android:name="ConfirmDialog"
android:configChanges="keyboard|keyboardHidden|orientation"
android:launchMode="singleInstance"
android:theme="@android:style/Theme.Dialog" >
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,18 @@
# exceptionhandler.properties
# This is the default Twenty Codes, LLC Exception Handler properties file
#
# @author Twenty Codes, LLC
# @author ricky barrette
# The following is for using our custom server based exception handler web application
# server is the physical web address for your server
# file is the path to your filing script
# get is the path to your json retrieval script
server = http://powers.doesntexist.com:666
file = /index.php?post=1
#get = /index.php?get=1
# uncomment the following if you want your application to use email to file reports.
# if this is uncommented, email will always be used.
#email = twentycodes@gmail.com

View File

@@ -0,0 +1,59 @@
/* 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.TwentyCodes.android.AutoPlayer;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int about=0x7f05000e;
public static final int activty_picker_button=0x7f05000a;
public static final int app_icon=0x7f050001;
public static final int body=0x7f050002;
public static final int confirmCheckBox=0x7f05000d;
public static final int description=0x7f050006;
public static final int exception_text=0x7f050008;
public static final int exception_title=0x7f050007;
public static final int linearLayout1=0x7f050000;
public static final int music_volume=0x7f05000c;
public static final int music_volume_tag=0x7f05000b;
public static final int okButton=0x7f050004;
public static final int progressBar=0x7f050003;
public static final int send=0x7f050005;
public static final int toggleButton=0x7f050009;
public static final int version=0x7f05000f;
}
public static final class layout {
public static final int confirm_dialog=0x7f030000;
public static final int exception_activity=0x7f030001;
public static final int exception_list_item=0x7f030002;
public static final int list=0x7f030003;
public static final int main=0x7f030004;
}
public static final class string {
public static final int about=0x7f04000b;
public static final int app_name=0x7f040007;
public static final int build=0x7f04000f;
public static final int confirm=0x7f04000d;
public static final int crash=0x7f040000;
public static final int description=0x7f040004;
public static final int enable=0x7f04000c;
public static final int hello=0x7f040006;
public static final int loading=0x7f04000a;
public static final int music_volume=0x7f040008;
public static final int pick_an_activity=0x7f040009;
public static final int send=0x7f040003;
public static final int sending=0x7f040002;
public static final int sorry=0x7f040001;
public static final int start=0x7f04000e;
public static final int version=0x7f040005;
}
}

View File

@@ -0,0 +1,59 @@
/* 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.TwentyCodes.android.exception;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int about=0x7f05000e;
public static final int activty_picker_button=0x7f05000a;
public static final int app_icon=0x7f050001;
public static final int body=0x7f050002;
public static final int confirmCheckBox=0x7f05000d;
public static final int description=0x7f050006;
public static final int exception_text=0x7f050008;
public static final int exception_title=0x7f050007;
public static final int linearLayout1=0x7f050000;
public static final int music_volume=0x7f05000c;
public static final int music_volume_tag=0x7f05000b;
public static final int okButton=0x7f050004;
public static final int progressBar=0x7f050003;
public static final int send=0x7f050005;
public static final int toggleButton=0x7f050009;
public static final int version=0x7f05000f;
}
public static final class layout {
public static final int confirm_dialog=0x7f030000;
public static final int exception_activity=0x7f030001;
public static final int exception_list_item=0x7f030002;
public static final int list=0x7f030003;
public static final int main=0x7f030004;
}
public static final class string {
public static final int about=0x7f04000b;
public static final int app_name=0x7f040007;
public static final int build=0x7f04000f;
public static final int confirm=0x7f04000d;
public static final int crash=0x7f040000;
public static final int description=0x7f040004;
public static final int enable=0x7f04000c;
public static final int hello=0x7f040006;
public static final int loading=0x7f04000a;
public static final int music_volume=0x7f040008;
public static final int pick_an_activity=0x7f040009;
public static final int send=0x7f040003;
public static final int sending=0x7f040002;
public static final int sorry=0x7f040001;
public static final int start=0x7f04000e;
public static final int version=0x7f040005;
}
}

3
AutoPlayer/lint.xml Normal file
View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>

36
AutoPlayer/proguard.cfg Normal file
View File

@@ -0,0 +1,36 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

5663
AutoPlayer/proguard/dump.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,106 @@
com.TwentyCodes.android.AutoPlayer.AutoPlayerActivity -> com.TwentyCodes.android.AutoPlayer.AutoPlayerActivity:
android.content.SharedPreferences mSettings -> a
android.widget.ImageView mAppIcon -> b
android.app.ProgressDialog mProgress -> c
void onCreate(android.os.Bundle) -> onCreate
void onClick(android.view.View) -> onClick
void onActivityResult(int,int,android.content.Intent) -> onActivityResult
void onProgressChanged(android.widget.SeekBar,int,boolean) -> onProgressChanged
void onStartTrackingTouch(android.widget.SeekBar) -> onStartTrackingTouch
void onStopTrackingTouch(android.widget.SeekBar) -> onStopTrackingTouch
void onCheckedChanged(android.widget.CompoundButton,boolean) -> onCheckedChanged
com.TwentyCodes.android.AutoPlayer.BootReceiver -> com.TwentyCodes.android.AutoPlayer.BootReceiver:
void onReceive(android.content.Context,android.content.Intent) -> onReceive
com.TwentyCodes.android.AutoPlayer.ConfirmDialog -> com.TwentyCodes.android.AutoPlayer.ConfirmDialog:
android.media.AudioManager mAudioManager -> a
android.content.SharedPreferences mSettings -> b
android.widget.ProgressBar mProgressBar -> c
android.os.Handler mHandler -> d
java.lang.Thread mTimer -> e
void onClick(android.view.View) -> onClick
void onCreate(android.os.Bundle) -> onCreate
android.os.Handler access$0(com.TwentyCodes.android.AutoPlayer.ConfirmDialog) -> a
android.content.SharedPreferences access$1(com.TwentyCodes.android.AutoPlayer.ConfirmDialog) -> b
android.media.AudioManager access$2(com.TwentyCodes.android.AutoPlayer.ConfirmDialog) -> c
void access$3$243a77b3(com.TwentyCodes.android.AutoPlayer.ConfirmDialog,int) -> a
android.widget.ProgressBar access$4(com.TwentyCodes.android.AutoPlayer.ConfirmDialog) -> d
com.TwentyCodes.android.AutoPlayer.ConfirmDialog$1 -> com.TwentyCodes.android.AutoPlayer.c:
com.TwentyCodes.android.AutoPlayer.ConfirmDialog this$0 -> a
void run() -> run
com.TwentyCodes.android.AutoPlayer.ConfirmDialog$1$1 -> com.TwentyCodes.android.AutoPlayer.a:
com.TwentyCodes.android.AutoPlayer.ConfirmDialog$1 this$1 -> a
void run() -> run
com.TwentyCodes.android.AutoPlayer.ConfirmDialog$2 -> com.TwentyCodes.android.AutoPlayer.b:
com.TwentyCodes.android.AutoPlayer.ConfirmDialog this$0 -> a
void handleMessage(android.os.Message) -> handleMessage
com.TwentyCodes.android.AutoPlayer.HeadPhoneReceiver -> com.TwentyCodes.android.AutoPlayer.HeadPhoneReceiver:
android.media.AudioManager mAudioManager -> a
android.content.SharedPreferences mSettings -> b
android.content.Context mContext -> c
void onReceive(android.content.Context,android.content.Intent) -> onReceive
void setStreamVolume$255f295(int) -> a
com.TwentyCodes.android.AutoPlayer.HeadphoneListenerService -> com.TwentyCodes.android.AutoPlayer.HeadphoneListenerService:
void onCreate() -> onCreate
int onStartCommand(android.content.Intent,int,int) -> onStartCommand
android.os.IBinder onBind(android.content.Intent) -> onBind
com.TwentyCodes.android.exception.ExceptionHandler -> com.TwentyCodes.android.exception.f:
java.lang.Thread$UncaughtExceptionHandler mDefaultUEH -> a
android.app.Activity mApp -> b
android.app.Service mService -> c
android.content.BroadcastReceiver mBroadcastReceiver -> d
android.content.Context mContext -> e
com.TwentyCodes.android.exception.Report mReport -> f
java.lang.String mURL -> g
java.lang.String mEmail -> h
void displayEmailNotification() -> a
void displayNotification(android.content.Intent) -> a
void parseProperties() -> b
void run() -> run
void uncaughtException(java.lang.Thread,java.lang.Throwable) -> uncaughtException
com.TwentyCodes.android.exception.ExceptionReportActivity -> com.TwentyCodes.android.exception.ExceptionReportActivity:
com.TwentyCodes.android.exception.Report mReport -> a
void onCreate(android.os.Bundle) -> onCreate
void onClick(android.view.View) -> onClick
com.TwentyCodes.android.exception.Report access$0(com.TwentyCodes.android.exception.ExceptionReportActivity) -> a
com.TwentyCodes.android.exception.ExceptionReportActivity$1 -> com.TwentyCodes.android.exception.e:
com.TwentyCodes.android.exception.ExceptionReportActivity this$0 -> a
android.app.ProgressDialog val$progress -> b
void run() -> run
com.TwentyCodes.android.exception.Report -> com.TwentyCodes.android.exception.Report:
java.lang.String mUrl -> a
java.util.ArrayList mReport -> b
android.os.Parcelable$Creator CREATOR -> CREATOR
int describeContents() -> describeContents
java.lang.String file() -> a
com.TwentyCodes.android.exception.Report generateReport(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) -> a
java.util.ArrayList getNameValuePairs() -> c
java.util.ArrayList getReport() -> b
com.TwentyCodes.android.exception.Report setDescription(java.lang.String) -> a
java.lang.String toString() -> toString
void writeToParcel(android.os.Parcel,int) -> writeToParcel
com.TwentyCodes.android.exception.Report$1 -> com.TwentyCodes.android.exception.b:
java.lang.Object createFromParcel(android.os.Parcel) -> createFromParcel
java.lang.Object[] newArray(int) -> newArray
com.TwentyCodes.android.exception.ReportAdapter -> com.TwentyCodes.android.exception.c:
java.util.ArrayList mReport -> a
android.view.LayoutInflater mInflater -> b
int getCount() -> getCount
org.apache.http.NameValuePair getItem(int) -> a
long getItemId(int) -> getItemId
android.view.View getView(int,android.view.View,android.view.ViewGroup) -> getView
java.lang.Object getItem(int) -> getItem
com.TwentyCodes.android.exception.ReportAdapter$ViewHolder -> com.TwentyCodes.android.exception.d:
android.widget.TextView title -> a
android.widget.TextView body -> b
com.TwentyCodes.android.exception.ReportAdapter this$0 -> c
com.TwentyCodes.android.exception.ReportItem -> com.TwentyCodes.android.exception.ReportItem:
android.os.Parcelable$Creator CREATOR -> CREATOR
java.lang.String mKey -> a
java.lang.String mValue -> b
int describeContents() -> describeContents
void writeToParcel(android.os.Parcel,int) -> writeToParcel
java.lang.String getKey() -> a
java.lang.String getValue() -> b
com.TwentyCodes.android.exception.ReportItem$1 -> com.TwentyCodes.android.exception.a:
java.lang.Object createFromParcel(android.os.Parcel) -> createFromParcel
java.lang.Object[] newArray(int) -> newArray

View File

@@ -0,0 +1,10 @@
com.TwentyCodes.android.exception.ExceptionReportActivity
com.TwentyCodes.android.AutoPlayer.ConfirmDialog
com.TwentyCodes.android.AutoPlayer.AutoPlayerActivity
com.TwentyCodes.android.AutoPlayer.HeadphoneListenerService
com.TwentyCodes.android.AutoPlayer.HeadPhoneReceiver
com.TwentyCodes.android.AutoPlayer.BootReceiver
com.TwentyCodes.android.exception.ReportItem
com.TwentyCodes.android.exception.ReportItem: android.os.Parcelable$Creator CREATOR
com.TwentyCodes.android.exception.Report
com.TwentyCodes.android.exception.Report: android.os.Parcelable$Creator CREATOR

View File

@@ -0,0 +1,35 @@
com.TwentyCodes.android.AutoPlayer.AutoPlayerActivity:
public static final java.lang.String SETTINGS
public static final java.lang.String KEY_APP
public static final java.lang.String KEY_VOLUME
public static final java.lang.String KEY_CONFIRM
public static final java.lang.String KEY_ENABLED
com.TwentyCodes.android.AutoPlayer.ConfirmDialog:
private static final byte PERIOD
protected static final int COUNT
com.TwentyCodes.android.AutoPlayer.HeadPhoneReceiver:
private static final java.lang.String TAG
private static final java.lang.String LOG
private static final java.lang.String MUSIC_VOLUME
com.TwentyCodes.android.AutoPlayer.R
com.TwentyCodes.android.AutoPlayer.R$attr
com.TwentyCodes.android.AutoPlayer.R$drawable
com.TwentyCodes.android.AutoPlayer.R$id
com.TwentyCodes.android.AutoPlayer.R$layout
com.TwentyCodes.android.AutoPlayer.R$string
com.TwentyCodes.android.exception.ExceptionHandler:
private static final java.lang.String MSG_SUBJECT_TAG
private static final java.lang.String MSG_BODY
protected static final int SIMPLE_NOTFICATION_ID
private static final java.lang.String TAG
82:87:public ExceptionHandler(android.app.Service)
com.TwentyCodes.android.exception.ExceptionReportActivity:
private static final java.lang.String TAG
com.TwentyCodes.android.exception.R
com.TwentyCodes.android.exception.R$attr
com.TwentyCodes.android.exception.R$drawable
com.TwentyCodes.android.exception.R$id
com.TwentyCodes.android.exception.R$layout
com.TwentyCodes.android.exception.R$string
com.TwentyCodes.android.exception.Report:
111:117:public com.TwentyCodes.android.exception.Report generateReport(org.json.JSONObject)

View File

@@ -0,0 +1,13 @@
# 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,
# "ant.properties", and override values to adapt the script to your
# project structure.
android.library.reference.1=../ExceptionHandlerLib
# Project target.
target=android-15
#proguard.config=proguard.cfg

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/app_icon"
android:layout_centerHorizontal="true" >
<TextView
android:id="@+id/body"
android:layout_width="wrap_content"
android:layout_height="@android:dimen/app_icon_size"
android:layout_gravity="center"
android:layout_marginRight="10dip"
android:gravity="center"
android:text="@string/start"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/app_icon"
android:layout_width="@android:dimen/app_icon_size"
android:layout_height="@android:dimen/app_icon_size"
android:layout_gravity="center|center_vertical"
android:layout_marginRight="11dip"
android:layout_toRightOf="@id/body"
android:scaleType="fitCenter" />
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linearLayout1"
android:layout_centerVertical="true"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip" />
<Button
android:id="@+id/okButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/progressBar"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="@android:string/cancel" />
</RelativeLayout>

View File

@@ -0,0 +1,95 @@
<?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" >
<ToggleButton
android:id="@+id/toggleButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:checked="true"
android:text="@string/enable" />
<ImageView
android:id="@+id/app_icon"
android:layout_width="@android:dimen/app_icon_size"
android:layout_height="@android:dimen/app_icon_size"
android:layout_alignParentLeft="true"
android:layout_below="@id/toggleButton"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dip"
android:layout_marginRight="11dip"
android:layout_marginTop="10dip"
android:background="@drawable/icon"
android:scaleType="fitCenter" />
<Button
android:id="@+id/activty_picker_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toggleButton"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:layout_toRightOf="@id/app_icon"
android:text="@string/pick_an_activity" >
</Button>
<TextView
android:id="@+id/music_volume_tag"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/activty_picker_button"
android:layout_marginTop="10dip"
android:text="@string/music_volume" />
<SeekBar
android:id="@+id/music_volume"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/music_volume_tag"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip" />
<CheckBox
android:id="@+id/confirmCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/music_volume"
android:layout_marginLeft="10dip"
android:layout_marginTop="10dip"
android:text="@string/confirm" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/confirmCheckBox"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/about"
android:text="@string/about"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_marginTop="10dip"
android:id="@+id/version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" />
</LinearLayout>
</ScrollView>
</RelativeLayout>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, AutoPlayerActivity!</string>
<string name="app_name">AutoPlayer</string>
<string name="music_volume">Music Volume</string>
<string name="pick_an_activity">Pick an Activity</string>
<string name="loading">Loading...</string>
<string name="about">Welcome to AutoPlayer \n\n
AutoPlayer allows you to program your Android powered device to start a specific application and set the music volume level upon plugging in your headphones, speakers, ect.\n\n
To start, simply select which application you want to start, and set your desired volume level. The next time you plug something into your headphone jack, AutoPlayer will apply your desired settings.\n\n</string>
<string name="enable">Enable</string>
<string name="confirm">Use Confirmation Dialog</string>
<string name="start">Starting...</string>
<string name="version">Version</string>
<string name="build">build</string>
</resources>

View File

@@ -0,0 +1,206 @@
/**
* AutoPlayerActivity.java
* @author ricky barrette
* @author Twenty Codes, LLC
* @date July 20, 2011
*/
package com.TwentyCodes.android.AutoPlayer;
import java.net.URISyntaxException;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.media.AudioManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.ToggleButton;
import com.TwentyCodes.android.exception.ExceptionHandler;
import com.TwentyCodes.android.exception.R;
/**
* This activity will be used to allow the user to pick an activity, and a set a volume level to be started/applied when a headphone is pluged in
* @author ricky
*/
public class AutoPlayerActivity extends Activity implements OnClickListener, OnSeekBarChangeListener, OnCheckedChangeListener {
public static final String SETTINGS = "setings";
public static final String KEY_APP = "app";
public static final String KEY_VOLUME = "volume";
public static final String KEY_CONFIRM = "confirm";
public static final String KEY_ENABLED = "enabled";
private SharedPreferences mSettings;
private ImageView mAppIcon;
private ProgressDialog mProgress;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.mSettings = this.getSharedPreferences(SETTINGS, Context.MODE_WORLD_WRITEABLE);
/*
* toggle button
*/
ToggleButton toggle = (ToggleButton) findViewById(R.id.toggleButton);
toggle.setChecked(mSettings.getBoolean(KEY_ENABLED, true));
toggle.setOnCheckedChangeListener(this);
/*
* confirmation check box
*/
CheckBox confimationCheckBox = (CheckBox) findViewById(R.id.confirmCheckBox);
confimationCheckBox.setOnCheckedChangeListener(this);
confimationCheckBox.setChecked(mSettings.getBoolean(KEY_CONFIRM, false));
/*
* start the service if enabled
*/
if(toggle.isChecked());
this.startService(new Intent(this, HeadphoneListenerService.class));
/*
* music volume
*/
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
SeekBar volume = (SeekBar) findViewById(R.id.music_volume);
volume.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
volume.setProgress(mSettings.getInt(KEY_VOLUME, audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)));
volume.setOnSeekBarChangeListener(this);
/*
* application icon
*/
mAppIcon = (ImageView) findViewById(R.id.app_icon);
try {
mAppIcon.setBackgroundDrawable(getPackageManager().getActivityIcon(Intent.getIntent(this.mSettings.getString(AutoPlayerActivity.KEY_APP, null))));
} catch (NameNotFoundException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (NullPointerException e){
e.printStackTrace();
}
/*
* application picker button
*/
findViewById(R.id.activty_picker_button).setOnClickListener(this);
/*
* Version information textview
*/
TextView version = (TextView) findViewById(R.id.version);
PackageManager pm = getPackageManager();
PackageInfo pi;
try {
pi = pm.getPackageInfo(getPackageName(), 0);
} catch (NameNotFoundException eNnf) {
//doubt this will ever run since we want info about our own package
pi = new PackageInfo();
pi.versionName = "unknown";
pi.versionCode = 1;
}
version.setText(getText(R.string.version)+" "+pi.versionName+" "+getString(R.string.build)+" "+pi.versionCode);
}
/**
* called when the application picker button is clicked
* (non-Javadoc)
* @see android.view.View.OnClickListener#onClick(android.view.View)
*/
@Override
public void onClick(View v) {
mProgress = ProgressDialog.show(this, "", getString(R.string.loading), true, true);
findViewById(R.id.activty_picker_button).setEnabled(false);
/// Pick an application
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent);
startActivityForResult(pickIntent, 0);
}
/**
* called when the application picker is finished
* (non-Javadoc)
* @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
*/
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(mProgress != null)
if(mProgress.isShowing())
mProgress.dismiss();
findViewById(R.id.activty_picker_button).setEnabled(true);
if (data != null) {
this.mSettings.edit().putString(KEY_APP, data.toURI()).commit();
try {
mAppIcon.setBackgroundDrawable(getPackageManager().getActivityIcon(data));
} catch (NameNotFoundException e) {
e.printStackTrace();
} catch (NullPointerException e){
e.printStackTrace();
}
}
}
/**
* called when the music volume setting is adjusted
* (non-Javadoc)
* @see android.widget.SeekBar.OnSeekBarChangeListener#onProgressChanged(android.widget.SeekBar, int, boolean)
*/
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
this.mSettings.edit().putInt(KEY_VOLUME, progress).commit();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// NOT USED
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// NOT USED
}
/**
* called when the main toggle or the confirmation check box is un/checked
* (non-Javadoc)
* @see android.widget.CompoundButton.OnCheckedChangeListener#onCheckedChanged(android.widget.CompoundButton, boolean)
*/
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch(buttonView.getId()){
case R.id.confirmCheckBox:
this.mSettings.edit().putBoolean(KEY_CONFIRM, isChecked).commit();
break;
case R.id.toggleButton:
this.mSettings.edit().putBoolean(KEY_ENABLED, isChecked).commit();
if(!isChecked)
this.stopService(new Intent(this, HeadphoneListenerService.class));
else
this.startService(new Intent(this, HeadphoneListenerService.class));
break;
}
}
}

View File

@@ -0,0 +1,29 @@
/**
* BootReceiver.java
* @date Jul 20, 2011
* @author Twenty Codes, LLC
* @author ricky barrette
*/
package com.TwentyCodes.android.AutoPlayer;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* This receiver will register HeadPhoneReceiver at boot
* @author ricky
*/
public class BootReceiver extends BroadcastReceiver {
/**
* (non-Javadoc)
* @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
* @author ricky barrette
*/
@Override
public void onReceive(Context context, Intent intent) {
if(context.getSharedPreferences(AutoPlayerActivity.SETTINGS, Context.MODE_WORLD_WRITEABLE).getBoolean(AutoPlayerActivity.KEY_ENABLED, true));
context.startService(new Intent(context, HeadphoneListenerService.class));
}
}

View File

@@ -0,0 +1,205 @@
/**
* ConfirmDialog.java
* @date Oct 7, 2011
* @author ricky barrette
* @author Twenty Codes, LLC
*/
package com.TwentyCodes.android.AutoPlayer;
import java.net.URISyntaxException;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ProgressBar;
import com.TwentyCodes.android.exception.ExceptionHandler;
import com.TwentyCodes.android.exception.R;
/**
* This is the confirmation dialog. it will allow the user to cancel auto player's actions for a specified amount of time.
* @author ricky barrette
*/
public class ConfirmDialog extends Activity implements OnClickListener {
/**
* Total period of this confirmation dialog
* This value is in seconds
*/
private static final byte PERIOD = 5;
/**
* Handler message code for the current count of elapsed seconds
*/
protected static final int COUNT = 0;
private AudioManager mAudioManager;
private SharedPreferences mSettings;
private ProgressBar mProgressBar;
private Handler mHandler;
/**
* This thread will be used as a timer. it will update the UI and apply the settings
*/
private Thread mTimer = new Thread(new Runnable(){
@Override
public void run() {
int count = 0;
boolean isCanceled = false;
/*
* this is the timer function of this thread.
* it will wait for the period to elapse before continuing.
* it will update the UI every second
*/
while (count < PERIOD){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
/*
* If this is caught, then the thread has been interrupted,
* we want to log this so we can handle it.
*/
e.printStackTrace();
isCanceled = true;
}
count++;
mHandler.sendMessage(mHandler.obtainMessage(COUNT, count));
}
if(!isCanceled){
try {
setStreamVolume(mSettings.getInt(AutoPlayerActivity.KEY_VOLUME, mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)), AudioManager.STREAM_MUSIC);
getApplicationContext().startActivity(Intent.getIntent(mSettings.getString(AutoPlayerActivity.KEY_APP, null)).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (NullPointerException e){
e.printStackTrace();
}
/*
* the following is performed on the UI thread
*/
ConfirmDialog.this.runOnUiThread(new Runnable(){
@Override
public void run() {
ConfirmDialog.this.finish();
}
});
}
}
});
@Override
public void onClick(View v) {
mTimer.interrupt();
this.finish();
}
/**
* (non-Javadoc)
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
this.setContentView(R.layout.confirm_dialog);
this.mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
this.mSettings = this.getSharedPreferences(AutoPlayerActivity.SETTINGS, Context.MODE_WORLD_WRITEABLE);
this.setTitle(R.string.app_name);
/*
* cancel button
*/
findViewById(R.id.okButton).setOnClickListener(this);
/*
* displays the icon of the application to be started
*/
ImageView appIcon = (ImageView) findViewById(R.id.app_icon);
try {
appIcon.setBackgroundDrawable(getPackageManager().getActivityIcon(Intent.getIntent(this.mSettings.getString(AutoPlayerActivity.KEY_APP, null))));
} catch (NameNotFoundException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (NullPointerException e){
e.printStackTrace();
}
/*
* displays the count down progress bar
*/
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
mProgressBar.setMax(PERIOD);
mProgressBar.setProgress(PERIOD);
/*
* prepare UI handler to handle updates from the timer thread.
* once this is complete, start the timer thread
*/
setUiHandler();
mTimer.start();
}
/**
* set the volume of a particular stream
* @param volume
* @param stream
* @author ricky barrette
*/
private void setStreamVolume(int volume, int stream) {
/*
* if the seek bar is set to a value that is higher than what the the stream value is set for
* then subtract the seek bar's value from the current volume of the stream, and then
* raise the stream by that many times
*/
if (volume > mAudioManager.getStreamVolume(stream)) {
int adjust = volume - mAudioManager.getStreamVolume(stream);
for (int i = 0; i < adjust; i++) {
mAudioManager.adjustSuggestedStreamVolume(AudioManager.ADJUST_RAISE, stream, 0);
}
}
/*
* if the seek bar is set to a value that is lower than what the the stream value is set for
* then subtract the current volume of the stream from the seek bar's value, and then
* lower the stream by that many times
*/
if (volume < mAudioManager.getStreamVolume(stream)) {
int adjust = mAudioManager.getStreamVolume(stream) - volume;
for (int i = 0; i < adjust; i++) {
mAudioManager.adjustSuggestedStreamVolume(AudioManager.ADJUST_LOWER, stream, 0);
}
}
}
/**
* Sets up the UI handler to receive updates from the timer thread
* @author ricky barrette
*/
private void setUiHandler() {
mHandler = new Handler(){
@Override
public void handleMessage(Message msg){
if(msg.what == COUNT){
mProgressBar.setProgress( PERIOD - (Integer) msg.obj);
}
}
};
}
}

View File

@@ -0,0 +1,123 @@
/**
* HeadPhoneReceiver.java
* @author ricky barrette
* @author Twenty Codes, LLC
* @date July 20, 2011
*/
package com.TwentyCodes.android.AutoPlayer;
import java.net.URISyntaxException;
import com.TwentyCodes.android.exception.ExceptionHandler;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.util.Log;
/**
* This receiver will handle head phone events
* @author ricky
*/
public class HeadPhoneReceiver extends BroadcastReceiver {
private static final String TAG = "HeadPhoneReceiver";
private static final String LOG = "HeadPhoneReceiverLog";
private static final String MUSIC_VOLUME = "music_volume";
private AudioManager mAudioManager;
private SharedPreferences mSettings;
private Context mContext;
/**
* (non-Javadoc)
* @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
*/
@Override
public void onReceive(Context context, Intent intent) {
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this, context));
this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
mSettings = context.getSharedPreferences(AutoPlayerActivity.SETTINGS, Context.MODE_WORLD_WRITEABLE);
mContext = context;
if(intent != null){
Log.v(TAG,"Headphone event");
if(intent.hasExtra("state")){
Log.v(TAG,"Headphone event: "+ intent.getIntExtra("state", 0));
if(intent.getIntExtra("state", 0) == 1){
//check the event log, if this is the first event then continue
if(! mSettings.getBoolean(LOG, false)) {
//log the event and current music volume
mSettings.edit().putBoolean(LOG, true).putInt(MUSIC_VOLUME, this.mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC)).commit();
//Perform user's settings
if(mSettings.getBoolean(AutoPlayerActivity.KEY_CONFIRM, false))
context.startActivity(new Intent(context, ConfirmDialog.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
else
applySettings();
}
} else {
//restore previous volume
setStreamVolume(mSettings.getInt(MUSIC_VOLUME, this.mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)), AudioManager.STREAM_MUSIC);
mSettings.edit().putBoolean(LOG, false).commit();
/*
* TODO stop music activity
*/
}
}
}
}
/**
* Sets the music stream volume, and starts the user specified activity
*
* @author ricky barrette
*/
private void applySettings() {
try {
setStreamVolume(mSettings.getInt(AutoPlayerActivity.KEY_VOLUME, this.mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)), AudioManager.STREAM_MUSIC);
mContext.getApplicationContext().startActivity(Intent.getIntent(mSettings.getString(AutoPlayerActivity.KEY_APP, null)).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (NullPointerException e){
e.printStackTrace();
}
}
/**
* set the volume of a particular stream
* @param volume
* @param stream
* @author ricky barrette
*/
private void setStreamVolume(int volume, int stream) {
/*
* if the seek bar is set to a value that is higher than what the the stream value is set for
* then subtract the seek bar's value from the current volume of the stream, and then
* raise the stream by that many times
*/
if (volume > mAudioManager.getStreamVolume(stream)) {
int adjust = volume - mAudioManager.getStreamVolume(stream);
for (int i = 0; i < adjust; i++) {
mAudioManager.adjustSuggestedStreamVolume(AudioManager.ADJUST_RAISE, stream, 0);
}
}
/*
* if the seek bar is set to a value that is lower than what the the stream value is set for
* then subtract the current volume of the stream from the seek bar's value, and then
* lower the stream by that many times
*/
if (volume < mAudioManager.getStreamVolume(stream)) {
int adjust = mAudioManager.getStreamVolume(stream) - volume;
for (int i = 0; i < adjust; i++) {
mAudioManager.adjustSuggestedStreamVolume(AudioManager.ADJUST_LOWER, stream, 0);
}
}
}
}

View File

@@ -0,0 +1,43 @@
/**
* HeadphoneListenerService.java
* @date Jul 20, 2011
* @author Twenty Codes, LLC
* @author ricky barrette
*/
package com.TwentyCodes.android.AutoPlayer;
import android.app.Service;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;
/**
* This only purpose of this service is to keep HeadPhoneReceiver.java a registered reciever
* @author ricky
*/
public class HeadphoneListenerService extends Service {
@Override
public void onCreate() {
this.registerReceiver(new HeadPhoneReceiver(), new IntentFilter(Intent.ACTION_HEADSET_PLUG));
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
return START_STICKY;
}
/**
* (non-Javadoc)
* @see android.app.Service#onBind(android.content.Intent)
* @author ricky barrette
*/
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
}