diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java
index 2b06dc4..6eb89b1 100644
--- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java
+++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java
@@ -8,6 +8,7 @@ import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.widget.EditText;
+import android.widget.Toast;
public class EditServiceDialogFragment extends DialogFragment{
@@ -47,18 +48,25 @@ public interface NoticeDialogListener {
Bundle args = new Bundle();
args.putString("name", (String)getArguments().get("name"));
EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput);
- double rate = Double.parseDouble(rateInput.getText().toString());
- args.putDouble("rate", rate);
-
- EditServiceDialogFragment.this.setArguments(args);
- mListener.onDialogEdit(EditServiceDialogFragment.this);
+ if(rateInput.getText().toString().length()>0){
+ Double rate = Double.parseDouble(rateInput.getText().toString());
+ args.putDouble("rate", rate);
+
+ EditServiceDialogFragment.this.setArguments(args);
+ mListener.onDialogEdit(EditServiceDialogFragment.this);
+ }
+ else{
+ Toast.makeText(getContext(), "Rate cannot be empty", Toast.LENGTH_LONG).show();
+
+ }
+
}
})
.setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Bundle args = new Bundle();
args.putString("name", (String)getArguments().get("name"));
-
+
EditServiceDialogFragment.this.setArguments(args);
mListener.onDialogDelete(EditServiceDialogFragment.this);
}
diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java
index a5240f5..3e2e5df 100644
--- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java
+++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java
@@ -15,6 +15,7 @@ import android.support.annotation.Nullable;
import android.view.ViewGroup;
import android.widget.EditText;
import android.view.View;
+import android.widget.Toast;
import com.rengwuxian.materialedittext.MaterialEditText;
@@ -63,13 +64,18 @@ public class NewServiceDialogFragment extends DialogFragment {
EditText nameInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.NameInput);
EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput);
String name = nameInput.getText().toString();
- double rate = Double.parseDouble(rateInput.getText().toString());
- Bundle args = new Bundle();
- args.putString("name", name);
- args.putDouble("rate", rate);
- NewServiceDialogFragment.this.setArguments(args);
- mListener.onDialogNew(NewServiceDialogFragment.this);
-
+ if (rateInput.getText().toString().length()>0 && name.length()>0 && name.matches("[a-zA-Z]*")){
+ Double rate = Double.parseDouble(rateInput.getText().toString());
+ Bundle args = new Bundle();
+ args.putString("name", name);
+ args.putDouble("rate", rate);
+ NewServiceDialogFragment.this.setArguments(args);
+ mListener.onDialogNew(NewServiceDialogFragment.this);
+ }
+ else{
+ Toast.makeText(getContext(), "Service must have an alphanumeric name and a rate", Toast.LENGTH_LONG).show();
+
+ }
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java
index db0cd9e..2591a71 100644
--- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java
+++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java
@@ -14,6 +14,7 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.TextView;
+import android.widget.Toast;
import java.util.Iterator;
import java.util.List;
@@ -91,6 +92,7 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF
DBHelper dbHelper = new DBHelper(this);
String name = (String)dialog.getArguments().get("name");
dbHelper.deleteService(name);
+ Toast.makeText(this, "Service \""+(String)dialog.getArguments().get("name")+"\" has been deleted", Toast.LENGTH_LONG).show();
dialog.dismiss();
this.recreate();
}
diff --git a/OlympusServices/app/src/main/res/layout/activity_services_list.xml b/OlympusServices/app/src/main/res/layout/activity_services_list.xml
index 03bbcf4..756282d 100644
--- a/OlympusServices/app/src/main/res/layout/activity_services_list.xml
+++ b/OlympusServices/app/src/main/res/layout/activity_services_list.xml
@@ -50,7 +50,7 @@
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
- android:text="Hourly Rate"
+ android:text="Hourly Rate($)"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@android:color/white"
android:textSize="15sp" />
@@ -67,11 +67,22 @@
android:layout_height="250dp"/>
+
diff --git a/OlympusServices/app/src/main/res/layout/dialog_service_edit.xml b/OlympusServices/app/src/main/res/layout/dialog_service_edit.xml
index 0252681..eb82837 100644
--- a/OlympusServices/app/src/main/res/layout/dialog_service_edit.xml
+++ b/OlympusServices/app/src/main/res/layout/dialog_service_edit.xml
@@ -16,6 +16,7 @@
android:inputType="numberDecimal"
android:textCursorDrawable="@color/colorWhite"
android:textSize="15sp"
+ android:text=""
app:met_baseColor="@android:color/black"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorBlack"
diff --git a/OlympusServices/app/src/main/res/layout/dialog_service_new.xml b/OlympusServices/app/src/main/res/layout/dialog_service_new.xml
index 9ef5359..ccce43c 100644
--- a/OlympusServices/app/src/main/res/layout/dialog_service_new.xml
+++ b/OlympusServices/app/src/main/res/layout/dialog_service_new.xml
@@ -14,6 +14,7 @@
android:hint="@string/servicename"
android:textCursorDrawable="@color/colorWhite"
android:textSize="15sp"
+ android:text=""
app:met_baseColor="@android:color/black"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorBlack"
@@ -28,6 +29,7 @@
android:layout_height="80dp"
android:layout_marginTop="20dp"
android:hint="@string/servicerate"
+ android:text=""
android:inputType="numberDecimal"
android:textCursorDrawable="@color/colorWhite"
android:textSize="15sp"
diff --git a/OlympusServices/app/src/main/res/layout/list_item.xml b/OlympusServices/app/src/main/res/layout/list_item.xml
index 6669b81..57c79f3 100644
--- a/OlympusServices/app/src/main/res/layout/list_item.xml
+++ b/OlympusServices/app/src/main/res/layout/list_item.xml
@@ -1,7 +1,7 @@
@@ -9,7 +9,8 @@