Skip to content

Commit 7c6ae82

Browse files
committed
Added Sending Common Message Utility
1 parent e0f55a3 commit 7c6ae82

12 files changed

+283
-10
lines changed

.idea/gradle.xml

+6-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

+45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/release/Body Fitness Zone.apk

1.33 MB
Binary file not shown.

app/release/output.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

app/src/main/AndroidManifest.xml

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
android:required="false" />
1616

1717
<application
18-
android:hardwareAccelerated="false"
19-
android:largeHeap="true"
2018
android:allowBackup="true"
19+
android:hardwareAccelerated="false"
2120
android:icon="@mipmap/ic_launcher"
2221
android:label="@string/app_name"
22+
android:largeHeap="true"
2323
android:roundIcon="@mipmap/ic_launcher_round"
2424
android:supportsRtl="true"
2525
android:theme="@style/AppTheme">
26-
<activity android:name=".DayRecord"></activity>
26+
<activity android:name=".SendCommonMessage"></activity>
27+
<activity android:name=".DayRecord" />
2728
<activity android:name=".AddPerson" />
2829
<activity android:name=".Functionality" />
2930
<activity android:name=".Detail" />

app/src/main/java/com/aina/dummydatabase/AddPerson.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ public void onClickSubmit(View v) {
535535
if (mode_operation.equals("insert")) {
536536
String phoneNo = phoneField.getText().toString();
537537
String nameCustomer = nameField.getText().toString();
538-
String message = "Dear " + nameCustomer + ", Thank you for joining BodyZone Gym! Have a Happy and Healthy Life!";
538+
String message = "Dear " + nameCustomer + ", Thank you for joining Body Fitness Zone! Have a Happy and Healthy Life!";
539539
if (phoneNo.length() > 0 && message.length() > 0) {
540540
sendSms(phoneNo, message);
541541
} else

app/src/main/java/com/aina/dummydatabase/Detail.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void onClick(View view) {
102102

103103

104104
String nameCustomer = nameView.getText().toString();
105-
String message = "Dear " + nameCustomer + ",\nYou have successfully deposited "+ amountfees +"/-" +"\nThanks,\nBodyZone Gym.";
105+
String message = "Dear " + nameCustomer + ",\nYou have successfully deposited "+ amountfees +"/-" +"\nThanks,\nBody Fitness Zone";
106106
if (phoneNumber.length() > 0 && message.length() > 0) {
107107
sendSms(phoneNumber, message);
108108
} else
@@ -356,7 +356,7 @@ public void onClickCall(View v){
356356

357357
public void onSendReminder(View v){
358358
String nameCustomer = nameView.getText().toString();
359-
String message = "Dear " + nameCustomer + ",\nPlease accept this message as a soft reminder for the pending fees of this month."+ "\nThanks,\nBodyZone Gym.";
359+
String message = "Dear " + nameCustomer + ",\nPlease accept this message as a soft reminder for the pending fees of this month."+ "\nThanks,\nBody Fitness Zone.";
360360
if (phoneNumber.length() > 0 && message.length() > 0) {
361361
sendSms(phoneNumber, message);
362362
} else

app/src/main/java/com/aina/dummydatabase/Functionality.java

+5
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ public void dayReminderClick(View v){
194194
startActivity(myInt);
195195
}
196196

197+
public void sendCommonMessageClick(View v){
198+
Intent myInt = new Intent(getBaseContext(), SendCommonMessage.class);
199+
startActivity(myInt);
200+
}
201+
197202
public void onBackupClick(View v){
198203
try {
199204

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
package com.aina.dummydatabase;
2+
3+
import android.app.DatePickerDialog;
4+
import android.content.Context;
5+
import android.database.Cursor;
6+
import android.database.sqlite.SQLiteDatabase;
7+
import android.support.v7.app.AppCompatActivity;
8+
import android.os.Bundle;
9+
import android.telephony.gsm.SmsManager;
10+
import android.util.Log;
11+
import android.view.View;
12+
import android.widget.DatePicker;
13+
import android.widget.EditText;
14+
import android.widget.Toast;
15+
16+
import java.text.SimpleDateFormat;
17+
import java.util.Calendar;
18+
import java.util.Locale;
19+
20+
public class SendCommonMessage extends AppCompatActivity {
21+
22+
@Override
23+
protected void onCreate(Bundle savedInstanceState) {
24+
super.onCreate(savedInstanceState);
25+
setContentView(R.layout.activity_send_common_message);
26+
27+
final EditText fromField = (EditText) findViewById(R.id.fromdate);
28+
final Calendar myCalendar2 = Calendar.getInstance();
29+
final DatePickerDialog.OnDateSetListener date2 = new DatePickerDialog.OnDateSetListener() {
30+
31+
@Override
32+
public void onDateSet(DatePicker view, int year, int monthOfYear,
33+
int dayOfMonth) {
34+
// TODO Auto-generated method stub
35+
myCalendar2.set(Calendar.YEAR, year);
36+
myCalendar2.set(Calendar.MONTH, monthOfYear);
37+
myCalendar2.set(Calendar.DAY_OF_MONTH, dayOfMonth);
38+
String myFormat = "dd/MM/yy"; //In which you need put here
39+
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
40+
fromField.setText(sdf.format(myCalendar2.getTime()));
41+
}
42+
43+
};
44+
45+
fromField.setOnClickListener(new View.OnClickListener() {
46+
47+
@Override
48+
public void onClick(View v) {
49+
// TODO Auto-generated method stub
50+
new DatePickerDialog(SendCommonMessage.this, date2, myCalendar2
51+
.get(Calendar.YEAR), myCalendar2.get(Calendar.MONTH),
52+
myCalendar2.get(Calendar.DAY_OF_MONTH)).show();
53+
}
54+
});
55+
56+
57+
58+
59+
final EditText toField = (EditText) findViewById(R.id.todate);
60+
61+
final Calendar myCalendar3 = Calendar.getInstance();
62+
final DatePickerDialog.OnDateSetListener date3 = new DatePickerDialog.OnDateSetListener() {
63+
64+
@Override
65+
public void onDateSet(DatePicker view, int year, int monthOfYear,
66+
int dayOfMonth) {
67+
// TODO Auto-generated method stub
68+
myCalendar3.set(Calendar.YEAR, year);
69+
myCalendar3.set(Calendar.MONTH, monthOfYear);
70+
myCalendar3.set(Calendar.DAY_OF_MONTH, dayOfMonth);
71+
String myFormat = "dd/MM/yy"; //In which you need put here
72+
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
73+
toField.setText(sdf.format(myCalendar3.getTime()));
74+
}
75+
76+
};
77+
78+
toField.setOnClickListener(new View.OnClickListener() {
79+
80+
@Override
81+
public void onClick(View v) {
82+
// TODO Auto-generated method stub
83+
new DatePickerDialog(SendCommonMessage.this, date3, myCalendar3
84+
.get(Calendar.YEAR), myCalendar3.get(Calendar.MONTH),
85+
myCalendar3.get(Calendar.DAY_OF_MONTH)).show();
86+
}
87+
});
88+
89+
}
90+
91+
public void sendCommonMessage(View v){
92+
EditText reasonField = (EditText) findViewById(R.id.reason);
93+
EditText fromField = (EditText) findViewById(R.id.fromdate);
94+
EditText toField = (EditText) findViewById(R.id.todate);
95+
96+
SQLiteDatabase mydb=openOrCreateDatabase("CustomerDB", Context.MODE_PRIVATE, null);
97+
String query_active = "SELECT name,mobile FROM customer WHERE activestat=1";
98+
Cursor c=mydb.rawQuery(query_active, null);
99+
while(c.moveToNext()) {
100+
String nameCustomer = c.getString(0);
101+
String phoneNumber = c.getString(1);
102+
String message = null;
103+
if (fromField.getText().toString().equals(toField.getText().toString())){
104+
message = "Dear " + nameCustomer + ",\nDue to " + reasonField.getText().toString() +", gym will be closed on " + fromField.getText().toString() + ".\nSorry for the inconvenience :(\nThanks,\nBody Fitness Zone";
105+
}
106+
else{
107+
message = "Dear " + nameCustomer + ",\nDue to " + reasonField.getText().toString() +", gym will be closed from " + fromField.getText().toString() + " to " + toField.getText().toString() + ".\nSorry for the inconvenience :(\nThanks,\nBody Fitness Zone";
108+
}
109+
if (phoneNumber.length() > 0 && message.length() > 0) {
110+
sendSms(phoneNumber, message);
111+
} else
112+
Toast.makeText(getBaseContext(),
113+
"Please enter both phone number and message.",
114+
Toast.LENGTH_SHORT).show();
115+
}
116+
Toast.makeText(getBaseContext(),
117+
"Message Sent Successfully",
118+
Toast.LENGTH_SHORT).show();
119+
}
120+
121+
122+
private void sendSms(String phoneNo, String msg) {
123+
try {
124+
SmsManager smsManager = SmsManager.getDefault();
125+
smsManager.sendTextMessage(phoneNo, null, msg, null, null);
126+
} catch (Exception ex) {
127+
Toast.makeText(getApplicationContext(),ex.getMessage().toString(),
128+
Toast.LENGTH_LONG).show();
129+
ex.printStackTrace();
130+
}
131+
}
132+
}

app/src/main/res/layout/activity_functionality.xml

+7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@
5555
android:onClick="viewPersonClick"
5656
android:text="View Person" />
5757

58+
<Button
59+
android:id="@+id/sendCommonMessage"
60+
android:layout_width="match_parent"
61+
android:layout_height="wrap_content"
62+
android:onClick="sendCommonMessageClick"
63+
android:text="Send Common Message" />
64+
5865
<Button
5966
android:id="@+id/button10"
6067
android:layout_width="match_parent"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context=".SendCommonMessage">
8+
9+
<TextView
10+
android:id="@+id/reasontextView"
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
android:text="Reason:"
14+
tools:layout_editor_absoluteX="0dp" />
15+
16+
<EditText
17+
android:id="@+id/reason"
18+
android:layout_width="match_parent"
19+
android:layout_height="wrap_content"
20+
android:layout_marginTop="15dp"
21+
android:ems="10"
22+
android:inputType="textPersonName"
23+
app:layout_constraintTop_toBottomOf="@+id/reasontextView"
24+
tools:layout_editor_absoluteX="0dp" />
25+
26+
<TextView
27+
android:id="@+id/fromtextView"
28+
android:layout_width="match_parent"
29+
android:layout_height="wrap_content"
30+
android:text="From:"
31+
app:layout_constraintTop_toBottomOf="@+id/reason"
32+
tools:layout_editor_absoluteX="0dp" />
33+
34+
35+
<EditText
36+
android:id="@+id/fromdate"
37+
android:layout_width="match_parent"
38+
android:layout_height="wrap_content"
39+
android:ems="10"
40+
android:clickable="true"
41+
android:editable="false"
42+
android:focusableInTouchMode="false"
43+
app:layout_constraintTop_toBottomOf="@+id/fromtextView"
44+
android:inputType="date" />
45+
46+
<TextView
47+
android:id="@+id/totextView"
48+
android:layout_width="match_parent"
49+
android:layout_height="wrap_content"
50+
android:text="To:"
51+
app:layout_constraintTop_toBottomOf="@+id/fromdate"
52+
tools:layout_editor_absoluteX="0dp" />
53+
54+
<EditText
55+
android:id="@+id/todate"
56+
android:layout_width="match_parent"
57+
android:layout_height="wrap_content"
58+
android:ems="10"
59+
android:clickable="true"
60+
android:editable="false"
61+
android:focusableInTouchMode="false"
62+
app:layout_constraintTop_toBottomOf="@+id/totextView"
63+
android:inputType="date" />
64+
65+
<Button
66+
android:id="@+id/sendCommon"
67+
android:layout_width="wrap_content"
68+
android:layout_height="wrap_content"
69+
android:layout_marginTop="30dp"
70+
android:text="Send"
71+
android:onClick="sendCommonMessage"
72+
app:layout_constraintEnd_toEndOf="parent"
73+
app:layout_constraintStart_toStartOf="parent"
74+
app:layout_constraintTop_toBottomOf="@+id/todate" />
75+
76+
77+
78+
79+
</android.support.constraint.ConstraintLayout>

app/src/main/res/values/strings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<resources>
2-
<string name="app_name">BodyZone Gym</string>
2+
<string name="app_name">Body Fitness Zone</string>
33
<string-array name="gender">
44
<item>S/O</item>
55
<item>D/O</item>

0 commit comments

Comments
 (0)