Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfio010 committed Mar 26, 2023
1 parent 91bca26 commit 6db72c2
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 54 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.2'
}
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
tools:targetApi="tiramisu">
<activity
android:name=".activities.adapters.IsChatActivity"
android:exported="false" />
android:exported="false"
android:label="@string/isChatActivity" />
<activity
android:name=".activities.home.SettingsActivity"
android:exported="false"
Expand All @@ -47,7 +48,7 @@
<activity
android:name=".activities.home.GroupChatActivity"
android:exported="false"
android:label="@string/grouped_chat" />
android:label="@string/group_chat" />
<activity
android:name=".activities.home.DeletedNotificationsActivity"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.content.pm.PackageManager
import com.android.whatsappbackup.models.Notifications
import com.android.whatsappbackup.models.PackageName
import com.android.whatsappbackup.utils.DatabaseFactory
import com.android.whatsappbackup.utils.MySharedPref
import com.google.android.material.color.DynamicColors
import io.objectbox.Box
import io.objectbox.BoxStore
Expand Down Expand Up @@ -48,7 +47,7 @@ class MyApplication : Application() {

sharedPref = getSharedPreferences("NotInfo", MODE_PRIVATE)

if (DynamicColors.isDynamicColorAvailable() && MySharedPref.getDynamicColors()) {
if (DynamicColors.isDynamicColorAvailable()) {
DynamicColors.applyToActivitiesIfAvailable(this)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,6 @@ class SettingsActivity : AppCompatActivity() {
if (version != null) {
version.title = "${version.title} ${BuildConfig.VERSION_NAME}"
}

val isDynamicColorsEnabled =
findPreference<SwitchPreferenceCompat>(MySharedPref.dynamicColorsEnabled)

if (isDynamicColorsEnabled != null) {
isDynamicColorsEnabled.isChecked = MySharedPref.getDynamicColors()
isDynamicColorsEnabled.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _, newValue ->
MySharedPref.setDynamicColors(newValue as Boolean)
true
}
}
}
}
}
14 changes: 0 additions & 14 deletions app/src/main/java/com/android/whatsappbackup/utils/MySharedPref.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.android.whatsappbackup.utils

import com.android.whatsappbackup.MyApplication
import com.android.whatsappbackup.MyApplication.Companion.application
import com.google.android.material.color.DynamicColors

object MySharedPref {
const val autoBlacklistEnabled = "isAutoBlacklistOn"
const val notificationEnabled = "isNotificationEnabled"
const val dynamicColorsEnabled = "isDynamicColorsEnabled"

fun setAutoBlacklist(value: Boolean) {
MyApplication.sharedPref.edit().putBoolean(autoBlacklistEnabled, value).apply()
Expand All @@ -24,15 +21,4 @@ object MySharedPref {
fun getNotificationEnabled(): Boolean {
return MyApplication.sharedPref.getBoolean(notificationEnabled, true)
}

fun setDynamicColors(value: Boolean) {
MyApplication.sharedPref.edit().putBoolean(dynamicColorsEnabled, value).apply()
if (value) {
DynamicColors.applyToActivitiesIfAvailable(application)
}
}

fun getDynamicColors(): Boolean {
return MyApplication.sharedPref.getBoolean(dynamicColorsEnabled, true)
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
android:layout_gravity="bottom|center|center_vertical"
android:layout_marginBottom="20sp"
android:shadowColor="#FFFFFF"
android:text="@string/grouped_chat"
android:text="@string/group_chat"
android:textAlignment="center"
android:textColor="#000000"
android:textIsSelectable="false"
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/res/values-it-rIT/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
<string name="back">Indietro</string>
<string name="version">Versione</string>
<string name="rating">Valuta l\'app</string>
<string name="grouped_chat">Chat raggruppate</string>
<string name="group_chat">Chat raggruppate</string>
<string name="open_app">Apri app</string>
<string name="open_blacklist">Visualizza blacklist</string>
<string name="info">Info</string>
<string name="interface_setting">Interfaccia</string>
<string name="active_dynamic_colors">Colori dinamici</string>
<string name="dynamic_colors_summary">Cambia i colori dell`interfaccia in base ai colori del dispositivo</string>
<string name="null_value">\"Nessun testo acquisito\"</string>
</resources>
7 changes: 2 additions & 5 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
<!-- SharedPref -->
<string name="isAutoBlacklistOn" translatable="false">isAutoBlacklistOn</string>
<string name="isNotificationEnabled" translatable="false">isNotificationEnabled</string>
<string name="isDynamicColorsEnabled" translatable="false">isDynamicColorsEnabled</string>

<!-- Activity name -->
<string name="all_notification">All notification</string>
<string name="deleted_notification">Deleted not.</string>
<string name="advanced_search">Advanced search</string>
<string name="chat" translatable="false">Chats</string>
<string name="grouped_chat">Grouped chats</string>
<string name="group_chat">Group chats</string>
<string name="home" translatable="false">Home</string>
<string name="isChatActivity" translatable="false">Chat apps</string>

<!-- Search Activity -->
<string name="title_text">Title/Text</string>
Expand Down Expand Up @@ -49,9 +49,6 @@
<string name="open_blacklist">Open blacklist</string>
<string name="notifications" translatable="false">Notifications</string>
<string name="info">About</string>
<string name="interface_setting">Interface</string>
<string name="active_dynamic_colors">Dynamic colors</string>
<string name="dynamic_colors_summary">Change interface colors to match device colors</string>
<string name="chat_title" translatable="false">Chat apps</string>
<string name="chat_summary">Applications marked as chat will be shown in the \"Chat\" section of the app</string>

Expand Down
12 changes: 0 additions & 12 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@

</PreferenceCategory>

<PreferenceCategory app:title="@string/interface_setting">

<SwitchPreferenceCompat
app:defaultValue="true"
app:key="@string/isDynamicColorsEnabled"
app:summary="@string/dynamic_colors_summary"
app:title="@string/active_dynamic_colors">

</SwitchPreferenceCompat>

</PreferenceCategory>

<PreferenceCategory app:title="@string/info">

<Preference
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
android.enableR8.fullMode=true

0 comments on commit 6db72c2

Please sign in to comment.