Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open-android
Commits
79ba481d
Commit
79ba481d
authored
Jan 15, 2017
by
Robert Hitt
Browse files
Added remove button for Notifications
parent
1b7b3efd
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/srct/whatsopen/presenters/NotificationPresenter.java
View file @
79ba481d
...
@@ -71,7 +71,7 @@ public class NotificationPresenter {
...
@@ -71,7 +71,7 @@ public class NotificationPresenter {
editNotifications
(
name
,
opening
,
closing
,
interval_on
,
interval_15
,
interval_30
,
editNotifications
(
name
,
opening
,
closing
,
interval_on
,
interval_15
,
interval_30
,
interval_hour
);
interval_hour
);
}
else
{
}
else
{
setNotifications
(
"Notifications set
.
"
,
name
,
opening
,
closing
,
interval_on
,
setNotifications
(
"Notifications set"
,
name
,
opening
,
closing
,
interval_on
,
interval_15
,
interval_30
,
interval_hour
);
interval_15
,
interval_30
,
interval_hour
);
}
}
}
}
...
@@ -84,20 +84,20 @@ public class NotificationPresenter {
...
@@ -84,20 +84,20 @@ public class NotificationPresenter {
if
(!
opening
&&
!
closing
&&
!
interval_on
&&
!
interval_15
&&
!
interval_30
&&
!
interval_hour
)
{
if
(!
opening
&&
!
closing
&&
!
interval_on
&&
!
interval_15
&&
!
interval_30
&&
!
interval_hour
)
{
removeNotifications
(
name
);
removeNotifications
(
name
);
}
else
{
}
else
{
setNotifications
(
"Notifications edited
.
"
,
name
,
opening
,
closing
,
interval_on
,
setNotifications
(
"Notifications edited"
,
name
,
opening
,
closing
,
interval_on
,
interval_15
,
interval_30
,
interval_hour
);
interval_15
,
interval_30
,
interval_hour
);
}
}
}
}
// Removes the Notification settings from SharedPreferences
// Removes the Notification settings from SharedPreferences
p
rivate
void
removeNotifications
(
String
name
)
{
p
ublic
void
removeNotifications
(
String
name
)
{
SharedPreferences
.
Editor
editor
=
pref
.
edit
();
SharedPreferences
.
Editor
editor
=
pref
.
edit
();
editor
.
putStringSet
(
name
+
"NotificationSettings"
,
null
);
editor
.
putStringSet
(
name
+
"NotificationSettings"
,
null
);
editor
.
apply
();
editor
.
apply
();
Toast
.
makeText
(
mNotificationView
.
getContext
(),
Toast
.
makeText
(
mNotificationView
.
getContext
(),
"Notifications removed"
,
"Notifications removed."
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
LENGTH_SHORT
).
show
();
mNotificationView
.
dismiss
();
mNotificationView
.
dismiss
();
}
}
...
...
app/src/main/java/srct/whatsopen/views/fragments/NotificationDialogFragment.java
View file @
79ba481d
...
@@ -3,7 +3,6 @@ package srct.whatsopen.views.fragments;
...
@@ -3,7 +3,6 @@ package srct.whatsopen.views.fragments;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.DialogInterface
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.v4.app.DialogFragment
;
import
android.support.v4.app.DialogFragment
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
...
@@ -39,11 +38,11 @@ public class NotificationDialogFragment extends DialogFragment implements Notifi
...
@@ -39,11 +38,11 @@ public class NotificationDialogFragment extends DialogFragment implements Notifi
@BindView
(
R
.
id
.
interval_hour_check
)
CheckBox
intervalHourCheckBox
;
@BindView
(
R
.
id
.
interval_hour_check
)
CheckBox
intervalHourCheckBox
;
@BindView
(
R
.
id
.
save_button
)
Button
saveButton
;
@BindView
(
R
.
id
.
save_button
)
Button
saveButton
;
@BindView
(
R
.
id
.
cancel_button
)
Button
cancelButton
;
@BindView
(
R
.
id
.
cancel_button
)
Button
cancelButton
;
@BindView
(
R
.
id
.
remove_button
)
Button
removeButton
;
private
String
mName
;
private
String
mName
;
private
NotificationPresenter
mPresenter
;
private
NotificationPresenter
mPresenter
;
private
boolean
inEditMode
;
private
boolean
inEditMode
;
private
Handler
mHandler
;
public
NotificationDialogFragment
()
{
public
NotificationDialogFragment
()
{
}
}
...
@@ -95,9 +94,13 @@ public class NotificationDialogFragment extends DialogFragment implements Notifi
...
@@ -95,9 +94,13 @@ public class NotificationDialogFragment extends DialogFragment implements Notifi
super
.
onViewCreated
(
view
,
savedInstanceState
);
super
.
onViewCreated
(
view
,
savedInstanceState
);
ButterKnife
.
bind
(
this
,
view
);
ButterKnife
.
bind
(
this
,
view
);
getDialog
().
setTitle
(
mName
+
" Notifications"
);
if
(
inEditMode
)
{
if
(
inEditMode
)
{
mPresenter
.
presentNotifications
(
mName
);
mPresenter
.
presentNotifications
(
mName
);
removeButton
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
removeButton
.
setVisibility
(
View
.
GONE
);
}
}
}
}
...
@@ -114,10 +117,18 @@ public class NotificationDialogFragment extends DialogFragment implements Notifi
...
@@ -114,10 +117,18 @@ public class NotificationDialogFragment extends DialogFragment implements Notifi
@OnClick
(
R
.
id
.
cancel_button
)
@OnClick
(
R
.
id
.
cancel_button
)
public
void
onCancel
()
{
public
void
onCancel
()
{
Toast
.
makeText
(
getActivity
(),
"Canceled
.
"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getActivity
(),
"Canceled"
,
Toast
.
LENGTH_SHORT
).
show
();
dismiss
();
dismiss
();
}
}
@OnClick
(
R
.
id
.
remove_button
)
public
void
onRemove
()
{
mPresenter
.
removeNotifications
(
mName
);
NotificationDialogListener
listener
=
(
NotificationDialogListener
)
getActivity
();
listener
.
onSetNotification
();
}
@Override
@Override
public
void
setNotificationChecks
(
boolean
opening
,
boolean
closing
,
public
void
setNotificationChecks
(
boolean
opening
,
boolean
closing
,
boolean
interval_on
,
boolean
interval_15
,
boolean
interval_on
,
boolean
interval_15
,
...
...
app/src/main/res/layout-land/fragment_notification_dialog.xml
View file @
79ba481d
...
@@ -56,20 +56,39 @@
...
@@ -56,20 +56,39 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
>
<Button
<LinearLayout
android:id=
"@+id/save_button"
android:orientation=
"horizontal"
android:text=
"Save"
android:textColor=
"@color/colorPrimary"
android:layout_gravity=
"center_horizontal"
style=
"?android:borderlessButtonStyle"
android:layout_width=
"wrap_content"
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
<Button
android:id=
"@+id/
cancel
_button"
android:id=
"@+id/
remove
_button"
android:text=
"
Cancel
"
android:text=
"
Remove
"
android:textColor=
"@color/colorPrimary"
android:textColor=
"@color/colorPrimary"
android:layout_gravity=
"center_horizontal"
android:layout_gravity=
"center_horizontal"
android:visibility=
"gone"
style=
"?android:borderlessButtonStyle"
style=
"?android:borderlessButtonStyle"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
/>
...
...
app/src/main/res/layout/fragment_notification_dialog.xml
View file @
79ba481d
...
@@ -124,6 +124,20 @@
...
@@ -124,6 +124,20 @@
android:text=
"Cancel"
android:text=
"Cancel"
android:textColor=
"@color/colorPrimary"
android:textColor=
"@color/colorPrimary"
android:layout_alignParentRight=
"true"
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"
style=
"?android:borderlessButtonStyle"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment