Commit 79ba481d authored by Robert Hitt's avatar Robert Hitt
Browse files

Added remove button for Notifications

parent 1b7b3efd
......@@ -71,7 +71,7 @@ public class NotificationPresenter {
editNotifications(name, opening, closing, interval_on, interval_15, interval_30,
interval_hour);
} else {
setNotifications("Notifications set.", name, opening, closing, interval_on,
setNotifications("Notifications set", name, opening, closing, interval_on,
interval_15, interval_30, interval_hour);
}
}
......@@ -84,20 +84,20 @@ public class NotificationPresenter {
if(!opening && !closing && !interval_on && !interval_15 && !interval_30 && !interval_hour) {
removeNotifications(name);
} else {
setNotifications("Notifications edited.", name, opening, closing, interval_on,
setNotifications("Notifications edited", name, opening, closing, interval_on,
interval_15, interval_30, interval_hour);
}
}
// Removes the Notification settings from SharedPreferences
private void removeNotifications(String name) {
public void removeNotifications(String name) {
SharedPreferences.Editor editor = pref.edit();
editor.putStringSet(name + "NotificationSettings", null);
editor.apply();
Toast.makeText(mNotificationView.getContext(),
"Notifications removed.", Toast.LENGTH_SHORT).show();
Toast.makeText(mNotificationView.getContext(), "Notifications removed",
Toast.LENGTH_SHORT).show();
mNotificationView.dismiss();
}
......
......@@ -3,7 +3,6 @@ package srct.whatsopen.views.fragments;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
......@@ -39,11 +38,11 @@ public class NotificationDialogFragment extends DialogFragment implements Notifi
@BindView(R.id.interval_hour_check) CheckBox intervalHourCheckBox;
@BindView(R.id.save_button) Button saveButton;
@BindView(R.id.cancel_button) Button cancelButton;
@BindView(R.id.remove_button) Button removeButton;
private String mName;
private NotificationPresenter mPresenter;
private boolean inEditMode;
private Handler mHandler;
public NotificationDialogFragment() {
}
......@@ -95,9 +94,13 @@ public class NotificationDialogFragment extends DialogFragment implements Notifi
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
getDialog().setTitle(mName+" Notifications");
if(inEditMode) {
mPresenter.presentNotifications(mName);
removeButton.setVisibility(View.VISIBLE);
} else {
removeButton.setVisibility(View.GONE);
}
}
......@@ -114,10 +117,18 @@ public class NotificationDialogFragment extends DialogFragment implements Notifi
@OnClick(R.id.cancel_button)
public void onCancel() {
Toast.makeText(getActivity(), "Canceled.", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), "Canceled", Toast.LENGTH_SHORT).show();
dismiss();
}
@OnClick(R.id.remove_button)
public void onRemove() {
mPresenter.removeNotifications(mName);
NotificationDialogListener listener = (NotificationDialogListener) getActivity();
listener.onSetNotification();
}
@Override
public void setNotificationChecks(boolean opening, boolean closing,
boolean interval_on, boolean interval_15,
......
......@@ -56,20 +56,39 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/save_button"
android:text="Save"
android:textColor="@color/colorPrimary"
android:layout_gravity="center_horizontal"
style="?android:borderlessButtonStyle"
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content">
<Button
android:id="@+id/save_button"
android:text="Save"
android:textColor="@color/colorPrimary"
android:layout_gravity="center_horizontal"
android:layout_weight="3"
style="?android:borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/cancel_button"
android:text="Cancel"
android:textColor="@color/colorPrimary"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
style="?android:borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<Button
android:id="@+id/cancel_button"
android:text="Cancel"
android:id="@+id/remove_button"
android:text="Remove"
android:textColor="@color/colorPrimary"
android:layout_gravity="center_horizontal"
android:visibility="gone"
style="?android:borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
......
......@@ -124,6 +124,20 @@
android:text="Cancel"
android:textColor="@color/colorPrimary"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
style="?android:borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/remove_button"
android:text="Remove"
android:textColor="@color/colorPrimary"
android:layout_toRightOf="@id/save_button"
android:layout_toEndOf="@id/save_button"
android:layout_toStartOf="@id/cancel_button"
android:layout_toLeftOf="@id/cancel_button"
android:visibility="gone"
style="?android:borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment