-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
106 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
app/src/main/java/zarag/locationbasedalarms/AlarmActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package zarag.locationbasedalarms; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.media.MediaPlayer; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.widget.CompoundButton; | ||
import android.widget.Switch; | ||
import android.widget.TextView; | ||
|
||
|
||
/** | ||
* Created by zara and javeed on 11.08.2015. | ||
* | ||
* The AlarmActivity is used for the alarm view, we will not use the AlarmClock class, because it is | ||
* activating the alarm by a time instant of a specific event. In out case, the user is close enough | ||
* to his/her destination. | ||
* */ | ||
public class AlarmActivity extends Activity { | ||
|
||
public static final String WAKE_UP_TEXT = "Wake up you are almost at your destination."; | ||
|
||
private TextView wakeUpTxt; | ||
|
||
private MediaPlayer mediaPlayer; | ||
|
||
private Switch turnOffSwtch; | ||
|
||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_alarm); | ||
|
||
wakeUpTxt = (TextView)findViewById(R.id.wakeUpTxt); | ||
// TODO maybe add the location-name later | ||
wakeUpTxt.setText(WAKE_UP_TEXT); | ||
|
||
mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.wakemeup); | ||
mediaPlayer.start(); | ||
|
||
turnOffSwtch = (Switch)findViewById(R.id.turnOffSwtch); | ||
turnOffSwtch.setChecked(true); | ||
|
||
turnOffSwtch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | ||
@Override | ||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | ||
if (!isChecked) { | ||
mediaPlayer.stop(); | ||
|
||
startActivity(new Intent(Intent.ACTION_MAIN). | ||
addCategory(Intent.CATEGORY_HOME). | ||
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); | ||
} | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<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:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
tools:context="zarag.locationbasedalarms.AlarmActivity" | ||
android:background="@drawable/destinationalarm"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/wakeUpTxt" | ||
android:layout_alignParentTop="true" | ||
android:layout_alignParentLeft="true" /> | ||
|
||
<Switch | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/turnOffSwtch" | ||
android:layout_alignParentBottom="true" | ||
android:layout_alignParentRight="true" | ||
android:checked="false" /> | ||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
tools:context="zarag.locationbasedalarms.AlarmActivity"> | ||
<item android:id="@+id/action_settings" android:title="@string/action_settings" | ||
android:orderInCategory="100" app:showAsAction="never" /> | ||
</menu> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters