Skip to content

Commit

Permalink
Merge pull request #16 from WrichikBasu/bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
WrichikBasu authored Nov 7, 2020
2 parents 14b9fd5 + d79f783 commit a5394f3
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 48 deletions.
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**To Reproduce:**
Steps to reproduce the behaviour:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error.

**Expected behaviour v/s Actual behaviour:**
A clear and concise description of what you expected to happen, and what happened istead.

**Screenshots/screen video:**
If applicable, add screenshots to help explain your problem.

**Device information:**
- Device model: [e.g. Samsung Galaxy On7 Pro]
- Android version: [e.g. Marshmallow/Oreo]
- App version [e.g. 1.2.8]
- Downloaded from (GitHub/Google Play):

**Additional context:**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "in.basulabs.shakealarmclock"
minSdkVersion 21
targetSdkVersion 30
versionCode 11
versionName "1.2.8"
versionCode 12
versionName "1.2.9"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.os.Build;
import android.os.Bundle;
import android.provider.AlarmClock;
import android.util.Log;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
Expand Down Expand Up @@ -68,22 +67,17 @@ public class Activity_IntentManager extends AppCompatActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Log.e(this.getClass().getSimpleName(), Objects.requireNonNull(getIntent().getAction()));

Intent intent = getIntent();

