Skip to content

Commit

Permalink
Absence Activity
Browse files Browse the repository at this point in the history
#5
- extend NotifyData.java model about tag sound
- AlertDialog after saving Absence to approve
  • Loading branch information
eurosecom committed Feb 27, 2017
1 parent 882da56 commit 362001d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
44 changes: 37 additions & 7 deletions app/src/main/java/com/eusecom/attendance/NewAbsenceActivity.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.eusecom.attendance;

import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
Expand All @@ -17,7 +17,6 @@
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.eusecom.attendance.models.Attendance;
import com.eusecom.attendance.models.MessData;
import com.eusecom.attendance.models.Message;
Expand Down Expand Up @@ -211,6 +210,8 @@ public void onSelectedDayChange(CalendarView view, int year, int month, int dayO
if (subscription != null && !subscription.isUnsubscribed()) {
subscription.unsubscribe();
}

hideProgressDialog();
super.onDestroy();
}

Expand Down Expand Up @@ -340,9 +341,9 @@ public void onDataChange(DataSnapshot dataSnapshot) {

}

hideProgressDialog();
//hideProgressDialog();
// Finish this Activity, back to the stream
finish();
//finish();
// [END_EXCLUDE]
}

Expand Down Expand Up @@ -428,9 +429,37 @@ public Subscription SendNotification() {
.subscribe(new Observer<Message>() {
@Override
public void onCompleted() {

hideProgressDialog();
Log.d(TAG, "In onCompleted()");
AlertDialog dialog = new AlertDialog.Builder(NewAbsenceActivity.this)
.setTitle(getString(R.string.abssave))
.setMessage(getString(R.string.mesapprovesent))
.setPositiveButton(getString(R.string.textok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {

finish();
}
})

.show();

dialog.setOnKeyListener(new Dialog.OnKeyListener() {

@Override
public boolean onKey(DialogInterface arg0, int keyCode,
KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode == KeyEvent.KEYCODE_BACK) {
finish();
dialog.dismiss();
}
return true;
}
});
}


@Override
public void onError(Throwable e) {
e.printStackTrace();
Expand All @@ -450,4 +479,5 @@ public void onNext(Message message) {
}//end of FirebaseRxSendMessaging



}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
public class NotifyData {
String title;
String body;
String sound;

public NotifyData(String title, String body ) {

this.title = title;
this.body = body;
this.sound = "default";
}

}
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@

<string name="textyes">Yes</string>
<string name="textno">No</string>
<string name="textok">OK</string>
<string name="cantedititem">You can not edit the items.</string>
<string name="notconnected">Not connected.</string>

Expand All @@ -192,5 +193,8 @@
<string name="msg_subscribed">Subscribed to news topic</string>
<string name="msg_token_fmt" translatable="false">InstanceID Token: %s</string>

<string name="abssave">Absence saved.</string>
<string name="mesapprovesent">Absence sent to approve.</string>


</resources>

0 comments on commit 362001d

Please sign in to comment.