Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Commit

Permalink
Release 2.6 - Refactor code for readability
Browse files Browse the repository at this point in the history
- Limit the use of scoping functions (let, apply, with, etc) and use
  intermediate variables to make code easier to read and understand.
- Clean up comments, function names, variable names, and class names.
- Fix some bugs related to UI updates not occuring in MainActivity.kt.
- Make the footer text in MainActivity.kt HTML formatted and clickable.
  • Loading branch information
nazmulidris committed Aug 2, 2020
1 parent 75449a4 commit d9bae17
Show file tree
Hide file tree
Showing 14 changed files with 276 additions and 186 deletions.
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.

6 changes: 3 additions & 3 deletions .idea/modules/app/app.iml

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

45 changes: 45 additions & 0 deletions .idea/watcherTasks.xml

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

44 changes: 32 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [stay-awake-app](#stay-awake-app)
- [Future of this app in question](#future-of-this-app-in-question)
- [Change master to main (2020-06-27)](#change-master-to-main-2020-06-27)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# stay-awake-app

This app is like Caffeine for Mac. It keeps your device awake as long as it's connected to power. It also uses quick
settings tiles from Android N as its main interface. It also works on Android O (with the new background behaviors).

## License
# Future of this app is in question

Copyright 2020 R3BL, LLC.
Android is deprecating most of the APIs that this app relies on and more than likely this app will be deprecated soon.
It heavily relies on background operation and the ability to acquire a wake lock, both of which are things that Android
does not want apps to do anymore.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you
under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License.
Here's [an article](https://medium.com/nala-money/the-bifurcation-of-android-6fa1cced074d) on how the Android OS is
implemented by various device manufacturers & carriers affects what can be done by app developers using the APIs that
are implemented differently on each device.

# Change master to main (2020-06-27)

Expand All @@ -39,3 +44,18 @@ notion of slave branches.
- https://www.hanselman.com/blog/EasilyRenameYourGitDefaultBranchFromMasterToMain.aspx

[#blacklivesmatter](https://blacklivesmatter.com/)

## License

Copyright 2020 R3BL, LLC.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you
under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
applicationId "com.r3bl.stayawake"
minSdkVersion 25
targetSdkVersion 28
versionCode 17
versionName "2.5"
versionCode 18
versionName "2.6"
}
buildTypes {
release {
Expand Down
12 changes: 5 additions & 7 deletions app/src/main/java/com/r3bl/stayawake/HandleNotifications.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ object HandleNotifications {
const val SMALL_ICON = R.drawable.ic_stat_visibility
const val STOP_ACTION_ICON = R.drawable.ic_stat_flare

/** PendingIntent to stop the service. */
private fun getPendingIntentToStopService(context: Service) = PendingIntent.getService(
context, randomNumber, getExplicitIntentToStopService(context), 0)
/** [PendingIntent] to stop the service. */
private fun getPendingIntentToStopService(context: Service) =
PendingIntent.getService(context, randomNumber, getExplicitIntentToStopService(context), 0)

/** Get pending intent to launch the activity. */
/** Get [PendingIntent] to launch the activity. */
private fun getPendingIntentToLaunchActivity(context: Service): PendingIntent {
val intentToLaunchMainActivity = Intent(context, MainActivity::class.java)
return PendingIntent.getActivity(context, randomNumber, intentToLaunchMainActivity, 0)
Expand All @@ -56,7 +56,6 @@ object HandleNotifications {
getStopActionText(context),
getPendingIntentToStopService(context))
.build()

// Create a notification.
// More information on ignored Channel ID: https://stackoverflow.com/a/45580202/2085356
val notification = NotificationCompat.Builder(context, "")
Expand Down Expand Up @@ -87,7 +86,6 @@ object HandleNotifications {
getStopActionText(context),
getPendingIntentToStopService(context))
.build()

// Create a notification.
return NotificationCompat.Builder(context, channelId)
.setContentTitle(getTitle(context))
Expand All @@ -113,4 +111,4 @@ object HandleNotifications {
private val randomNumber: Int
get() = Random().nextInt(100000)

} // end class HandleNotifications.
}
Loading

0 comments on commit d9bae17

Please sign in to comment.