Permalink
Browse files

update dialog style

  • Loading branch information...
1 parent dc35198 commit 46a98c8bf61383828caccfb7fd2d9f80232a4848 @thibault thibault committed Mar 1, 2011
@@ -57,7 +57,8 @@ along with Napply. If not, see <http://www.gnu.org/licenses/>.
</service>
<!-- Dialog to show cancel/snooze dialog -->
- <activity android:name="AlarmCancelDialog">
+ <activity android:name="AlarmCancelDialog" android:label="@string/wake_up"
+ android:theme="@android:style/Theme.Dialog">
<intent-filter>
<action android:name="fr.miximum.napply.RING_ALARM" />
</intent-filter>
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+© Copyright 2011 Thibault Jouannic <thibault@jouannic.fr>. All Rights Reserved.
+
+This file is part of Napply.
+
+Napply is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Napply is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Napply. If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="10dip"
+ android:orientation="vertical" >
+
+ <Button
+ android:id="@+id/snooze_alarm"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent"
+ android:text="@string/snooze"
+ android:layout_marginBottom="10dp"
+ style="@style/Button"/>
+
+ <Button
+ android:id="@+id/dismiss_alarm"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent"
+ android:text="@string/dismiss"
+ style="@style/Button" />
+</LinearLayout>
@@ -29,4 +29,8 @@ along with Napply. If not, see <http://www.gnu.org/licenses/>.
<style name="Widget.EndTime">
<item name="android:textSize">15dp</item>
</style>
+
+ <style name="Button">
+ <item name="android:textSize">30sp</item>
+ </style>
</resources>
@@ -18,6 +18,9 @@
import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.PowerManager;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
/**
* This class has a simple purpose: displaying a dialog to dismiss or snooze the alarm
@@ -106,6 +109,9 @@ public void onAccuracyChanged(Sensor sensor, int accuracy) {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ // Set activity layout
+ setContentView(R.layout.alarm_cancel_dialog_layout);
+
// Get AppWidget id from launching intent
mAppWidgetId = NapplyWidget.getAppWidgetId(getIntent());
@@ -129,8 +135,9 @@ public void onCreate(Bundle savedInstanceState) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, Napply.TAG);
+ setClickHandlers();
+
ringAlarm(getApplicationContext());
- showDialog(DIALOG_ID);
}
@Override
@@ -139,6 +146,7 @@ public void onDestroy() {
super.onDestroy();
}
+ /** Acquire needed resources (keyguard, wakelock, sensors) */
@Override
public void onResume() {
// Disable the lock and turn the screen on
@@ -155,6 +163,7 @@ public void onResume() {
super.onResume();
}
+ /** Release resources */
@Override
public void onPause() {
// Reenable screen lock, and release the power lock
@@ -167,36 +176,28 @@ public void onPause() {
}
/**
- * Create the dialog
+ * Configure button event handlers
*/
- protected Dialog onCreateDialog(int id) {
- Dialog dialog;
- Context context = getApplicationContext();
- switch (id) {
- case DIALOG_ID:
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage(context.getString(R.string.wake_up))
- .setCancelable(false)
- .setPositiveButton(context.getString(R.string.snooze), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- snoozeAlarm(getApplicationContext());
- finish();
- }
- })
- .setNegativeButton(context.getString(R.string.dismiss), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dismissAlarm(getApplicationContext());
- finish();
- }
- });
- AlertDialog alert = builder.create();
- dialog = alert;
- break;
-
- default:
- dialog = null;
- }
- return dialog;
+ protected void setClickHandlers() {
+ // Set snooze click handler
+ Button snooze = (Button) findViewById(R.id.snooze_alarm);
+ snooze.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ snoozeAlarm(getApplicationContext());
+ finish();
+ }
+ });
+
+ // Set dismiss click handler
+ Button dismiss = (Button) findViewById(R.id.dismiss_alarm);
+ dismiss.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dismissAlarm(getApplicationContext());
+ finish();
+ }
+ });
}
/**

0 comments on commit 46a98c8

Please sign in to comment.