Skip to content

Commit 7f83e09

Browse files
committed
Diálogos y Notificaciones
1 parent e40f2c4 commit 7f83e09

File tree

24 files changed

+332
-8
lines changed

24 files changed

+332
-8
lines changed

android-dialogos/src/net/sgoliver/android/dialogos/DialogoAlerta.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ public class DialogoAlerta extends DialogFragment {
1010
@Override
1111
public Dialog onCreateDialog(Bundle savedInstanceState) {
1212

13-
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
13+
AlertDialog.Builder builder =
14+
new AlertDialog.Builder(getActivity());
15+
1416
builder.setMessage("Esto es un mensaje de alerta.")
1517
.setTitle("Información")
1618
.setPositiveButton("OK", new DialogInterface.OnClickListener() {

android-dialogos/src/net/sgoliver/android/dialogos/DialogoConfirmacion.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ public class DialogoConfirmacion extends DialogFragment {
1111
@Override
1212
public Dialog onCreateDialog(Bundle savedInstanceState) {
1313

14-
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
14+
AlertDialog.Builder builder =
15+
new AlertDialog.Builder(getActivity());
16+
1517
builder.setMessage("¿Confirma la acción seleccionada?")
1618
.setTitle("Confirmacion")
1719
.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {

android-dialogos/src/net/sgoliver/android/dialogos/DialogoSeleccion.java

+24-6
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,31 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
1313

1414
final String[] items = {"Español", "Inglés", "Francés"};
1515

16-
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
16+
AlertDialog.Builder builder =
17+
new AlertDialog.Builder(getActivity());
18+
1719
builder.setTitle("Selección")
18-
.setItems(items, new DialogInterface.OnClickListener() {
19-
public void onClick(DialogInterface dialog, int item) {
20-
Log.i("Dialogos", "Opción elegida: " + items[item]);
21-
}
22-
});
20+
.setItems(items, new DialogInterface.OnClickListener() {
21+
public void onClick(DialogInterface dialog, int item) {
22+
Log.i("Dialogos", "Opción elegida: " + items[item]);
23+
}
24+
});
25+
26+
// builder.setTitle("Selección")
27+
// .setMultiChoiceItems(items, null,
28+
// new DialogInterface.OnMultiChoiceClickListener() {
29+
// public void onClick(DialogInterface dialog, int item, boolean isChecked) {
30+
// Log.i("Dialogos", "Opción elegida: " + items[item]);
31+
// }
32+
// });
33+
34+
// builder.setTitle("Selección")
35+
// .setSingleChoiceItems(items, -1,
36+
// new DialogInterface.OnClickListener() {
37+
// public void onClick(DialogInterface dialog, int item) {
38+
// Log.i("Dialogos", "Opción elegida: " + items[item]);
39+
// }
40+
// });
2341

2442
return builder.create();
2543
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="net.sgoliver.android.notificaciones"
4+
android:versionCode="1"
5+
android:versionName="1.0" >
6+
7+
<uses-sdk
8+
android:minSdkVersion="8"
9+
android:targetSdkVersion="17" />
10+
11+
<application
12+
android:allowBackup="true"
13+
android:icon="@drawable/ic_launcher"
14+
android:label="@string/app_name"
15+
android:theme="@style/AppTheme" >
16+
<activity
17+
android:name="net.sgoliver.android.notificaciones.MainActivity"
18+
android:label="@string/app_name" >
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
</activity>
25+
</application>
26+
27+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/** Automatically generated file. DO NOT MODIFY */
2+
package net.sgoliver.android.notificaciones;
3+
4+
public final class BuildConfig {
5+
public final static boolean DEBUG = true;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* AUTO-GENERATED FILE. DO NOT MODIFY.
2+
*
3+
* This class was automatically generated by the
4+
* aapt tool from the resource data it found. It
5+
* should not be modified by hand.
6+
*/
7+
8+
package net.sgoliver.android.notificaciones;
9+
10+
public final class R {
11+
public static final class attr {
12+
}
13+
public static final class dimen {
14+
/** Default screen margins, per the Android Design guidelines.
15+
16+
Customize dimensions originally defined in res/values/dimens.xml (such as
17+
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
18+
19+
*/
20+
public static final int activity_horizontal_margin=0x7f040000;
21+
public static final int activity_vertical_margin=0x7f040001;
22+
}
23+
public static final class drawable {
24+
public static final int ic_launcher=0x7f020000;
25+
}
26+
public static final class id {
27+
public static final int BtnNotif=0x7f080000;
28+
public static final int action_settings=0x7f080001;
29+
}
30+
public static final class layout {
31+
public static final int activity_main=0x7f030000;
32+
}
33+
public static final class menu {
34+
public static final int main=0x7f070000;
35+
}
36+
public static final class string {
37+
public static final int action_settings=0x7f050001;
38+
public static final int app_name=0x7f050000;
39+
public static final int hello_world=0x7f050002;
40+
public static final int notificacion=0x7f050003;
41+
}
42+
public static final class style {
43+
/**
44+
Base application theme, dependent on API level. This theme is replaced
45+
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
46+
47+
48+
Theme customizations available in newer API levels can go in
49+
res/values-vXX/styles.xml, while customizations related to
50+
backward-compatibility can go here.
51+
52+
53+
Base application theme for API 11+. This theme completely replaces
54+
AppBaseTheme from res/values/styles.xml on API 11+ devices.
55+
56+
API 11 theme customizations can go here.
57+
58+
Base application theme for API 14+. This theme completely replaces
59+
AppBaseTheme from BOTH res/values/styles.xml and
60+
res/values-v11/styles.xml on API 14+ devices.
61+
62+
API 14 theme customizations can go here.
63+
*/
64+
public static final int AppBaseTheme=0x7f060000;
65+
/** Application theme.
66+
All customizations that are NOT specific to a particular API-level can go here.
67+
*/
68+
public static final int AppTheme=0x7f060001;
69+
}
70+
}
50.2 KB
Loading
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# To enable ProGuard in your project, edit project.properties
2+
# to define the proguard.config property as described in that file.
3+
#
4+
# Add project specific ProGuard rules here.
5+
# By default, the flags in this file are appended to flags specified
6+
# in ${sdk.dir}/tools/proguard/proguard-android.txt
7+
# You can edit the include path and order by changing the ProGuard
8+
# include property in project.properties.
9+
#
10+
# For more details, see
11+
# http://developer.android.com/guide/developing/tools/proguard.html
12+
13+
# Add any project specific keep options here:
14+
15+
# If your project uses WebView with JS, uncomment the following
16+
# and specify the fully qualified class name to the JavaScript interface
17+
# class:
18+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19+
# public *;
20+
#}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system edit
7+
# "ant.properties", and override values to adapt the script to your
8+
# project structure.
9+
#
10+
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11+
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12+
13+
# Project target.
14+
target=android-17
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:paddingBottom="@dimen/activity_vertical_margin"
6+
android:paddingLeft="@dimen/activity_horizontal_margin"
7+
android:paddingRight="@dimen/activity_horizontal_margin"
8+
android:paddingTop="@dimen/activity_vertical_margin"
9+
tools:context=".MainActivity" >
10+
11+
<Button android:id="@+id/BtnNotif"
12+
android:layout_width="wrap_content"
13+
android:layout_height="wrap_content"
14+
android:text="@string/notificacion" />
15+
16+
</LinearLayout>
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
2+
3+
<item
4+
android:id="@+id/action_settings"
5+
android:orderInCategory="100"
6+
android:showAsAction="never"
7+
android:title="@string/action_settings"/>
8+
9+
</menu>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<resources>
2+
3+
<!--
4+
Customize dimensions originally defined in res/values/dimens.xml (such as
5+
screen margins) for sw600dp devices (e.g. 7" tablets) here.
6+
-->
7+
8+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<resources>
2+
3+
<!--
4+
Customize dimensions originally defined in res/values/dimens.xml (such as
5+
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
6+
-->
7+
<dimen name="activity_horizontal_margin">128dp</dimen>
8+
9+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<resources>
2+
3+
<!--
4+
Base application theme for API 11+. This theme completely replaces
5+
AppBaseTheme from res/values/styles.xml on API 11+ devices.
6+
-->
7+
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
8+
<!-- API 11 theme customizations can go here. -->
9+
</style>
10+
11+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<resources>
2+
3+
<!--
4+
Base application theme for API 14+. This theme completely replaces
5+
AppBaseTheme from BOTH res/values/styles.xml and
6+
res/values-v11/styles.xml on API 14+ devices.
7+
-->
8+
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
9+
<!-- API 14 theme customizations can go here. -->
10+
</style>
11+
12+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<resources>
2+
3+
<!-- Default screen margins, per the Android Design guidelines. -->
4+
<dimen name="activity_horizontal_margin">16dp</dimen>
5+
<dimen name="activity_vertical_margin">16dp</dimen>
6+
7+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<string name="app_name">Notificaciones Android</string>
5+
<string name="action_settings">Settings</string>
6+
<string name="hello_world">Hello world!</string>
7+
<string name="notificacion">Notificación</string>
8+
9+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<resources>
2+
3+
<!--
4+
Base application theme, dependent on API level. This theme is replaced
5+
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
6+
-->
7+
<style name="AppBaseTheme" parent="android:Theme.Light">
8+
<!--
9+
Theme customizations available in newer API levels can go in
10+
res/values-vXX/styles.xml, while customizations related to
11+
backward-compatibility can go here.
12+
-->
13+
</style>
14+
15+
<!-- Application theme. -->
16+
<style name="AppTheme" parent="AppBaseTheme">
17+
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
18+
</style>
19+
20+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package net.sgoliver.android.notificaciones;
2+
3+
import android.os.Bundle;
4+
import android.app.Activity;
5+
import android.app.NotificationManager;
6+
import android.app.PendingIntent;
7+
import android.content.Context;
8+
import android.content.Intent;
9+
import android.graphics.drawable.BitmapDrawable;
10+
import android.support.v4.app.NotificationCompat;
11+
import android.view.Menu;
12+
import android.view.View;
13+
import android.view.View.OnClickListener;
14+
import android.widget.Button;
15+
16+
public class MainActivity extends Activity {
17+
18+
private Button btnNotificacion;
19+
20+
private static final int NOTIF_ALERTA_ID = 1;
21+
22+
@Override
23+
protected void onCreate(Bundle savedInstanceState) {
24+
super.onCreate(savedInstanceState);
25+
setContentView(R.layout.activity_main);
26+
27+
btnNotificacion = (Button)findViewById(R.id.BtnNotif);
28+
29+
btnNotificacion.setOnClickListener(new OnClickListener() {
30+
public void onClick(View v) {
31+
NotificationCompat.Builder mBuilder =
32+
new NotificationCompat.Builder(MainActivity.this)
33+
.setSmallIcon(android.R.drawable.stat_sys_warning)
34+
.setLargeIcon((((BitmapDrawable)getResources()
35+
.getDrawable(R.drawable.ic_launcher)).getBitmap()))
36+
.setContentTitle("Mensaje de Alerta")
37+
.setContentText("Ejemplo de notificación.")
38+
.setContentInfo("4")
39+
.setTicker("Alerta!");
40+
41+
Intent notIntent =
42+
new Intent(MainActivity.this, MainActivity.class);
43+
44+
PendingIntent contIntent = PendingIntent.getActivity(
45+
MainActivity.this, 0, notIntent, 0);
46+
47+
mBuilder.setContentIntent(contIntent);
48+
49+
NotificationManager mNotificationManager =
50+
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
51+
52+
mNotificationManager.notify(NOTIF_ALERTA_ID, mBuilder.build());
53+
}
54+
});
55+
}
56+
57+
@Override
58+
public boolean onCreateOptionsMenu(Menu menu) {
59+
// Inflate the menu; this adds items to the action bar if it is present.
60+
getMenuInflater().inflate(R.menu.main, menu);
61+
return true;
62+
}
63+
64+
}

0 commit comments

Comments
 (0)