forked from iSoron/uhabits
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
189 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 0 additions & 128 deletions
128
uhabits-android/src/main/java/org/isoron/uhabits/notifications/SnoozeDelayActivity.java
This file was deleted.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
...its-android/src/main/java/org/isoron/uhabits/notifications/SnoozeDelayPickerActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package org.isoron.uhabits.notifications; | ||
|
||
import android.os.*; | ||
import android.support.annotation.*; | ||
import android.support.v4.app.*; | ||
import android.support.v7.app.*; | ||
import android.text.format.*; | ||
import android.view.*; | ||
import android.widget.*; | ||
|
||
import com.android.datetimepicker.time.*; | ||
|
||
import org.isoron.uhabits.*; | ||
import org.isoron.uhabits.R; | ||
import org.isoron.uhabits.core.models.*; | ||
import org.isoron.uhabits.receivers.*; | ||
|
||
import java.util.*; | ||
|
||
import butterknife.*; | ||
|
||
import static android.content.ContentUris.*; | ||
|
||
public class SnoozeDelayPickerActivity extends AppCompatActivity implements AdapterView | ||
.OnItemClickListener | ||
{ | ||
public static final String ACTION_ASK_SNOOZE = "org.isoron.uhabits.ACTION_ASK_SNOOZE"; | ||
|
||
private Habit habit; | ||
|
||
private ReminderController reminderController; | ||
|
||
@BindArray(R.array.snooze_picker_names) | ||
protected String[] snoozeNames; | ||
|
||
@BindArray(R.array.snooze_picker_values) | ||
protected int[] snoozeValues; | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle bundle) | ||
{ | ||
super.onCreate(bundle); | ||
if (getIntent() == null) finish(); | ||
if (getIntent().getData() == null) finish(); | ||
|
||
HabitsApplication app = (HabitsApplication) getApplicationContext(); | ||
HabitsApplicationComponent appComponent = app.getComponent(); | ||
reminderController = appComponent.getReminderController(); | ||
habit = appComponent.getHabitList().getById(parseId(getIntent().getData())); | ||
if (habit == null) finish(); | ||
|
||
setTheme(R.style.Theme_AppCompat_Light_Dialog_Alert); | ||
ButterKnife.bind(this); | ||
|
||
ListView listView = new ListView(this); | ||
listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, | ||
snoozeNames)); | ||
listView.setOnItemClickListener(this); | ||
setContentView(listView); | ||
} | ||
|
||
@Override | ||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) | ||
{ | ||
if (snoozeValues[position] >= 0) | ||
{ | ||
reminderController.onSnoozeDelayPicked(habit, snoozeValues[position]); | ||
finish(); | ||
} | ||
else showTimePicker(); | ||
} | ||
|
||
private void showTimePicker() | ||
{ | ||
final Calendar calendar = Calendar.getInstance(); | ||
int defaultHour = calendar.get(Calendar.HOUR_OF_DAY); | ||
int defaultMinute = calendar.get(Calendar.MINUTE); | ||
TimePickerDialog dialog = TimePickerDialog.newInstance( | ||
(view, hour, minute) -> | ||
reminderController.onSnoozeTimePicked(habit, hour, minute), | ||
defaultHour, defaultMinute, DateFormat.is24HourFormat(this)); | ||
|
||
dialog.show(getSupportFragmentManager(), "timePicker"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.