Skip to content

Instantly share code, notes, and snippets.

View kfaraj's full-sized avatar

Kamal Faraj kfaraj

View GitHub Profile
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
@Test
fun loadNote() = runTest {
val testDispatcher = UnconfinedTestDispatcher(testScheduler)
Dispatchers.setMain(testDispatcher)
try {
val viewModel = NoteViewModel()
viewModel.loadNote()
assertEquals("Lorem ipsum", viewModel.note.value)
} finally {
Dispatchers.resetMain()
val advertisingId = AdvertisingIdClient.getAdvertisingIdInfo(this).id
// Do something with the advertising ID.
val reviewManager = ReviewManagerFactory.create(this)
reviewManager.requestReviewFlow()
.addOnCompleteListener { task ->
if (task.isSuccessful) {
reviewManager.launchReviewFlow(this, task.result)
.addOnCompleteListener {
// Continue the normal user flow.
}
} else {
// Continue the normal user flow.
implementation 'com.google.android.play:core:1.9.0'
implementation 'com.google.android.play:core-ktx:1.8.1'
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
val mode = prefs.getInt(Settings.NIGHT_MODE, Settings.MODE_NIGHT_DEFAULT)
AppCompatDelegate.setDefaultNightMode(mode)
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
prefs.edit().putInt(Settings.NIGHT_MODE, mode).apply()
AppCompatDelegate.setDefaultNightMode(mode)
<com.google.android.material.floatingactionbutton.FloatingActionButton
style="@style/Widget.MaterialComponents.FloatingActionButton"
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/margin"
android:src="@drawable/ic_mode_night_default_black_24dp"
app:tint="?android:attr/textColorPrimaryInverse" />
<color name="primary">#ff212121</color>
<color name="primary_dark">#ff000000</color>
<color name="accent">#ff80cbc4</color>
<color name="primary">#fff5f5f5</color>
<color name="primary_dark">#ff757575</color>
<color name="accent">#ff009688</color>