switch (Objects.requireNonNull(intent.getAction())) {

case AlarmClock.ACTION_SET_ALARM:

Log.e(this.getClass().getSimpleName(), "received action SET_ALARM.");

if (! intent.hasExtra(AlarmClock.EXTRA_HOUR) || ! intent.hasExtra(AlarmClock.EXTRA_MINUTES)) {
///////////////////////////////////////////////////////////////////////
// These two extras are necessary for an alarm to be set. Without
// these, the user will be redirected to Activity_AlarmsList.
///////////////////////////////////////////////////////////////////////
Log.e(this.getClass().getSimpleName(), "Intent does not have any extras.");

Intent intent1 = new Intent(this, Activity_AlarmsList.class);
intent1.setAction(ACTION_NEW_ALARM_FROM_INTENT)
Expand All @@ -94,11 +88,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (isVoiceInteraction()) {

Log.e(this.getClass().getSimpleName(), "Voice interaction.");

Bundle status = new Bundle();
VoiceInteractor.Prompt prompt = new VoiceInteractor.Prompt(
new String[]{"You can do that in the app."},
VoiceInteractor.Prompt prompt = new VoiceInteractor.Prompt(new String[]{"You can do that in the app."},
"You can do that in the app.");

VoiceInteractor.Request request = new VoiceInteractor.CompleteVoiceRequest(prompt, status);
Expand All @@ -111,11 +102,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (isVoiceInteraction()) {

Log.e(this.getClass().getSimpleName(), "Voice interaction.");

Bundle status = new Bundle();
VoiceInteractor.Prompt prompt = new VoiceInteractor.Prompt(
new String[]{"Your alarm has been set by Shake Alarm Clock."},
VoiceInteractor.Prompt prompt = new VoiceInteractor.Prompt(new String[]{"Your alarm has been set by Shake Alarm Clock."},
"Your alarm has been set by Shake Alarm Clock.");

VoiceInteractor.Request request = new VoiceInteractor.CompleteVoiceRequest(prompt, status);
Expand All @@ -128,12 +116,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

case AlarmClock.ACTION_DISMISS_ALARM:

if (Service_RingAlarm.isThisServiceRunning && Service_RingAlarm.alarmID != - 1) {
Intent intent1 = new Intent(this, Service_RingAlarm.class);
stopService(intent1);
} else if (Service_SnoozeAlarm.isThisServiceRunning && Service_SnoozeAlarm.alarmID != - 1) {
Intent intent1 = new Intent(this, Service_SnoozeAlarm.class);
stopService(intent1);
if (Service_RingAlarm.isThisServiceRunning || Service_SnoozeAlarm.isThisServiceRunning) {
sendBroadcast(new Intent(ConstantsAndStatics.ACTION_CANCEL_ALARM));
} else {
Intent intent2 = new Intent(this, Activity_AlarmsList.class)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
Expand Down Expand Up @@ -206,21 +190,18 @@ private void setAlarm() {

if (! doesFileExist(alarmToneUri)) {
// Uri invalid or file doesn't exist; fall back to default tone
alarmToneUri = Uri.parse(sharedPreferences.getString(SHARED_PREF_KEY_DEFAULT_ALARM_TONE_URI,
"content://settings/system/alarm_alert"));
alarmToneUri = Uri.parse(sharedPreferences.getString(SHARED_PREF_KEY_DEFAULT_ALARM_TONE_URI, "content://settings/system/alarm_alert"));
}

}
} else {
alarmToneUri = Uri.parse(sharedPreferences.getString(SHARED_PREF_KEY_DEFAULT_ALARM_TONE_URI,
"content://settings/system/alarm_alert"));
alarmToneUri = Uri.parse(sharedPreferences.getString(SHARED_PREF_KEY_DEFAULT_ALARM_TONE_URI, "content://settings/system/alarm_alert"));
}

int volume;
if (alarmToneUri != null) {
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
volume = sharedPreferences.getInt(SHARED_PREF_KEY_DEFAULT_ALARM_VOLUME,
audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM) - 1);
volume = sharedPreferences.getInt(SHARED_PREF_KEY_DEFAULT_ALARM_VOLUME, audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM) - 1);
} else {
volume = 0;
}
Expand All @@ -241,8 +222,7 @@ private void setAlarm() {
////////////////////////////////
AlarmDatabase alarmDatabase = AlarmDatabase.getInstance(this);

LocalDateTime alarmDateTime = ConstantsAndStatics.getAlarmDateTime(LocalDate.now(), alarmTime,
isRepeatOn, repeatDays);
LocalDateTime alarmDateTime = ConstantsAndStatics.getAlarmDateTime(LocalDate.now(), alarmTime, isRepeatOn, repeatDays);

if (intent.getExtras().getBoolean(AlarmClock.EXTRA_SKIP_UI, false)) {
// We have been asked to skip the UI. Alarm will be set by this activity itself.
Expand All @@ -269,8 +249,8 @@ private void setAlarm() {

AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

Intent intent1 = new Intent(this, AlarmBroadcastReceiver.class);
intent1.setAction(ConstantsAndStatics.ACTION_DELIVER_ALARM)
Intent intent1 = new Intent(this, AlarmBroadcastReceiver.class)
.setAction(ConstantsAndStatics.ACTION_DELIVER_ALARM)
.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);

alarmEntity.alarmID = alarmID.get();
Expand All @@ -280,13 +260,11 @@ private void setAlarm() {
data.putInt(BUNDLE_KEY_ALARM_ID, alarmID.get());
intent1.putExtra(BUNDLE_KEY_ALARM_DETAILS, data);

PendingIntent pendingIntent = PendingIntent.getBroadcast(this, alarmID.get(),
intent1, PendingIntent.FLAG_CANCEL_CURRENT);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), alarmID.get(), intent1, 0);

ZonedDateTime zonedDateTime = ZonedDateTime.of(alarmDateTime.withSecond(0), ZoneId.systemDefault());
ZonedDateTime zonedDateTime = ZonedDateTime.of(alarmDateTime.withSecond(0).withNano(0), ZoneId.systemDefault());

alarmManager.setAlarmClock(new AlarmManager.AlarmClockInfo(zonedDateTime.toEpochSecond() * 1000,
pendingIntent), pendingIntent);
alarmManager.setAlarmClock(new AlarmManager.AlarmClockInfo(zonedDateTime.toEpochSecond() * 1000, pendingIntent), pendingIntent);

ConstantsAndStatics.schedulePeriodicWork(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Activity_RingAlarm extends AppCompatActivity implements View.OnClic

private SharedPreferences sharedPreferences;

private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (Objects.equals(intent.getAction(), ConstantsAndStatics.ACTION_DESTROY_RING_ALARM_ACTIVITY)) {
Expand Down Expand Up @@ -73,7 +73,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
alarmTimeTextView.setText(getResources().getString(R.string.time_24hour,
localTime.getHour(), localTime.getMinute()));
} else {
String amPm = localTime.getHour() <= 12 ? "AM" : "PM";
String amPm = localTime.getHour() < 12 ? "AM" : "PM";

if ((localTime.getHour() <= 12) && (localTime.getHour() > 0)) {

Expand Down
Loading

0 comments on commit a5394f3

Please sign in to comment.