-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use Activity to make sure the refresh mode change is fast e…
…nough.
- Loading branch information
1 parent
e58a0b6
commit 4b75285
Showing
11 changed files
with
70 additions
and
25 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
38 changes: 38 additions & 0 deletions
38
app/src/main/java/info/plateaukao/quickrotate/RefreshModeActivity.kt
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,38 @@ | ||
package info.plateaukao.quickrotate | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import com.onyx.android.sdk.api.device.epd.UpdateOption | ||
import com.onyx.android.sdk.device.Device | ||
|
||
private val device = Device.currentDevice | ||
|
||
class RefreshModeActivity : Activity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
handleIntent() | ||
finish() | ||
} | ||
|
||
private fun handleIntent() { | ||
val updateOption = findUpdateOption(intent.getIntExtra(ARG_UPDATE_OPTION, UpdateOption.NORMAL.ordinal)) | ||
device.systemRefreshMode = updateOption | ||
} | ||
|
||
private fun findUpdateOption(value: Int): UpdateOption = | ||
UpdateOption.values().firstOrNull { it.ordinal == value } ?: UpdateOption.NORMAL | ||
|
||
companion object { | ||
private const val ARG_UPDATE_OPTION = "update_option" | ||
|
||
fun createIntent(context: Context, option: UpdateOption): Intent { | ||
return Intent(context, RefreshModeActivity::class.java).apply { | ||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
putExtra(ARG_UPDATE_OPTION, option.ordinal) | ||
} | ||
} | ||
} | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".RefreshModeActivity"> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
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