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
|
@ -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'
|
||||
}
|
|
@ -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.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.clock.BuildConfig
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.adapters.ViewPagerAdapter
|
||||
import com.simplemobiletools.clock.databinding.ActivityMainBinding
|
||||
import com.simplemobiletools.clock.extensions.*
|
||||
import com.simplemobiletools.clock.helpers.*
|
||||
import com.simplemobiletools.commons.databinding.BottomTablayoutItemBinding
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.FAQItem
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import me.grantland.widget.AutofitHelper
|
||||
|
||||
class MainActivity : SimpleActivity() {
|
||||
private var storedTextColor = 0
|
||||
private var storedBackgroundColor = 0
|
||||
private var storedPrimaryColor = 0
|
||||
private lateinit var binding: ActivityMainBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
appLaunched(BuildConfig.APPLICATION_ID)
|
||||
setupOptionsMenu()
|
||||
refreshMenuItems()
|
||||
|
||||
updateMaterialActivityViews(main_coordinator, main_holder, useTransparentNavigation = false, useTopSearchMenu = false)
|
||||
updateMaterialActivityViews(binding.mainCoordinator, binding.mainHolder, useTransparentNavigation = false, useTopSearchMenu = false)
|
||||
|
||||
storeStateVariables()
|
||||
initFragments()
|
||||
|
@ -52,23 +53,23 @@ class MainActivity : SimpleActivity() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(main_toolbar, statusBarColor = getProperBackgroundColor())
|
||||
setupToolbar(binding.mainToolbar, statusBarColor = getProperBackgroundColor())
|
||||
val configTextColor = getProperTextColor()
|
||||
if (storedTextColor != configTextColor) {
|
||||
getInactiveTabIndexes(view_pager.currentItem).forEach {
|
||||
main_tabs_holder.getTabAt(it)?.icon?.applyColorFilter(configTextColor)
|
||||
getInactiveTabIndexes(binding.viewPager.currentItem).forEach {
|
||||
binding.mainTabsHolder.getTabAt(it)?.icon?.applyColorFilter(configTextColor)
|
||||
}
|
||||
}
|
||||
|
||||
val configBackgroundColor = getProperBackgroundColor()
|
||||
if (storedBackgroundColor != configBackgroundColor) {
|
||||
main_tabs_holder.background = ColorDrawable(configBackgroundColor)
|
||||
binding.mainTabsHolder.background = ColorDrawable(configBackgroundColor)
|
||||
}
|
||||
|
||||
val configPrimaryColor = getProperPrimaryColor()
|
||||
if (storedPrimaryColor != configPrimaryColor) {
|
||||
main_tabs_holder.setSelectedTabIndicatorColor(getProperPrimaryColor())
|
||||
main_tabs_holder.getTabAt(view_pager.currentItem)?.icon?.applyColorFilter(getProperPrimaryColor())
|
||||
binding.mainTabsHolder.setSelectedTabIndicatorColor(getProperPrimaryColor())
|
||||
binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.icon?.applyColorFilter(getProperPrimaryColor())
|
||||
}
|
||||
|
||||
if (config.preventPhoneFromSleeping) {
|
||||
|
@ -120,11 +121,11 @@ class MainActivity : SimpleActivity() {
|
|||
if (config.preventPhoneFromSleeping) {
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
config.lastUsedViewPagerPage = view_pager.currentItem
|
||||
config.lastUsedViewPagerPage = binding.viewPager.currentItem
|
||||
}
|
||||
|
||||
private fun setupOptionsMenu() {
|
||||
main_toolbar.setOnMenuItemClickListener { menuItem ->
|
||||
binding.mainToolbar.setOnMenuItemClickListener { menuItem ->
|
||||
when (menuItem.itemId) {
|
||||
R.id.sort -> getViewPagerAdapter()?.showAlarmSortDialog()
|
||||
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
||||
|
@ -137,23 +138,23 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun refreshMenuItems() {
|
||||
main_toolbar.menu.apply {
|
||||
findItem(R.id.sort).isVisible = view_pager.currentItem == TAB_ALARM
|
||||
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
|
||||
binding.mainToolbar.menu.apply {
|
||||
findItem(R.id.sort).isVisible = binding.viewPager.currentItem == TAB_ALARM
|
||||
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
if (intent.extras?.containsKey(OPEN_TAB) == true) {
|
||||
val tabToOpen = intent.getIntExtra(OPEN_TAB, TAB_CLOCK)
|
||||
view_pager.setCurrentItem(tabToOpen, false)
|
||||
binding.viewPager.setCurrentItem(tabToOpen, false)
|
||||
if (tabToOpen == TAB_TIMER) {
|
||||
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 (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) {
|
||||
val newAlarmSound = storeNewYourAlarmSound(resultData)
|
||||
|
||||
when (view_pager.currentItem) {
|
||||
when (binding.viewPager.currentItem) {
|
||||
TAB_ALARM -> getViewPagerAdapter()?.updateAlarmTabAlarmSound(newAlarmSound)
|
||||
TAB_TIMER -> getViewPagerAdapter()?.updateTimerTabAlarmSound(newAlarmSound)
|
||||
}
|
||||
|
@ -186,13 +187,13 @@ class MainActivity : SimpleActivity() {
|
|||
getViewPagerAdapter()?.updateClockTabAlarm()
|
||||
}
|
||||
|
||||
private fun getViewPagerAdapter() = view_pager.adapter as? ViewPagerAdapter
|
||||
private fun getViewPagerAdapter() = binding.viewPager.adapter as? ViewPagerAdapter
|
||||
|
||||
private fun initFragments() {
|
||||
val viewPagerAdapter = ViewPagerAdapter(supportFragmentManager)
|
||||
view_pager.adapter = viewPagerAdapter
|
||||
view_pager.onPageChangeListener {
|
||||
main_tabs_holder.getTabAt(it)?.select()
|
||||
binding.viewPager.adapter = viewPagerAdapter
|
||||
binding.viewPager.onPageChangeListener {
|
||||
binding.mainTabsHolder.getTabAt(it)?.select()
|
||||
refreshMenuItems()
|
||||
}
|
||||
|
||||
|
@ -207,61 +208,68 @@ class MainActivity : SimpleActivity() {
|
|||
config.toggleStopwatch = intent.getBooleanExtra(TOGGLE_STOPWATCH, false)
|
||||
}
|
||||
|
||||
view_pager.offscreenPageLimit = TABS_COUNT - 1
|
||||
view_pager.currentItem = tabToOpen
|
||||
binding.viewPager.offscreenPageLimit = TABS_COUNT - 1
|
||||
binding.viewPager.currentItem = tabToOpen
|
||||
}
|
||||
|
||||
private fun setupTabs() {
|
||||
main_tabs_holder.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 tabLabels = arrayOf(R.string.clock, R.string.alarm, R.string.stopwatch, R.string.timer)
|
||||
binding.mainTabsHolder.removeAllTabs()
|
||||
val tabDrawables = arrayOf(
|
||||
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 ->
|
||||
main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
|
||||
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getDrawable(drawableId))
|
||||
customView?.findViewById<TextView>(R.id.tab_item_label)?.setText(tabLabels[i])
|
||||
AutofitHelper.create(customView?.findViewById(R.id.tab_item_label))
|
||||
main_tabs_holder.addTab(this)
|
||||
binding.mainTabsHolder.newTab().setCustomView(com.simplemobiletools.commons.R.layout.bottom_tablayout_item).apply tab@{
|
||||
customView?.let { BottomTablayoutItemBinding.bind(it) }?.apply {
|
||||
tabItemIcon.setImageDrawable(getDrawable(drawableId))
|
||||
tabItemLabel.setText(tabLabels[i])
|
||||
AutofitHelper.create(tabItemLabel)
|
||||
binding.mainTabsHolder.addTab(this@tab)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main_tabs_holder.onTabSelectionChanged(
|
||||
binding.mainTabsHolder.onTabSelectionChanged(
|
||||
tabUnselectedAction = {
|
||||
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
|
||||
},
|
||||
tabSelectedAction = {
|
||||
view_pager.currentItem = it.position
|
||||
binding.viewPager.currentItem = it.position
|
||||
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun setupTabColors() {
|
||||
val activeView = main_tabs_holder.getTabAt(view_pager.currentItem)?.customView
|
||||
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[view_pager.currentItem])
|
||||
val activeView = binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.customView
|
||||
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[binding.viewPager.currentItem])
|
||||
|
||||
getInactiveTabIndexes(view_pager.currentItem).forEach { index ->
|
||||
val inactiveView = main_tabs_holder.getTabAt(index)?.customView
|
||||
getInactiveTabIndexes(binding.viewPager.currentItem).forEach { index ->
|
||||
val inactiveView = binding.mainTabsHolder.getTabAt(index)?.customView
|
||||
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
|
||||
}
|
||||
|
||||
main_tabs_holder.getTabAt(view_pager.currentItem)?.select()
|
||||
binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.select()
|
||||
val bottomBarColor = getBottomNavigationBackgroundColor()
|
||||
main_tabs_holder.setBackgroundColor(bottomBarColor)
|
||||
binding.mainTabsHolder.setBackgroundColor(bottomBarColor)
|
||||
updateNavigationBarColor(bottomBarColor)
|
||||
}
|
||||
|
||||
private fun getInactiveTabIndexes(activeIndex: Int) = arrayListOf(0, 1, 2, 3).filter { it != activeIndex }
|
||||
|
||||
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_stopwatch_filled_vector,
|
||||
R.drawable.ic_hourglass_filled_vector
|
||||
)
|
||||
|
||||
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_stopwatch_vector,
|
||||
R.drawable.ic_hourglass_vector
|
||||
|
@ -276,14 +284,14 @@ class MainActivity : SimpleActivity() {
|
|||
|
||||
val faqItems = arrayListOf(
|
||||
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(R.string.faq_4_title_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_1_title_commons, com.simplemobiletools.commons.R.string.faq_1_text_commons),
|
||||
FAQItem(com.simplemobiletools.commons.R.string.faq_4_title_commons, com.simplemobiletools.commons.R.string.faq_4_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)) {
|
||||
faqItems.add(FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons))
|
||||
faqItems.add(FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons))
|
||||
if (!resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)) {
|
||||
faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_2_title_commons, com.simplemobiletools.commons.R.string.faq_2_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)
|
||||
|
|
|
@ -8,17 +8,16 @@ import android.media.MediaPlayer
|
|||
import android.net.Uri
|
||||
import android.os.*
|
||||
import android.view.MotionEvent
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.AnimationUtils
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.databinding.ActivityReminderBinding
|
||||
import com.simplemobiletools.clock.extensions.*
|
||||
import com.simplemobiletools.clock.helpers.ALARM_ID
|
||||
import com.simplemobiletools.clock.helpers.getPassedSeconds
|
||||
import com.simplemobiletools.clock.models.Alarm
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import kotlinx.android.synthetic.main.activity_reminder.*
|
||||
|
||||
class ReminderActivity : SimpleActivity() {
|
||||
private val INCREASE_VOLUME_DELAY = 300L
|
||||
|
@ -36,13 +35,15 @@ class ReminderActivity : SimpleActivity() {
|
|||
private var vibrator: Vibrator? = null
|
||||
private var lastVolumeValue = 0.1f
|
||||
private var dragDownX = 0f
|
||||
private lateinit var binding: ActivityReminderBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_reminder)
|
||||
binding = ActivityReminderBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
showOverLockscreen()
|
||||
updateTextColors(reminder_holder as ViewGroup)
|
||||
updateTextColors(binding.root)
|
||||
updateStatusbarColor(getProperBackgroundColor())
|
||||
|
||||
val id = intent.getIntExtra(ALARM_ID, -1)
|
||||
|
@ -53,7 +54,7 @@ class ReminderActivity : SimpleActivity() {
|
|||
|
||||
val label = if (isAlarmReminder) {
|
||||
if (alarm!!.label.isEmpty()) {
|
||||
getString(R.string.alarm)
|
||||
getString(com.simplemobiletools.commons.R.string.alarm)
|
||||
} else {
|
||||
alarm!!.label
|
||||
}
|
||||
|
@ -61,8 +62,8 @@ class ReminderActivity : SimpleActivity() {
|
|||
getString(R.string.timer)
|
||||
}
|
||||
|
||||
reminder_title.text = label
|
||||
reminder_text.text = if (isAlarmReminder) getFormattedTime(getPassedSeconds(), false, false) else getString(R.string.time_expired)
|
||||
binding.reminderTitle.text = label
|
||||
binding.reminderText.text = if (isAlarmReminder) getFormattedTime(getPassedSeconds(), false, false) else getString(R.string.time_expired)
|
||||
|
||||
val maxDuration = if (isAlarmReminder) config.alarmMaxReminderSecs else config.timerMaxReminderSecs
|
||||
maxReminderDurationHandler.postDelayed({
|
||||
|
@ -83,52 +84,52 @@ class ReminderActivity : SimpleActivity() {
|
|||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun setupAlarmButtons() {
|
||||
reminder_stop.beGone()
|
||||
reminder_draggable_background.startAnimation(AnimationUtils.loadAnimation(this, R.anim.pulsing_animation))
|
||||
reminder_draggable_background.applyColorFilter(getProperPrimaryColor())
|
||||
binding.reminderStop.beGone()
|
||||
binding.reminderDraggableBackground.startAnimation(AnimationUtils.loadAnimation(this, R.anim.pulsing_animation))
|
||||
binding.reminderDraggableBackground.applyColorFilter(getProperPrimaryColor())
|
||||
|
||||
val textColor = getProperTextColor()
|
||||
reminder_dismiss.applyColorFilter(textColor)
|
||||
reminder_draggable.applyColorFilter(textColor)
|
||||
reminder_snooze.applyColorFilter(textColor)
|
||||
binding.reminderDismiss.applyColorFilter(textColor)
|
||||
binding.reminderDraggable.applyColorFilter(textColor)
|
||||
binding.reminderSnooze.applyColorFilter(textColor)
|
||||
|
||||
var minDragX = 0f
|
||||
var maxDragX = 0f
|
||||
var initialDraggableX = 0f
|
||||
|
||||
reminder_dismiss.onGlobalLayout {
|
||||
minDragX = reminder_snooze.left.toFloat()
|
||||
maxDragX = reminder_dismiss.left.toFloat()
|
||||
initialDraggableX = reminder_draggable.left.toFloat()
|
||||
binding.reminderDismiss.onGlobalLayout {
|
||||
minDragX = binding.reminderSnooze.left.toFloat()
|
||||
maxDragX = binding.reminderDismiss.left.toFloat()
|
||||
initialDraggableX = binding.reminderDraggable.left.toFloat()
|
||||
}
|
||||
|
||||
reminder_draggable.setOnTouchListener { v, event ->
|
||||
binding.reminderDraggable.setOnTouchListener { v, event ->
|
||||
when (event.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
dragDownX = event.x
|
||||
reminder_draggable_background.animate().alpha(0f)
|
||||
binding.reminderDraggableBackground.animate().alpha(0f)
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||
dragDownX = 0f
|
||||
if (!didVibrate) {
|
||||
reminder_draggable.animate().x(initialDraggableX).withEndAction {
|
||||
reminder_draggable_background.animate().alpha(0.2f)
|
||||
binding.reminderDraggable.animate().x(initialDraggableX).withEndAction {
|
||||
binding.reminderDraggableBackground.animate().alpha(0.2f)
|
||||
}
|
||||
|
||||
reminder_guide.animate().alpha(1f).start()
|
||||
binding.reminderGuide.animate().alpha(1f).start()
|
||||
swipeGuideFadeHandler.removeCallbacksAndMessages(null)
|
||||
swipeGuideFadeHandler.postDelayed({
|
||||
reminder_guide.animate().alpha(0f).start()
|
||||
binding.reminderGuide.animate().alpha(0f).start()
|
||||
}, 2000L)
|
||||
}
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
reminder_draggable.x = Math.min(maxDragX, Math.max(minDragX, event.rawX - dragDownX))
|
||||
if (reminder_draggable.x >= maxDragX - 50f) {
|
||||
binding.reminderDraggable.x = Math.min(maxDragX, Math.max(minDragX, event.rawX - dragDownX))
|
||||
if (binding.reminderDraggable.x >= maxDragX - 50f) {
|
||||
if (!didVibrate) {
|
||||
reminder_draggable.performHapticFeedback()
|
||||
binding.reminderDraggable.performHapticFeedback()
|
||||
didVibrate = true
|
||||
finishActivity()
|
||||
}
|
||||
|
@ -136,9 +137,9 @@ class ReminderActivity : SimpleActivity() {
|
|||
if (isOreoPlus()) {
|
||||
notificationManager.cancelAll()
|
||||
}
|
||||
} else if (reminder_draggable.x <= minDragX + 50f) {
|
||||
} else if (binding.reminderDraggable.x <= minDragX + 50f) {
|
||||
if (!didVibrate) {
|
||||
reminder_draggable.performHapticFeedback()
|
||||
binding.reminderDraggable.performHapticFeedback()
|
||||
didVibrate = true
|
||||
snoozeAlarm()
|
||||
}
|
||||
|
@ -154,12 +155,12 @@ class ReminderActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupTimerButtons() {
|
||||
reminder_stop.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, getProperPrimaryColor())
|
||||
arrayOf(reminder_snooze, reminder_draggable_background, reminder_draggable, reminder_dismiss).forEach {
|
||||
binding.reminderStop.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, getProperPrimaryColor())
|
||||
arrayOf(binding.reminderSnooze, binding.reminderDraggableBackground, binding.reminderDraggable, binding.reminderDismiss).forEach {
|
||||
it.beGone()
|
||||
}
|
||||
|
||||
reminder_stop.setOnClickListener {
|
||||
binding.reminderStop.setOnClickListener {
|
||||
finishActivity()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.simplemobiletools.clock.activities
|
|||
|
||||
import android.content.Intent
|
||||
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.helpers.DEFAULT_MAX_ALARM_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.NavigationIcon
|
||||
import com.simplemobiletools.commons.helpers.isTiramisuPlus
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
private lateinit var binding: ActivitySettingsBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings)
|
||||
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar)
|
||||
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
|
||||
setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
|
||||
|
||||
setupPurchaseThankYou()
|
||||
setupCustomizeColors()
|
||||
|
@ -41,69 +43,69 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupTimerMaxReminder()
|
||||
setupIncreaseVolumeGradually()
|
||||
setupCustomizeWidgetColors()
|
||||
updateTextColors(settings_holder)
|
||||
updateTextColors(binding.settingsHolder)
|
||||
|
||||
arrayOf(
|
||||
settings_color_customization_section_label,
|
||||
settings_general_settings_label,
|
||||
settings_alarm_tab_label,
|
||||
settings_timer_tab_label,
|
||||
binding.settingsColorCustomizationSectionLabel,
|
||||
binding.settingsGeneralSettingsLabel,
|
||||
binding.settingsAlarmTabLabel,
|
||||
binding.settingsTimerTabLabel,
|
||||
).forEach {
|
||||
it.setTextColor(getProperPrimaryColor())
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupPurchaseThankYou() {
|
||||
settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled())
|
||||
settings_purchase_thank_you_holder.setOnClickListener {
|
||||
binding.settingsPurchaseThankYouHolder.beGoneIf(isOrWasThankYouInstalled())
|
||||
binding.settingsPurchaseThankYouHolder.setOnClickListener {
|
||||
launchPurchaseThankYouIntent()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupCustomizeColors() {
|
||||
settings_color_customization_label.text = getCustomizeColorsString()
|
||||
settings_color_customization_holder.setOnClickListener {
|
||||
binding.settingsColorCustomizationLabel.text = getCustomizeColorsString()
|
||||
binding.settingsColorCustomizationHolder.setOnClickListener {
|
||||
handleCustomizeColorsClick()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupUseEnglish() {
|
||||
settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||
settings_use_english.isChecked = config.useEnglish
|
||||
settings_use_english_holder.setOnClickListener {
|
||||
settings_use_english.toggle()
|
||||
config.useEnglish = settings_use_english.isChecked
|
||||
binding.settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||
binding.settingsUseEnglish.isChecked = config.useEnglish
|
||||
binding.settingsUseEnglishHolder.setOnClickListener {
|
||||
binding.settingsUseEnglish.toggle()
|
||||
config.useEnglish = binding.settingsUseEnglish.isChecked
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupLanguage() {
|
||||
settings_language.text = Locale.getDefault().displayLanguage
|
||||
settings_language_holder.beVisibleIf(isTiramisuPlus())
|
||||
settings_language_holder.setOnClickListener {
|
||||
binding.settingsLanguage.text = Locale.getDefault().displayLanguage
|
||||
binding.settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
|
||||
binding.settingsLanguageHolder.setOnClickListener {
|
||||
launchChangeAppLanguageIntent()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupPreventPhoneFromSleeping() {
|
||||
settings_prevent_phone_from_sleeping.isChecked = config.preventPhoneFromSleeping
|
||||
settings_prevent_phone_from_sleeping_holder.setOnClickListener {
|
||||
settings_prevent_phone_from_sleeping.toggle()
|
||||
config.preventPhoneFromSleeping = settings_prevent_phone_from_sleeping.isChecked
|
||||
binding.settingsPreventPhoneFromSleeping.isChecked = config.preventPhoneFromSleeping
|
||||
binding.settingsPreventPhoneFromSleepingHolder.setOnClickListener {
|
||||
binding.settingsPreventPhoneFromSleeping.toggle()
|
||||
config.preventPhoneFromSleeping = binding.settingsPreventPhoneFromSleeping.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSundayFirst() {
|
||||
settings_sunday_first.isChecked = config.isSundayFirst
|
||||
settings_sunday_first_holder.setOnClickListener {
|
||||
settings_sunday_first.toggle()
|
||||
config.isSundayFirst = settings_sunday_first.isChecked
|
||||
binding.settingsSundayFirst.isChecked = config.isSundayFirst
|
||||
binding.settingsSundayFirstHolder.setOnClickListener {
|
||||
binding.settingsSundayFirst.toggle()
|
||||
config.isSundayFirst = binding.settingsSundayFirst.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupAlarmMaxReminder() {
|
||||
updateAlarmMaxReminderText()
|
||||
settings_alarm_max_reminder_holder.setOnClickListener {
|
||||
binding.settingsAlarmMaxReminderHolder.setOnClickListener {
|
||||
showPickSecondsDialog(config.alarmMaxReminderSecs, true, true) {
|
||||
config.alarmMaxReminderSecs = if (it != 0) it else DEFAULT_MAX_ALARM_REMINDER_SECS
|
||||
updateAlarmMaxReminderText()
|
||||
|
@ -112,18 +114,18 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupUseSameSnooze() {
|
||||
settings_snooze_time_holder.beVisibleIf(config.useSameSnooze)
|
||||
settings_use_same_snooze.isChecked = config.useSameSnooze
|
||||
settings_use_same_snooze_holder.setOnClickListener {
|
||||
settings_use_same_snooze.toggle()
|
||||
config.useSameSnooze = settings_use_same_snooze.isChecked
|
||||
settings_snooze_time_holder.beVisibleIf(config.useSameSnooze)
|
||||
binding.settingsSnoozeTimeHolder.beVisibleIf(config.useSameSnooze)
|
||||
binding.settingsUseSameSnooze.isChecked = config.useSameSnooze
|
||||
binding.settingsUseSameSnoozeHolder.setOnClickListener {
|
||||
binding.settingsUseSameSnooze.toggle()
|
||||
config.useSameSnooze = binding.settingsUseSameSnooze.isChecked
|
||||
binding.settingsSnoozeTimeHolder.beVisibleIf(config.useSameSnooze)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSnoozeTime() {
|
||||
updateSnoozeText()
|
||||
settings_snooze_time_holder.setOnClickListener {
|
||||
binding.settingsSnoozeTimeHolder.setOnClickListener {
|
||||
showPickSecondsDialog(config.snoozeTime * MINUTE_SECONDS, true) {
|
||||
config.snoozeTime = it / MINUTE_SECONDS
|
||||
updateSnoozeText()
|
||||
|
@ -133,7 +135,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
|
||||
private fun setupTimerMaxReminder() {
|
||||
updateTimerMaxReminderText()
|
||||
settings_timer_max_reminder_holder.setOnClickListener {
|
||||
binding.settingsTimerMaxReminderHolder.setOnClickListener {
|
||||
showPickSecondsDialog(config.timerMaxReminderSecs, true, true) {
|
||||
config.timerMaxReminderSecs = if (it != 0) it else DEFAULT_MAX_TIMER_REMINDER_SECS
|
||||
updateTimerMaxReminderText()
|
||||
|
@ -142,27 +144,27 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupIncreaseVolumeGradually() {
|
||||
settings_increase_volume_gradually.isChecked = config.increaseVolumeGradually
|
||||
settings_increase_volume_gradually_holder.setOnClickListener {
|
||||
settings_increase_volume_gradually.toggle()
|
||||
config.increaseVolumeGradually = settings_increase_volume_gradually.isChecked
|
||||
binding.settingsIncreaseVolumeGradually.isChecked = config.increaseVolumeGradually
|
||||
binding.settingsIncreaseVolumeGraduallyHolder.setOnClickListener {
|
||||
binding.settingsIncreaseVolumeGradually.toggle()
|
||||
config.increaseVolumeGradually = binding.settingsIncreaseVolumeGradually.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateSnoozeText() {
|
||||
settings_snooze_time.text = formatMinutesToTimeString(config.snoozeTime)
|
||||
binding.settingsSnoozeTime.text = formatMinutesToTimeString(config.snoozeTime)
|
||||
}
|
||||
|
||||
private fun updateAlarmMaxReminderText() {
|
||||
settings_alarm_max_reminder.text = formatSecondsToTimeString(config.alarmMaxReminderSecs)
|
||||
binding.settingsAlarmMaxReminder.text = formatSecondsToTimeString(config.alarmMaxReminderSecs)
|
||||
}
|
||||
|
||||
private fun updateTimerMaxReminderText() {
|
||||
settings_timer_max_reminder.text = formatSecondsToTimeString(config.timerMaxReminderSecs)
|
||||
binding.settingsTimerMaxReminder.text = formatSecondsToTimeString(config.timerMaxReminderSecs)
|
||||
}
|
||||
|
||||
private fun setupCustomizeWidgetColors() {
|
||||
settings_widget_color_customization_holder.setOnClickListener {
|
||||
binding.settingsWidgetColorCustomizationHolder.setOnClickListener {
|
||||
Intent(this, WidgetDigitalConfigureActivity::class.java).apply {
|
||||
putExtra(IS_CUSTOMIZING_COLORS, true)
|
||||
startActivity(this)
|
||||
|
|
|
@ -7,14 +7,13 @@ import android.content.res.ColorStateList
|
|||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
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.helpers.MyAnalogueTimeWidgetProvider
|
||||
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||
import com.simplemobiletools.commons.dialogs.FeatureLockedDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
||||
import kotlinx.android.synthetic.main.widget_config_analogue.*
|
||||
|
||||
class WidgetAnalogueConfigureActivity : SimpleActivity() {
|
||||
private var mBgAlpha = 0f
|
||||
|
@ -22,12 +21,14 @@ class WidgetAnalogueConfigureActivity : SimpleActivity() {
|
|||
private var mBgColor = 0
|
||||
private var mBgColorWithoutTransparency = 0
|
||||
private var mFeatureLockedDialog: FeatureLockedDialog? = null
|
||||
private lateinit var binding: WidgetConfigAnalogueBinding
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
useDynamicTheme = false
|
||||
super.onCreate(savedInstanceState)
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
setContentView(R.layout.widget_config_analogue)
|
||||
binding = WidgetConfigAnalogueBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
initVariables()
|
||||
|
||||
val isCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
|
||||
|
@ -37,12 +38,12 @@ class WidgetAnalogueConfigureActivity : SimpleActivity() {
|
|||
finish()
|
||||
}
|
||||
|
||||
config_analogue_save.setOnClickListener { saveConfig() }
|
||||
config_analogue_save.setTextColor(getProperPrimaryColor().getContrastColor())
|
||||
config_analogue_bg_color.setOnClickListener { pickBackgroundColor() }
|
||||
binding.configAnalogueSave.setOnClickListener { saveConfig() }
|
||||
binding.configAnalogueSave.setTextColor(getProperPrimaryColor().getContrastColor())
|
||||
binding.configAnalogueBgColor.setOnClickListener { pickBackgroundColor() }
|
||||
|
||||
val primaryColor = getProperPrimaryColor()
|
||||
config_analogue_bg_seekbar.setColors(getProperTextColor(), primaryColor, primaryColor)
|
||||
binding.configAnalogueBgSeekbar.setColors(getProperTextColor(), primaryColor, primaryColor)
|
||||
|
||||
if (!isCustomizingColors && !isOrWasThankYouInstalled()) {
|
||||
mFeatureLockedDialog = FeatureLockedDialog(this) {
|
||||
|
@ -62,15 +63,15 @@ class WidgetAnalogueConfigureActivity : SimpleActivity() {
|
|||
|
||||
private fun initVariables() {
|
||||
mBgColor = config.widgetBgColor
|
||||
if (mBgColor == resources.getColor(R.color.default_widget_bg_color) && config.isUsingSystemTheme) {
|
||||
mBgColor = resources.getColor(R.color.you_primary_color, theme)
|
||||
if (mBgColor == resources.getColor(com.simplemobiletools.commons.R.color.default_widget_bg_color) && config.isUsingSystemTheme) {
|
||||
mBgColor = resources.getColor(com.simplemobiletools.commons.R.color.you_primary_color, theme)
|
||||
}
|
||||
|
||||
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat()
|
||||
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
|
||||
|
||||
config_analogue_bg_seekbar.setOnSeekBarChangeListener(bgSeekbarChangeListener)
|
||||
config_analogue_bg_seekbar.progress = (mBgAlpha * 100).toInt()
|
||||
binding.configAnalogueBgSeekbar.setOnSeekBarChangeListener(bgSeekbarChangeListener)
|
||||
binding.configAnalogueBgSeekbar.progress = (mBgAlpha * 100).toInt()
|
||||
updateBackgroundColor()
|
||||
}
|
||||
|
||||
|
@ -109,9 +110,9 @@ class WidgetAnalogueConfigureActivity : SimpleActivity() {
|
|||
|
||||
private fun updateBackgroundColor() {
|
||||
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
||||
config_analogue_bg_color.setFillWithStroke(mBgColor, mBgColor)
|
||||
config_analogue_background.applyColorFilter(mBgColor)
|
||||
config_analogue_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
|
||||
binding.configAnalogueBgColor.setFillWithStroke(mBgColor, mBgColor)
|
||||
binding.configAnalogueBackground.applyColorFilter(mBgColor)
|
||||
binding.configAnalogueSave.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
|
||||
}
|
||||
|
||||
private val bgSeekbarChangeListener = object : SeekBar.OnSeekBarChangeListener {
|
||||
|
|
|
@ -8,7 +8,7 @@ import android.graphics.Color
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
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.helpers.MyDigitalTimeWidgetProvider
|
||||
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.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
||||
import kotlinx.android.synthetic.main.widget_config_digital.*
|
||||
|
||||
class WidgetDigitalConfigureActivity : SimpleActivity() {
|
||||
private var mBgAlpha = 0f
|
||||
|
@ -25,12 +24,14 @@ class WidgetDigitalConfigureActivity : SimpleActivity() {
|
|||
private var mTextColor = 0
|
||||
private var mBgColorWithoutTransparency = 0
|
||||
private var mFeatureLockedDialog: FeatureLockedDialog? = null
|
||||
private lateinit var binding: WidgetConfigDigitalBinding
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
useDynamicTheme = false
|
||||
super.onCreate(savedInstanceState)
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
setContentView(R.layout.widget_config_digital)
|
||||
binding = WidgetConfigDigitalBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
initVariables()
|
||||
|
||||
mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID
|
||||
|
@ -46,12 +47,12 @@ class WidgetDigitalConfigureActivity : SimpleActivity() {
|
|||
finish()
|
||||
}
|
||||
|
||||
config_digital_save.setOnClickListener { saveConfig() }
|
||||
config_digital_bg_color.setOnClickListener { pickBackgroundColor() }
|
||||
config_digital_text_color.setOnClickListener { pickTextColor() }
|
||||
binding.configDigitalSave.setOnClickListener { saveConfig() }
|
||||
binding.configDigitalBgColor.setOnClickListener { pickBackgroundColor() }
|
||||
binding.configDigitalTextColor.setOnClickListener { pickTextColor() }
|
||||
|
||||
val primaryColor = getProperPrimaryColor()
|
||||
config_digital_bg_seekbar.setColors(mTextColor, primaryColor, primaryColor)
|
||||
binding.configDigitalBgSeekbar.setColors(mTextColor, primaryColor, primaryColor)
|
||||
|
||||
if (!isCustomizingColors && !isOrWasThankYouInstalled()) {
|
||||
mFeatureLockedDialog = FeatureLockedDialog(this) {
|
||||
|
@ -74,13 +75,13 @@ class WidgetDigitalConfigureActivity : SimpleActivity() {
|
|||
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat()
|
||||
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
|
||||
|
||||
config_digital_bg_seekbar.setOnSeekBarChangeListener(bgSeekbarChangeListener)
|
||||
config_digital_bg_seekbar.progress = (mBgAlpha * 100).toInt()
|
||||
binding.configDigitalBgSeekbar.setOnSeekBarChangeListener(bgSeekbarChangeListener)
|
||||
binding.configDigitalBgSeekbar.progress = (mBgAlpha * 100).toInt()
|
||||
updateBackgroundColor()
|
||||
|
||||
mTextColor = config.widgetTextColor
|
||||
if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) {
|
||||
mTextColor = resources.getColor(R.color.you_primary_color, theme)
|
||||
if (mTextColor == resources.getColor(com.simplemobiletools.commons.R.color.default_widget_text_color) && config.isUsingSystemTheme) {
|
||||
mTextColor = resources.getColor(com.simplemobiletools.commons.R.color.you_primary_color, theme)
|
||||
}
|
||||
|
||||
updateTextColor()
|
||||
|
@ -130,17 +131,17 @@ class WidgetDigitalConfigureActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun updateTextColor() {
|
||||
config_digital_text_color.setFillWithStroke(mTextColor, mTextColor)
|
||||
config_digital_time.setTextColor(mTextColor)
|
||||
config_digital_date.setTextColor(mTextColor)
|
||||
config_digital_save.setTextColor(getProperPrimaryColor().getContrastColor())
|
||||
binding.configDigitalTextColor.setFillWithStroke(mTextColor, mTextColor)
|
||||
binding.configDigitalTime.setTextColor(mTextColor)
|
||||
binding.configDigitalDate.setTextColor(mTextColor)
|
||||
binding.configDigitalSave.setTextColor(getProperPrimaryColor().getContrastColor())
|
||||
}
|
||||
|
||||
private fun updateBackgroundColor() {
|
||||
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
||||
config_digital_bg_color.setFillWithStroke(mBgColor, mBgColor)
|
||||
config_digital_background.applyColorFilter(mBgColor)
|
||||
config_digital_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
|
||||
binding.configDigitalBgColor.setFillWithStroke(mBgColor, mBgColor)
|
||||
binding.configDigitalBackground.applyColorFilter(mBgColor)
|
||||
binding.configDigitalSave.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
|
||||
}
|
||||
|
||||
private val bgSeekbarChangeListener = object : SeekBar.OnSeekBarChangeListener {
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.view.ViewGroup
|
|||
import android.widget.RelativeLayout
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.databinding.ItemAlarmBinding
|
||||
import com.simplemobiletools.clock.extensions.*
|
||||
import com.simplemobiletools.clock.helpers.TODAY_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.toast
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import kotlinx.android.synthetic.main.item_alarm.view.*
|
||||
|
||||
class AlarmsAdapter(
|
||||
activity: SimpleActivity, var alarms: ArrayList<Alarm>, val toggleAlarmInterface: ToggleAlarmInterface,
|
||||
|
@ -55,7 +55,9 @@ class AlarmsAdapter(
|
|||
|
||||
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) {
|
||||
val alarm = alarms[position]
|
||||
|
@ -89,50 +91,55 @@ class AlarmsAdapter(
|
|||
|
||||
private fun setupView(view: View, alarm: Alarm) {
|
||||
val isSelected = selectedKeys.contains(alarm.id)
|
||||
view.apply {
|
||||
alarm_frame.isSelected = isSelected
|
||||
alarm_time.text = activity.getFormattedTime(alarm.timeInMinutes * 60, false, true)
|
||||
alarm_time.setTextColor(textColor)
|
||||
ItemAlarmBinding.bind(view).apply {
|
||||
alarmFrame.isSelected = isSelected
|
||||
alarmTime.text = activity.getFormattedTime(alarm.timeInMinutes * 60, false, true)
|
||||
alarmTime.setTextColor(textColor)
|
||||
|
||||
alarm_days.text = activity.getAlarmSelectedDaysString(alarm.days)
|
||||
alarm_days.setTextColor(textColor)
|
||||
alarmDays.text = activity.getAlarmSelectedDaysString(alarm.days)
|
||||
alarmDays.setTextColor(textColor)
|
||||
|
||||
alarm_label.text = alarm.label
|
||||
alarm_label.setTextColor(textColor)
|
||||
alarm_label.beVisibleIf(alarm.label.isNotEmpty())
|
||||
alarmLabel.text = alarm.label
|
||||
alarmLabel.setTextColor(textColor)
|
||||
alarmLabel.beVisibleIf(alarm.label.isNotEmpty())
|
||||
|
||||
alarm_switch.isChecked = alarm.isEnabled
|
||||
alarm_switch.setColors(textColor, properPrimaryColor, backgroundColor)
|
||||
alarm_switch.setOnClickListener {
|
||||
alarmSwitch.isChecked = alarm.isEnabled
|
||||
alarmSwitch.setColors(textColor, properPrimaryColor, backgroundColor)
|
||||
alarmSwitch.setOnClickListener {
|
||||
if (alarm.days > 0) {
|
||||
if (activity.config.wasAlarmWarningShown) {
|
||||
toggleAlarmInterface.alarmToggled(alarm.id, alarm_switch.isChecked)
|
||||
toggleAlarmInterface.alarmToggled(alarm.id, alarmSwitch.isChecked)
|
||||
} 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
|
||||
toggleAlarmInterface.alarmToggled(alarm.id, alarm_switch.isChecked)
|
||||
toggleAlarmInterface.alarmToggled(alarm.id, alarmSwitch.isChecked)
|
||||
}
|
||||
}
|
||||
} else if (alarm.days == TODAY_BIT) {
|
||||
if (alarm.timeInMinutes <= getCurrentDayMinutes()) {
|
||||
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)
|
||||
context.scheduleNextAlarm(alarm, true)
|
||||
toggleAlarmInterface.alarmToggled(alarm.id, alarm_switch.isChecked)
|
||||
root.context.scheduleNextAlarm(alarm, true)
|
||||
toggleAlarmInterface.alarmToggled(alarm.id, alarmSwitch.isChecked)
|
||||
} else if (alarm.days == TOMORROW_BIT) {
|
||||
toggleAlarmInterface.alarmToggled(alarm.id, alarm_switch.isChecked)
|
||||
} else if (alarm_switch.isChecked) {
|
||||
toggleAlarmInterface.alarmToggled(alarm.id, alarmSwitch.isChecked)
|
||||
} else if (alarmSwitch.isChecked) {
|
||||
activity.toast(R.string.no_days_selected)
|
||||
alarm_switch.isChecked = false
|
||||
alarmSwitch.isChecked = false
|
||||
} else {
|
||||
toggleAlarmInterface.alarmToggled(alarm.id, alarm_switch.isChecked)
|
||||
toggleAlarmInterface.alarmToggled(alarm.id, alarmSwitch.isChecked)
|
||||
}
|
||||
}
|
||||
|
||||
val layoutParams = alarm_switch.layoutParams as RelativeLayout.LayoutParams
|
||||
layoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, if (alarm_label.isVisible()) alarm_label.id else alarm_days.id)
|
||||
val layoutParams = alarmSwitch.layoutParams as RelativeLayout.LayoutParams
|
||||
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.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.databinding.ItemAddTimeZoneBinding
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.clock.models.MyTimeZone
|
||||
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
|
||||
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
|
||||
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>() {
|
||||
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 {
|
||||
val view = activity.layoutInflater.inflate(R.layout.item_add_time_zone, parent, false)
|
||||
return ViewHolder(view)
|
||||
return ViewHolder(ItemAddTimeZoneBinding.inflate(activity.layoutInflater, parent, false))
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
|
@ -51,16 +49,16 @@ class SelectTimeZonesAdapter(val activity: SimpleActivity, val timeZones: ArrayL
|
|||
|
||||
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 {
|
||||
val isSelected = selectedKeys.contains(myTimeZone.id)
|
||||
itemView.apply {
|
||||
add_time_zone_checkbox.isChecked = isSelected
|
||||
add_time_zone_title.text = myTimeZone.title
|
||||
add_time_zone_title.setTextColor(textColor)
|
||||
binding.apply {
|
||||
addTimeZoneCheckbox.isChecked = isSelected
|
||||
addTimeZoneTitle.text = myTimeZone.title
|
||||
addTimeZoneTitle.setTextColor(textColor)
|
||||
|
||||
add_time_zone_checkbox.setColors(textColor, primaryColor, backgroundColor)
|
||||
add_time_zone_holder.setOnClickListener {
|
||||
addTimeZoneCheckbox.setColors(textColor, primaryColor, backgroundColor)
|
||||
addTimeZoneHolder.setOnClickListener {
|
||||
viewClicked(myTimeZone)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ import android.view.Menu
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.databinding.ItemLapBinding
|
||||
import com.simplemobiletools.clock.extensions.formatStopwatchTime
|
||||
import com.simplemobiletools.clock.helpers.SORT_BY_LAP
|
||||
import com.simplemobiletools.clock.helpers.SORT_BY_LAP_TIME
|
||||
|
@ -13,11 +13,9 @@ import com.simplemobiletools.clock.helpers.SORT_BY_TOTAL_TIME
|
|||
import com.simplemobiletools.clock.models.Lap
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
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) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||
private var lastLapTimeView: TextView? = null
|
||||
private var lastTotalTimeView: TextView? = null
|
||||
private var lastLapId = 0
|
||||
|
@ -40,7 +38,9 @@ class StopwatchAdapter(activity: SimpleActivity, var laps: ArrayList<Lap>, recyc
|
|||
|
||||
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) {
|
||||
val lap = laps[position]
|
||||
|
@ -66,28 +66,28 @@ class StopwatchAdapter(activity: SimpleActivity, var laps: ArrayList<Lap>, recyc
|
|||
}
|
||||
|
||||
private fun setupView(view: View, lap: Lap) {
|
||||
view.apply {
|
||||
lap_order.text = lap.id.toString()
|
||||
lap_order.setTextColor(textColor)
|
||||
lap_order.setOnClickListener {
|
||||
ItemLapBinding.bind(view).apply {
|
||||
lapOrder.text = lap.id.toString()
|
||||
lapOrder.setTextColor(textColor)
|
||||
lapOrder.setOnClickListener {
|
||||
itemClick(SORT_BY_LAP)
|
||||
}
|
||||
|
||||
lap_lap_time.text = lap.lapTime.formatStopwatchTime(false)
|
||||
lap_lap_time.setTextColor(textColor)
|
||||
lap_lap_time.setOnClickListener {
|
||||
lapLapTime.text = lap.lapTime.formatStopwatchTime(false)
|
||||
lapLapTime.setTextColor(textColor)
|
||||
lapLapTime.setOnClickListener {
|
||||
itemClick(SORT_BY_LAP_TIME)
|
||||
}
|
||||
|
||||
lap_total_time.text = lap.totalTime.formatStopwatchTime(false)
|
||||
lap_total_time.setTextColor(textColor)
|
||||
lap_total_time.setOnClickListener {
|
||||
lapTotalTime.text = lap.totalTime.formatStopwatchTime(false)
|
||||
lapTotalTime.setTextColor(textColor)
|
||||
lapTotalTime.setOnClickListener {
|
||||
itemClick(SORT_BY_TOTAL_TIME)
|
||||
}
|
||||
|
||||
if (lap.id > lastLapId) {
|
||||
lastLapTimeView = lap_lap_time
|
||||
lastTotalTimeView = lap_total_time
|
||||
lastLapTimeView = lapLapTime
|
||||
lastTotalTimeView = lapTotalTime
|
||||
lastLapId = lap.id
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.databinding.ItemTimeZoneBinding
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.clock.extensions.getFormattedDate
|
||||
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.beVisible
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import kotlinx.android.synthetic.main.item_time_zone.view.*
|
||||
import java.util.*
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.TimeZone
|
||||
|
||||
class TimeZonesAdapter(activity: SimpleActivity, var timeZones: ArrayList<MyTimeZone>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||
|
@ -51,7 +53,9 @@ class TimeZonesAdapter(activity: SimpleActivity, var timeZones: ArrayList<MyTime
|
|||
|
||||
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) {
|
||||
val timeZone = timeZones[position]
|
||||
|
@ -105,20 +109,20 @@ class TimeZonesAdapter(activity: SimpleActivity, var timeZones: ArrayList<MyTime
|
|||
val formattedDate = activity.getFormattedDate(calendar)
|
||||
|
||||
val isSelected = selectedKeys.contains(timeZone.id)
|
||||
view.apply {
|
||||
time_zone_frame.isSelected = isSelected
|
||||
time_zone_title.text = timeZone.title
|
||||
time_zone_title.setTextColor(textColor)
|
||||
ItemTimeZoneBinding.bind(view).apply {
|
||||
timeZoneFrame.isSelected = isSelected
|
||||
timeZoneTitle.text = timeZone.title
|
||||
timeZoneTitle.setTextColor(textColor)
|
||||
|
||||
time_zone_time.text = formattedTime
|
||||
time_zone_time.setTextColor(textColor)
|
||||
timeZoneTime.text = formattedTime
|
||||
timeZoneTime.setTextColor(textColor)
|
||||
|
||||
if (formattedDate != todayDateString) {
|
||||
time_zone_date.beVisible()
|
||||
time_zone_date.text = formattedDate
|
||||
time_zone_date.setTextColor(textColor)
|
||||
timeZoneDate.beVisible()
|
||||
timeZoneDate.text = formattedDate
|
||||
timeZoneDate.setTextColor(textColor)
|
||||
} else {
|
||||
time_zone_date.beGone()
|
||||
timeZoneDate.beGone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.view.ViewGroup
|
|||
import androidx.recyclerview.widget.DiffUtil
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.databinding.ItemTimerBinding
|
||||
import com.simplemobiletools.clock.extensions.getFormattedDuration
|
||||
import com.simplemobiletools.clock.extensions.hideTimerNotification
|
||||
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.extensions.*
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import kotlinx.android.synthetic.main.item_timer.view.*
|
||||
import me.grantland.widget.AutofitHelper
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
|
@ -78,7 +78,9 @@ class TimerAdapter(
|
|||
|
||||
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) {
|
||||
holder.bindView(getItem(position), true, true) { itemView, _ ->
|
||||
|
@ -97,30 +99,30 @@ class TimerAdapter(
|
|||
}
|
||||
|
||||
private fun setupView(view: View, timer: Timer) {
|
||||
view.apply {
|
||||
ItemTimerBinding.bind(view).apply {
|
||||
val isSelected = selectedKeys.contains(timer.id)
|
||||
timer_frame.isSelected = isSelected
|
||||
timerFrame.isSelected = isSelected
|
||||
|
||||
timer_label.setTextColor(textColor)
|
||||
timer_label.setHintTextColor(textColor.adjustAlpha(0.7f))
|
||||
timer_label.text = timer.label
|
||||
timerLabel.setTextColor(textColor)
|
||||
timerLabel.setHintTextColor(textColor.adjustAlpha(0.7f))
|
||||
timerLabel.text = timer.label
|
||||
|
||||
AutofitHelper.create(timer_time)
|
||||
timer_time.setTextColor(textColor)
|
||||
timer_time.text = when (timer.state) {
|
||||
AutofitHelper.create(timerTime)
|
||||
timerTime.setTextColor(textColor)
|
||||
timerTime.text = when (timer.state) {
|
||||
is TimerState.Finished -> 0.getFormattedDuration()
|
||||
is TimerState.Idle -> timer.seconds.getFormattedDuration()
|
||||
is TimerState.Paused -> timer.state.tick.getFormattedDuration()
|
||||
is TimerState.Running -> timer.state.tick.getFormattedDuration()
|
||||
}
|
||||
|
||||
timer_reset.applyColorFilter(textColor)
|
||||
timer_reset.setOnClickListener {
|
||||
timerReset.applyColorFilter(textColor)
|
||||
timerReset.setOnClickListener {
|
||||
resetTimer(timer)
|
||||
}
|
||||
|
||||
timer_play_pause.applyColorFilter(textColor)
|
||||
timer_play_pause.setOnClickListener {
|
||||
timerPlayPause.applyColorFilter(textColor)
|
||||
timerPlayPause.setOnClickListener {
|
||||
(activity as SimpleActivity).handleNotificationPermission { granted ->
|
||||
if (granted) {
|
||||
when (val state = timer.state) {
|
||||
|
@ -130,16 +132,20 @@ class TimerAdapter(
|
|||
is TimerState.Finished -> EventBus.getDefault().post(TimerEvent.Start(timer.id!!, timer.seconds.secondsToMillis))
|
||||
}
|
||||
} 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 resetPossible = state is TimerState.Running || state is TimerState.Paused || state is TimerState.Finished
|
||||
timer_reset.beInvisibleIf(!resetPossible)
|
||||
val drawableId = if (state is TimerState.Running) R.drawable.ic_pause_vector else R.drawable.ic_play_vector
|
||||
timer_play_pause.setImageDrawable(simpleActivity.resources.getColoredDrawableWithColor(drawableId, textColor))
|
||||
timerReset.beInvisibleIf(!resetPossible)
|
||||
val drawableId =
|
||||
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
|
||||
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.adapters.SelectTimeZonesAdapter
|
||||
import com.simplemobiletools.clock.databinding.DialogSelectTimeZonesBinding
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.clock.helpers.getAllTimeZones
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
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) {
|
||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_select_time_zones, null)
|
||||
private val binding = DialogSelectTimeZonesBinding.inflate(activity.layoutInflater)
|
||||
|
||||
init {
|
||||
view.select_time_zones_list.adapter = SelectTimeZonesAdapter(activity, getAllTimeZones())
|
||||
binding.selectTimeZonesList.adapter = SelectTimeZonesAdapter(activity, getAllTimeZones())
|
||||
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
activity.setupDialogStuff(binding.root, this)
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
activity.config.selectedTimeZones = selectedTimeZones
|
||||
callback()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simplemobiletools.clock.dialogs
|
||||
|
||||
import android.view.View
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.databinding.DialogChangeAlarmSortBinding
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.clock.helpers.SORT_BY_ALARM_TIME
|
||||
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.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import kotlinx.android.synthetic.main.dialog_change_alarm_sort.view.*
|
||||
|
||||
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) {
|
||||
SORT_BY_ALARM_TIME -> sorting_dialog_radio_alarm_time
|
||||
SORT_BY_DATE_AND_TIME -> sorting_dialog_radio_day_and_time
|
||||
else -> sorting_dialog_radio_creation_order
|
||||
SORT_BY_ALARM_TIME -> sortingDialogRadioAlarmTime
|
||||
SORT_BY_DATE_AND_TIME -> sortingDialogRadioDayAndTime
|
||||
else -> sortingDialogRadioCreationOrder
|
||||
}
|
||||
activeRadioButton?.isChecked = true
|
||||
activeRadioButton.isChecked = true
|
||||
}
|
||||
|
||||
init {
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { _, _ -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { _, _ -> dialogConfirmed() }
|
||||
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.sort_by)
|
||||
activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.sort_by)
|
||||
}
|
||||
}
|
||||
|
||||
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_day_and_time -> SORT_BY_DATE_AND_TIME
|
||||
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.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.databinding.DialogEditAlarmBinding
|
||||
import com.simplemobiletools.clock.extensions.*
|
||||
import com.simplemobiletools.clock.helpers.PICK_AUDIO_FILE_INTENT_ID
|
||||
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.extensions.*
|
||||
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) {
|
||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_edit_alarm, null)
|
||||
private val binding = DialogEditAlarmBinding.inflate(activity.layoutInflater)
|
||||
private val textColor = activity.getProperTextColor()
|
||||
|
||||
init {
|
||||
restoreLastAlarm()
|
||||
updateAlarmTime()
|
||||
|
||||
view.apply {
|
||||
edit_alarm_time.setOnClickListener {
|
||||
binding.apply {
|
||||
editAlarmTime.setOnClickListener {
|
||||
if (activity.config.isUsingSystemTheme) {
|
||||
val timeFormat = if (DateFormat.is24HourFormat(activity)) {
|
||||
TimeFormat.CLOCK_24H
|
||||
|
@ -55,8 +55,8 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
|||
timePicker.show(activity.supportFragmentManager, "")
|
||||
} else {
|
||||
TimePickerDialog(
|
||||
context,
|
||||
context.getTimePickerDialogTheme(),
|
||||
root.context,
|
||||
root.context.getTimePickerDialogTheme(),
|
||||
timeSetListener,
|
||||
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)
|
||||
edit_alarm_sound.text = alarm.soundTitle
|
||||
edit_alarm_sound.setOnClickListener {
|
||||
editAlarmSound.colorCompoundDrawable(textColor)
|
||||
editAlarmSound.text = alarm.soundTitle
|
||||
editAlarmSound.setOnClickListener {
|
||||
SelectAlarmSoundDialog(activity, alarm.soundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID, RingtoneManager.TYPE_ALARM, true,
|
||||
onAlarmPicked = {
|
||||
if (it != null) {
|
||||
|
@ -75,24 +75,24 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
|||
}
|
||||
}, onAlarmSoundDeleted = {
|
||||
if (alarm.soundUri == it.uri) {
|
||||
val defaultAlarm = context.getDefaultAlarmSound(RingtoneManager.TYPE_ALARM)
|
||||
val defaultAlarm = root.context.getDefaultAlarmSound(RingtoneManager.TYPE_ALARM)
|
||||
updateSelectedAlarmSound(defaultAlarm)
|
||||
}
|
||||
activity.checkAlarmsWithDeletedSoundUri(it.uri)
|
||||
})
|
||||
}
|
||||
|
||||
edit_alarm_vibrate_icon.setColorFilter(textColor)
|
||||
edit_alarm_vibrate.isChecked = alarm.vibrate
|
||||
edit_alarm_vibrate_holder.setOnClickListener {
|
||||
edit_alarm_vibrate.toggle()
|
||||
alarm.vibrate = edit_alarm_vibrate.isChecked
|
||||
editAlarmVibrateIcon.setColorFilter(textColor)
|
||||
editAlarmVibrate.isChecked = alarm.vibrate
|
||||
editAlarmVibrateHolder.setOnClickListener {
|
||||
editAlarmVibrate.toggle()
|
||||
alarm.vibrate = editAlarmVibrate.isChecked
|
||||
}
|
||||
|
||||
edit_alarm_label_image.applyColorFilter(textColor)
|
||||
edit_alarm.setText(alarm.label)
|
||||
editAlarmLabelImage.applyColorFilter(textColor)
|
||||
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)
|
||||
if (activity.config.isSundayFirst) {
|
||||
dayIndexes.moveLastItemToFront()
|
||||
|
@ -100,13 +100,13 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
|||
|
||||
dayIndexes.forEach {
|
||||
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]
|
||||
|
||||
val isDayChecked = alarm.days > 0 && alarm.days and pow != 0
|
||||
day.background = getProperDayDrawable(isDayChecked)
|
||||
|
||||
day.setTextColor(if (isDayChecked) context.getProperBackgroundColor() else textColor)
|
||||
day.setTextColor(if (isDayChecked) root.context.getProperBackgroundColor() else textColor)
|
||||
day.setOnClickListener {
|
||||
if (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)
|
||||
}
|
||||
day.background = getProperDayDrawable(selectDay)
|
||||
day.setTextColor(if (selectDay) context.getProperBackgroundColor() else textColor)
|
||||
day.setTextColor(if (selectDay) root.context.getProperBackgroundColor() else textColor)
|
||||
checkDaylessAlarm()
|
||||
}
|
||||
|
||||
edit_alarm_days_holder.addView(day)
|
||||
editAlarmDaysHolder.addView(day)
|
||||
}
|
||||
}
|
||||
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
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
|
||||
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
|
||||
|
||||
var alarmId = alarm.id
|
||||
|
@ -159,11 +164,11 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
|||
if (alarm.id == 0) {
|
||||
alarmId = activity.dbHelper.insertAlarm(alarm)
|
||||
if (alarmId == -1) {
|
||||
activity.toast(R.string.unknown_error_occurred)
|
||||
activity.toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||
}
|
||||
} else {
|
||||
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)
|
||||
alertDialog.dismiss()
|
||||
} 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() {
|
||||
view.edit_alarm_time.text = activity.getFormattedTime(alarm.timeInMinutes * 60, false, true)
|
||||
binding.editAlarmTime.text = activity.getFormattedTime(alarm.timeInMinutes * 60, false, true)
|
||||
checkDaylessAlarm()
|
||||
}
|
||||
|
||||
private fun checkDaylessAlarm() {
|
||||
if (alarm.days <= 0) {
|
||||
val textId = if (alarm.timeInMinutes > getCurrentDayMinutes()) {
|
||||
R.string.today
|
||||
com.simplemobiletools.commons.R.string.today
|
||||
} 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 {
|
||||
|
@ -229,6 +237,6 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
|||
fun updateSelectedAlarmSound(alarmSound: AlarmSound) {
|
||||
alarm.soundTitle = alarmSound.title
|
||||
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
|
||||
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.databinding.DialogEditTimeZoneBinding
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.clock.extensions.getEditedTimeZonesMap
|
||||
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.showKeyboard
|
||||
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) {
|
||||
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_edit_time_zone, null).apply {
|
||||
edit_time_zone_title.setText(activity.getModifiedTimeZoneTitle(myTimeZone.id))
|
||||
edit_time_zone_label.setText(getDefaultTimeZoneTitle(myTimeZone.id))
|
||||
val binding = DialogEditTimeZoneBinding.inflate(activity.layoutInflater).apply {
|
||||
editTimeZoneTitle.setText(activity.getModifiedTimeZoneTitle(myTimeZone.id))
|
||||
editTimeZoneLabel.setText(getDefaultTimeZoneTitle(myTimeZone.id))
|
||||
}
|
||||
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed(view.edit_time_zone_title.value) }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed(binding.editTimeZoneTitle.value) }
|
||||
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.edit_time_zone_title)
|
||||
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||
alertDialog.showKeyboard(binding.editTimeZoneTitle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,42 +5,42 @@ import android.media.RingtoneManager
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.databinding.DialogEditTimerBinding
|
||||
import com.simplemobiletools.clock.extensions.*
|
||||
import com.simplemobiletools.clock.helpers.PICK_AUDIO_FILE_INTENT_ID
|
||||
import com.simplemobiletools.clock.models.Timer
|
||||
import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
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) {
|
||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_edit_timer, null)
|
||||
private val binding = DialogEditTimerBinding.inflate(activity.layoutInflater)
|
||||
private val textColor = activity.getProperTextColor()
|
||||
|
||||
init {
|
||||
restoreLastAlarm()
|
||||
updateAlarmTime()
|
||||
|
||||
view.apply {
|
||||
edit_timer_initial_time.colorCompoundDrawable(textColor)
|
||||
edit_timer_initial_time.text = timer.seconds.getFormattedDuration()
|
||||
edit_timer_initial_time.setTextColor(textColor)
|
||||
edit_timer_initial_time.setOnClickListener {
|
||||
binding.apply {
|
||||
editTimerInitialTime.colorCompoundDrawable(textColor)
|
||||
editTimerInitialTime.text = timer.seconds.getFormattedDuration()
|
||||
editTimerInitialTime.setTextColor(textColor)
|
||||
editTimerInitialTime.setOnClickListener {
|
||||
changeDuration(timer)
|
||||
}
|
||||
|
||||
edit_timer_vibrate_icon.setColorFilter(textColor)
|
||||
edit_timer_vibrate.isChecked = timer.vibrate
|
||||
edit_timer_vibrate.setTextColor(textColor)
|
||||
edit_timer_vibrate_holder.setOnClickListener {
|
||||
edit_timer_vibrate.toggle()
|
||||
timer.vibrate = edit_timer_vibrate.isChecked
|
||||
editTimerVibrateIcon.setColorFilter(textColor)
|
||||
editTimerVibrate.isChecked = timer.vibrate
|
||||
editTimerVibrate.setTextColor(textColor)
|
||||
editTimerVibrateHolder.setOnClickListener {
|
||||
editTimerVibrate.toggle()
|
||||
timer.vibrate = editTimerVibrate.isChecked
|
||||
timer.channelId = null
|
||||
}
|
||||
|
||||
edit_timer_sound.colorCompoundDrawable(textColor)
|
||||
edit_timer_sound.text = timer.soundTitle
|
||||
edit_timer_sound.setOnClickListener {
|
||||
editTimerSound.colorCompoundDrawable(textColor)
|
||||
editTimerSound.text = timer.soundTitle
|
||||
editTimerSound.setOnClickListener {
|
||||
SelectAlarmSoundDialog(activity, timer.soundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID,
|
||||
RingtoneManager.TYPE_ALARM, true,
|
||||
onAlarmPicked = { sound ->
|
||||
|
@ -50,25 +50,25 @@ class EditTimerDialog(val activity: SimpleActivity, val timer: Timer, val callba
|
|||
},
|
||||
onAlarmSoundDeleted = { sound ->
|
||||
if (timer.soundUri == sound.uri) {
|
||||
val defaultAlarm = context.getDefaultAlarmSound(RingtoneManager.TYPE_ALARM)
|
||||
val defaultAlarm = root.context.getDefaultAlarmSound(RingtoneManager.TYPE_ALARM)
|
||||
updateAlarmSound(defaultAlarm)
|
||||
}
|
||||
|
||||
context.checkAlarmsWithDeletedSoundUri(sound.uri)
|
||||
root.context.checkAlarmsWithDeletedSoundUri(sound.uri)
|
||||
})
|
||||
}
|
||||
|
||||
edit_timer_label_image.applyColorFilter(textColor)
|
||||
edit_timer.setText(timer.label)
|
||||
editTimerLabelImage.applyColorFilter(textColor)
|
||||
editTimer.setText(timer.label)
|
||||
}
|
||||
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
timer.label = view.edit_timer.value
|
||||
timer.label = binding.editTimer.value
|
||||
activity.timerHelper.insertOrUpdateTimer(timer) {
|
||||
activity.config.timerLastConfig = timer
|
||||
callback()
|
||||
|
@ -92,14 +92,14 @@ class EditTimerDialog(val activity: SimpleActivity, val timer: Timer, val callba
|
|||
}
|
||||
|
||||
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) {
|
||||
MyTimePickerDialogDialog(activity, timer.seconds) { seconds ->
|
||||
val timerSeconds = if (seconds <= 0) 10 else seconds
|
||||
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.soundUri = alarmSound.uri
|
||||
timer.channelId = null
|
||||
view.edit_timer_sound.text = alarmSound.title
|
||||
binding.editTimerSound.text = alarmSound.title
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +1,41 @@
|
|||
package com.simplemobiletools.clock.dialogs
|
||||
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.databinding.DialogMyTimePickerBinding
|
||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||
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) {
|
||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_my_time_picker, null)
|
||||
private val binding = DialogMyTimePickerBinding.inflate(activity.layoutInflater)
|
||||
|
||||
init {
|
||||
view.apply {
|
||||
binding.apply {
|
||||
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.selectedTextColor = textColor
|
||||
it.dividerColor = textColor
|
||||
}
|
||||
|
||||
my_time_picker_hours.value = initialSeconds / 3600
|
||||
my_time_picker_minutes.value = (initialSeconds) / 60 % 60
|
||||
my_time_picker_seconds.value = initialSeconds % 60
|
||||
myTimePickerHours.value = initialSeconds / 3600
|
||||
myTimePickerMinutes.value = (initialSeconds) / 60 % 60
|
||||
myTimePickerSeconds.value = initialSeconds % 60
|
||||
}
|
||||
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
activity.setupDialogStuff(binding.root, this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dialogConfirmed() {
|
||||
view.apply {
|
||||
val hours = my_time_picker_hours.value
|
||||
val minutes = my_time_picker_minutes.value
|
||||
val seconds = my_time_picker_seconds.value
|
||||
binding.apply {
|
||||
val hours = myTimePickerHours.value
|
||||
val minutes = myTimePickerMinutes.value
|
||||
val seconds = myTimePickerSeconds.value
|
||||
callback(hours * 3600 + minutes * 60 + seconds)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.simplemobiletools.clock.extensions
|
||||
|
||||
import com.simplemobiletools.clock.BuildConfig
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
|
||||
import com.simplemobiletools.commons.extensions.canUseFullScreenIntent
|
||||
|
@ -15,7 +14,7 @@ fun BaseSimpleActivity.handleFullScreenNotificationsPermission(callback: (grante
|
|||
} else {
|
||||
PermissionRequiredDialog(
|
||||
activity = this,
|
||||
textId = R.string.allow_full_screen_notifications_reminders,
|
||||
textId = com.simplemobiletools.commons.R.string.allow_full_screen_notifications_reminders,
|
||||
positiveActionCallback = {
|
||||
openFullScreenIntentSettings(BuildConfig.APPLICATION_ID)
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ fun Context.getFormattedDate(calendar: Calendar): String {
|
|||
val dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH)
|
||||
val month = calendar.get(Calendar.MONTH)
|
||||
|
||||
val dayString = resources.getStringArray(R.array.week_days_short)[dayOfWeek]
|
||||
val monthString = resources.getStringArray(R.array.months)[month]
|
||||
val dayString = resources.getStringArray(com.simplemobiletools.commons.R.array.week_days_short)[dayOfWeek]
|
||||
val monthString = resources.getStringArray(com.simplemobiletools.commons.R.array.months)[month]
|
||||
return "$dayString, $dayOfMonth $monthString"
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ fun Context.scheduleNextAlarm(alarm: Alarm, showToast: Boolean) {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ fun Context.getFormattedTime(passedSeconds: Int, showSeconds: Boolean, makeAmPmS
|
|||
}
|
||||
|
||||
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
|
||||
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 }
|
||||
calendar.add(Calendar.MINUTE, closestAlarmTime)
|
||||
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)) {
|
||||
"HH:mm"
|
||||
} else {
|
||||
|
@ -403,8 +403,8 @@ fun Context.getTimerNotification(timer: Timer, pendingIntent: PendingIntent, add
|
|||
.setSound(Uri.parse(soundUri), STREAM_ALARM)
|
||||
.setChannelId(channelId)
|
||||
.addAction(
|
||||
R.drawable.ic_cross_vector,
|
||||
getString(R.string.dismiss),
|
||||
com.simplemobiletools.commons.R.drawable.ic_cross_vector,
|
||||
getString(com.simplemobiletools.commons.R.string.dismiss),
|
||||
if (addDeleteIntent) {
|
||||
reminderActivityIntent
|
||||
} else {
|
||||
|
@ -457,7 +457,7 @@ fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm): No
|
|||
}
|
||||
val channelId = "simple_alarm_channel_${soundUri}_${alarm.vibrate}"
|
||||
val label = alarm.label.ifEmpty {
|
||||
getString(R.string.alarm)
|
||||
getString(com.simplemobiletools.commons.R.string.alarm)
|
||||
}
|
||||
|
||||
if (isOreoPlus()) {
|
||||
|
@ -490,8 +490,8 @@ fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm): No
|
|||
.setDefaults(Notification.DEFAULT_LIGHTS)
|
||||
.setAutoCancel(true)
|
||||
.setChannelId(channelId)
|
||||
.addAction(R.drawable.ic_snooze_vector, getString(R.string.snooze), getSnoozePendingIntent(alarm))
|
||||
.addAction(R.drawable.ic_cross_vector, getString(R.string.dismiss), dismissIntent)
|
||||
.addAction(com.simplemobiletools.commons.R.drawable.ic_snooze_vector, getString(com.simplemobiletools.commons.R.string.snooze), getSnoozePendingIntent(alarm))
|
||||
.addAction(com.simplemobiletools.commons.R.drawable.ic_cross_vector, getString(com.simplemobiletools.commons.R.string.dismiss), dismissIntent)
|
||||
.setDeleteIntent(dismissIntent)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
|
||||
|
@ -536,9 +536,9 @@ fun Context.checkAlarmsWithDeletedSoundUri(uri: String) {
|
|||
|
||||
fun Context.getAlarmSelectedDaysString(bitMask: Int): String {
|
||||
return when (bitMask) {
|
||||
TODAY_BIT -> getString(R.string.today)
|
||||
TOMORROW_BIT -> getString(R.string.tomorrow)
|
||||
EVERY_DAY_BIT -> getString(R.string.every_day)
|
||||
TODAY_BIT -> getString(com.simplemobiletools.commons.R.string.today)
|
||||
TOMORROW_BIT -> getString(com.simplemobiletools.commons.R.string.tomorrow)
|
||||
EVERY_DAY_BIT -> getString(com.simplemobiletools.commons.R.string.every_day)
|
||||
else -> getSelectedDaysString(bitMask)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.MainActivity
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.adapters.AlarmsAdapter
|
||||
import com.simplemobiletools.clock.databinding.FragmentAlarmBinding
|
||||
import com.simplemobiletools.clock.dialogs.ChangeAlarmSortDialog
|
||||
import com.simplemobiletools.clock.dialogs.EditAlarmDialog
|
||||
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.ensureBackgroundThread
|
||||
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 {
|
||||
private var alarms = ArrayList<Alarm>()
|
||||
|
@ -33,12 +30,12 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
|||
|
||||
private var storedTextColor = 0
|
||||
|
||||
lateinit var view: ViewGroup
|
||||
private lateinit var binding: FragmentAlarmBinding
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
storeStateVariables()
|
||||
view = inflater.inflate(R.layout.fragment_alarm, container, false) as ViewGroup
|
||||
return view
|
||||
binding = FragmentAlarmBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -47,7 +44,7 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
|||
|
||||
val configTextColor = requireContext().getProperTextColor()
|
||||
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() {
|
||||
view.apply {
|
||||
requireContext().updateTextColors(alarm_fragment)
|
||||
alarm_fab.setOnClickListener {
|
||||
val newAlarm = context.createNewAlarm(DEFAULT_ALARM_MINUTES, 0)
|
||||
binding.apply {
|
||||
requireContext().updateTextColors(alarmFragment)
|
||||
alarmFab.setOnClickListener {
|
||||
val newAlarm = root.context.createNewAlarm(DEFAULT_ALARM_MINUTES, 0)
|
||||
newAlarm.isEnabled = true
|
||||
newAlarm.days = getTomorrowBit()
|
||||
openEditAlarm(newAlarm)
|
||||
|
@ -105,12 +102,12 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
|||
}
|
||||
}
|
||||
|
||||
val currAdapter = view.alarms_list.adapter
|
||||
val currAdapter = binding.alarmsList.adapter
|
||||
if (currAdapter == null) {
|
||||
AlarmsAdapter(activity as SimpleActivity, alarms, this, view.alarms_list) {
|
||||
AlarmsAdapter(activity as SimpleActivity, alarms, this, binding.alarmsList) {
|
||||
openEditAlarm(it as Alarm)
|
||||
}.apply {
|
||||
view.alarms_list.adapter = this
|
||||
binding.alarmsList.adapter = this
|
||||
}
|
||||
} else {
|
||||
(currAdapter as AlarmsAdapter).updateItems(alarms)
|
||||
|
@ -134,13 +131,13 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
|||
alarm.isEnabled = isEnabled
|
||||
checkAlarmState(alarm)
|
||||
} else {
|
||||
requireActivity().toast(R.string.unknown_error_occurred)
|
||||
requireActivity().toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||
}
|
||||
requireContext().updateWidgets()
|
||||
} else {
|
||||
PermissionRequiredDialog(
|
||||
activity as SimpleActivity,
|
||||
R.string.allow_notifications_reminders,
|
||||
com.simplemobiletools.commons.R.string.allow_notifications_reminders,
|
||||
{ (activity as SimpleActivity).openNotificationSettings() })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import androidx.fragment.app.Fragment
|
|||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.adapters.TimeZonesAdapter
|
||||
import com.simplemobiletools.clock.databinding.FragmentClockBinding
|
||||
import com.simplemobiletools.clock.dialogs.AddTimeZonesDialog
|
||||
import com.simplemobiletools.clock.dialogs.EditTimeZoneDialog
|
||||
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.getProperTextColor
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import kotlinx.android.synthetic.main.fragment_clock.view.*
|
||||
import java.util.Calendar
|
||||
|
||||
class ClockFragment : Fragment() {
|
||||
|
@ -30,12 +30,12 @@ class ClockFragment : Fragment() {
|
|||
|
||||
private var storedTextColor = 0
|
||||
|
||||
lateinit var view: ViewGroup
|
||||
private lateinit var binding: FragmentClockBinding
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
storeStateVariables()
|
||||
view = inflater.inflate(R.layout.fragment_clock, container, false) as ViewGroup
|
||||
return view
|
||||
binding = FragmentClockBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -44,10 +44,10 @@ class ClockFragment : Fragment() {
|
|||
|
||||
val configTextColor = requireContext().getProperTextColor()
|
||||
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() {
|
||||
|
@ -70,10 +70,10 @@ class ClockFragment : Fragment() {
|
|||
}
|
||||
|
||||
private fun setupViews() {
|
||||
view.apply {
|
||||
requireContext().updateTextColors(clock_fragment)
|
||||
clock_time.setTextColor(requireContext().getProperTextColor())
|
||||
clock_fab.setOnClickListener {
|
||||
binding.apply {
|
||||
requireContext().updateTextColors(clockFragment)
|
||||
clockTime.setTextColor(requireContext().getProperTextColor())
|
||||
clockFab.setOnClickListener {
|
||||
fabClicked()
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ class ClockFragment : Fragment() {
|
|||
val seconds = passedSeconds % 60
|
||||
|
||||
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) {
|
||||
|
@ -95,7 +95,7 @@ class ClockFragment : Fragment() {
|
|||
updateDate()
|
||||
}
|
||||
|
||||
(view.time_zones_list.adapter as? TimeZonesAdapter)?.updateTimes()
|
||||
(binding.timeZonesList.adapter as? TimeZonesAdapter)?.updateTimes()
|
||||
}
|
||||
|
||||
updateHandler.postDelayed({
|
||||
|
@ -107,36 +107,36 @@ class ClockFragment : Fragment() {
|
|||
private fun updateDate() {
|
||||
calendar = Calendar.getInstance()
|
||||
val formattedDate = requireContext().getFormattedDate(calendar)
|
||||
(view.time_zones_list.adapter as? TimeZonesAdapter)?.todayDateString = formattedDate
|
||||
(binding.timeZonesList.adapter as? TimeZonesAdapter)?.todayDateString = formattedDate
|
||||
}
|
||||
|
||||
fun updateAlarm() {
|
||||
context?.getClosestEnabledAlarmString { nextAlarm ->
|
||||
view.apply {
|
||||
clock_alarm.beVisibleIf(nextAlarm.isNotEmpty())
|
||||
clock_alarm.text = nextAlarm
|
||||
clock_alarm.colorCompoundDrawable(requireContext().getProperTextColor())
|
||||
binding.apply {
|
||||
clockAlarm.beVisibleIf(nextAlarm.isNotEmpty())
|
||||
clockAlarm.text = nextAlarm
|
||||
clockAlarm.colorCompoundDrawable(requireContext().getProperTextColor())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTimeZones() {
|
||||
val selectedTimeZones = context?.config?.selectedTimeZones ?: return
|
||||
view.time_zones_list.beVisibleIf(selectedTimeZones.isNotEmpty())
|
||||
binding.timeZonesList.beVisibleIf(selectedTimeZones.isNotEmpty())
|
||||
if (selectedTimeZones.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
val selectedTimeZoneIDs = selectedTimeZones.map { it.toInt() }
|
||||
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) {
|
||||
TimeZonesAdapter(activity as SimpleActivity, timeZones, view.time_zones_list) {
|
||||
TimeZonesAdapter(activity as SimpleActivity, timeZones, binding.timeZonesList) {
|
||||
EditTimeZoneDialog(activity as SimpleActivity, it as MyTimeZone) {
|
||||
updateTimeZones()
|
||||
}
|
||||
}.apply {
|
||||
view.time_zones_list.adapter = this
|
||||
this@ClockFragment.binding.timeZonesList.adapter = this
|
||||
}
|
||||
} else {
|
||||
(currAdapter as TimeZonesAdapter).updateItems(timeZones)
|
||||
|
|
|
@ -11,6 +11,7 @@ import androidx.fragment.app.Fragment
|
|||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.adapters.StopwatchAdapter
|
||||
import com.simplemobiletools.clock.databinding.FragmentStopwatchBinding
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.clock.extensions.formatStopwatchTime
|
||||
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.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.SORT_DESCENDING
|
||||
import kotlinx.android.synthetic.main.fragment_stopwatch.view.*
|
||||
|
||||
class StopwatchFragment : Fragment() {
|
||||
|
||||
private var storedTextColor = 0
|
||||
|
||||
lateinit var stopwatchAdapter: StopwatchAdapter
|
||||
lateinit var view: ViewGroup
|
||||
private lateinit var binding: FragmentStopwatchBinding
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
storeStateVariables()
|
||||
val sorting = requireContext().config.stopwatchLapsSort
|
||||
Lap.sorting = sorting
|
||||
view = (inflater.inflate(R.layout.fragment_stopwatch, container, false) as ViewGroup).apply {
|
||||
stopwatch_time.setOnClickListener {
|
||||
binding = FragmentStopwatchBinding.inflate(inflater, container, false).apply {
|
||||
stopwatchTime.setOnClickListener {
|
||||
togglePlayPause()
|
||||
}
|
||||
|
||||
stopwatch_play_pause.setOnClickListener {
|
||||
stopwatchPlayPause.setOnClickListener {
|
||||
togglePlayPause()
|
||||
}
|
||||
|
||||
stopwatch_reset.setOnClickListener {
|
||||
stopwatchReset.setOnClickListener {
|
||||
resetStopwatch()
|
||||
}
|
||||
|
||||
stopwatch_sorting_indicator_1.setOnClickListener {
|
||||
stopwatchSortingIndicator1.setOnClickListener {
|
||||
changeSorting(SORT_BY_LAP)
|
||||
}
|
||||
|
||||
stopwatch_sorting_indicator_2.setOnClickListener {
|
||||
stopwatchSortingIndicator2.setOnClickListener {
|
||||
changeSorting(SORT_BY_LAP_TIME)
|
||||
}
|
||||
|
||||
stopwatch_sorting_indicator_3.setOnClickListener {
|
||||
stopwatchSortingIndicator3.setOnClickListener {
|
||||
changeSorting(SORT_BY_TOTAL_TIME)
|
||||
}
|
||||
|
||||
stopwatch_lap.setOnClickListener {
|
||||
stopwatch_sorting_indicators_holder.beVisible()
|
||||
stopwatchLap.setOnClickListener {
|
||||
stopwatchSortingIndicatorsHolder.beVisible()
|
||||
Stopwatch.lap()
|
||||
updateLaps()
|
||||
}
|
||||
|
||||
stopwatchAdapter = StopwatchAdapter(activity as SimpleActivity, ArrayList(), stopwatch_list) {
|
||||
stopwatchAdapter = StopwatchAdapter(activity as SimpleActivity, ArrayList(), stopwatchList) {
|
||||
if (it is Int) {
|
||||
changeSorting(it)
|
||||
}
|
||||
}
|
||||
stopwatch_list.adapter = stopwatchAdapter
|
||||
stopwatchList.adapter = stopwatchAdapter
|
||||
}
|
||||
|
||||
updateSortingIndicators(sorting)
|
||||
return view
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -88,7 +88,7 @@ class StopwatchFragment : Fragment() {
|
|||
|
||||
Stopwatch.addUpdateListener(updateListener)
|
||||
updateLaps()
|
||||
view.stopwatch_sorting_indicators_holder.beVisibleIf(Stopwatch.laps.isNotEmpty())
|
||||
binding.stopwatchSortingIndicatorsHolder.beVisibleIf(Stopwatch.laps.isNotEmpty())
|
||||
if (Stopwatch.laps.isNotEmpty()) {
|
||||
updateSorting(Lap.sorting)
|
||||
}
|
||||
|
@ -111,17 +111,18 @@ class StopwatchFragment : Fragment() {
|
|||
|
||||
private fun setupViews() {
|
||||
val properPrimaryColor = requireContext().getProperPrimaryColor()
|
||||
view.apply {
|
||||
requireContext().updateTextColors(stopwatch_fragment)
|
||||
stopwatch_play_pause.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, properPrimaryColor)
|
||||
stopwatch_reset.applyColorFilter(requireContext().getProperTextColor())
|
||||
binding.apply {
|
||||
requireContext().updateTextColors(stopwatchFragment)
|
||||
stopwatchPlayPause.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, properPrimaryColor)
|
||||
stopwatchReset.applyColorFilter(requireContext().getProperTextColor())
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
view.stopwatch_play_pause.setImageDrawable(resources.getColoredDrawableWithColor(drawableId, iconColor))
|
||||
binding.stopwatchPlayPause.setImageDrawable(resources.getColoredDrawableWithColor(drawableId, iconColor))
|
||||
}
|
||||
|
||||
private fun togglePlayPause() {
|
||||
|
@ -131,14 +132,14 @@ class StopwatchFragment : Fragment() {
|
|||
} else {
|
||||
PermissionRequiredDialog(
|
||||
activity as SimpleActivity,
|
||||
R.string.allow_notifications_reminders,
|
||||
com.simplemobiletools.commons.R.string.allow_notifications_reminders,
|
||||
{ (activity as SimpleActivity).openNotificationSettings() })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
stopwatchAdapter.updateLastField(lapTime, totalTime)
|
||||
}
|
||||
|
@ -148,11 +149,11 @@ class StopwatchFragment : Fragment() {
|
|||
Stopwatch.reset()
|
||||
|
||||
updateLaps()
|
||||
view.apply {
|
||||
stopwatch_reset.beGone()
|
||||
stopwatch_lap.beGone()
|
||||
stopwatch_time.text = 0L.formatStopwatchTime(false)
|
||||
stopwatch_sorting_indicators_holder.beInvisible()
|
||||
binding.apply {
|
||||
stopwatchReset.beGone()
|
||||
stopwatchLap.beGone()
|
||||
stopwatchTime.text = 0L.formatStopwatchTime(false)
|
||||
stopwatchSortingIndicatorsHolder.beInvisible()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,15 +175,15 @@ class StopwatchFragment : Fragment() {
|
|||
|
||||
private fun updateSortingIndicators(sorting: Int) {
|
||||
var bitmap = requireContext().resources.getColoredBitmap(R.drawable.ic_sorting_triangle_vector, requireContext().getProperPrimaryColor())
|
||||
view.apply {
|
||||
stopwatch_sorting_indicator_1.beInvisibleIf(sorting and SORT_BY_LAP == 0)
|
||||
stopwatch_sorting_indicator_2.beInvisibleIf(sorting and SORT_BY_LAP_TIME == 0)
|
||||
stopwatch_sorting_indicator_3.beInvisibleIf(sorting and SORT_BY_TOTAL_TIME == 0)
|
||||
binding.apply {
|
||||
stopwatchSortingIndicator1.beInvisibleIf(sorting and SORT_BY_LAP == 0)
|
||||
stopwatchSortingIndicator2.beInvisibleIf(sorting and SORT_BY_LAP_TIME == 0)
|
||||
stopwatchSortingIndicator3.beInvisibleIf(sorting and SORT_BY_TOTAL_TIME == 0)
|
||||
|
||||
val activeIndicator = when {
|
||||
sorting and SORT_BY_LAP != 0 -> stopwatch_sorting_indicator_1
|
||||
sorting and SORT_BY_LAP_TIME != 0 -> stopwatch_sorting_indicator_2
|
||||
else -> stopwatch_sorting_indicator_3
|
||||
sorting and SORT_BY_LAP != 0 -> stopwatchSortingIndicator1
|
||||
sorting and SORT_BY_LAP_TIME != 0 -> stopwatchSortingIndicator2
|
||||
else -> stopwatchSortingIndicator3
|
||||
}
|
||||
|
||||
if (sorting and SORT_DESCENDING == 0) {
|
||||
|
@ -211,8 +212,8 @@ class StopwatchFragment : Fragment() {
|
|||
|
||||
override fun onStateChanged(state: Stopwatch.State) {
|
||||
updateIcons(state)
|
||||
view.stopwatch_lap.beVisibleIf(state == Stopwatch.State.RUNNING)
|
||||
view.stopwatch_reset.beVisibleIf(state != Stopwatch.State.STOPPED)
|
||||
binding.stopwatchLap.beVisibleIf(state == Stopwatch.State.RUNNING)
|
||||
binding.stopwatchReset.beVisibleIf(state != Stopwatch.State.STOPPED)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.adapters.TimerAdapter
|
||||
import com.simplemobiletools.clock.databinding.FragmentTimerBinding
|
||||
import com.simplemobiletools.clock.dialogs.EditTimerDialog
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
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.updateTextColors
|
||||
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.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
class TimerFragment : Fragment() {
|
||||
private val INVALID_POSITION = -1
|
||||
private lateinit var view: ViewGroup
|
||||
private lateinit var binding: FragmentTimerBinding
|
||||
private lateinit var timerAdapter: TimerAdapter
|
||||
private var timerPositionToScrollTo = INVALID_POSITION
|
||||
private var storedTextColor = 0
|
||||
|
@ -46,10 +44,10 @@ class TimerFragment : Fragment() {
|
|||
}
|
||||
|
||||
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()
|
||||
timers_list.itemAnimator = DisabledItemChangeAnimator()
|
||||
timer_add.setOnClickListener {
|
||||
timersList.itemAnimator = DisabledItemChangeAnimator()
|
||||
timerAdd.setOnClickListener {
|
||||
activity?.run {
|
||||
hideKeyboard()
|
||||
openEditTimer(createNewTimer())
|
||||
|
@ -67,17 +65,17 @@ class TimerFragment : Fragment() {
|
|||
}, 1000)
|
||||
}
|
||||
|
||||
return view
|
||||
return binding.root
|
||||
}
|
||||
|
||||
private fun initAdapter() {
|
||||
timerAdapter = TimerAdapter(requireActivity() as SimpleActivity, view.timers_list, ::refreshTimers, ::openEditTimer)
|
||||
view.timers_list.adapter = timerAdapter
|
||||
timerAdapter = TimerAdapter(requireActivity() as SimpleActivity, binding.timersList, ::refreshTimers, ::openEditTimer)
|
||||
binding.timersList.adapter = timerAdapter
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
requireContext().updateTextColors(timer_fragment)
|
||||
requireContext().updateTextColors(binding.root)
|
||||
val configTextColor = requireContext().getProperTextColor()
|
||||
if (storedTextColor != configTextColor) {
|
||||
initAdapter()
|
||||
|
@ -97,10 +95,10 @@ class TimerFragment : Fragment() {
|
|||
timerAdapter.submitList(timers) {
|
||||
getView()?.post {
|
||||
if (timerPositionToScrollTo != INVALID_POSITION && timerAdapter.itemCount > timerPositionToScrollTo) {
|
||||
view.timers_list.scrollToPosition(timerPositionToScrollTo)
|
||||
binding.timersList.scrollToPosition(timerPositionToScrollTo)
|
||||
timerPositionToScrollTo = INVALID_POSITION
|
||||
} 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) {
|
||||
activity?.runOnUiThread {
|
||||
if (timerAdapter.itemCount > position) {
|
||||
view.timers_list.scrollToPosition(position)
|
||||
binding.timersList.scrollToPosition(position)
|
||||
} else {
|
||||
timerPositionToScrollTo = position
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ class AlarmReceiver : BroadcastReceiver() {
|
|||
|
||||
val builder = NotificationCompat.Builder(context, ALARM_NOTIFICATION_CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.ic_alarm_vector)
|
||||
.setContentTitle(context.getString(R.string.alarm))
|
||||
.setContentTitle(context.getString(com.simplemobiletools.commons.R.string.alarm))
|
||||
.setAutoCancel(true)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.setCategory(NotificationCompat.CATEGORY_ALARM)
|
||||
|
|
|
@ -48,7 +48,7 @@ class EarlyAlarmDismissalReceiver : BroadcastReceiver() {
|
|||
.setContentText(alarmString)
|
||||
.setSmallIcon(R.drawable.ic_alarm_vector)
|
||||
.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)
|
||||
.setSound(null)
|
||||
.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
|
||||
}
|
|
@ -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.useAndroidX=true
|
||||
android.useAndroidX=true
|
||||
android.nonTransitiveRClass=true
|
||||
|
|
|
@ -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" }
|
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
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'
|
|
@ -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 New Issue