Migrate to viewbinding and kotlin gradle scripts
- Updated to viewbinding and kotlin gradle scripts - Updated kotlin to 1.9.0 - Updated Android Gradle Plugin to 8.1.0 - Updated `androidx.lifecycle` to 2.6.1 - Updated `room` to 2.6.0-alpha02 - Updated `androidx.work` to 2.8.1 - Updated `kotlinx.coroutines` to 1.7.3 - Updated `stetho` to 1.6.0
This commit is contained in:
parent
3e83e61748
commit
8e713bb68c
34 changed files with 776 additions and 574 deletions
|
@ -1,82 +0,0 @@
|
||||||
apply plugin: 'com.android.application'
|
|
||||||
apply plugin: 'kotlin-android'
|
|
||||||
apply plugin: 'kotlin-android-extensions'
|
|
||||||
apply plugin: 'kotlin-kapt'
|
|
||||||
|
|
||||||
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
|
||||||
def keystoreProperties = new Properties()
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 34
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
applicationId "com.simplemobiletools.clock"
|
|
||||||
minSdkVersion 23
|
|
||||||
targetSdkVersion 34
|
|
||||||
versionCode 39
|
|
||||||
versionName "5.10.3"
|
|
||||||
setProperty("archivesBaseName", "clock")
|
|
||||||
vectorDrawables.useSupportLibrary = true
|
|
||||||
}
|
|
||||||
|
|
||||||
signingConfigs {
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
release {
|
|
||||||
keyAlias keystoreProperties['keyAlias']
|
|
||||||
keyPassword keystoreProperties['keyPassword']
|
|
||||||
storeFile file(keystoreProperties['storeFile'])
|
|
||||||
storePassword keystoreProperties['storePassword']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
debug {
|
|
||||||
applicationIdSuffix ".debug"
|
|
||||||
}
|
|
||||||
release {
|
|
||||||
minifyEnabled true
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
signingConfig signingConfigs.release
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flavorDimensions "variants"
|
|
||||||
productFlavors {
|
|
||||||
core {}
|
|
||||||
fdroid {}
|
|
||||||
prepaid {}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
|
||||||
}
|
|
||||||
|
|
||||||
lintOptions {
|
|
||||||
checkReleaseBuilds false
|
|
||||||
abortOnError false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation 'com.github.esensar:Simple-Commons:2d54383217'
|
|
||||||
implementation 'com.facebook.stetho:stetho:1.5.1'
|
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
|
||||||
implementation 'io.github.ShawnLin013:number-picker:2.4.13'
|
|
||||||
implementation "androidx.preference:preference-ktx:1.2.0"
|
|
||||||
implementation "androidx.work:work-runtime-ktx:2.7.1"
|
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'
|
|
||||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
|
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
|
|
||||||
implementation 'org.greenrobot:eventbus:3.3.1'
|
|
||||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
|
||||||
implementation 'me.grantland:autofittextview:0.2.1'
|
|
||||||
|
|
||||||
implementation 'androidx.room:room-runtime:2.5.1'
|
|
||||||
kapt 'androidx.room:room-compiler:2.5.1'
|
|
||||||
}
|
|
109
app/build.gradle.kts
Normal file
109
app/build.gradle.kts
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
import java.io.FileInputStream
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
import org.jetbrains.kotlin.konan.properties.Properties
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android)
|
||||||
|
alias(libs.plugins.kotlinAndroid)
|
||||||
|
alias(libs.plugins.ksp)
|
||||||
|
}
|
||||||
|
|
||||||
|
val keystorePropertiesFile: File = rootProject.file("keystore.properties")
|
||||||
|
val keystoreProperties = Properties()
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdk = project.libs.versions.app.build.compileSDKVersion.get().toInt()
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = libs.versions.app.version.appId.get()
|
||||||
|
minSdk = project.libs.versions.app.build.minimumSDK.get().toInt()
|
||||||
|
targetSdk = project.libs.versions.app.build.targetSDK.get().toInt()
|
||||||
|
versionName = project.libs.versions.app.version.versionName.get()
|
||||||
|
versionCode = project.libs.versions.app.version.versionCode.get().toInt()
|
||||||
|
setProperty("archivesBaseName", "clock")
|
||||||
|
ksp {
|
||||||
|
arg("room.schemaLocation", "$projectDir/schemas")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
signingConfigs {
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
register("release") {
|
||||||
|
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||||
|
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||||
|
storeFile = file(keystoreProperties.getProperty("storeFile"))
|
||||||
|
storePassword = keystoreProperties.getProperty("storePassword")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
viewBinding = true
|
||||||
|
buildConfig = true
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
applicationIdSuffix = ".debug"
|
||||||
|
}
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = true
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
signingConfig = signingConfigs.getByName("release")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flavorDimensions.add("variants")
|
||||||
|
productFlavors {
|
||||||
|
register("core")
|
||||||
|
register("fdroid")
|
||||||
|
register("prepaid")
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
getByName("main").java.srcDirs("src/main/kotlin")
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
val currentJavaVersionFromLibs = JavaVersion.valueOf(libs.versions.app.build.javaVersion.get().toString())
|
||||||
|
sourceCompatibility = currentJavaVersionFromLibs
|
||||||
|
targetCompatibility = currentJavaVersionFromLibs
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<KotlinCompile> {
|
||||||
|
kotlinOptions.jvmTarget = project.libs.versions.app.build.kotlinJVMTarget.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace = libs.versions.app.version.appId.get()
|
||||||
|
|
||||||
|
lint {
|
||||||
|
checkReleaseBuilds = false
|
||||||
|
abortOnError = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.simple.tools.commons)
|
||||||
|
|
||||||
|
// implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||||
|
implementation(libs.bundles.lifecycle)
|
||||||
|
implementation(libs.androidx.constraintlayout)
|
||||||
|
implementation(libs.androidx.preference)
|
||||||
|
implementation(libs.androidx.work)
|
||||||
|
implementation(libs.kotlinx.coroutines)
|
||||||
|
implementation(libs.stetho)
|
||||||
|
implementation(libs.numberpicker)
|
||||||
|
implementation(libs.autofittextview)
|
||||||
|
implementation(libs.eventbus)
|
||||||
|
|
||||||
|
implementation(libs.bundles.room)
|
||||||
|
ksp(libs.androidx.room.compiler)
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
{
|
||||||
|
"formatVersion": 1,
|
||||||
|
"database": {
|
||||||
|
"version": 1,
|
||||||
|
"identityHash": "d1a9a1d39e0899af980c9ddc7632dd8f",
|
||||||
|
"entities": [
|
||||||
|
{
|
||||||
|
"tableName": "timers",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `seconds` INTEGER NOT NULL, `state` TEXT NOT NULL, `vibrate` INTEGER NOT NULL, `soundUri` TEXT NOT NULL, `soundTitle` TEXT NOT NULL, `label` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `channelId` TEXT)",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "seconds",
|
||||||
|
"columnName": "seconds",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "state",
|
||||||
|
"columnName": "state",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "vibrate",
|
||||||
|
"columnName": "vibrate",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "soundUri",
|
||||||
|
"columnName": "soundUri",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "soundTitle",
|
||||||
|
"columnName": "soundTitle",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "label",
|
||||||
|
"columnName": "label",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "createdAt",
|
||||||
|
"columnName": "createdAt",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "channelId",
|
||||||
|
"columnName": "channelId",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [],
|
||||||
|
"foreignKeys": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"views": [],
|
||||||
|
"setupQueries": [
|
||||||
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd1a9a1d39e0899af980c9ddc7632dd8f')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,33 +8,34 @@ import android.graphics.drawable.Icon
|
||||||
import android.graphics.drawable.LayerDrawable
|
import android.graphics.drawable.LayerDrawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.TextView
|
|
||||||
import com.simplemobiletools.clock.BuildConfig
|
import com.simplemobiletools.clock.BuildConfig
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.adapters.ViewPagerAdapter
|
import com.simplemobiletools.clock.adapters.ViewPagerAdapter
|
||||||
|
import com.simplemobiletools.clock.databinding.ActivityMainBinding
|
||||||
import com.simplemobiletools.clock.extensions.*
|
import com.simplemobiletools.clock.extensions.*
|
||||||
import com.simplemobiletools.clock.helpers.*
|
import com.simplemobiletools.clock.helpers.*
|
||||||
|
import com.simplemobiletools.commons.databinding.BottomTablayoutItemBinding
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.FAQItem
|
import com.simplemobiletools.commons.models.FAQItem
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
|
||||||
import me.grantland.widget.AutofitHelper
|
import me.grantland.widget.AutofitHelper
|
||||||
|
|
||||||
class MainActivity : SimpleActivity() {
|
class MainActivity : SimpleActivity() {
|
||||||
private var storedTextColor = 0
|
private var storedTextColor = 0
|
||||||
private var storedBackgroundColor = 0
|
private var storedBackgroundColor = 0
|
||||||
private var storedPrimaryColor = 0
|
private var storedPrimaryColor = 0
|
||||||
|
private lateinit var binding: ActivityMainBinding
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
appLaunched(BuildConfig.APPLICATION_ID)
|
appLaunched(BuildConfig.APPLICATION_ID)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
|
|
||||||
updateMaterialActivityViews(main_coordinator, main_holder, useTransparentNavigation = false, useTopSearchMenu = false)
|
updateMaterialActivityViews(binding.mainCoordinator, binding.mainHolder, useTransparentNavigation = false, useTopSearchMenu = false)
|
||||||
|
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
initFragments()
|
initFragments()
|
||||||
|
@ -52,23 +53,23 @@ class MainActivity : SimpleActivity() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(main_toolbar, statusBarColor = getProperBackgroundColor())
|
setupToolbar(binding.mainToolbar, statusBarColor = getProperBackgroundColor())
|
||||||
val configTextColor = getProperTextColor()
|
val configTextColor = getProperTextColor()
|
||||||
if (storedTextColor != configTextColor) {
|
if (storedTextColor != configTextColor) {
|
||||||
getInactiveTabIndexes(view_pager.currentItem).forEach {
|
getInactiveTabIndexes(binding.viewPager.currentItem).forEach {
|
||||||
main_tabs_holder.getTabAt(it)?.icon?.applyColorFilter(configTextColor)
|
binding.mainTabsHolder.getTabAt(it)?.icon?.applyColorFilter(configTextColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val configBackgroundColor = getProperBackgroundColor()
|
val configBackgroundColor = getProperBackgroundColor()
|
||||||
if (storedBackgroundColor != configBackgroundColor) {
|
if (storedBackgroundColor != configBackgroundColor) {
|
||||||
main_tabs_holder.background = ColorDrawable(configBackgroundColor)
|
binding.mainTabsHolder.background = ColorDrawable(configBackgroundColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
val configPrimaryColor = getProperPrimaryColor()
|
val configPrimaryColor = getProperPrimaryColor()
|
||||||
if (storedPrimaryColor != configPrimaryColor) {
|
if (storedPrimaryColor != configPrimaryColor) {
|
||||||
main_tabs_holder.setSelectedTabIndicatorColor(getProperPrimaryColor())
|
binding.mainTabsHolder.setSelectedTabIndicatorColor(getProperPrimaryColor())
|
||||||
main_tabs_holder.getTabAt(view_pager.currentItem)?.icon?.applyColorFilter(getProperPrimaryColor())
|
binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.icon?.applyColorFilter(getProperPrimaryColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.preventPhoneFromSleeping) {
|
if (config.preventPhoneFromSleeping) {
|
||||||
|
@ -120,11 +121,11 @@ class MainActivity : SimpleActivity() {
|
||||||
if (config.preventPhoneFromSleeping) {
|
if (config.preventPhoneFromSleeping) {
|
||||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
}
|
}
|
||||||
config.lastUsedViewPagerPage = view_pager.currentItem
|
config.lastUsedViewPagerPage = binding.viewPager.currentItem
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
main_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.mainToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.sort -> getViewPagerAdapter()?.showAlarmSortDialog()
|
R.id.sort -> getViewPagerAdapter()?.showAlarmSortDialog()
|
||||||
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
||||||
|
@ -137,23 +138,23 @@ class MainActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun refreshMenuItems() {
|
private fun refreshMenuItems() {
|
||||||
main_toolbar.menu.apply {
|
binding.mainToolbar.menu.apply {
|
||||||
findItem(R.id.sort).isVisible = view_pager.currentItem == TAB_ALARM
|
findItem(R.id.sort).isVisible = binding.viewPager.currentItem == TAB_ALARM
|
||||||
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
|
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent) {
|
override fun onNewIntent(intent: Intent) {
|
||||||
if (intent.extras?.containsKey(OPEN_TAB) == true) {
|
if (intent.extras?.containsKey(OPEN_TAB) == true) {
|
||||||
val tabToOpen = intent.getIntExtra(OPEN_TAB, TAB_CLOCK)
|
val tabToOpen = intent.getIntExtra(OPEN_TAB, TAB_CLOCK)
|
||||||
view_pager.setCurrentItem(tabToOpen, false)
|
binding.viewPager.setCurrentItem(tabToOpen, false)
|
||||||
if (tabToOpen == TAB_TIMER) {
|
if (tabToOpen == TAB_TIMER) {
|
||||||
val timerId = intent.getIntExtra(TIMER_ID, INVALID_TIMER_ID)
|
val timerId = intent.getIntExtra(TIMER_ID, INVALID_TIMER_ID)
|
||||||
(view_pager.adapter as ViewPagerAdapter).updateTimerPosition(timerId)
|
(binding.viewPager.adapter as ViewPagerAdapter).updateTimerPosition(timerId)
|
||||||
}
|
}
|
||||||
if (tabToOpen == TAB_STOPWATCH) {
|
if (tabToOpen == TAB_STOPWATCH) {
|
||||||
if (intent.getBooleanExtra(TOGGLE_STOPWATCH, false)) {
|
if (intent.getBooleanExtra(TOGGLE_STOPWATCH, false)) {
|
||||||
(view_pager.adapter as ViewPagerAdapter).startStopWatch()
|
(binding.viewPager.adapter as ViewPagerAdapter).startStopWatch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +177,7 @@ class MainActivity : SimpleActivity() {
|
||||||
private fun storeNewAlarmSound(resultData: Intent) {
|
private fun storeNewAlarmSound(resultData: Intent) {
|
||||||
val newAlarmSound = storeNewYourAlarmSound(resultData)
|
val newAlarmSound = storeNewYourAlarmSound(resultData)
|
||||||
|
|
||||||
when (view_pager.currentItem) {
|
when (binding.viewPager.currentItem) {
|
||||||
TAB_ALARM -> getViewPagerAdapter()?.updateAlarmTabAlarmSound(newAlarmSound)
|
TAB_ALARM -> getViewPagerAdapter()?.updateAlarmTabAlarmSound(newAlarmSound)
|
||||||
TAB_TIMER -> getViewPagerAdapter()?.updateTimerTabAlarmSound(newAlarmSound)
|
TAB_TIMER -> getViewPagerAdapter()?.updateTimerTabAlarmSound(newAlarmSound)
|
||||||
}
|
}
|
||||||
|
@ -186,13 +187,13 @@ class MainActivity : SimpleActivity() {
|
||||||
getViewPagerAdapter()?.updateClockTabAlarm()
|
getViewPagerAdapter()?.updateClockTabAlarm()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getViewPagerAdapter() = view_pager.adapter as? ViewPagerAdapter
|
private fun getViewPagerAdapter() = binding.viewPager.adapter as? ViewPagerAdapter
|
||||||
|
|
||||||
private fun initFragments() {
|
private fun initFragments() {
|
||||||
val viewPagerAdapter = ViewPagerAdapter(supportFragmentManager)
|
val viewPagerAdapter = ViewPagerAdapter(supportFragmentManager)
|
||||||
view_pager.adapter = viewPagerAdapter
|
binding.viewPager.adapter = viewPagerAdapter
|
||||||
view_pager.onPageChangeListener {
|
binding.viewPager.onPageChangeListener {
|
||||||
main_tabs_holder.getTabAt(it)?.select()
|
binding.mainTabsHolder.getTabAt(it)?.select()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,61 +208,68 @@ class MainActivity : SimpleActivity() {
|
||||||
config.toggleStopwatch = intent.getBooleanExtra(TOGGLE_STOPWATCH, false)
|
config.toggleStopwatch = intent.getBooleanExtra(TOGGLE_STOPWATCH, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
view_pager.offscreenPageLimit = TABS_COUNT - 1
|
binding.viewPager.offscreenPageLimit = TABS_COUNT - 1
|
||||||
view_pager.currentItem = tabToOpen
|
binding.viewPager.currentItem = tabToOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTabs() {
|
private fun setupTabs() {
|
||||||
main_tabs_holder.removeAllTabs()
|
binding.mainTabsHolder.removeAllTabs()
|
||||||
val tabDrawables = arrayOf(R.drawable.ic_clock_vector, R.drawable.ic_alarm_vector, R.drawable.ic_stopwatch_vector, R.drawable.ic_hourglass_vector)
|
val tabDrawables = arrayOf(
|
||||||
val tabLabels = arrayOf(R.string.clock, R.string.alarm, R.string.stopwatch, R.string.timer)
|
com.simplemobiletools.commons.R.drawable.ic_clock_vector,
|
||||||
|
R.drawable.ic_alarm_vector,
|
||||||
|
R.drawable.ic_stopwatch_vector,
|
||||||
|
R.drawable.ic_hourglass_vector
|
||||||
|
)
|
||||||
|
val tabLabels = arrayOf(R.string.clock, com.simplemobiletools.commons.R.string.alarm, R.string.stopwatch, R.string.timer)
|
||||||
|
|
||||||
tabDrawables.forEachIndexed { i, drawableId ->
|
tabDrawables.forEachIndexed { i, drawableId ->
|
||||||
main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
|
binding.mainTabsHolder.newTab().setCustomView(com.simplemobiletools.commons.R.layout.bottom_tablayout_item).apply tab@{
|
||||||
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getDrawable(drawableId))
|
customView?.let { BottomTablayoutItemBinding.bind(it) }?.apply {
|
||||||
customView?.findViewById<TextView>(R.id.tab_item_label)?.setText(tabLabels[i])
|
tabItemIcon.setImageDrawable(getDrawable(drawableId))
|
||||||
AutofitHelper.create(customView?.findViewById(R.id.tab_item_label))
|
tabItemLabel.setText(tabLabels[i])
|
||||||
main_tabs_holder.addTab(this)
|
AutofitHelper.create(tabItemLabel)
|
||||||
|
binding.mainTabsHolder.addTab(this@tab)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main_tabs_holder.onTabSelectionChanged(
|
binding.mainTabsHolder.onTabSelectionChanged(
|
||||||
tabUnselectedAction = {
|
tabUnselectedAction = {
|
||||||
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
|
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
|
||||||
},
|
},
|
||||||
tabSelectedAction = {
|
tabSelectedAction = {
|
||||||
view_pager.currentItem = it.position
|
binding.viewPager.currentItem = it.position
|
||||||
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTabColors() {
|
private fun setupTabColors() {
|
||||||
val activeView = main_tabs_holder.getTabAt(view_pager.currentItem)?.customView
|
val activeView = binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.customView
|
||||||
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[view_pager.currentItem])
|
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[binding.viewPager.currentItem])
|
||||||
|
|
||||||
getInactiveTabIndexes(view_pager.currentItem).forEach { index ->
|
getInactiveTabIndexes(binding.viewPager.currentItem).forEach { index ->
|
||||||
val inactiveView = main_tabs_holder.getTabAt(index)?.customView
|
val inactiveView = binding.mainTabsHolder.getTabAt(index)?.customView
|
||||||
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
|
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
|
||||||
}
|
}
|
||||||
|
|
||||||
main_tabs_holder.getTabAt(view_pager.currentItem)?.select()
|
binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.select()
|
||||||
val bottomBarColor = getBottomNavigationBackgroundColor()
|
val bottomBarColor = getBottomNavigationBackgroundColor()
|
||||||
main_tabs_holder.setBackgroundColor(bottomBarColor)
|
binding.mainTabsHolder.setBackgroundColor(bottomBarColor)
|
||||||
updateNavigationBarColor(bottomBarColor)
|
updateNavigationBarColor(bottomBarColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getInactiveTabIndexes(activeIndex: Int) = arrayListOf(0, 1, 2, 3).filter { it != activeIndex }
|
private fun getInactiveTabIndexes(activeIndex: Int) = arrayListOf(0, 1, 2, 3).filter { it != activeIndex }
|
||||||
|
|
||||||
private fun getSelectedTabDrawableIds() = arrayOf(
|
private fun getSelectedTabDrawableIds() = arrayOf(
|
||||||
R.drawable.ic_clock_filled_vector,
|
com.simplemobiletools.commons.R.drawable.ic_clock_filled_vector,
|
||||||
R.drawable.ic_alarm_filled_vector,
|
R.drawable.ic_alarm_filled_vector,
|
||||||
R.drawable.ic_stopwatch_filled_vector,
|
R.drawable.ic_stopwatch_filled_vector,
|
||||||
R.drawable.ic_hourglass_filled_vector
|
R.drawable.ic_hourglass_filled_vector
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun getDeselectedTabDrawableIds() = arrayOf(
|
private fun getDeselectedTabDrawableIds() = arrayOf(
|
||||||
R.drawable.ic_clock_vector,
|
com.simplemobiletools.commons.R.drawable.ic_clock_vector,
|
||||||
R.drawable.ic_alarm_vector,
|
R.drawable.ic_alarm_vector,
|
||||||
R.drawable.ic_stopwatch_vector,
|
R.drawable.ic_stopwatch_vector,
|
||||||
R.drawable.ic_hourglass_vector
|
R.drawable.ic_hourglass_vector
|
||||||
|
@ -276,14 +284,14 @@ class MainActivity : SimpleActivity() {
|
||||||
|
|
||||||
val faqItems = arrayListOf(
|
val faqItems = arrayListOf(
|
||||||
FAQItem(R.string.faq_1_title, R.string.faq_1_text),
|
FAQItem(R.string.faq_1_title, R.string.faq_1_text),
|
||||||
FAQItem(R.string.faq_1_title_commons, R.string.faq_1_text_commons),
|
FAQItem(com.simplemobiletools.commons.R.string.faq_1_title_commons, com.simplemobiletools.commons.R.string.faq_1_text_commons),
|
||||||
FAQItem(R.string.faq_4_title_commons, R.string.faq_4_text_commons),
|
FAQItem(com.simplemobiletools.commons.R.string.faq_4_title_commons, com.simplemobiletools.commons.R.string.faq_4_text_commons),
|
||||||
FAQItem(R.string.faq_9_title_commons, R.string.faq_9_text_commons)
|
FAQItem(com.simplemobiletools.commons.R.string.faq_9_title_commons, com.simplemobiletools.commons.R.string.faq_9_text_commons)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!resources.getBoolean(R.bool.hide_google_relations)) {
|
if (!resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)) {
|
||||||
faqItems.add(FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons))
|
faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_2_title_commons, com.simplemobiletools.commons.R.string.faq_2_text_commons))
|
||||||
faqItems.add(FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons))
|
faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_6_title_commons, com.simplemobiletools.commons.R.string.faq_6_text_commons))
|
||||||
}
|
}
|
||||||
|
|
||||||
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
|
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
|
||||||
|
|
|
@ -8,17 +8,16 @@ import android.media.MediaPlayer
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.*
|
import android.os.*
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.view.animation.AnimationUtils
|
import android.view.animation.AnimationUtils
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
|
import com.simplemobiletools.clock.databinding.ActivityReminderBinding
|
||||||
import com.simplemobiletools.clock.extensions.*
|
import com.simplemobiletools.clock.extensions.*
|
||||||
import com.simplemobiletools.clock.helpers.ALARM_ID
|
import com.simplemobiletools.clock.helpers.ALARM_ID
|
||||||
import com.simplemobiletools.clock.helpers.getPassedSeconds
|
import com.simplemobiletools.clock.helpers.getPassedSeconds
|
||||||
import com.simplemobiletools.clock.models.Alarm
|
import com.simplemobiletools.clock.models.Alarm
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import kotlinx.android.synthetic.main.activity_reminder.*
|
|
||||||
|
|
||||||
class ReminderActivity : SimpleActivity() {
|
class ReminderActivity : SimpleActivity() {
|
||||||
private val INCREASE_VOLUME_DELAY = 300L
|
private val INCREASE_VOLUME_DELAY = 300L
|
||||||
|
@ -36,13 +35,15 @@ class ReminderActivity : SimpleActivity() {
|
||||||
private var vibrator: Vibrator? = null
|
private var vibrator: Vibrator? = null
|
||||||
private var lastVolumeValue = 0.1f
|
private var lastVolumeValue = 0.1f
|
||||||
private var dragDownX = 0f
|
private var dragDownX = 0f
|
||||||
|
private lateinit var binding: ActivityReminderBinding
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_reminder)
|
binding = ActivityReminderBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
showOverLockscreen()
|
showOverLockscreen()
|
||||||
updateTextColors(reminder_holder as ViewGroup)
|
updateTextColors(binding.root)
|
||||||
updateStatusbarColor(getProperBackgroundColor())
|
updateStatusbarColor(getProperBackgroundColor())
|
||||||
|
|
||||||
val id = intent.getIntExtra(ALARM_ID, -1)
|
val id = intent.getIntExtra(ALARM_ID, -1)
|
||||||
|
@ -53,7 +54,7 @@ class ReminderActivity : SimpleActivity() {
|
||||||
|
|
||||||
val label = if (isAlarmReminder) {
|
val label = if (isAlarmReminder) {
|
||||||
if (alarm!!.label.isEmpty()) {
|
if (alarm!!.label.isEmpty()) {
|
||||||
getString(R.string.alarm)
|
getString(com.simplemobiletools.commons.R.string.alarm)
|
||||||
} else {
|
} else {
|
||||||
alarm!!.label
|
alarm!!.label
|
||||||
}
|
}
|
||||||
|
@ -61,8 +62,8 @@ class ReminderActivity : SimpleActivity() {
|
||||||
getString(R.string.timer)
|
getString(R.string.timer)
|
||||||
}
|
}
|
||||||
|
|
||||||
reminder_title.text = label
|
binding.reminderTitle.text = label
|
||||||
reminder_text.text = if (isAlarmReminder) getFormattedTime(getPassedSeconds(), false, false) else getString(R.string.time_expired)
|
binding.reminderText.text = if (isAlarmReminder) getFormattedTime(getPassedSeconds(), false, false) else getString(R.string.time_expired)
|
||||||
|
|
||||||
val maxDuration = if (isAlarmReminder) config.alarmMaxReminderSecs else config.timerMaxReminderSecs
|
val maxDuration = if (isAlarmReminder) config.alarmMaxReminderSecs else config.timerMaxReminderSecs
|
||||||
maxReminderDurationHandler.postDelayed({
|
maxReminderDurationHandler.postDelayed({
|
||||||
|
@ -83,52 +84,52 @@ class ReminderActivity : SimpleActivity() {
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun setupAlarmButtons() {
|
private fun setupAlarmButtons() {
|
||||||
reminder_stop.beGone()
|
binding.reminderStop.beGone()
|
||||||
reminder_draggable_background.startAnimation(AnimationUtils.loadAnimation(this, R.anim.pulsing_animation))
|
binding.reminderDraggableBackground.startAnimation(AnimationUtils.loadAnimation(this, R.anim.pulsing_animation))
|
||||||
reminder_draggable_background.applyColorFilter(getProperPrimaryColor())
|
binding.reminderDraggableBackground.applyColorFilter(getProperPrimaryColor())
|
||||||
|
|
||||||
val textColor = getProperTextColor()
|
val textColor = getProperTextColor()
|
||||||
reminder_dismiss.applyColorFilter(textColor)
|
binding.reminderDismiss.applyColorFilter(textColor)
|
||||||
reminder_draggable.applyColorFilter(textColor)
|
binding.reminderDraggable.applyColorFilter(textColor)
|
||||||
reminder_snooze.applyColorFilter(textColor)
|
binding.reminderSnooze.applyColorFilter(textColor)
|
||||||
|
|
||||||
var minDragX = 0f
|
var minDragX = 0f
|
||||||
var maxDragX = 0f
|
var maxDragX = 0f
|
||||||
var initialDraggableX = 0f
|
var initialDraggableX = 0f
|
||||||
|
|
||||||
reminder_dismiss.onGlobalLayout {
|
binding.reminderDismiss.onGlobalLayout {
|
||||||
minDragX = reminder_snooze.left.toFloat()
|
minDragX = binding.reminderSnooze.left.toFloat()
|
||||||
maxDragX = reminder_dismiss.left.toFloat()
|
maxDragX = binding.reminderDismiss.left.toFloat()
|
||||||
initialDraggableX = reminder_draggable.left.toFloat()
|
initialDraggableX = binding.reminderDraggable.left.toFloat()
|
||||||
}
|
}
|
||||||
|
|
||||||
reminder_draggable.setOnTouchListener { v, event ->
|
binding.reminderDraggable.setOnTouchListener { v, event ->
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
dragDownX = event.x
|
dragDownX = event.x
|
||||||
reminder_draggable_background.animate().alpha(0f)
|
binding.reminderDraggableBackground.animate().alpha(0f)
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||||
dragDownX = 0f
|
dragDownX = 0f
|
||||||
if (!didVibrate) {
|
if (!didVibrate) {
|
||||||
reminder_draggable.animate().x(initialDraggableX).withEndAction {
|
binding.reminderDraggable.animate().x(initialDraggableX).withEndAction {
|
||||||
reminder_draggable_background.animate().alpha(0.2f)
|
binding.reminderDraggableBackground.animate().alpha(0.2f)
|
||||||
}
|
}
|
||||||
|
|
||||||
reminder_guide.animate().alpha(1f).start()
|
binding.reminderGuide.animate().alpha(1f).start()
|
||||||
swipeGuideFadeHandler.removeCallbacksAndMessages(null)
|
swipeGuideFadeHandler.removeCallbacksAndMessages(null)
|
||||||
swipeGuideFadeHandler.postDelayed({
|
swipeGuideFadeHandler.postDelayed({
|
||||||
reminder_guide.animate().alpha(0f).start()
|
binding.reminderGuide.animate().alpha(0f).start()
|
||||||
}, 2000L)
|
}, 2000L)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
reminder_draggable.x = Math.min(maxDragX, Math.max(minDragX, event.rawX - dragDownX))
|
binding.reminderDraggable.x = Math.min(maxDragX, Math.max(minDragX, event.rawX - dragDownX))
|
||||||
if (reminder_draggable.x >= maxDragX - 50f) {
|
if (binding.reminderDraggable.x >= maxDragX - 50f) {
|
||||||
if (!didVibrate) {
|
if (!didVibrate) {
|
||||||
reminder_draggable.performHapticFeedback()
|
binding.reminderDraggable.performHapticFeedback()
|
||||||
didVibrate = true
|
didVibrate = true
|
||||||
finishActivity()
|
finishActivity()
|
||||||
}
|
}
|
||||||
|
@ -136,9 +137,9 @@ class ReminderActivity : SimpleActivity() {
|
||||||
if (isOreoPlus()) {
|
if (isOreoPlus()) {
|
||||||
notificationManager.cancelAll()
|
notificationManager.cancelAll()
|
||||||
}
|
}
|
||||||
} else if (reminder_draggable.x <= minDragX + 50f) {
|
} else if (binding.reminderDraggable.x <= minDragX + 50f) {
|
||||||
if (!didVibrate) {
|
if (!didVibrate) {
|
||||||
reminder_draggable.performHapticFeedback()
|
binding.reminderDraggable.performHapticFeedback()
|
||||||
didVibrate = true
|
didVibrate = true
|
||||||
snoozeAlarm()
|
snoozeAlarm()
|
||||||
}
|
}
|
||||||
|
@ -154,12 +155,12 @@ class ReminderActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTimerButtons() {
|
private fun setupTimerButtons() {
|
||||||
reminder_stop.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, getProperPrimaryColor())
|
binding.reminderStop.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, getProperPrimaryColor())
|
||||||
arrayOf(reminder_snooze, reminder_draggable_background, reminder_draggable, reminder_dismiss).forEach {
|
arrayOf(binding.reminderSnooze, binding.reminderDraggableBackground, binding.reminderDraggable, binding.reminderDismiss).forEach {
|
||||||
it.beGone()
|
it.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
reminder_stop.setOnClickListener {
|
binding.reminderStop.setOnClickListener {
|
||||||
finishActivity()
|
finishActivity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.simplemobiletools.clock.activities
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.databinding.ActivitySettingsBinding
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.clock.helpers.DEFAULT_MAX_ALARM_REMINDER_SECS
|
import com.simplemobiletools.clock.helpers.DEFAULT_MAX_ALARM_REMINDER_SECS
|
||||||
import com.simplemobiletools.clock.helpers.DEFAULT_MAX_TIMER_REMINDER_SECS
|
import com.simplemobiletools.clock.helpers.DEFAULT_MAX_TIMER_REMINDER_SECS
|
||||||
|
@ -11,23 +11,25 @@ import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
||||||
import com.simplemobiletools.commons.helpers.MINUTE_SECONDS
|
import com.simplemobiletools.commons.helpers.MINUTE_SECONDS
|
||||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
import com.simplemobiletools.commons.helpers.isTiramisuPlus
|
import com.simplemobiletools.commons.helpers.isTiramisuPlus
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import java.util.Locale
|
||||||
import java.util.*
|
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
class SettingsActivity : SimpleActivity() {
|
class SettingsActivity : SimpleActivity() {
|
||||||
|
private lateinit var binding: ActivitySettingsBinding
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_settings)
|
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
|
||||||
updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false)
|
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar)
|
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
|
||||||
|
|
||||||
setupPurchaseThankYou()
|
setupPurchaseThankYou()
|
||||||
setupCustomizeColors()
|
setupCustomizeColors()
|
||||||
|
@ -41,69 +43,69 @@ class SettingsActivity : SimpleActivity() {
|
||||||
setupTimerMaxReminder()
|
setupTimerMaxReminder()
|
||||||
setupIncreaseVolumeGradually()
|
setupIncreaseVolumeGradually()
|
||||||
setupCustomizeWidgetColors()
|
setupCustomizeWidgetColors()
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(binding.settingsHolder)
|
||||||
|
|
||||||
arrayOf(
|
arrayOf(
|
||||||
settings_color_customization_section_label,
|
binding.settingsColorCustomizationSectionLabel,
|
||||||
settings_general_settings_label,
|
binding.settingsGeneralSettingsLabel,
|
||||||
settings_alarm_tab_label,
|
binding.settingsAlarmTabLabel,
|
||||||
settings_timer_tab_label,
|
binding.settingsTimerTabLabel,
|
||||||
).forEach {
|
).forEach {
|
||||||
it.setTextColor(getProperPrimaryColor())
|
it.setTextColor(getProperPrimaryColor())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupPurchaseThankYou() {
|
private fun setupPurchaseThankYou() {
|
||||||
settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled())
|
binding.settingsPurchaseThankYouHolder.beGoneIf(isOrWasThankYouInstalled())
|
||||||
settings_purchase_thank_you_holder.setOnClickListener {
|
binding.settingsPurchaseThankYouHolder.setOnClickListener {
|
||||||
launchPurchaseThankYouIntent()
|
launchPurchaseThankYouIntent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCustomizeColors() {
|
private fun setupCustomizeColors() {
|
||||||
settings_color_customization_label.text = getCustomizeColorsString()
|
binding.settingsColorCustomizationLabel.text = getCustomizeColorsString()
|
||||||
settings_color_customization_holder.setOnClickListener {
|
binding.settingsColorCustomizationHolder.setOnClickListener {
|
||||||
handleCustomizeColorsClick()
|
handleCustomizeColorsClick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupUseEnglish() {
|
private fun setupUseEnglish() {
|
||||||
settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
binding.settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||||
settings_use_english.isChecked = config.useEnglish
|
binding.settingsUseEnglish.isChecked = config.useEnglish
|
||||||
settings_use_english_holder.setOnClickListener {
|
binding.settingsUseEnglishHolder.setOnClickListener {
|
||||||
settings_use_english.toggle()
|
binding.settingsUseEnglish.toggle()
|
||||||
config.useEnglish = settings_use_english.isChecked
|
config.useEnglish = binding.settingsUseEnglish.isChecked
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLanguage() {
|
private fun setupLanguage() {
|
||||||
settings_language.text = Locale.getDefault().displayLanguage
|
binding.settingsLanguage.text = Locale.getDefault().displayLanguage
|
||||||
settings_language_holder.beVisibleIf(isTiramisuPlus())
|
binding.settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
|
||||||
settings_language_holder.setOnClickListener {
|
binding.settingsLanguageHolder.setOnClickListener {
|
||||||
launchChangeAppLanguageIntent()
|
launchChangeAppLanguageIntent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupPreventPhoneFromSleeping() {
|
private fun setupPreventPhoneFromSleeping() {
|
||||||
settings_prevent_phone_from_sleeping.isChecked = config.preventPhoneFromSleeping
|
binding.settingsPreventPhoneFromSleeping.isChecked = config.preventPhoneFromSleeping
|
||||||
settings_prevent_phone_from_sleeping_holder.setOnClickListener {
|
binding.settingsPreventPhoneFromSleepingHolder.setOnClickListener {
|
||||||
settings_prevent_phone_from_sleeping.toggle()
|
binding.settingsPreventPhoneFromSleeping.toggle()
|
||||||
config.preventPhoneFromSleeping = settings_prevent_phone_from_sleeping.isChecked
|
config.preventPhoneFromSleeping = binding.settingsPreventPhoneFromSleeping.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSundayFirst() {
|
private fun setupSundayFirst() {
|
||||||
settings_sunday_first.isChecked = config.isSundayFirst
|
binding.settingsSundayFirst.isChecked = config.isSundayFirst
|
||||||
settings_sunday_first_holder.setOnClickListener {
|
binding.settingsSundayFirstHolder.setOnClickListener {
|
||||||
settings_sunday_first.toggle()
|
binding.settingsSundayFirst.toggle()
|
||||||
config.isSundayFirst = settings_sunday_first.isChecked
|
config.isSundayFirst = binding.settingsSundayFirst.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAlarmMaxReminder() {
|
private fun setupAlarmMaxReminder() {
|
||||||
updateAlarmMaxReminderText()
|
updateAlarmMaxReminderText()
|
||||||
settings_alarm_max_reminder_holder.setOnClickListener {
|
binding.settingsAlarmMaxReminderHolder.setOnClickListener {
|
||||||
showPickSecondsDialog(config.alarmMaxReminderSecs, true, true) {
|
showPickSecondsDialog(config.alarmMaxReminderSecs, true, true) {
|
||||||
config.alarmMaxReminderSecs = if (it != 0) it else DEFAULT_MAX_ALARM_REMINDER_SECS
|
config.alarmMaxReminderSecs = if (it != 0) it else DEFAULT_MAX_ALARM_REMINDER_SECS
|
||||||
updateAlarmMaxReminderText()
|
updateAlarmMaxReminderText()
|
||||||
|
@ -112,18 +114,18 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupUseSameSnooze() {
|
private fun setupUseSameSnooze() {
|
||||||
settings_snooze_time_holder.beVisibleIf(config.useSameSnooze)
|
binding.settingsSnoozeTimeHolder.beVisibleIf(config.useSameSnooze)
|
||||||
settings_use_same_snooze.isChecked = config.useSameSnooze
|
binding.settingsUseSameSnooze.isChecked = config.useSameSnooze
|
||||||
settings_use_same_snooze_holder.setOnClickListener {
|
binding.settingsUseSameSnoozeHolder.setOnClickListener {
|
||||||
settings_use_same_snooze.toggle()
|
binding.settingsUseSameSnooze.toggle()
|
||||||
config.useSameSnooze = settings_use_same_snooze.isChecked
|
config.useSameSnooze = binding.settingsUseSameSnooze.isChecked
|
||||||
settings_snooze_time_holder.beVisibleIf(config.useSameSnooze)
|
binding.settingsSnoozeTimeHolder.beVisibleIf(config.useSameSnooze)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSnoozeTime() {
|
private fun setupSnoozeTime() {
|
||||||
updateSnoozeText()
|
updateSnoozeText()
|
||||||
settings_snooze_time_holder.setOnClickListener {
|
binding.settingsSnoozeTimeHolder.setOnClickListener {
|
||||||
showPickSecondsDialog(config.snoozeTime * MINUTE_SECONDS, true) {
|
showPickSecondsDialog(config.snoozeTime * MINUTE_SECONDS, true) {
|
||||||
config.snoozeTime = it / MINUTE_SECONDS
|
config.snoozeTime = it / MINUTE_SECONDS
|
||||||
updateSnoozeText()
|
updateSnoozeText()
|
||||||
|
@ -133,7 +135,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun setupTimerMaxReminder() {
|
private fun setupTimerMaxReminder() {
|
||||||
updateTimerMaxReminderText()
|
updateTimerMaxReminderText()
|
||||||
settings_timer_max_reminder_holder.setOnClickListener {
|
binding.settingsTimerMaxReminderHolder.setOnClickListener {
|
||||||
showPickSecondsDialog(config.timerMaxReminderSecs, true, true) {
|
showPickSecondsDialog(config.timerMaxReminderSecs, true, true) {
|
||||||
config.timerMaxReminderSecs = if (it != 0) it else DEFAULT_MAX_TIMER_REMINDER_SECS
|
config.timerMaxReminderSecs = if (it != 0) it else DEFAULT_MAX_TIMER_REMINDER_SECS
|
||||||
updateTimerMaxReminderText()
|
updateTimerMaxReminderText()
|
||||||
|
@ -142,27 +144,27 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupIncreaseVolumeGradually() {
|
private fun setupIncreaseVolumeGradually() {
|
||||||
settings_increase_volume_gradually.isChecked = config.increaseVolumeGradually
|
binding.settingsIncreaseVolumeGradually.isChecked = config.increaseVolumeGradually
|
||||||
settings_increase_volume_gradually_holder.setOnClickListener {
|
binding.settingsIncreaseVolumeGraduallyHolder.setOnClickListener {
|
||||||
settings_increase_volume_gradually.toggle()
|
binding.settingsIncreaseVolumeGradually.toggle()
|
||||||
config.increaseVolumeGradually = settings_increase_volume_gradually.isChecked
|
config.increaseVolumeGradually = binding.settingsIncreaseVolumeGradually.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSnoozeText() {
|
private fun updateSnoozeText() {
|
||||||
settings_snooze_time.text = formatMinutesToTimeString(config.snoozeTime)
|
binding.settingsSnoozeTime.text = formatMinutesToTimeString(config.snoozeTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAlarmMaxReminderText() {
|
private fun updateAlarmMaxReminderText() {
|
||||||
settings_alarm_max_reminder.text = formatSecondsToTimeString(config.alarmMaxReminderSecs)
|
binding.settingsAlarmMaxReminder.text = formatSecondsToTimeString(config.alarmMaxReminderSecs)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTimerMaxReminderText() {
|
private fun updateTimerMaxReminderText() {
|
||||||
settings_timer_max_reminder.text = formatSecondsToTimeString(config.timerMaxReminderSecs)
|
binding.settingsTimerMaxReminder.text = formatSecondsToTimeString(config.timerMaxReminderSecs)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCustomizeWidgetColors() {
|
private fun setupCustomizeWidgetColors() {
|
||||||
settings_widget_color_customization_holder.setOnClickListener {
|
binding.settingsWidgetColorCustomizationHolder.setOnClickListener {
|
||||||
Intent(this, WidgetDigitalConfigureActivity::class.java).apply {
|
Intent(this, WidgetDigitalConfigureActivity::class.java).apply {
|
||||||
putExtra(IS_CUSTOMIZING_COLORS, true)
|
putExtra(IS_CUSTOMIZING_COLORS, true)
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
|
|
|
@ -7,14 +7,13 @@ import android.content.res.ColorStateList
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.databinding.WidgetConfigAnalogueBinding
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.clock.helpers.MyAnalogueTimeWidgetProvider
|
import com.simplemobiletools.clock.helpers.MyAnalogueTimeWidgetProvider
|
||||||
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FeatureLockedDialog
|
import com.simplemobiletools.commons.dialogs.FeatureLockedDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
||||||
import kotlinx.android.synthetic.main.widget_config_analogue.*
|
|
||||||
|
|
||||||
class WidgetAnalogueConfigureActivity : SimpleActivity() {
|
class WidgetAnalogueConfigureActivity : SimpleActivity() {
|
||||||
private var mBgAlpha = 0f
|
private var mBgAlpha = 0f
|
||||||
|
@ -22,12 +21,14 @@ class WidgetAnalogueConfigureActivity : SimpleActivity() {
|
||||||
private var mBgColor = 0
|
private var mBgColor = 0
|
||||||
private var mBgColorWithoutTransparency = 0
|
private var mBgColorWithoutTransparency = 0
|
||||||
private var mFeatureLockedDialog: FeatureLockedDialog? = null
|
private var mFeatureLockedDialog: FeatureLockedDialog? = null
|
||||||
|
private lateinit var binding: WidgetConfigAnalogueBinding
|
||||||
|
|
||||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
useDynamicTheme = false
|
useDynamicTheme = false
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setResult(Activity.RESULT_CANCELED)
|
setResult(Activity.RESULT_CANCELED)
|
||||||
setContentView(R.layout.widget_config_analogue)
|
binding = WidgetConfigAnalogueBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
initVariables()
|
initVariables()
|
||||||
|
|
||||||
val isCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
|
val isCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
|
||||||
|
@ -37,12 +38,12 @@ class WidgetAnalogueConfigureActivity : SimpleActivity() {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
config_analogue_save.setOnClickListener { saveConfig() }
|
binding.configAnalogueSave.setOnClickListener { saveConfig() }
|
||||||
config_analogue_save.setTextColor(getProperPrimaryColor().getContrastColor())
|
binding.configAnalogueSave.setTextColor(getProperPrimaryColor().getContrastColor())
|
||||||
config_analogue_bg_color.setOnClickListener { pickBackgroundColor() }
|
binding.configAnalogueBgColor.setOnClickListener { pickBackgroundColor() }
|
||||||
|
|
||||||
val primaryColor = getProperPrimaryColor()
|
val primaryColor = getProperPrimaryColor()
|
||||||
config_analogue_bg_seekbar.setColors(getProperTextColor(), primaryColor, primaryColor)
|
binding.configAnalogueBgSeekbar.setColors(getProperTextColor(), primaryColor, primaryColor)
|
||||||
|
|
||||||
if (!isCustomizingColors && !isOrWasThankYouInstalled()) {
|
if (!isCustomizingColors && !isOrWasThankYouInstalled()) {
|
||||||
mFeatureLockedDialog = FeatureLockedDialog(this) {
|
mFeatureLockedDialog = FeatureLockedDialog(this) {
|
||||||
|
@ -62,15 +63,15 @@ class WidgetAnalogueConfigureActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun initVariables() {
|
private fun initVariables() {
|
||||||
mBgColor = config.widgetBgColor
|
mBgColor = config.widgetBgColor
|
||||||
if (mBgColor == resources.getColor(R.color.default_widget_bg_color) && config.isUsingSystemTheme) {
|
if (mBgColor == resources.getColor(com.simplemobiletools.commons.R.color.default_widget_bg_color) && config.isUsingSystemTheme) {
|
||||||
mBgColor = resources.getColor(R.color.you_primary_color, theme)
|
mBgColor = resources.getColor(com.simplemobiletools.commons.R.color.you_primary_color, theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat()
|
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat()
|
||||||
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
|
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
|
||||||
|
|
||||||
config_analogue_bg_seekbar.setOnSeekBarChangeListener(bgSeekbarChangeListener)
|
binding.configAnalogueBgSeekbar.setOnSeekBarChangeListener(bgSeekbarChangeListener)
|
||||||
config_analogue_bg_seekbar.progress = (mBgAlpha * 100).toInt()
|
binding.configAnalogueBgSeekbar.progress = (mBgAlpha * 100).toInt()
|
||||||
updateBackgroundColor()
|
updateBackgroundColor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,9 +110,9 @@ class WidgetAnalogueConfigureActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun updateBackgroundColor() {
|
private fun updateBackgroundColor() {
|
||||||
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
||||||
config_analogue_bg_color.setFillWithStroke(mBgColor, mBgColor)
|
binding.configAnalogueBgColor.setFillWithStroke(mBgColor, mBgColor)
|
||||||
config_analogue_background.applyColorFilter(mBgColor)
|
binding.configAnalogueBackground.applyColorFilter(mBgColor)
|
||||||
config_analogue_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
|
binding.configAnalogueSave.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
private val bgSeekbarChangeListener = object : SeekBar.OnSeekBarChangeListener {
|
private val bgSeekbarChangeListener = object : SeekBar.OnSeekBarChangeListener {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import android.graphics.Color
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.databinding.WidgetConfigDigitalBinding
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.clock.helpers.MyDigitalTimeWidgetProvider
|
import com.simplemobiletools.clock.helpers.MyDigitalTimeWidgetProvider
|
||||||
import com.simplemobiletools.clock.helpers.SIMPLE_PHONE
|
import com.simplemobiletools.clock.helpers.SIMPLE_PHONE
|
||||||
|
@ -16,7 +16,6 @@ import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FeatureLockedDialog
|
import com.simplemobiletools.commons.dialogs.FeatureLockedDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
||||||
import kotlinx.android.synthetic.main.widget_config_digital.*
|
|
||||||
|
|
||||||
class WidgetDigitalConfigureActivity : SimpleActivity() {
|
class WidgetDigitalConfigureActivity : SimpleActivity() {
|
||||||
private var mBgAlpha = 0f
|
private var mBgAlpha = 0f
|
||||||
|
@ -25,12 +24,14 @@ class WidgetDigitalConfigureActivity : SimpleActivity() {
|
||||||
private var mTextColor = 0
|
private var mTextColor = 0
|
||||||
private var mBgColorWithoutTransparency = 0
|
private var mBgColorWithoutTransparency = 0
|
||||||
private var mFeatureLockedDialog: FeatureLockedDialog? = null
|
private var mFeatureLockedDialog: FeatureLockedDialog? = null
|
||||||
|
private lateinit var binding: WidgetConfigDigitalBinding
|
||||||
|
|
||||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
useDynamicTheme = false
|
useDynamicTheme = false
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setResult(Activity.RESULT_CANCELED)
|
setResult(Activity.RESULT_CANCELED)
|
||||||
setContentView(R.layout.widget_config_digital)
|
binding = WidgetConfigDigitalBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
initVariables()
|
initVariables()
|
||||||
|
|
||||||
mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID
|
mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID
|
||||||
|
@ -46,12 +47,12 @@ class WidgetDigitalConfigureActivity : SimpleActivity() {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
config_digital_save.setOnClickListener { saveConfig() }
|
binding.configDigitalSave.setOnClickListener { saveConfig() }
|
||||||
config_digital_bg_color.setOnClickListener { pickBackgroundColor() }
|
binding.configDigitalBgColor.setOnClickListener { pickBackgroundColor() }
|
||||||
config_digital_text_color.setOnClickListener { pickTextColor() }
|
binding.configDigitalTextColor.setOnClickListener { pickTextColor() }
|
||||||
|
|
||||||
val primaryColor = getProperPrimaryColor()
|
val primaryColor = getProperPrimaryColor()
|
||||||
config_digital_bg_seekbar.setColors(mTextColor, primaryColor, primaryColor)
|
binding.configDigitalBgSeekbar.setColors(mTextColor, primaryColor, primaryColor)
|
||||||
|
|
||||||
if (!isCustomizingColors && !isOrWasThankYouInstalled()) {
|
if (!isCustomizingColors && !isOrWasThankYouInstalled()) {
|
||||||
mFeatureLockedDialog = FeatureLockedDialog(this) {
|
mFeatureLockedDialog = FeatureLockedDialog(this) {
|
||||||
|
@ -74,13 +75,13 @@ class WidgetDigitalConfigureActivity : SimpleActivity() {
|
||||||
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat()
|
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat()
|
||||||
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
|
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
|
||||||
|
|
||||||
config_digital_bg_seekbar.setOnSeekBarChangeListener(bgSeekbarChangeListener)
|
binding.configDigitalBgSeekbar.setOnSeekBarChangeListener(bgSeekbarChangeListener)
|
||||||
config_digital_bg_seekbar.progress = (mBgAlpha * 100).toInt()
|
binding.configDigitalBgSeekbar.progress = (mBgAlpha * 100).toInt()
|
||||||
updateBackgroundColor()
|
updateBackgroundColor()
|
||||||
|
|
||||||
mTextColor = config.widgetTextColor
|
mTextColor = config.widgetTextColor
|
||||||
if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) {
|
if (mTextColor == resources.getColor(com.simplemobiletools.commons.R.color.default_widget_text_color) && config.isUsingSystemTheme) {
|
||||||
mTextColor = resources.getColor(R.color.you_primary_color, theme)
|
mTextColor = resources.getColor(com.simplemobiletools.commons.R.color.you_primary_color, theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTextColor()
|
updateTextColor()
|
||||||
|
@ -130,17 +131,17 @@ class WidgetDigitalConfigureActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTextColor() {
|
private fun updateTextColor() {
|
||||||
config_digital_text_color.setFillWithStroke(mTextColor, mTextColor)
|
binding.configDigitalTextColor.setFillWithStroke(mTextColor, mTextColor)
|
||||||
config_digital_time.setTextColor(mTextColor)
|
binding.configDigitalTime.setTextColor(mTextColor)
|
||||||
config_digital_date.setTextColor(mTextColor)
|
binding.configDigitalDate.setTextColor(mTextColor)
|
||||||
config_digital_save.setTextColor(getProperPrimaryColor().getContrastColor())
|
binding.configDigitalSave.setTextColor(getProperPrimaryColor().getContrastColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateBackgroundColor() {
|
private fun updateBackgroundColor() {
|
||||||
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
||||||
config_digital_bg_color.setFillWithStroke(mBgColor, mBgColor)
|
binding.configDigitalBgColor.setFillWithStroke(mBgColor, mBgColor)
|
||||||
config_digital_background.applyColorFilter(mBgColor)
|
binding.configDigitalBackground.applyColorFilter(mBgColor)
|
||||||
config_digital_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
|
binding.configDigitalSave.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
private val bgSeekbarChangeListener = object : SeekBar.OnSeekBarChangeListener {
|
private val bgSeekbarChangeListener = object : SeekBar.OnSeekBarChangeListener {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.view.ViewGroup
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.clock.databinding.ItemAlarmBinding
|
||||||
import com.simplemobiletools.clock.extensions.*
|
import com.simplemobiletools.clock.extensions.*
|
||||||
import com.simplemobiletools.clock.helpers.TODAY_BIT
|
import com.simplemobiletools.clock.helpers.TODAY_BIT
|
||||||
import com.simplemobiletools.clock.helpers.TOMORROW_BIT
|
import com.simplemobiletools.clock.helpers.TOMORROW_BIT
|
||||||
|
@ -18,7 +19,6 @@ import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.isVisible
|
import com.simplemobiletools.commons.extensions.isVisible
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import kotlinx.android.synthetic.main.item_alarm.view.*
|
|
||||||
|
|
||||||
class AlarmsAdapter(
|
class AlarmsAdapter(
|
||||||
activity: SimpleActivity, var alarms: ArrayList<Alarm>, val toggleAlarmInterface: ToggleAlarmInterface,
|
activity: SimpleActivity, var alarms: ArrayList<Alarm>, val toggleAlarmInterface: ToggleAlarmInterface,
|
||||||
|
@ -55,7 +55,9 @@ class AlarmsAdapter(
|
||||||
|
|
||||||
override fun onActionModeDestroyed() {}
|
override fun onActionModeDestroyed() {}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_alarm, parent)
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
return createViewHolder(ItemAlarmBinding.inflate(layoutInflater, parent, false).root)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val alarm = alarms[position]
|
val alarm = alarms[position]
|
||||||
|
@ -89,50 +91,55 @@ class AlarmsAdapter(
|
||||||
|
|
||||||
private fun setupView(view: View, alarm: Alarm) {
|
private fun setupView(view: View, alarm: Alarm) {
|
||||||
val isSelected = selectedKeys.contains(alarm.id)
|
val isSelected = selectedKeys.contains(alarm.id)
|
||||||
view.apply {
|
ItemAlarmBinding.bind(view).apply {
|
||||||
alarm_frame.isSelected = isSelected
|
alarmFrame.isSelected = isSelected
|
||||||
alarm_time.text = activity.getFormattedTime(alarm.timeInMinutes * 60, false, true)
|
alarmTime.text = activity.getFormattedTime(alarm.timeInMinutes * 60, false, true)
|
||||||
alarm_time.setTextColor(textColor)
|
alarmTime.setTextColor(textColor)
|
||||||
|
|
||||||
alarm_days.text = activity.getAlarmSelectedDaysString(alarm.days)
|
alarmDays.text = activity.getAlarmSelectedDaysString(alarm.days)
|
||||||
alarm_days.setTextColor(textColor)
|
alarmDays.setTextColor(textColor)
|
||||||
|
|
||||||
alarm_label.text = alarm.label
|
alarmLabel.text = alarm.label
|
||||||
alarm_label.setTextColor(textColor)
|
alarmLabel.setTextColor(textColor)
|
||||||
alarm_label.beVisibleIf(alarm.label.isNotEmpty())
|
alarmLabel.beVisibleIf(alarm.label.isNotEmpty())
|
||||||
|
|
||||||
alarm_switch.isChecked = alarm.isEnabled
|
alarmSwitch.isChecked = alarm.isEnabled
|
||||||
alarm_switch.setColors(textColor, properPrimaryColor, backgroundColor)
|
alarmSwitch.setColors(textColor, properPrimaryColor, backgroundColor)
|
||||||
alarm_switch.setOnClickListener {
|
alarmSwitch.setOnClickListener {
|
||||||
if (alarm.days > 0) {
|
if (alarm.days > 0) {
|
||||||
if (activity.config.wasAlarmWarningShown) {
|
if (activity.config.wasAlarmWarningShown) {
|
||||||
toggleAlarmInterface.alarmToggled(alarm.id, alarm_switch.isChecked)
|
toggleAlarmInterface.alarmToggled(alarm.id, alarmSwitch.isChecked)
|
||||||
} else {
|
} else {
|
||||||
ConfirmationDialog(activity, messageId = R.string.alarm_warning, positive = R.string.ok, negative = 0) {
|
ConfirmationDialog(
|
||||||
|
activity,
|
||||||
|
messageId = com.simplemobiletools.commons.R.string.alarm_warning,
|
||||||
|
positive = com.simplemobiletools.commons.R.string.ok,
|
||||||
|
negative = 0
|
||||||
|
) {
|
||||||
activity.config.wasAlarmWarningShown = true
|
activity.config.wasAlarmWarningShown = true
|
||||||
toggleAlarmInterface.alarmToggled(alarm.id, alarm_switch.isChecked)
|
toggleAlarmInterface.alarmToggled(alarm.id, alarmSwitch.isChecked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (alarm.days == TODAY_BIT) {
|
} else if (alarm.days == TODAY_BIT) {
|
||||||
if (alarm.timeInMinutes <= getCurrentDayMinutes()) {
|
if (alarm.timeInMinutes <= getCurrentDayMinutes()) {
|
||||||
alarm.days = TOMORROW_BIT
|
alarm.days = TOMORROW_BIT
|
||||||
alarm_days.text = resources.getString(R.string.tomorrow)
|
alarmDays.text = resources.getString(com.simplemobiletools.commons.R.string.tomorrow)
|
||||||
}
|
}
|
||||||
activity.dbHelper.updateAlarm(alarm)
|
activity.dbHelper.updateAlarm(alarm)
|
||||||
context.scheduleNextAlarm(alarm, true)
|
root.context.scheduleNextAlarm(alarm, true)
|
||||||
toggleAlarmInterface.alarmToggled(alarm.id, alarm_switch.isChecked)
|
toggleAlarmInterface.alarmToggled(alarm.id, alarmSwitch.isChecked)
|
||||||
} else if (alarm.days == TOMORROW_BIT) {
|
} else if (alarm.days == TOMORROW_BIT) {
|
||||||
toggleAlarmInterface.alarmToggled(alarm.id, alarm_switch.isChecked)
|
toggleAlarmInterface.alarmToggled(alarm.id, alarmSwitch.isChecked)
|
||||||
} else if (alarm_switch.isChecked) {
|
} else if (alarmSwitch.isChecked) {
|
||||||
activity.toast(R.string.no_days_selected)
|
activity.toast(R.string.no_days_selected)
|
||||||
alarm_switch.isChecked = false
|
alarmSwitch.isChecked = false
|
||||||
} else {
|
} else {
|
||||||
toggleAlarmInterface.alarmToggled(alarm.id, alarm_switch.isChecked)
|
toggleAlarmInterface.alarmToggled(alarm.id, alarmSwitch.isChecked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val layoutParams = alarm_switch.layoutParams as RelativeLayout.LayoutParams
|
val layoutParams = alarmSwitch.layoutParams as RelativeLayout.LayoutParams
|
||||||
layoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, if (alarm_label.isVisible()) alarm_label.id else alarm_days.id)
|
layoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, if (alarmLabel.isVisible()) alarmLabel.id else alarmLabel.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,13 @@ package com.simplemobiletools.clock.adapters
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.simplemobiletools.clock.R
|
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.clock.databinding.ItemAddTimeZoneBinding
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.clock.models.MyTimeZone
|
import com.simplemobiletools.clock.models.MyTimeZone
|
||||||
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
|
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
|
||||||
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
|
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import kotlinx.android.synthetic.main.item_add_time_zone.view.*
|
|
||||||
|
|
||||||
class SelectTimeZonesAdapter(val activity: SimpleActivity, val timeZones: ArrayList<MyTimeZone>) : RecyclerView.Adapter<SelectTimeZonesAdapter.ViewHolder>() {
|
class SelectTimeZonesAdapter(val activity: SimpleActivity, val timeZones: ArrayList<MyTimeZone>) : RecyclerView.Adapter<SelectTimeZonesAdapter.ViewHolder>() {
|
||||||
private val config = activity.config
|
private val config = activity.config
|
||||||
|
@ -41,8 +40,7 @@ class SelectTimeZonesAdapter(val activity: SimpleActivity, val timeZones: ArrayL
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.item_add_time_zone, parent, false)
|
return ViewHolder(ItemAddTimeZoneBinding.inflate(activity.layoutInflater, parent, false))
|
||||||
return ViewHolder(view)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
@ -51,16 +49,16 @@ class SelectTimeZonesAdapter(val activity: SimpleActivity, val timeZones: ArrayL
|
||||||
|
|
||||||
override fun getItemCount() = timeZones.size
|
override fun getItemCount() = timeZones.size
|
||||||
|
|
||||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
inner class ViewHolder(private val binding: ItemAddTimeZoneBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||||
fun bindView(myTimeZone: MyTimeZone, textColor: Int, primaryColor: Int, backgroundColor: Int): View {
|
fun bindView(myTimeZone: MyTimeZone, textColor: Int, primaryColor: Int, backgroundColor: Int): View {
|
||||||
val isSelected = selectedKeys.contains(myTimeZone.id)
|
val isSelected = selectedKeys.contains(myTimeZone.id)
|
||||||
itemView.apply {
|
binding.apply {
|
||||||
add_time_zone_checkbox.isChecked = isSelected
|
addTimeZoneCheckbox.isChecked = isSelected
|
||||||
add_time_zone_title.text = myTimeZone.title
|
addTimeZoneTitle.text = myTimeZone.title
|
||||||
add_time_zone_title.setTextColor(textColor)
|
addTimeZoneTitle.setTextColor(textColor)
|
||||||
|
|
||||||
add_time_zone_checkbox.setColors(textColor, primaryColor, backgroundColor)
|
addTimeZoneCheckbox.setColors(textColor, primaryColor, backgroundColor)
|
||||||
add_time_zone_holder.setOnClickListener {
|
addTimeZoneHolder.setOnClickListener {
|
||||||
viewClicked(myTimeZone)
|
viewClicked(myTimeZone)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import android.view.Menu
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.simplemobiletools.clock.R
|
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.clock.databinding.ItemLapBinding
|
||||||
import com.simplemobiletools.clock.extensions.formatStopwatchTime
|
import com.simplemobiletools.clock.extensions.formatStopwatchTime
|
||||||
import com.simplemobiletools.clock.helpers.SORT_BY_LAP
|
import com.simplemobiletools.clock.helpers.SORT_BY_LAP
|
||||||
import com.simplemobiletools.clock.helpers.SORT_BY_LAP_TIME
|
import com.simplemobiletools.clock.helpers.SORT_BY_LAP_TIME
|
||||||
|
@ -13,8 +13,6 @@ import com.simplemobiletools.clock.helpers.SORT_BY_TOTAL_TIME
|
||||||
import com.simplemobiletools.clock.models.Lap
|
import com.simplemobiletools.clock.models.Lap
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import kotlinx.android.synthetic.main.item_lap.view.*
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class StopwatchAdapter(activity: SimpleActivity, var laps: ArrayList<Lap>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
class StopwatchAdapter(activity: SimpleActivity, var laps: ArrayList<Lap>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||||
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||||
|
@ -40,7 +38,9 @@ class StopwatchAdapter(activity: SimpleActivity, var laps: ArrayList<Lap>, recyc
|
||||||
|
|
||||||
override fun onActionModeDestroyed() {}
|
override fun onActionModeDestroyed() {}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_lap, parent)
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
return createViewHolder(ItemLapBinding.inflate(layoutInflater, parent, false).root)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||||
val lap = laps[position]
|
val lap = laps[position]
|
||||||
|
@ -66,28 +66,28 @@ class StopwatchAdapter(activity: SimpleActivity, var laps: ArrayList<Lap>, recyc
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupView(view: View, lap: Lap) {
|
private fun setupView(view: View, lap: Lap) {
|
||||||
view.apply {
|
ItemLapBinding.bind(view).apply {
|
||||||
lap_order.text = lap.id.toString()
|
lapOrder.text = lap.id.toString()
|
||||||
lap_order.setTextColor(textColor)
|
lapOrder.setTextColor(textColor)
|
||||||
lap_order.setOnClickListener {
|
lapOrder.setOnClickListener {
|
||||||
itemClick(SORT_BY_LAP)
|
itemClick(SORT_BY_LAP)
|
||||||
}
|
}
|
||||||
|
|
||||||
lap_lap_time.text = lap.lapTime.formatStopwatchTime(false)
|
lapLapTime.text = lap.lapTime.formatStopwatchTime(false)
|
||||||
lap_lap_time.setTextColor(textColor)
|
lapLapTime.setTextColor(textColor)
|
||||||
lap_lap_time.setOnClickListener {
|
lapLapTime.setOnClickListener {
|
||||||
itemClick(SORT_BY_LAP_TIME)
|
itemClick(SORT_BY_LAP_TIME)
|
||||||
}
|
}
|
||||||
|
|
||||||
lap_total_time.text = lap.totalTime.formatStopwatchTime(false)
|
lapTotalTime.text = lap.totalTime.formatStopwatchTime(false)
|
||||||
lap_total_time.setTextColor(textColor)
|
lapTotalTime.setTextColor(textColor)
|
||||||
lap_total_time.setOnClickListener {
|
lapTotalTime.setOnClickListener {
|
||||||
itemClick(SORT_BY_TOTAL_TIME)
|
itemClick(SORT_BY_TOTAL_TIME)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lap.id > lastLapId) {
|
if (lap.id > lastLapId) {
|
||||||
lastLapTimeView = lap_lap_time
|
lastLapTimeView = lapLapTime
|
||||||
lastTotalTimeView = lap_total_time
|
lastTotalTimeView = lapTotalTime
|
||||||
lastLapId = lap.id
|
lastLapId = lap.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.clock.databinding.ItemTimeZoneBinding
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.clock.extensions.getFormattedDate
|
import com.simplemobiletools.clock.extensions.getFormattedDate
|
||||||
import com.simplemobiletools.clock.extensions.getFormattedTime
|
import com.simplemobiletools.clock.extensions.getFormattedTime
|
||||||
|
@ -13,8 +14,9 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.extensions.beGone
|
import com.simplemobiletools.commons.extensions.beGone
|
||||||
import com.simplemobiletools.commons.extensions.beVisible
|
import com.simplemobiletools.commons.extensions.beVisible
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import kotlinx.android.synthetic.main.item_time_zone.view.*
|
import java.util.Calendar
|
||||||
import java.util.*
|
import java.util.Date
|
||||||
|
import java.util.TimeZone
|
||||||
|
|
||||||
class TimeZonesAdapter(activity: SimpleActivity, var timeZones: ArrayList<MyTimeZone>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
class TimeZonesAdapter(activity: SimpleActivity, var timeZones: ArrayList<MyTimeZone>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||||
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||||
|
@ -51,7 +53,9 @@ class TimeZonesAdapter(activity: SimpleActivity, var timeZones: ArrayList<MyTime
|
||||||
|
|
||||||
override fun onActionModeDestroyed() {}
|
override fun onActionModeDestroyed() {}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_time_zone, parent)
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
return createViewHolder(ItemTimeZoneBinding.inflate(layoutInflater, parent, false).root)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||||
val timeZone = timeZones[position]
|
val timeZone = timeZones[position]
|
||||||
|
@ -105,20 +109,20 @@ class TimeZonesAdapter(activity: SimpleActivity, var timeZones: ArrayList<MyTime
|
||||||
val formattedDate = activity.getFormattedDate(calendar)
|
val formattedDate = activity.getFormattedDate(calendar)
|
||||||
|
|
||||||
val isSelected = selectedKeys.contains(timeZone.id)
|
val isSelected = selectedKeys.contains(timeZone.id)
|
||||||
view.apply {
|
ItemTimeZoneBinding.bind(view).apply {
|
||||||
time_zone_frame.isSelected = isSelected
|
timeZoneFrame.isSelected = isSelected
|
||||||
time_zone_title.text = timeZone.title
|
timeZoneTitle.text = timeZone.title
|
||||||
time_zone_title.setTextColor(textColor)
|
timeZoneTitle.setTextColor(textColor)
|
||||||
|
|
||||||
time_zone_time.text = formattedTime
|
timeZoneTime.text = formattedTime
|
||||||
time_zone_time.setTextColor(textColor)
|
timeZoneTime.setTextColor(textColor)
|
||||||
|
|
||||||
if (formattedDate != todayDateString) {
|
if (formattedDate != todayDateString) {
|
||||||
time_zone_date.beVisible()
|
timeZoneDate.beVisible()
|
||||||
time_zone_date.text = formattedDate
|
timeZoneDate.text = formattedDate
|
||||||
time_zone_date.setTextColor(textColor)
|
timeZoneDate.setTextColor(textColor)
|
||||||
} else {
|
} else {
|
||||||
time_zone_date.beGone()
|
timeZoneDate.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.clock.databinding.ItemTimerBinding
|
||||||
import com.simplemobiletools.clock.extensions.getFormattedDuration
|
import com.simplemobiletools.clock.extensions.getFormattedDuration
|
||||||
import com.simplemobiletools.clock.extensions.hideTimerNotification
|
import com.simplemobiletools.clock.extensions.hideTimerNotification
|
||||||
import com.simplemobiletools.clock.extensions.secondsToMillis
|
import com.simplemobiletools.clock.extensions.secondsToMillis
|
||||||
|
@ -16,7 +17,6 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewListAdapter
|
||||||
import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
|
import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import kotlinx.android.synthetic.main.item_timer.view.*
|
|
||||||
import me.grantland.widget.AutofitHelper
|
import me.grantland.widget.AutofitHelper
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
|
|
||||||
|
@ -78,7 +78,9 @@ class TimerAdapter(
|
||||||
|
|
||||||
override fun onActionModeDestroyed() {}
|
override fun onActionModeDestroyed() {}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_timer, parent)
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
return createViewHolder(ItemTimerBinding.inflate(layoutInflater, parent, false).root)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
holder.bindView(getItem(position), true, true) { itemView, _ ->
|
holder.bindView(getItem(position), true, true) { itemView, _ ->
|
||||||
|
@ -97,30 +99,30 @@ class TimerAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupView(view: View, timer: Timer) {
|
private fun setupView(view: View, timer: Timer) {
|
||||||
view.apply {
|
ItemTimerBinding.bind(view).apply {
|
||||||
val isSelected = selectedKeys.contains(timer.id)
|
val isSelected = selectedKeys.contains(timer.id)
|
||||||
timer_frame.isSelected = isSelected
|
timerFrame.isSelected = isSelected
|
||||||
|
|
||||||
timer_label.setTextColor(textColor)
|
timerLabel.setTextColor(textColor)
|
||||||
timer_label.setHintTextColor(textColor.adjustAlpha(0.7f))
|
timerLabel.setHintTextColor(textColor.adjustAlpha(0.7f))
|
||||||
timer_label.text = timer.label
|
timerLabel.text = timer.label
|
||||||
|
|
||||||
AutofitHelper.create(timer_time)
|
AutofitHelper.create(timerTime)
|
||||||
timer_time.setTextColor(textColor)
|
timerTime.setTextColor(textColor)
|
||||||
timer_time.text = when (timer.state) {
|
timerTime.text = when (timer.state) {
|
||||||
is TimerState.Finished -> 0.getFormattedDuration()
|
is TimerState.Finished -> 0.getFormattedDuration()
|
||||||
is TimerState.Idle -> timer.seconds.getFormattedDuration()
|
is TimerState.Idle -> timer.seconds.getFormattedDuration()
|
||||||
is TimerState.Paused -> timer.state.tick.getFormattedDuration()
|
is TimerState.Paused -> timer.state.tick.getFormattedDuration()
|
||||||
is TimerState.Running -> timer.state.tick.getFormattedDuration()
|
is TimerState.Running -> timer.state.tick.getFormattedDuration()
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_reset.applyColorFilter(textColor)
|
timerReset.applyColorFilter(textColor)
|
||||||
timer_reset.setOnClickListener {
|
timerReset.setOnClickListener {
|
||||||
resetTimer(timer)
|
resetTimer(timer)
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_play_pause.applyColorFilter(textColor)
|
timerPlayPause.applyColorFilter(textColor)
|
||||||
timer_play_pause.setOnClickListener {
|
timerPlayPause.setOnClickListener {
|
||||||
(activity as SimpleActivity).handleNotificationPermission { granted ->
|
(activity as SimpleActivity).handleNotificationPermission { granted ->
|
||||||
if (granted) {
|
if (granted) {
|
||||||
when (val state = timer.state) {
|
when (val state = timer.state) {
|
||||||
|
@ -130,16 +132,20 @@ class TimerAdapter(
|
||||||
is TimerState.Finished -> EventBus.getDefault().post(TimerEvent.Start(timer.id!!, timer.seconds.secondsToMillis))
|
is TimerState.Finished -> EventBus.getDefault().post(TimerEvent.Start(timer.id!!, timer.seconds.secondsToMillis))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PermissionRequiredDialog(activity, R.string.allow_notifications_reminders, { activity.openNotificationSettings() })
|
PermissionRequiredDialog(
|
||||||
|
activity,
|
||||||
|
com.simplemobiletools.commons.R.string.allow_notifications_reminders,
|
||||||
|
{ activity.openNotificationSettings() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val state = timer.state
|
val state = timer.state
|
||||||
val resetPossible = state is TimerState.Running || state is TimerState.Paused || state is TimerState.Finished
|
val resetPossible = state is TimerState.Running || state is TimerState.Paused || state is TimerState.Finished
|
||||||
timer_reset.beInvisibleIf(!resetPossible)
|
timerReset.beInvisibleIf(!resetPossible)
|
||||||
val drawableId = if (state is TimerState.Running) R.drawable.ic_pause_vector else R.drawable.ic_play_vector
|
val drawableId =
|
||||||
timer_play_pause.setImageDrawable(simpleActivity.resources.getColoredDrawableWithColor(drawableId, textColor))
|
if (state is TimerState.Running) com.simplemobiletools.commons.R.drawable.ic_pause_vector else com.simplemobiletools.commons.R.drawable.ic_play_vector
|
||||||
|
timerPlayPause.setImageDrawable(simpleActivity.resources.getColoredDrawableWithColor(drawableId, textColor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,29 @@
|
||||||
package com.simplemobiletools.clock.dialogs
|
package com.simplemobiletools.clock.dialogs
|
||||||
|
|
||||||
import com.simplemobiletools.clock.R
|
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
import com.simplemobiletools.clock.adapters.SelectTimeZonesAdapter
|
import com.simplemobiletools.clock.adapters.SelectTimeZonesAdapter
|
||||||
|
import com.simplemobiletools.clock.databinding.DialogSelectTimeZonesBinding
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.clock.helpers.getAllTimeZones
|
import com.simplemobiletools.clock.helpers.getAllTimeZones
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import kotlinx.android.synthetic.main.dialog_select_time_zones.view.*
|
|
||||||
|
|
||||||
class AddTimeZonesDialog(val activity: SimpleActivity, private val callback: () -> Unit) {
|
class AddTimeZonesDialog(val activity: SimpleActivity, private val callback: () -> Unit) {
|
||||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_select_time_zones, null)
|
private val binding = DialogSelectTimeZonesBinding.inflate(activity.layoutInflater)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
view.select_time_zones_list.adapter = SelectTimeZonesAdapter(activity, getAllTimeZones())
|
binding.selectTimeZonesList.adapter = SelectTimeZonesAdapter(activity, getAllTimeZones())
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(binding.root, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
val adapter = view?.select_time_zones_list?.adapter as? SelectTimeZonesAdapter
|
val adapter = binding.selectTimeZonesList.adapter as? SelectTimeZonesAdapter
|
||||||
val selectedTimeZones = adapter?.selectedKeys?.map { it.toString() }?.toHashSet() ?: LinkedHashSet()
|
val selectedTimeZones = adapter?.selectedKeys?.map { it.toString() }?.toHashSet() ?: LinkedHashSet()
|
||||||
activity.config.selectedTimeZones = selectedTimeZones
|
activity.config.selectedTimeZones = selectedTimeZones
|
||||||
callback()
|
callback()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simplemobiletools.clock.dialogs
|
package com.simplemobiletools.clock.dialogs
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
|
import com.simplemobiletools.clock.databinding.DialogChangeAlarmSortBinding
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.clock.helpers.SORT_BY_ALARM_TIME
|
import com.simplemobiletools.clock.helpers.SORT_BY_ALARM_TIME
|
||||||
import com.simplemobiletools.clock.helpers.SORT_BY_CREATION_ORDER
|
import com.simplemobiletools.clock.helpers.SORT_BY_CREATION_ORDER
|
||||||
|
@ -9,29 +9,28 @@ import com.simplemobiletools.clock.helpers.SORT_BY_DATE_AND_TIME
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import kotlinx.android.synthetic.main.dialog_change_alarm_sort.view.*
|
|
||||||
|
|
||||||
class ChangeAlarmSortDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) {
|
class ChangeAlarmSortDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) {
|
||||||
private var view: View = activity.layoutInflater.inflate(R.layout.dialog_change_alarm_sort, null).apply {
|
private var binding = DialogChangeAlarmSortBinding.inflate(activity.layoutInflater).apply {
|
||||||
val activeRadioButton = when (activity.config.alarmSort) {
|
val activeRadioButton = when (activity.config.alarmSort) {
|
||||||
SORT_BY_ALARM_TIME -> sorting_dialog_radio_alarm_time
|
SORT_BY_ALARM_TIME -> sortingDialogRadioAlarmTime
|
||||||
SORT_BY_DATE_AND_TIME -> sorting_dialog_radio_day_and_time
|
SORT_BY_DATE_AND_TIME -> sortingDialogRadioDayAndTime
|
||||||
else -> sorting_dialog_radio_creation_order
|
else -> sortingDialogRadioCreationOrder
|
||||||
}
|
}
|
||||||
activeRadioButton?.isChecked = true
|
activeRadioButton.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { _, _ -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { _, _ -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.sort_by)
|
activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.sort_by)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
val sort = when (view.sorting_dialog_radio_sorting.checkedRadioButtonId) {
|
val sort = when (binding.sortingDialogRadioSorting.checkedRadioButtonId) {
|
||||||
R.id.sorting_dialog_radio_alarm_time -> SORT_BY_ALARM_TIME
|
R.id.sorting_dialog_radio_alarm_time -> SORT_BY_ALARM_TIME
|
||||||
R.id.sorting_dialog_radio_day_and_time -> SORT_BY_DATE_AND_TIME
|
R.id.sorting_dialog_radio_day_and_time -> SORT_BY_DATE_AND_TIME
|
||||||
else -> SORT_BY_CREATION_ORDER
|
else -> SORT_BY_CREATION_ORDER
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.google.android.material.timepicker.MaterialTimePicker
|
||||||
import com.google.android.material.timepicker.TimeFormat
|
import com.google.android.material.timepicker.TimeFormat
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.clock.databinding.DialogEditAlarmBinding
|
||||||
import com.simplemobiletools.clock.extensions.*
|
import com.simplemobiletools.clock.extensions.*
|
||||||
import com.simplemobiletools.clock.helpers.PICK_AUDIO_FILE_INTENT_ID
|
import com.simplemobiletools.clock.helpers.PICK_AUDIO_FILE_INTENT_ID
|
||||||
import com.simplemobiletools.clock.helpers.TODAY_BIT
|
import com.simplemobiletools.clock.helpers.TODAY_BIT
|
||||||
|
@ -22,18 +23,17 @@ import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
|
||||||
import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog
|
import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.models.AlarmSound
|
import com.simplemobiletools.commons.models.AlarmSound
|
||||||
import kotlinx.android.synthetic.main.dialog_edit_alarm.view.*
|
|
||||||
|
|
||||||
class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callback: (alarmId: Int) -> Unit) {
|
class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callback: (alarmId: Int) -> Unit) {
|
||||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_edit_alarm, null)
|
private val binding = DialogEditAlarmBinding.inflate(activity.layoutInflater)
|
||||||
private val textColor = activity.getProperTextColor()
|
private val textColor = activity.getProperTextColor()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
restoreLastAlarm()
|
restoreLastAlarm()
|
||||||
updateAlarmTime()
|
updateAlarmTime()
|
||||||
|
|
||||||
view.apply {
|
binding.apply {
|
||||||
edit_alarm_time.setOnClickListener {
|
editAlarmTime.setOnClickListener {
|
||||||
if (activity.config.isUsingSystemTheme) {
|
if (activity.config.isUsingSystemTheme) {
|
||||||
val timeFormat = if (DateFormat.is24HourFormat(activity)) {
|
val timeFormat = if (DateFormat.is24HourFormat(activity)) {
|
||||||
TimeFormat.CLOCK_24H
|
TimeFormat.CLOCK_24H
|
||||||
|
@ -55,8 +55,8 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
||||||
timePicker.show(activity.supportFragmentManager, "")
|
timePicker.show(activity.supportFragmentManager, "")
|
||||||
} else {
|
} else {
|
||||||
TimePickerDialog(
|
TimePickerDialog(
|
||||||
context,
|
root.context,
|
||||||
context.getTimePickerDialogTheme(),
|
root.context.getTimePickerDialogTheme(),
|
||||||
timeSetListener,
|
timeSetListener,
|
||||||
alarm.timeInMinutes / 60,
|
alarm.timeInMinutes / 60,
|
||||||
alarm.timeInMinutes % 60,
|
alarm.timeInMinutes % 60,
|
||||||
|
@ -65,9 +65,9 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_alarm_sound.colorCompoundDrawable(textColor)
|
editAlarmSound.colorCompoundDrawable(textColor)
|
||||||
edit_alarm_sound.text = alarm.soundTitle
|
editAlarmSound.text = alarm.soundTitle
|
||||||
edit_alarm_sound.setOnClickListener {
|
editAlarmSound.setOnClickListener {
|
||||||
SelectAlarmSoundDialog(activity, alarm.soundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID, RingtoneManager.TYPE_ALARM, true,
|
SelectAlarmSoundDialog(activity, alarm.soundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID, RingtoneManager.TYPE_ALARM, true,
|
||||||
onAlarmPicked = {
|
onAlarmPicked = {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
|
@ -75,24 +75,24 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
||||||
}
|
}
|
||||||
}, onAlarmSoundDeleted = {
|
}, onAlarmSoundDeleted = {
|
||||||
if (alarm.soundUri == it.uri) {
|
if (alarm.soundUri == it.uri) {
|
||||||
val defaultAlarm = context.getDefaultAlarmSound(RingtoneManager.TYPE_ALARM)
|
val defaultAlarm = root.context.getDefaultAlarmSound(RingtoneManager.TYPE_ALARM)
|
||||||
updateSelectedAlarmSound(defaultAlarm)
|
updateSelectedAlarmSound(defaultAlarm)
|
||||||
}
|
}
|
||||||
activity.checkAlarmsWithDeletedSoundUri(it.uri)
|
activity.checkAlarmsWithDeletedSoundUri(it.uri)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_alarm_vibrate_icon.setColorFilter(textColor)
|
editAlarmVibrateIcon.setColorFilter(textColor)
|
||||||
edit_alarm_vibrate.isChecked = alarm.vibrate
|
editAlarmVibrate.isChecked = alarm.vibrate
|
||||||
edit_alarm_vibrate_holder.setOnClickListener {
|
editAlarmVibrateHolder.setOnClickListener {
|
||||||
edit_alarm_vibrate.toggle()
|
editAlarmVibrate.toggle()
|
||||||
alarm.vibrate = edit_alarm_vibrate.isChecked
|
alarm.vibrate = editAlarmVibrate.isChecked
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_alarm_label_image.applyColorFilter(textColor)
|
editAlarmLabelImage.applyColorFilter(textColor)
|
||||||
edit_alarm.setText(alarm.label)
|
editAlarm.setText(alarm.label)
|
||||||
|
|
||||||
val dayLetters = activity.resources.getStringArray(R.array.week_day_letters).toList() as ArrayList<String>
|
val dayLetters = activity.resources.getStringArray(com.simplemobiletools.commons.R.array.week_day_letters).toList() as ArrayList<String>
|
||||||
val dayIndexes = arrayListOf(0, 1, 2, 3, 4, 5, 6)
|
val dayIndexes = arrayListOf(0, 1, 2, 3, 4, 5, 6)
|
||||||
if (activity.config.isSundayFirst) {
|
if (activity.config.isSundayFirst) {
|
||||||
dayIndexes.moveLastItemToFront()
|
dayIndexes.moveLastItemToFront()
|
||||||
|
@ -100,13 +100,13 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
||||||
|
|
||||||
dayIndexes.forEach {
|
dayIndexes.forEach {
|
||||||
val pow = Math.pow(2.0, it.toDouble()).toInt()
|
val pow = Math.pow(2.0, it.toDouble()).toInt()
|
||||||
val day = activity.layoutInflater.inflate(R.layout.alarm_day, edit_alarm_days_holder, false) as TextView
|
val day = activity.layoutInflater.inflate(R.layout.alarm_day, editAlarmDaysHolder, false) as TextView
|
||||||
day.text = dayLetters[it]
|
day.text = dayLetters[it]
|
||||||
|
|
||||||
val isDayChecked = alarm.days > 0 && alarm.days and pow != 0
|
val isDayChecked = alarm.days > 0 && alarm.days and pow != 0
|
||||||
day.background = getProperDayDrawable(isDayChecked)
|
day.background = getProperDayDrawable(isDayChecked)
|
||||||
|
|
||||||
day.setTextColor(if (isDayChecked) context.getProperBackgroundColor() else textColor)
|
day.setTextColor(if (isDayChecked) root.context.getProperBackgroundColor() else textColor)
|
||||||
day.setOnClickListener {
|
day.setOnClickListener {
|
||||||
if (alarm.days < 0) {
|
if (alarm.days < 0) {
|
||||||
alarm.days = 0
|
alarm.days = 0
|
||||||
|
@ -119,22 +119,27 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
||||||
alarm.days = alarm.days.removeBit(pow)
|
alarm.days = alarm.days.removeBit(pow)
|
||||||
}
|
}
|
||||||
day.background = getProperDayDrawable(selectDay)
|
day.background = getProperDayDrawable(selectDay)
|
||||||
day.setTextColor(if (selectDay) context.getProperBackgroundColor() else textColor)
|
day.setTextColor(if (selectDay) root.context.getProperBackgroundColor() else textColor)
|
||||||
checkDaylessAlarm()
|
checkDaylessAlarm()
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_alarm_days_holder.addView(day)
|
editAlarmDaysHolder.addView(day)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
if (!activity.config.wasAlarmWarningShown) {
|
if (!activity.config.wasAlarmWarningShown) {
|
||||||
ConfirmationDialog(activity, messageId = R.string.alarm_warning, positive = R.string.ok, negative = 0) {
|
ConfirmationDialog(
|
||||||
|
activity,
|
||||||
|
messageId = com.simplemobiletools.commons.R.string.alarm_warning,
|
||||||
|
positive = com.simplemobiletools.commons.R.string.ok,
|
||||||
|
negative = 0
|
||||||
|
) {
|
||||||
activity.config.wasAlarmWarningShown = true
|
activity.config.wasAlarmWarningShown = true
|
||||||
it.performClick()
|
it.performClick()
|
||||||
}
|
}
|
||||||
|
@ -150,7 +155,7 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alarm.label = view.edit_alarm.value
|
alarm.label = binding.editAlarm.value
|
||||||
alarm.isEnabled = true
|
alarm.isEnabled = true
|
||||||
|
|
||||||
var alarmId = alarm.id
|
var alarmId = alarm.id
|
||||||
|
@ -159,11 +164,11 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
||||||
if (alarm.id == 0) {
|
if (alarm.id == 0) {
|
||||||
alarmId = activity.dbHelper.insertAlarm(alarm)
|
alarmId = activity.dbHelper.insertAlarm(alarm)
|
||||||
if (alarmId == -1) {
|
if (alarmId == -1) {
|
||||||
activity.toast(R.string.unknown_error_occurred)
|
activity.toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!activity.dbHelper.updateAlarm(alarm)) {
|
if (!activity.dbHelper.updateAlarm(alarm)) {
|
||||||
activity.toast(R.string.unknown_error_occurred)
|
activity.toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +176,10 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
||||||
callback(alarmId)
|
callback(alarmId)
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
} else {
|
} else {
|
||||||
PermissionRequiredDialog(activity, R.string.allow_notifications_reminders, { activity.openNotificationSettings() })
|
PermissionRequiredDialog(
|
||||||
|
activity,
|
||||||
|
com.simplemobiletools.commons.R.string.allow_notifications_reminders,
|
||||||
|
{ activity.openNotificationSettings() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,21 +210,21 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAlarmTime() {
|
private fun updateAlarmTime() {
|
||||||
view.edit_alarm_time.text = activity.getFormattedTime(alarm.timeInMinutes * 60, false, true)
|
binding.editAlarmTime.text = activity.getFormattedTime(alarm.timeInMinutes * 60, false, true)
|
||||||
checkDaylessAlarm()
|
checkDaylessAlarm()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkDaylessAlarm() {
|
private fun checkDaylessAlarm() {
|
||||||
if (alarm.days <= 0) {
|
if (alarm.days <= 0) {
|
||||||
val textId = if (alarm.timeInMinutes > getCurrentDayMinutes()) {
|
val textId = if (alarm.timeInMinutes > getCurrentDayMinutes()) {
|
||||||
R.string.today
|
com.simplemobiletools.commons.R.string.today
|
||||||
} else {
|
} else {
|
||||||
R.string.tomorrow
|
com.simplemobiletools.commons.R.string.tomorrow
|
||||||
}
|
}
|
||||||
|
|
||||||
view.edit_alarm_dayless_label.text = "(${activity.getString(textId)})"
|
binding.editAlarmDaylessLabel.text = "(${activity.getString(textId)})"
|
||||||
}
|
}
|
||||||
view.edit_alarm_dayless_label.beVisibleIf(alarm.days <= 0)
|
binding.editAlarmDaylessLabel.beVisibleIf(alarm.days <= 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getProperDayDrawable(selected: Boolean): Drawable {
|
private fun getProperDayDrawable(selected: Boolean): Drawable {
|
||||||
|
@ -229,6 +237,6 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
||||||
fun updateSelectedAlarmSound(alarmSound: AlarmSound) {
|
fun updateSelectedAlarmSound(alarmSound: AlarmSound) {
|
||||||
alarm.soundTitle = alarmSound.title
|
alarm.soundTitle = alarmSound.title
|
||||||
alarm.soundUri = alarmSound.uri
|
alarm.soundUri = alarmSound.uri
|
||||||
view.edit_alarm_sound.text = alarmSound.title
|
binding.editAlarmSound.text = alarmSound.title
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simplemobiletools.clock.dialogs
|
package com.simplemobiletools.clock.dialogs
|
||||||
|
|
||||||
import com.simplemobiletools.clock.R
|
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.clock.databinding.DialogEditTimeZoneBinding
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.clock.extensions.getEditedTimeZonesMap
|
import com.simplemobiletools.clock.extensions.getEditedTimeZonesMap
|
||||||
import com.simplemobiletools.clock.extensions.getModifiedTimeZoneTitle
|
import com.simplemobiletools.clock.extensions.getModifiedTimeZoneTitle
|
||||||
|
@ -12,22 +12,21 @@ import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.extensions.showKeyboard
|
import com.simplemobiletools.commons.extensions.showKeyboard
|
||||||
import com.simplemobiletools.commons.extensions.value
|
import com.simplemobiletools.commons.extensions.value
|
||||||
import kotlinx.android.synthetic.main.dialog_edit_time_zone.view.*
|
|
||||||
|
|
||||||
class EditTimeZoneDialog(val activity: SimpleActivity, val myTimeZone: MyTimeZone, val callback: () -> Unit) {
|
class EditTimeZoneDialog(val activity: SimpleActivity, val myTimeZone: MyTimeZone, val callback: () -> Unit) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_edit_time_zone, null).apply {
|
val binding = DialogEditTimeZoneBinding.inflate(activity.layoutInflater).apply {
|
||||||
edit_time_zone_title.setText(activity.getModifiedTimeZoneTitle(myTimeZone.id))
|
editTimeZoneTitle.setText(activity.getModifiedTimeZoneTitle(myTimeZone.id))
|
||||||
edit_time_zone_label.setText(getDefaultTimeZoneTitle(myTimeZone.id))
|
editTimeZoneLabel.setText(getDefaultTimeZoneTitle(myTimeZone.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed(view.edit_time_zone_title.value) }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed(binding.editTimeZoneTitle.value) }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.edit_time_zone_title)
|
alertDialog.showKeyboard(binding.editTimeZoneTitle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,42 +5,42 @@ import android.media.RingtoneManager
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.clock.databinding.DialogEditTimerBinding
|
||||||
import com.simplemobiletools.clock.extensions.*
|
import com.simplemobiletools.clock.extensions.*
|
||||||
import com.simplemobiletools.clock.helpers.PICK_AUDIO_FILE_INTENT_ID
|
import com.simplemobiletools.clock.helpers.PICK_AUDIO_FILE_INTENT_ID
|
||||||
import com.simplemobiletools.clock.models.Timer
|
import com.simplemobiletools.clock.models.Timer
|
||||||
import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog
|
import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.models.AlarmSound
|
import com.simplemobiletools.commons.models.AlarmSound
|
||||||
import kotlinx.android.synthetic.main.dialog_edit_timer.view.*
|
|
||||||
|
|
||||||
class EditTimerDialog(val activity: SimpleActivity, val timer: Timer, val callback: () -> Unit) {
|
class EditTimerDialog(val activity: SimpleActivity, val timer: Timer, val callback: () -> Unit) {
|
||||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_edit_timer, null)
|
private val binding = DialogEditTimerBinding.inflate(activity.layoutInflater)
|
||||||
private val textColor = activity.getProperTextColor()
|
private val textColor = activity.getProperTextColor()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
restoreLastAlarm()
|
restoreLastAlarm()
|
||||||
updateAlarmTime()
|
updateAlarmTime()
|
||||||
|
|
||||||
view.apply {
|
binding.apply {
|
||||||
edit_timer_initial_time.colorCompoundDrawable(textColor)
|
editTimerInitialTime.colorCompoundDrawable(textColor)
|
||||||
edit_timer_initial_time.text = timer.seconds.getFormattedDuration()
|
editTimerInitialTime.text = timer.seconds.getFormattedDuration()
|
||||||
edit_timer_initial_time.setTextColor(textColor)
|
editTimerInitialTime.setTextColor(textColor)
|
||||||
edit_timer_initial_time.setOnClickListener {
|
editTimerInitialTime.setOnClickListener {
|
||||||
changeDuration(timer)
|
changeDuration(timer)
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_timer_vibrate_icon.setColorFilter(textColor)
|
editTimerVibrateIcon.setColorFilter(textColor)
|
||||||
edit_timer_vibrate.isChecked = timer.vibrate
|
editTimerVibrate.isChecked = timer.vibrate
|
||||||
edit_timer_vibrate.setTextColor(textColor)
|
editTimerVibrate.setTextColor(textColor)
|
||||||
edit_timer_vibrate_holder.setOnClickListener {
|
editTimerVibrateHolder.setOnClickListener {
|
||||||
edit_timer_vibrate.toggle()
|
editTimerVibrate.toggle()
|
||||||
timer.vibrate = edit_timer_vibrate.isChecked
|
timer.vibrate = editTimerVibrate.isChecked
|
||||||
timer.channelId = null
|
timer.channelId = null
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_timer_sound.colorCompoundDrawable(textColor)
|
editTimerSound.colorCompoundDrawable(textColor)
|
||||||
edit_timer_sound.text = timer.soundTitle
|
editTimerSound.text = timer.soundTitle
|
||||||
edit_timer_sound.setOnClickListener {
|
editTimerSound.setOnClickListener {
|
||||||
SelectAlarmSoundDialog(activity, timer.soundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID,
|
SelectAlarmSoundDialog(activity, timer.soundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID,
|
||||||
RingtoneManager.TYPE_ALARM, true,
|
RingtoneManager.TYPE_ALARM, true,
|
||||||
onAlarmPicked = { sound ->
|
onAlarmPicked = { sound ->
|
||||||
|
@ -50,25 +50,25 @@ class EditTimerDialog(val activity: SimpleActivity, val timer: Timer, val callba
|
||||||
},
|
},
|
||||||
onAlarmSoundDeleted = { sound ->
|
onAlarmSoundDeleted = { sound ->
|
||||||
if (timer.soundUri == sound.uri) {
|
if (timer.soundUri == sound.uri) {
|
||||||
val defaultAlarm = context.getDefaultAlarmSound(RingtoneManager.TYPE_ALARM)
|
val defaultAlarm = root.context.getDefaultAlarmSound(RingtoneManager.TYPE_ALARM)
|
||||||
updateAlarmSound(defaultAlarm)
|
updateAlarmSound(defaultAlarm)
|
||||||
}
|
}
|
||||||
|
|
||||||
context.checkAlarmsWithDeletedSoundUri(sound.uri)
|
root.context.checkAlarmsWithDeletedSoundUri(sound.uri)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_timer_label_image.applyColorFilter(textColor)
|
editTimerLabelImage.applyColorFilter(textColor)
|
||||||
edit_timer.setText(timer.label)
|
editTimer.setText(timer.label)
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
timer.label = view.edit_timer.value
|
timer.label = binding.editTimer.value
|
||||||
activity.timerHelper.insertOrUpdateTimer(timer) {
|
activity.timerHelper.insertOrUpdateTimer(timer) {
|
||||||
activity.config.timerLastConfig = timer
|
activity.config.timerLastConfig = timer
|
||||||
callback()
|
callback()
|
||||||
|
@ -92,14 +92,14 @@ class EditTimerDialog(val activity: SimpleActivity, val timer: Timer, val callba
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAlarmTime() {
|
private fun updateAlarmTime() {
|
||||||
view.edit_timer_initial_time.text = activity.getFormattedTime(timer.seconds * 60, false, true)
|
binding.editTimerInitialTime.text = activity.getFormattedTime(timer.seconds * 60, false, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changeDuration(timer: Timer) {
|
private fun changeDuration(timer: Timer) {
|
||||||
MyTimePickerDialogDialog(activity, timer.seconds) { seconds ->
|
MyTimePickerDialogDialog(activity, timer.seconds) { seconds ->
|
||||||
val timerSeconds = if (seconds <= 0) 10 else seconds
|
val timerSeconds = if (seconds <= 0) 10 else seconds
|
||||||
timer.seconds = timerSeconds
|
timer.seconds = timerSeconds
|
||||||
view.edit_timer_initial_time.text = timerSeconds.getFormattedDuration()
|
binding.editTimerInitialTime.text = timerSeconds.getFormattedDuration()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +107,6 @@ class EditTimerDialog(val activity: SimpleActivity, val timer: Timer, val callba
|
||||||
timer.soundTitle = alarmSound.title
|
timer.soundTitle = alarmSound.title
|
||||||
timer.soundUri = alarmSound.uri
|
timer.soundUri = alarmSound.uri
|
||||||
timer.channelId = null
|
timer.channelId = null
|
||||||
view.edit_timer_sound.text = alarmSound.title
|
binding.editTimerSound.text = alarmSound.title
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +1,41 @@
|
||||||
package com.simplemobiletools.clock.dialogs
|
package com.simplemobiletools.clock.dialogs
|
||||||
|
|
||||||
import com.simplemobiletools.clock.R
|
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.clock.databinding.DialogMyTimePickerBinding
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import kotlinx.android.synthetic.main.dialog_my_time_picker.view.*
|
|
||||||
|
|
||||||
class MyTimePickerDialogDialog(val activity: SimpleActivity, val initialSeconds: Int, val callback: (result: Int) -> Unit) {
|
class MyTimePickerDialogDialog(val activity: SimpleActivity, val initialSeconds: Int, val callback: (result: Int) -> Unit) {
|
||||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_my_time_picker, null)
|
private val binding = DialogMyTimePickerBinding.inflate(activity.layoutInflater)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
view.apply {
|
binding.apply {
|
||||||
val textColor = activity.getProperTextColor()
|
val textColor = activity.getProperTextColor()
|
||||||
arrayOf(my_time_picker_hours, my_time_picker_minutes, my_time_picker_seconds).forEach {
|
arrayOf(myTimePickerHours, myTimePickerMinutes, myTimePickerSeconds).forEach {
|
||||||
it.textColor = textColor
|
it.textColor = textColor
|
||||||
it.selectedTextColor = textColor
|
it.selectedTextColor = textColor
|
||||||
it.dividerColor = textColor
|
it.dividerColor = textColor
|
||||||
}
|
}
|
||||||
|
|
||||||
my_time_picker_hours.value = initialSeconds / 3600
|
myTimePickerHours.value = initialSeconds / 3600
|
||||||
my_time_picker_minutes.value = (initialSeconds) / 60 % 60
|
myTimePickerMinutes.value = (initialSeconds) / 60 % 60
|
||||||
my_time_picker_seconds.value = initialSeconds % 60
|
myTimePickerSeconds.value = initialSeconds % 60
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(binding.root, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
view.apply {
|
binding.apply {
|
||||||
val hours = my_time_picker_hours.value
|
val hours = myTimePickerHours.value
|
||||||
val minutes = my_time_picker_minutes.value
|
val minutes = myTimePickerMinutes.value
|
||||||
val seconds = my_time_picker_seconds.value
|
val seconds = myTimePickerSeconds.value
|
||||||
callback(hours * 3600 + minutes * 60 + seconds)
|
callback(hours * 3600 + minutes * 60 + seconds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.simplemobiletools.clock.extensions
|
package com.simplemobiletools.clock.extensions
|
||||||
|
|
||||||
import com.simplemobiletools.clock.BuildConfig
|
import com.simplemobiletools.clock.BuildConfig
|
||||||
import com.simplemobiletools.clock.R
|
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
|
import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
|
||||||
import com.simplemobiletools.commons.extensions.canUseFullScreenIntent
|
import com.simplemobiletools.commons.extensions.canUseFullScreenIntent
|
||||||
|
@ -15,7 +14,7 @@ fun BaseSimpleActivity.handleFullScreenNotificationsPermission(callback: (grante
|
||||||
} else {
|
} else {
|
||||||
PermissionRequiredDialog(
|
PermissionRequiredDialog(
|
||||||
activity = this,
|
activity = this,
|
||||||
textId = R.string.allow_full_screen_notifications_reminders,
|
textId = com.simplemobiletools.commons.R.string.allow_full_screen_notifications_reminders,
|
||||||
positiveActionCallback = {
|
positiveActionCallback = {
|
||||||
openFullScreenIntentSettings(BuildConfig.APPLICATION_ID)
|
openFullScreenIntentSettings(BuildConfig.APPLICATION_ID)
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,8 @@ fun Context.getFormattedDate(calendar: Calendar): String {
|
||||||
val dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH)
|
val dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH)
|
||||||
val month = calendar.get(Calendar.MONTH)
|
val month = calendar.get(Calendar.MONTH)
|
||||||
|
|
||||||
val dayString = resources.getStringArray(R.array.week_days_short)[dayOfWeek]
|
val dayString = resources.getStringArray(com.simplemobiletools.commons.R.array.week_days_short)[dayOfWeek]
|
||||||
val monthString = resources.getStringArray(R.array.months)[month]
|
val monthString = resources.getStringArray(com.simplemobiletools.commons.R.array.months)[month]
|
||||||
return "$dayString, $dayOfMonth $monthString"
|
return "$dayString, $dayOfMonth $monthString"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ fun Context.scheduleNextAlarm(alarm: Alarm, showToast: Boolean) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.showRemainingTimeMessage(totalMinutes: Int) {
|
fun Context.showRemainingTimeMessage(totalMinutes: Int) {
|
||||||
val fullString = String.format(getString(R.string.time_remaining), formatMinutesToTimeString(totalMinutes))
|
val fullString = String.format(getString(com.simplemobiletools.commons.R.string.time_remaining), formatMinutesToTimeString(totalMinutes))
|
||||||
toast(fullString, Toast.LENGTH_LONG)
|
toast(fullString, Toast.LENGTH_LONG)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ fun Context.getFormattedTime(passedSeconds: Int, showSeconds: Boolean, makeAmPmS
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.formatTo12HourFormat(showSeconds: Boolean, hours: Int, minutes: Int, seconds: Int): String {
|
fun Context.formatTo12HourFormat(showSeconds: Boolean, hours: Int, minutes: Int, seconds: Int): String {
|
||||||
val appendable = getString(if (hours >= 12) R.string.p_m else R.string.a_m)
|
val appendable = getString(if (hours >= 12) com.simplemobiletools.commons.R.string.p_m else com.simplemobiletools.commons.R.string.a_m)
|
||||||
val newHours = if (hours == 0 || hours == 12) 12 else hours % 12
|
val newHours = if (hours == 0 || hours == 12) 12 else hours % 12
|
||||||
return "${formatTime(showSeconds, false, newHours, minutes, seconds)} $appendable"
|
return "${formatTime(showSeconds, false, newHours, minutes, seconds)} $appendable"
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,7 @@ fun Context.getClosestEnabledAlarmString(callback: (result: String) -> Unit) {
|
||||||
val calendar = Calendar.getInstance().apply { firstDayOfWeek = Calendar.MONDAY }
|
val calendar = Calendar.getInstance().apply { firstDayOfWeek = Calendar.MONDAY }
|
||||||
calendar.add(Calendar.MINUTE, closestAlarmTime)
|
calendar.add(Calendar.MINUTE, closestAlarmTime)
|
||||||
val dayOfWeekIndex = (calendar.get(Calendar.DAY_OF_WEEK) + 5) % 7
|
val dayOfWeekIndex = (calendar.get(Calendar.DAY_OF_WEEK) + 5) % 7
|
||||||
val dayOfWeek = resources.getStringArray(R.array.week_days_short)[dayOfWeekIndex]
|
val dayOfWeek = resources.getStringArray(com.simplemobiletools.commons.R.array.week_days_short)[dayOfWeekIndex]
|
||||||
val pattern = if (DateFormat.is24HourFormat(this)) {
|
val pattern = if (DateFormat.is24HourFormat(this)) {
|
||||||
"HH:mm"
|
"HH:mm"
|
||||||
} else {
|
} else {
|
||||||
|
@ -403,8 +403,8 @@ fun Context.getTimerNotification(timer: Timer, pendingIntent: PendingIntent, add
|
||||||
.setSound(Uri.parse(soundUri), STREAM_ALARM)
|
.setSound(Uri.parse(soundUri), STREAM_ALARM)
|
||||||
.setChannelId(channelId)
|
.setChannelId(channelId)
|
||||||
.addAction(
|
.addAction(
|
||||||
R.drawable.ic_cross_vector,
|
com.simplemobiletools.commons.R.drawable.ic_cross_vector,
|
||||||
getString(R.string.dismiss),
|
getString(com.simplemobiletools.commons.R.string.dismiss),
|
||||||
if (addDeleteIntent) {
|
if (addDeleteIntent) {
|
||||||
reminderActivityIntent
|
reminderActivityIntent
|
||||||
} else {
|
} else {
|
||||||
|
@ -457,7 +457,7 @@ fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm): No
|
||||||
}
|
}
|
||||||
val channelId = "simple_alarm_channel_${soundUri}_${alarm.vibrate}"
|
val channelId = "simple_alarm_channel_${soundUri}_${alarm.vibrate}"
|
||||||
val label = alarm.label.ifEmpty {
|
val label = alarm.label.ifEmpty {
|
||||||
getString(R.string.alarm)
|
getString(com.simplemobiletools.commons.R.string.alarm)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOreoPlus()) {
|
if (isOreoPlus()) {
|
||||||
|
@ -490,8 +490,8 @@ fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm): No
|
||||||
.setDefaults(Notification.DEFAULT_LIGHTS)
|
.setDefaults(Notification.DEFAULT_LIGHTS)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setChannelId(channelId)
|
.setChannelId(channelId)
|
||||||
.addAction(R.drawable.ic_snooze_vector, getString(R.string.snooze), getSnoozePendingIntent(alarm))
|
.addAction(com.simplemobiletools.commons.R.drawable.ic_snooze_vector, getString(com.simplemobiletools.commons.R.string.snooze), getSnoozePendingIntent(alarm))
|
||||||
.addAction(R.drawable.ic_cross_vector, getString(R.string.dismiss), dismissIntent)
|
.addAction(com.simplemobiletools.commons.R.drawable.ic_cross_vector, getString(com.simplemobiletools.commons.R.string.dismiss), dismissIntent)
|
||||||
.setDeleteIntent(dismissIntent)
|
.setDeleteIntent(dismissIntent)
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
|
|
||||||
|
@ -536,9 +536,9 @@ fun Context.checkAlarmsWithDeletedSoundUri(uri: String) {
|
||||||
|
|
||||||
fun Context.getAlarmSelectedDaysString(bitMask: Int): String {
|
fun Context.getAlarmSelectedDaysString(bitMask: Int): String {
|
||||||
return when (bitMask) {
|
return when (bitMask) {
|
||||||
TODAY_BIT -> getString(R.string.today)
|
TODAY_BIT -> getString(com.simplemobiletools.commons.R.string.today)
|
||||||
TOMORROW_BIT -> getString(R.string.tomorrow)
|
TOMORROW_BIT -> getString(com.simplemobiletools.commons.R.string.tomorrow)
|
||||||
EVERY_DAY_BIT -> getString(R.string.every_day)
|
EVERY_DAY_BIT -> getString(com.simplemobiletools.commons.R.string.every_day)
|
||||||
else -> getSelectedDaysString(bitMask)
|
else -> getSelectedDaysString(bitMask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.simplemobiletools.clock.R
|
|
||||||
import com.simplemobiletools.clock.activities.MainActivity
|
import com.simplemobiletools.clock.activities.MainActivity
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
import com.simplemobiletools.clock.adapters.AlarmsAdapter
|
import com.simplemobiletools.clock.adapters.AlarmsAdapter
|
||||||
|
import com.simplemobiletools.clock.databinding.FragmentAlarmBinding
|
||||||
import com.simplemobiletools.clock.dialogs.ChangeAlarmSortDialog
|
import com.simplemobiletools.clock.dialogs.ChangeAlarmSortDialog
|
||||||
import com.simplemobiletools.clock.dialogs.EditAlarmDialog
|
import com.simplemobiletools.clock.dialogs.EditAlarmDialog
|
||||||
import com.simplemobiletools.clock.extensions.*
|
import com.simplemobiletools.clock.extensions.*
|
||||||
|
@ -23,9 +23,6 @@ import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_CREATED
|
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_CREATED
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.models.AlarmSound
|
import com.simplemobiletools.commons.models.AlarmSound
|
||||||
import kotlinx.android.synthetic.main.fragment_alarm.view.alarm_fab
|
|
||||||
import kotlinx.android.synthetic.main.fragment_alarm.view.alarm_fragment
|
|
||||||
import kotlinx.android.synthetic.main.fragment_alarm.view.alarms_list
|
|
||||||
|
|
||||||
class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
||||||
private var alarms = ArrayList<Alarm>()
|
private var alarms = ArrayList<Alarm>()
|
||||||
|
@ -33,12 +30,12 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
||||||
|
|
||||||
private var storedTextColor = 0
|
private var storedTextColor = 0
|
||||||
|
|
||||||
lateinit var view: ViewGroup
|
private lateinit var binding: FragmentAlarmBinding
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
view = inflater.inflate(R.layout.fragment_alarm, container, false) as ViewGroup
|
binding = FragmentAlarmBinding.inflate(inflater, container, false)
|
||||||
return view
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -47,7 +44,7 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
||||||
|
|
||||||
val configTextColor = requireContext().getProperTextColor()
|
val configTextColor = requireContext().getProperTextColor()
|
||||||
if (storedTextColor != configTextColor) {
|
if (storedTextColor != configTextColor) {
|
||||||
(view.alarms_list.adapter as AlarmsAdapter).updateTextColor(configTextColor)
|
(binding.alarmsList.adapter as AlarmsAdapter).updateTextColor(configTextColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,10 +64,10 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
view.apply {
|
binding.apply {
|
||||||
requireContext().updateTextColors(alarm_fragment)
|
requireContext().updateTextColors(alarmFragment)
|
||||||
alarm_fab.setOnClickListener {
|
alarmFab.setOnClickListener {
|
||||||
val newAlarm = context.createNewAlarm(DEFAULT_ALARM_MINUTES, 0)
|
val newAlarm = root.context.createNewAlarm(DEFAULT_ALARM_MINUTES, 0)
|
||||||
newAlarm.isEnabled = true
|
newAlarm.isEnabled = true
|
||||||
newAlarm.days = getTomorrowBit()
|
newAlarm.days = getTomorrowBit()
|
||||||
openEditAlarm(newAlarm)
|
openEditAlarm(newAlarm)
|
||||||
|
@ -105,12 +102,12 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val currAdapter = view.alarms_list.adapter
|
val currAdapter = binding.alarmsList.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
AlarmsAdapter(activity as SimpleActivity, alarms, this, view.alarms_list) {
|
AlarmsAdapter(activity as SimpleActivity, alarms, this, binding.alarmsList) {
|
||||||
openEditAlarm(it as Alarm)
|
openEditAlarm(it as Alarm)
|
||||||
}.apply {
|
}.apply {
|
||||||
view.alarms_list.adapter = this
|
binding.alarmsList.adapter = this
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(currAdapter as AlarmsAdapter).updateItems(alarms)
|
(currAdapter as AlarmsAdapter).updateItems(alarms)
|
||||||
|
@ -134,13 +131,13 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
||||||
alarm.isEnabled = isEnabled
|
alarm.isEnabled = isEnabled
|
||||||
checkAlarmState(alarm)
|
checkAlarmState(alarm)
|
||||||
} else {
|
} else {
|
||||||
requireActivity().toast(R.string.unknown_error_occurred)
|
requireActivity().toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
requireContext().updateWidgets()
|
requireContext().updateWidgets()
|
||||||
} else {
|
} else {
|
||||||
PermissionRequiredDialog(
|
PermissionRequiredDialog(
|
||||||
activity as SimpleActivity,
|
activity as SimpleActivity,
|
||||||
R.string.allow_notifications_reminders,
|
com.simplemobiletools.commons.R.string.allow_notifications_reminders,
|
||||||
{ (activity as SimpleActivity).openNotificationSettings() })
|
{ (activity as SimpleActivity).openNotificationSettings() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import androidx.fragment.app.Fragment
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
import com.simplemobiletools.clock.adapters.TimeZonesAdapter
|
import com.simplemobiletools.clock.adapters.TimeZonesAdapter
|
||||||
|
import com.simplemobiletools.clock.databinding.FragmentClockBinding
|
||||||
import com.simplemobiletools.clock.dialogs.AddTimeZonesDialog
|
import com.simplemobiletools.clock.dialogs.AddTimeZonesDialog
|
||||||
import com.simplemobiletools.clock.dialogs.EditTimeZoneDialog
|
import com.simplemobiletools.clock.dialogs.EditTimeZoneDialog
|
||||||
import com.simplemobiletools.clock.extensions.*
|
import com.simplemobiletools.clock.extensions.*
|
||||||
|
@ -18,7 +19,6 @@ import com.simplemobiletools.clock.models.MyTimeZone
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
import kotlinx.android.synthetic.main.fragment_clock.view.*
|
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
|
||||||
class ClockFragment : Fragment() {
|
class ClockFragment : Fragment() {
|
||||||
|
@ -30,12 +30,12 @@ class ClockFragment : Fragment() {
|
||||||
|
|
||||||
private var storedTextColor = 0
|
private var storedTextColor = 0
|
||||||
|
|
||||||
lateinit var view: ViewGroup
|
private lateinit var binding: FragmentClockBinding
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
view = inflater.inflate(R.layout.fragment_clock, container, false) as ViewGroup
|
binding = FragmentClockBinding.inflate(inflater, container, false)
|
||||||
return view
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -44,10 +44,10 @@ class ClockFragment : Fragment() {
|
||||||
|
|
||||||
val configTextColor = requireContext().getProperTextColor()
|
val configTextColor = requireContext().getProperTextColor()
|
||||||
if (storedTextColor != configTextColor) {
|
if (storedTextColor != configTextColor) {
|
||||||
(view.time_zones_list.adapter as? TimeZonesAdapter)?.updateTextColor(configTextColor)
|
(binding.timeZonesList.adapter as? TimeZonesAdapter)?.updateTextColor(configTextColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
view.clock_date.setTextColor(configTextColor)
|
binding.clockDate.setTextColor(configTextColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
@ -70,10 +70,10 @@ class ClockFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
view.apply {
|
binding.apply {
|
||||||
requireContext().updateTextColors(clock_fragment)
|
requireContext().updateTextColors(clockFragment)
|
||||||
clock_time.setTextColor(requireContext().getProperTextColor())
|
clockTime.setTextColor(requireContext().getProperTextColor())
|
||||||
clock_fab.setOnClickListener {
|
clockFab.setOnClickListener {
|
||||||
fabClicked()
|
fabClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ class ClockFragment : Fragment() {
|
||||||
val seconds = passedSeconds % 60
|
val seconds = passedSeconds % 60
|
||||||
|
|
||||||
if (!DateFormat.is24HourFormat(requireContext())) {
|
if (!DateFormat.is24HourFormat(requireContext())) {
|
||||||
view.clock_time.textSize = resources.getDimension(R.dimen.clock_text_size_smaller) / resources.displayMetrics.density
|
binding.clockTime.textSize = resources.getDimension(R.dimen.clock_text_size_smaller) / resources.displayMetrics.density
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seconds == 0) {
|
if (seconds == 0) {
|
||||||
|
@ -95,7 +95,7 @@ class ClockFragment : Fragment() {
|
||||||
updateDate()
|
updateDate()
|
||||||
}
|
}
|
||||||
|
|
||||||
(view.time_zones_list.adapter as? TimeZonesAdapter)?.updateTimes()
|
(binding.timeZonesList.adapter as? TimeZonesAdapter)?.updateTimes()
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHandler.postDelayed({
|
updateHandler.postDelayed({
|
||||||
|
@ -107,36 +107,36 @@ class ClockFragment : Fragment() {
|
||||||
private fun updateDate() {
|
private fun updateDate() {
|
||||||
calendar = Calendar.getInstance()
|
calendar = Calendar.getInstance()
|
||||||
val formattedDate = requireContext().getFormattedDate(calendar)
|
val formattedDate = requireContext().getFormattedDate(calendar)
|
||||||
(view.time_zones_list.adapter as? TimeZonesAdapter)?.todayDateString = formattedDate
|
(binding.timeZonesList.adapter as? TimeZonesAdapter)?.todayDateString = formattedDate
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateAlarm() {
|
fun updateAlarm() {
|
||||||
context?.getClosestEnabledAlarmString { nextAlarm ->
|
context?.getClosestEnabledAlarmString { nextAlarm ->
|
||||||
view.apply {
|
binding.apply {
|
||||||
clock_alarm.beVisibleIf(nextAlarm.isNotEmpty())
|
clockAlarm.beVisibleIf(nextAlarm.isNotEmpty())
|
||||||
clock_alarm.text = nextAlarm
|
clockAlarm.text = nextAlarm
|
||||||
clock_alarm.colorCompoundDrawable(requireContext().getProperTextColor())
|
clockAlarm.colorCompoundDrawable(requireContext().getProperTextColor())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTimeZones() {
|
private fun updateTimeZones() {
|
||||||
val selectedTimeZones = context?.config?.selectedTimeZones ?: return
|
val selectedTimeZones = context?.config?.selectedTimeZones ?: return
|
||||||
view.time_zones_list.beVisibleIf(selectedTimeZones.isNotEmpty())
|
binding.timeZonesList.beVisibleIf(selectedTimeZones.isNotEmpty())
|
||||||
if (selectedTimeZones.isEmpty()) {
|
if (selectedTimeZones.isEmpty()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val selectedTimeZoneIDs = selectedTimeZones.map { it.toInt() }
|
val selectedTimeZoneIDs = selectedTimeZones.map { it.toInt() }
|
||||||
val timeZones = requireContext().getAllTimeZonesModified().filter { selectedTimeZoneIDs.contains(it.id) } as ArrayList<MyTimeZone>
|
val timeZones = requireContext().getAllTimeZonesModified().filter { selectedTimeZoneIDs.contains(it.id) } as ArrayList<MyTimeZone>
|
||||||
val currAdapter = view.time_zones_list.adapter
|
val currAdapter = binding.timeZonesList.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
TimeZonesAdapter(activity as SimpleActivity, timeZones, view.time_zones_list) {
|
TimeZonesAdapter(activity as SimpleActivity, timeZones, binding.timeZonesList) {
|
||||||
EditTimeZoneDialog(activity as SimpleActivity, it as MyTimeZone) {
|
EditTimeZoneDialog(activity as SimpleActivity, it as MyTimeZone) {
|
||||||
updateTimeZones()
|
updateTimeZones()
|
||||||
}
|
}
|
||||||
}.apply {
|
}.apply {
|
||||||
view.time_zones_list.adapter = this
|
this@ClockFragment.binding.timeZonesList.adapter = this
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(currAdapter as TimeZonesAdapter).updateItems(timeZones)
|
(currAdapter as TimeZonesAdapter).updateItems(timeZones)
|
||||||
|
|
|
@ -11,6 +11,7 @@ import androidx.fragment.app.Fragment
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
import com.simplemobiletools.clock.adapters.StopwatchAdapter
|
import com.simplemobiletools.clock.adapters.StopwatchAdapter
|
||||||
|
import com.simplemobiletools.clock.databinding.FragmentStopwatchBinding
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.clock.extensions.formatStopwatchTime
|
import com.simplemobiletools.clock.extensions.formatStopwatchTime
|
||||||
import com.simplemobiletools.clock.helpers.SORT_BY_LAP
|
import com.simplemobiletools.clock.helpers.SORT_BY_LAP
|
||||||
|
@ -21,60 +22,59 @@ import com.simplemobiletools.clock.models.Lap
|
||||||
import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
|
import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.SORT_DESCENDING
|
import com.simplemobiletools.commons.helpers.SORT_DESCENDING
|
||||||
import kotlinx.android.synthetic.main.fragment_stopwatch.view.*
|
|
||||||
|
|
||||||
class StopwatchFragment : Fragment() {
|
class StopwatchFragment : Fragment() {
|
||||||
|
|
||||||
private var storedTextColor = 0
|
private var storedTextColor = 0
|
||||||
|
|
||||||
lateinit var stopwatchAdapter: StopwatchAdapter
|
lateinit var stopwatchAdapter: StopwatchAdapter
|
||||||
lateinit var view: ViewGroup
|
private lateinit var binding: FragmentStopwatchBinding
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
val sorting = requireContext().config.stopwatchLapsSort
|
val sorting = requireContext().config.stopwatchLapsSort
|
||||||
Lap.sorting = sorting
|
Lap.sorting = sorting
|
||||||
view = (inflater.inflate(R.layout.fragment_stopwatch, container, false) as ViewGroup).apply {
|
binding = FragmentStopwatchBinding.inflate(inflater, container, false).apply {
|
||||||
stopwatch_time.setOnClickListener {
|
stopwatchTime.setOnClickListener {
|
||||||
togglePlayPause()
|
togglePlayPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
stopwatch_play_pause.setOnClickListener {
|
stopwatchPlayPause.setOnClickListener {
|
||||||
togglePlayPause()
|
togglePlayPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
stopwatch_reset.setOnClickListener {
|
stopwatchReset.setOnClickListener {
|
||||||
resetStopwatch()
|
resetStopwatch()
|
||||||
}
|
}
|
||||||
|
|
||||||
stopwatch_sorting_indicator_1.setOnClickListener {
|
stopwatchSortingIndicator1.setOnClickListener {
|
||||||
changeSorting(SORT_BY_LAP)
|
changeSorting(SORT_BY_LAP)
|
||||||
}
|
}
|
||||||
|
|
||||||
stopwatch_sorting_indicator_2.setOnClickListener {
|
stopwatchSortingIndicator2.setOnClickListener {
|
||||||
changeSorting(SORT_BY_LAP_TIME)
|
changeSorting(SORT_BY_LAP_TIME)
|
||||||
}
|
}
|
||||||
|
|
||||||
stopwatch_sorting_indicator_3.setOnClickListener {
|
stopwatchSortingIndicator3.setOnClickListener {
|
||||||
changeSorting(SORT_BY_TOTAL_TIME)
|
changeSorting(SORT_BY_TOTAL_TIME)
|
||||||
}
|
}
|
||||||
|
|
||||||
stopwatch_lap.setOnClickListener {
|
stopwatchLap.setOnClickListener {
|
||||||
stopwatch_sorting_indicators_holder.beVisible()
|
stopwatchSortingIndicatorsHolder.beVisible()
|
||||||
Stopwatch.lap()
|
Stopwatch.lap()
|
||||||
updateLaps()
|
updateLaps()
|
||||||
}
|
}
|
||||||
|
|
||||||
stopwatchAdapter = StopwatchAdapter(activity as SimpleActivity, ArrayList(), stopwatch_list) {
|
stopwatchAdapter = StopwatchAdapter(activity as SimpleActivity, ArrayList(), stopwatchList) {
|
||||||
if (it is Int) {
|
if (it is Int) {
|
||||||
changeSorting(it)
|
changeSorting(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stopwatch_list.adapter = stopwatchAdapter
|
stopwatchList.adapter = stopwatchAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSortingIndicators(sorting)
|
updateSortingIndicators(sorting)
|
||||||
return view
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -88,7 +88,7 @@ class StopwatchFragment : Fragment() {
|
||||||
|
|
||||||
Stopwatch.addUpdateListener(updateListener)
|
Stopwatch.addUpdateListener(updateListener)
|
||||||
updateLaps()
|
updateLaps()
|
||||||
view.stopwatch_sorting_indicators_holder.beVisibleIf(Stopwatch.laps.isNotEmpty())
|
binding.stopwatchSortingIndicatorsHolder.beVisibleIf(Stopwatch.laps.isNotEmpty())
|
||||||
if (Stopwatch.laps.isNotEmpty()) {
|
if (Stopwatch.laps.isNotEmpty()) {
|
||||||
updateSorting(Lap.sorting)
|
updateSorting(Lap.sorting)
|
||||||
}
|
}
|
||||||
|
@ -111,17 +111,18 @@ class StopwatchFragment : Fragment() {
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
val properPrimaryColor = requireContext().getProperPrimaryColor()
|
val properPrimaryColor = requireContext().getProperPrimaryColor()
|
||||||
view.apply {
|
binding.apply {
|
||||||
requireContext().updateTextColors(stopwatch_fragment)
|
requireContext().updateTextColors(stopwatchFragment)
|
||||||
stopwatch_play_pause.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, properPrimaryColor)
|
stopwatchPlayPause.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, properPrimaryColor)
|
||||||
stopwatch_reset.applyColorFilter(requireContext().getProperTextColor())
|
stopwatchReset.applyColorFilter(requireContext().getProperTextColor())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateIcons(state: Stopwatch.State) {
|
private fun updateIcons(state: Stopwatch.State) {
|
||||||
val drawableId = if (state == Stopwatch.State.RUNNING) R.drawable.ic_pause_vector else R.drawable.ic_play_vector
|
val drawableId =
|
||||||
|
if (state == Stopwatch.State.RUNNING) com.simplemobiletools.commons.R.drawable.ic_pause_vector else com.simplemobiletools.commons.R.drawable.ic_play_vector
|
||||||
val iconColor = if (requireContext().getProperPrimaryColor() == Color.WHITE) Color.BLACK else Color.WHITE
|
val iconColor = if (requireContext().getProperPrimaryColor() == Color.WHITE) Color.BLACK else Color.WHITE
|
||||||
view.stopwatch_play_pause.setImageDrawable(resources.getColoredDrawableWithColor(drawableId, iconColor))
|
binding.stopwatchPlayPause.setImageDrawable(resources.getColoredDrawableWithColor(drawableId, iconColor))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun togglePlayPause() {
|
private fun togglePlayPause() {
|
||||||
|
@ -131,14 +132,14 @@ class StopwatchFragment : Fragment() {
|
||||||
} else {
|
} else {
|
||||||
PermissionRequiredDialog(
|
PermissionRequiredDialog(
|
||||||
activity as SimpleActivity,
|
activity as SimpleActivity,
|
||||||
R.string.allow_notifications_reminders,
|
com.simplemobiletools.commons.R.string.allow_notifications_reminders,
|
||||||
{ (activity as SimpleActivity).openNotificationSettings() })
|
{ (activity as SimpleActivity).openNotificationSettings() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateDisplayedText(totalTime: Long, lapTime: Long, useLongerMSFormat: Boolean) {
|
private fun updateDisplayedText(totalTime: Long, lapTime: Long, useLongerMSFormat: Boolean) {
|
||||||
view.stopwatch_time.text = totalTime.formatStopwatchTime(useLongerMSFormat)
|
binding.stopwatchTime.text = totalTime.formatStopwatchTime(useLongerMSFormat)
|
||||||
if (Stopwatch.laps.isNotEmpty() && lapTime != -1L) {
|
if (Stopwatch.laps.isNotEmpty() && lapTime != -1L) {
|
||||||
stopwatchAdapter.updateLastField(lapTime, totalTime)
|
stopwatchAdapter.updateLastField(lapTime, totalTime)
|
||||||
}
|
}
|
||||||
|
@ -148,11 +149,11 @@ class StopwatchFragment : Fragment() {
|
||||||
Stopwatch.reset()
|
Stopwatch.reset()
|
||||||
|
|
||||||
updateLaps()
|
updateLaps()
|
||||||
view.apply {
|
binding.apply {
|
||||||
stopwatch_reset.beGone()
|
stopwatchReset.beGone()
|
||||||
stopwatch_lap.beGone()
|
stopwatchLap.beGone()
|
||||||
stopwatch_time.text = 0L.formatStopwatchTime(false)
|
stopwatchTime.text = 0L.formatStopwatchTime(false)
|
||||||
stopwatch_sorting_indicators_holder.beInvisible()
|
stopwatchSortingIndicatorsHolder.beInvisible()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,15 +175,15 @@ class StopwatchFragment : Fragment() {
|
||||||
|
|
||||||
private fun updateSortingIndicators(sorting: Int) {
|
private fun updateSortingIndicators(sorting: Int) {
|
||||||
var bitmap = requireContext().resources.getColoredBitmap(R.drawable.ic_sorting_triangle_vector, requireContext().getProperPrimaryColor())
|
var bitmap = requireContext().resources.getColoredBitmap(R.drawable.ic_sorting_triangle_vector, requireContext().getProperPrimaryColor())
|
||||||
view.apply {
|
binding.apply {
|
||||||
stopwatch_sorting_indicator_1.beInvisibleIf(sorting and SORT_BY_LAP == 0)
|
stopwatchSortingIndicator1.beInvisibleIf(sorting and SORT_BY_LAP == 0)
|
||||||
stopwatch_sorting_indicator_2.beInvisibleIf(sorting and SORT_BY_LAP_TIME == 0)
|
stopwatchSortingIndicator2.beInvisibleIf(sorting and SORT_BY_LAP_TIME == 0)
|
||||||
stopwatch_sorting_indicator_3.beInvisibleIf(sorting and SORT_BY_TOTAL_TIME == 0)
|
stopwatchSortingIndicator3.beInvisibleIf(sorting and SORT_BY_TOTAL_TIME == 0)
|
||||||
|
|
||||||
val activeIndicator = when {
|
val activeIndicator = when {
|
||||||
sorting and SORT_BY_LAP != 0 -> stopwatch_sorting_indicator_1
|
sorting and SORT_BY_LAP != 0 -> stopwatchSortingIndicator1
|
||||||
sorting and SORT_BY_LAP_TIME != 0 -> stopwatch_sorting_indicator_2
|
sorting and SORT_BY_LAP_TIME != 0 -> stopwatchSortingIndicator2
|
||||||
else -> stopwatch_sorting_indicator_3
|
else -> stopwatchSortingIndicator3
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sorting and SORT_DESCENDING == 0) {
|
if (sorting and SORT_DESCENDING == 0) {
|
||||||
|
@ -211,8 +212,8 @@ class StopwatchFragment : Fragment() {
|
||||||
|
|
||||||
override fun onStateChanged(state: Stopwatch.State) {
|
override fun onStateChanged(state: Stopwatch.State) {
|
||||||
updateIcons(state)
|
updateIcons(state)
|
||||||
view.stopwatch_lap.beVisibleIf(state == Stopwatch.State.RUNNING)
|
binding.stopwatchLap.beVisibleIf(state == Stopwatch.State.RUNNING)
|
||||||
view.stopwatch_reset.beVisibleIf(state != Stopwatch.State.STOPPED)
|
binding.stopwatchReset.beVisibleIf(state != Stopwatch.State.STOPPED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.simplemobiletools.clock.R
|
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
import com.simplemobiletools.clock.adapters.TimerAdapter
|
import com.simplemobiletools.clock.adapters.TimerAdapter
|
||||||
|
import com.simplemobiletools.clock.databinding.FragmentTimerBinding
|
||||||
import com.simplemobiletools.clock.dialogs.EditTimerDialog
|
import com.simplemobiletools.clock.dialogs.EditTimerDialog
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.clock.extensions.createNewTimer
|
import com.simplemobiletools.clock.extensions.createNewTimer
|
||||||
|
@ -21,15 +21,13 @@ import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import com.simplemobiletools.commons.extensions.hideKeyboard
|
import com.simplemobiletools.commons.extensions.hideKeyboard
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
import com.simplemobiletools.commons.models.AlarmSound
|
import com.simplemobiletools.commons.models.AlarmSound
|
||||||
import kotlinx.android.synthetic.main.fragment_timer.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_timer.view.*
|
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
|
|
||||||
class TimerFragment : Fragment() {
|
class TimerFragment : Fragment() {
|
||||||
private val INVALID_POSITION = -1
|
private val INVALID_POSITION = -1
|
||||||
private lateinit var view: ViewGroup
|
private lateinit var binding: FragmentTimerBinding
|
||||||
private lateinit var timerAdapter: TimerAdapter
|
private lateinit var timerAdapter: TimerAdapter
|
||||||
private var timerPositionToScrollTo = INVALID_POSITION
|
private var timerPositionToScrollTo = INVALID_POSITION
|
||||||
private var storedTextColor = 0
|
private var storedTextColor = 0
|
||||||
|
@ -46,10 +44,10 @@ class TimerFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
view = (inflater.inflate(R.layout.fragment_timer, container, false) as ViewGroup).apply {
|
binding = FragmentTimerBinding.inflate(inflater, container, false).apply {
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
timers_list.itemAnimator = DisabledItemChangeAnimator()
|
timersList.itemAnimator = DisabledItemChangeAnimator()
|
||||||
timer_add.setOnClickListener {
|
timerAdd.setOnClickListener {
|
||||||
activity?.run {
|
activity?.run {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
openEditTimer(createNewTimer())
|
openEditTimer(createNewTimer())
|
||||||
|
@ -67,17 +65,17 @@ class TimerFragment : Fragment() {
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
return view
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initAdapter() {
|
private fun initAdapter() {
|
||||||
timerAdapter = TimerAdapter(requireActivity() as SimpleActivity, view.timers_list, ::refreshTimers, ::openEditTimer)
|
timerAdapter = TimerAdapter(requireActivity() as SimpleActivity, binding.timersList, ::refreshTimers, ::openEditTimer)
|
||||||
view.timers_list.adapter = timerAdapter
|
binding.timersList.adapter = timerAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
requireContext().updateTextColors(timer_fragment)
|
requireContext().updateTextColors(binding.root)
|
||||||
val configTextColor = requireContext().getProperTextColor()
|
val configTextColor = requireContext().getProperTextColor()
|
||||||
if (storedTextColor != configTextColor) {
|
if (storedTextColor != configTextColor) {
|
||||||
initAdapter()
|
initAdapter()
|
||||||
|
@ -97,10 +95,10 @@ class TimerFragment : Fragment() {
|
||||||
timerAdapter.submitList(timers) {
|
timerAdapter.submitList(timers) {
|
||||||
getView()?.post {
|
getView()?.post {
|
||||||
if (timerPositionToScrollTo != INVALID_POSITION && timerAdapter.itemCount > timerPositionToScrollTo) {
|
if (timerPositionToScrollTo != INVALID_POSITION && timerAdapter.itemCount > timerPositionToScrollTo) {
|
||||||
view.timers_list.scrollToPosition(timerPositionToScrollTo)
|
binding.timersList.scrollToPosition(timerPositionToScrollTo)
|
||||||
timerPositionToScrollTo = INVALID_POSITION
|
timerPositionToScrollTo = INVALID_POSITION
|
||||||
} else if (scrollToLatest) {
|
} else if (scrollToLatest) {
|
||||||
view.timers_list.scrollToPosition(timers.lastIndex)
|
binding.timersList.scrollToPosition(timers.lastIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +125,7 @@ class TimerFragment : Fragment() {
|
||||||
if (position != INVALID_POSITION) {
|
if (position != INVALID_POSITION) {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
if (timerAdapter.itemCount > position) {
|
if (timerAdapter.itemCount > position) {
|
||||||
view.timers_list.scrollToPosition(position)
|
binding.timersList.scrollToPosition(position)
|
||||||
} else {
|
} else {
|
||||||
timerPositionToScrollTo = position
|
timerPositionToScrollTo = position
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ class AlarmReceiver : BroadcastReceiver() {
|
||||||
|
|
||||||
val builder = NotificationCompat.Builder(context, ALARM_NOTIFICATION_CHANNEL_ID)
|
val builder = NotificationCompat.Builder(context, ALARM_NOTIFICATION_CHANNEL_ID)
|
||||||
.setSmallIcon(R.drawable.ic_alarm_vector)
|
.setSmallIcon(R.drawable.ic_alarm_vector)
|
||||||
.setContentTitle(context.getString(R.string.alarm))
|
.setContentTitle(context.getString(com.simplemobiletools.commons.R.string.alarm))
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
.setCategory(NotificationCompat.CATEGORY_ALARM)
|
.setCategory(NotificationCompat.CATEGORY_ALARM)
|
||||||
|
|
|
@ -48,7 +48,7 @@ class EarlyAlarmDismissalReceiver : BroadcastReceiver() {
|
||||||
.setContentText(alarmString)
|
.setContentText(alarmString)
|
||||||
.setSmallIcon(R.drawable.ic_alarm_vector)
|
.setSmallIcon(R.drawable.ic_alarm_vector)
|
||||||
.setPriority(Notification.PRIORITY_LOW)
|
.setPriority(Notification.PRIORITY_LOW)
|
||||||
.addAction(0, context.getString(R.string.dismiss), dismissIntent)
|
.addAction(0, context.getString(com.simplemobiletools.commons.R.string.dismiss), dismissIntent)
|
||||||
.setContentIntent(contentIntent)
|
.setContentIntent(contentIntent)
|
||||||
.setSound(null)
|
.setSound(null)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
|
|
30
build.gradle
30
build.gradle
|
@ -1,30 +0,0 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
ext.kotlin_version = '1.7.10'
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath 'com.android.tools.build:gradle:7.3.1'
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
|
||||||
// in the individual module build.gradle files
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
maven { url 'https://jitpack.io' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task clean(type: Delete) {
|
|
||||||
delete rootProject.buildDir
|
|
||||||
}
|
|
5
build.gradle.kts
Normal file
5
build.gradle.kts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android).apply(false)
|
||||||
|
alias(libs.plugins.kotlinAndroid).apply(false)
|
||||||
|
alias(libs.plugins.ksp).apply(false)
|
||||||
|
}
|
|
@ -1,2 +1,3 @@
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
|
android.nonTransitiveRClass=true
|
||||||
|
|
75
gradle/libs.versions.toml
Normal file
75
gradle/libs.versions.toml
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
[versions]
|
||||||
|
#jetbrains
|
||||||
|
kotlin = "1.9.0"
|
||||||
|
#KSP
|
||||||
|
ksp = "1.9.0-1.0.12"
|
||||||
|
#AndroidX
|
||||||
|
androidx-constraintlayout = "2.1.4"
|
||||||
|
androidx-lifecycle = "2.6.1"
|
||||||
|
androidx-preference = "1.2.0"
|
||||||
|
androidx-work = "2.8.1"
|
||||||
|
#AutoFitTextView
|
||||||
|
autofittextview = "0.2.1"
|
||||||
|
#Eventbus
|
||||||
|
eventbus = "3.3.1"
|
||||||
|
#KotlinX
|
||||||
|
kotlinx-coroutines = "1.7.3"
|
||||||
|
#NumberPicker
|
||||||
|
numberpicker = "2.4.13"
|
||||||
|
#Room
|
||||||
|
room = "2.6.0-alpha02"
|
||||||
|
#Simple tools
|
||||||
|
simple-commons = "0bdbc422dd"
|
||||||
|
#Stetho
|
||||||
|
stetho = "1.6.0"
|
||||||
|
#Gradle
|
||||||
|
gradlePlugins-agp = "8.1.0"
|
||||||
|
#build
|
||||||
|
app-build-compileSDKVersion = "34"
|
||||||
|
app-build-targetSDK = "34"
|
||||||
|
app-build-minimumSDK = "23"
|
||||||
|
app-build-javaVersion = "VERSION_17"
|
||||||
|
app-build-kotlinJVMTarget = "17"
|
||||||
|
#versioning
|
||||||
|
app-version-appId = "com.simplemobiletools.clock"
|
||||||
|
app-version-versionCode = "39"
|
||||||
|
app-version-versionName = "5.10.3"
|
||||||
|
[libraries]
|
||||||
|
#AndroidX
|
||||||
|
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidx-constraintlayout" }
|
||||||
|
androidx-preference = { module = "androidx.preference:preference-ktx", version.ref = "androidx-preference" }
|
||||||
|
androidx-work = { module = "androidx.work:work-runtime-ktx", version.ref = "androidx-work" }
|
||||||
|
#Android X lifecycle
|
||||||
|
androidx-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx-lifecycle" }
|
||||||
|
androidx-lifecycle-viewModel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle" }
|
||||||
|
androidx-lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version.ref = "androidx-lifecycle" }
|
||||||
|
#AutoFitTextView
|
||||||
|
autofittextview = { module = "me.grantland:autofittextview", version.ref = "autofittextview" }
|
||||||
|
#EventBus
|
||||||
|
eventbus = { module = "org.greenrobot:eventbus", version.ref = "eventbus" }
|
||||||
|
#KotlinX
|
||||||
|
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
|
||||||
|
#NumberPicker
|
||||||
|
numberpicker = { module = "io.github.ShawnLin013:number-picker", version.ref = "numberpicker" }
|
||||||
|
#Room
|
||||||
|
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
|
||||||
|
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
|
||||||
|
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
|
||||||
|
#Simple Mobile Tools
|
||||||
|
simple-tools-commons = { module = "com.github.SimpleMobileTools:Simple-Commons", version.ref = "simple-commons" }
|
||||||
|
#Stetho
|
||||||
|
stetho = { module = "com.facebook.stetho:stetho", version.ref = "stetho" }
|
||||||
|
[bundles]
|
||||||
|
room = [
|
||||||
|
"androidx-room-ktx",
|
||||||
|
"androidx-room-runtime",
|
||||||
|
]
|
||||||
|
lifecycle = [
|
||||||
|
"androidx-lifecycle-runtime",
|
||||||
|
"androidx-lifecycle-viewModel",
|
||||||
|
"androidx-lifecycle-process",
|
||||||
|
]
|
||||||
|
[plugins]
|
||||||
|
android = { id = "com.android.application", version.ref = "gradlePlugins-agp" }
|
||||||
|
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
include ':app'
|
|
16
settings.gradle.kts
Normal file
16
settings.gradle.kts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
google()
|
||||||
|
maven { setUrl("https://jitpack.io") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
include(":app")
|
Loading…
Reference in a new issue