Skip to content

Commit

Permalink
Formatting change and added gitignore
Browse files Browse the repository at this point in the history
Added code formatting changes and added gitignore to ignore binary files
  • Loading branch information
Saurabh Gangarde committed Sep 23, 2012
1 parent fb2fa44 commit 7d80f0a
Show file tree
Hide file tree
Showing 15 changed files with 400 additions and 360 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# Eclipse project files
.classpath
.project

/libs
KinoSenseFramework/.classpath
2 changes: 1 addition & 1 deletion KinoSenseFramework/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
android:resource="@xml/trigger_widget_info" />
</receiver>
</application>

Expand Down
54 changes: 25 additions & 29 deletions KinoSenseFramework/src/org/punegdg/kinosense/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
/**
* Copyright 2012 Pune-GDG (http://meetup.com/pune-gdg)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package org.punegdg.kinosense;

Expand All @@ -25,61 +22,60 @@
import android.view.Menu;

/**
* Currently this Activity is bootstrap to number of things in the PoC state e.g like the Service which listens to Sensor events and code which registers various broadcast recievers.
* Currently this Activity is bootstrap to number of things in the PoC state e.g like the Service which listens to
* Sensor events and code which registers various broadcast recievers.
*
* @author "Rohit Ghatol"<[email protected]>
*
*
*/
public class MainActivity extends Activity {
public class MainActivity extends Activity
{

/**
* Power Connected Disconnected BroadCastReceiver
*/
private BroadCastReceiverBasedTrigger bbTrigger = new PowerConnectedTrigger();




/* (non-Javadoc)
/*
* (non-Javadoc)
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
public void onCreate(Bundle savedInstanceState) {
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

bbTrigger.onCreate(getApplicationContext());

Intent startServiceIntent = new Intent(getApplicationContext(),
SensorService.class);
Intent startServiceIntent = new Intent(getApplicationContext(), SensorService.class);
startService(startServiceIntent);

}



/* (non-Javadoc)
/*
* (non-Javadoc)
* @see android.app.Activity#onCreateOptionsMenu(android.view.Menu)
*/
@Override

public boolean onCreateOptionsMenu(Menu menu) {
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}



/* (non-Javadoc)
/*
* (non-Javadoc)
* @see android.app.Activity#onStop()
*/
@Override
protected void onStop() {
protected void onStop()
{
super.onStop();
bbTrigger.onDestroy();
}




}
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
/**
* Copyright 2012 Pune-GDG (http://meetup.com/pune-gdg)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package org.punegdg.kinosense.actions;

Expand All @@ -20,41 +17,39 @@
import android.content.Context;

/**
* Contract for all Action classes. The life cycle methods are explained as
* follows
* Contract for all Action classes. The life cycle methods are explained as follows
* <ul>
* <li>onCreate - Called once when creating an instance of this action.
* Application Context is passed here</li>
* <li>onCreate - Called once when creating an instance of this action. Application Context is passed here</li>
* <li>performAction - Called each time when an action needs to be performed</li>
* <li>onDestroy - Called once when this action needs to be destroyed. Clean up
* needs to be done here</li>
* <li>onDestroy - Called once when this action needs to be destroyed. Clean up needs to be done here</li>
*
*
* </ul>
*
* @author "Rohit Ghatol"<[email protected]>
*
*/
public interface AbstractAction {
public interface AbstractAction
{
/**
* Called once when creating an instance of this action.
*
* @param context
* Android Application Context
* @param context Android Application Context
*/
public void onCreate(Context context);


/**
* Called each time when an action needs to be performed
*
* @param action
* @param extra
*/
public void perform(Map<String,Object> data);
public void perform(Map<String, Object> data);


/**
* Called once when this action needs to be destroyed. Clean up needs to be
* done here
* Called once when this action needs to be destroyed. Clean up needs to be done here
*/
public void onDestroy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,41 @@

/**
* @author rohit
*
*
*/
public class NotificationAction implements AbstractAction {
public class NotificationAction implements AbstractAction
{

private Context context = null;
/* (non-Javadoc)


/*
* (non-Javadoc)
* @see org.punegdg.kinosense.actions.AbstractAction#onCreate(android.content.Context)
*/
public void onCreate(Context context) {
public void onCreate(Context context)
{
this.context = context;

}

/* (non-Javadoc)

/*
* (non-Javadoc)
* @see org.punegdg.kinosense.actions.AbstractAction#perform(java.util.Map)
*/
public void perform(Map<String, Object> data) {
public void perform(Map<String, Object> data)
{
String message = (String)data.get("message");

}

/* (non-Javadoc)

/*
* (non-Javadoc)
* @see org.punegdg.kinosense.actions.AbstractAction#onDestroy()
*/
public void onDestroy() {
public void onDestroy()
{
// TODO Auto-generated method stub

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
/**
* Copyright 2012 Pune-GDG (http://meetup.com/pune-gdg)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package org.punegdg.kinosense.actions;

Expand All @@ -21,15 +18,15 @@
import android.media.AudioManager;

/**
* Action which can silent the phone and on the flip side raise the volume to
* max.
* Action which can silent the phone and on the flip side raise the volume to max.
*
*@author "Rohit Ghatol"<[email protected]>
* @author "Rohit Ghatol"<[email protected]>
*
*/
// FIXME - Need to decide what is the scope of Silent Action, also what can we
// do to undo this action
public class SilentAction implements AbstractAction {
public class SilentAction implements AbstractAction
{

/**
* Android Application Context
Expand All @@ -39,52 +36,52 @@ public class SilentAction implements AbstractAction {
* Audio Manager used to change the ringer volume
*/
private AudioManager audioManager = null;

/**
* Last stored volume
*/
private int lastVolume = 0;


/*
* (non-Javadoc)
*
* @see
* org.punegdg.kinosense.actions.BaseAction#onCreate(android.content.Context
* )
* @see org.punegdg.kinosense.actions.BaseAction#onCreate(android.content.Context )
*/
public void onCreate(Context context) {
public void onCreate(Context context)
{
this.context = context;
audioManager = (AudioManager) context
.getSystemService(context.AUDIO_SERVICE);
audioManager = (AudioManager)context.getSystemService(context.AUDIO_SERVICE);
// lastVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
}


/*
* (non-Javadoc)
*
* @see org.punegdg.kinosense.actions.BaseAction#onAction(java.lang.String,
* java.lang.String)
* @see org.punegdg.kinosense.actions.BaseAction#onAction(java.lang.String, java.lang.String)
*/
public void perform(Map<String,Object> data) {
public void perform(Map<String, Object> data)
{
String action = (String)data.get("action");
if ("Silence".equals(action)) {
if ( "Silence".equals(action) )
{
lastVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
audioManager.setStreamVolume(AudioManager.STREAM_RING, 0,
AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);
} else if ("Restore".equals(action)) {
audioManager.setStreamVolume(AudioManager.STREAM_RING, 7,
AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);
audioManager.setStreamVolume(AudioManager.STREAM_RING, 0, AudioManager.FLAG_SHOW_UI
+ AudioManager.FLAG_PLAY_SOUND);
}
else if ( "Restore".equals(action) )
{
audioManager.setStreamVolume(AudioManager.STREAM_RING, 7, AudioManager.FLAG_SHOW_UI
+ AudioManager.FLAG_PLAY_SOUND);
}
}


/*
* (non-Javadoc)
*
* @see
* org.punegdg.kinosense.actions.BaseAction#onDestroy(android.content.Context
* )
* @see org.punegdg.kinosense.actions.BaseAction#onDestroy(android.content.Context )
*/
public void onDestroy() {
public void onDestroy()
{
audioManager = null;
}

Expand Down
Loading

0 comments on commit 7d80f0a

Please sign in to comment.