Код: Выделить всё
Theme.MaterialComponents.DayNight.DarkActionBar
Код: Выделить всё
Код: Выделить всё
class MainActivity : AppCompatActivity() {
companion object{
private const val TAG = "MainActivity"
}
private lateinit var binding: ActivityMainBinding
private lateinit var navController: NavController
lateinit var viewModel: NewsViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { // Q هو API 29
enableEdgeToEdge()
Log.d(TAG, "Edge-to-Edge enabled for API ${Build.VERSION.SDK_INT}")
}
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.rootView)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
val navHostFragment = supportFragmentManager.findFragmentById(R.id.newsNavHostFragment) as NavHostFragment
navController = navHostFragment.navController
binding.bottomNavigationView.setupWithNavController(navController)
val newsRepository = NewsRepository(ArticleDatabase(this))
val viewModelProviderFactory = NewsViewModelProviderFactory(application,newsRepository)
viewModel = ViewModelProvider(this, viewModelProviderFactory)[NewsViewModel::class.java]
}
}
Код: Выделить всё
@color/purple_500
@color/purple_700
@color/white
@color/teal_200
@color/teal_700
@color/black
?attr/colorPrimaryVariant
< /code>
Вот моя старая build.gradle для справки: < /p>
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id "androidx.navigation.safeargs.kotlin"
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.mml.newsapp"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
viewBinding = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
namespace 'com.mml.newsapp'
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Architectural Components
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
// Room
implementation "androidx.room:room-runtime:2.4.3"
kapt "androidx.room:room-compiler:2.4.3"
// Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:2.4.3"
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1'
// Coroutine Lifecycle Scopes
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.squareup.okhttp3:logging-interceptor:4.9.0"
// Navigation Components
implementation "androidx.navigation:navigation-fragment-ktx:2.5.1"
implementation "androidx.navigation:navigation-ui-ktx:2.5.1"
// Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
}
< /code>
И это новое: < /p>
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id "androidx.navigation.safeargs.kotlin"
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}
android {
compileSdk = 36
defaultConfig {
applicationId "com.mml.newsapp"
minSdk 21
targetSdk 36
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
viewBinding = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
namespace 'com.mml.newsapp'
}
dependencies {
implementation 'androidx.core:core-ktx:1.17.0'
implementation 'androidx.appcompat:appcompat:1.7.1'
implementation 'com.google.android.material:material:1.13.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
// Architectural Components
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.3"
// Room
implementation "androidx.room:room-runtime:2.7.2"
kapt "androidx.room:room-compiler:2.7.2"
// Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:2.7.2"
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2'
// Coroutine Lifecycle Scopes
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.3"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.9.3"
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:3.0.0'
implementation 'com.squareup.retrofit2:converter-gson:3.0.0'
implementation "com.squareup.okhttp3:logging-interceptor:5.1.0"
// Navigation Components
implementation "androidx.navigation:navigation-fragment-ktx:2.9.3"
implementation "androidx.navigation:navigation-ui-ktx:2.9.3"
// Glide
implementation 'com.github.bumptech.glide:glide:5.0.4'
kapt 'com.github.bumptech.glide:compiler:5.0.4'
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... ndroid-app