-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from pachi81/develop_gda
Develop GDA
- Loading branch information
Showing
44 changed files
with
804 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
auto/src/main/java/de/michelinside/glucodataauto/Dialogs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package de.michelinside.glucodataauto | ||
|
||
import android.app.UiModeManager | ||
import android.content.Context | ||
import android.content.DialogInterface | ||
import android.os.Build | ||
import androidx.appcompat.app.AppCompatDelegate | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
import de.michelinside.glucodatahandler.common.Constants | ||
import de.michelinside.glucodatahandler.common.R | ||
|
||
|
||
object Dialogs { | ||
fun showOkDialog(context: Context, titleResId: Int, messageResId: Int, okListener: DialogInterface.OnClickListener?) { | ||
MaterialAlertDialogBuilder(context) | ||
.setTitle(context.resources.getString(titleResId)) | ||
.setMessage(context.resources.getString(messageResId)) | ||
.setPositiveButton(context.resources.getText(R.string.button_ok), okListener) | ||
.show() | ||
} | ||
fun showOkCancelDialog(context: Context, titleResId: Int, messageResId: Int, okListener: DialogInterface.OnClickListener?) { | ||
MaterialAlertDialogBuilder(context) | ||
.setTitle(context.resources.getString(titleResId)) | ||
.setMessage(context.resources.getString(messageResId)) | ||
.setPositiveButton(context.resources.getText(R.string.button_ok), okListener) | ||
.setNegativeButton(context.resources.getText(R.string.button_cancel), null) | ||
.show() | ||
} | ||
|
||
fun updateColorScheme(context: Context) { | ||
val sharedPref = context.getSharedPreferences(Constants.SHARED_PREF_TAG, Context.MODE_PRIVATE) | ||
val colorScheme = sharedPref.getString(Constants.SHARED_PREF_APP_COLOR_SCHEME, "") | ||
// This will be the top level handling of theme | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
// If you don't want to adapt the device's theme settings, uncomment the snippet below | ||
val uiModeManager = context.getSystemService(Context.UI_MODE_SERVICE) as UiModeManager | ||
uiModeManager.setApplicationNightMode( | ||
when (colorScheme) { | ||
"light" -> UiModeManager.MODE_NIGHT_NO // User set this explicitly | ||
"dark" -> UiModeManager.MODE_NIGHT_YES // User set this explicitly | ||
else -> UiModeManager.MODE_NIGHT_AUTO // Follow the device Dark Theme settings when not define yet by user | ||
} | ||
) | ||
} else { | ||
AppCompatDelegate.setDefaultNightMode( | ||
when (colorScheme) { | ||
"light" -> AppCompatDelegate.MODE_NIGHT_NO // User set this explicitly | ||
"dark" -> AppCompatDelegate.MODE_NIGHT_YES // User set this explicitly | ||
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM // For Android 10 and 11, follow the device Dark Theme settings when not define yet by user | ||
} | ||
) | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.