Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.

Commit ac67233

Browse files
committed
2.3_12_03
1 parent 680f396 commit ac67233

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ android {
1616
minSdk 21
1717
targetSdk = 34
1818
versionCode 9
19-
versionName '2.3_12_02'
19+
versionName '2.3_12_03'
2020
multiDexEnabled false
2121
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2222
}

app/src/main/java/ru/dimon6018/neko11/NekoApplication.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ class NekoApplication : Application() {
5656
@JvmStatic
5757
fun getCatMood(context: Context, cat: Cat): String {
5858
val prefs = PrefState(context)
59-
val result = when (prefs.getMoodPref(cat)) {
59+
return when (prefs.getMoodPref(cat)) {
6060
1 -> context.getString(R.string.mood1)
6161
2 -> context.getString(R.string.mood2)
6262
3 -> context.getString(R.string.mood3)
6363
4 -> context.getString(R.string.mood4)
6464
5 -> context.getString(R.string.mood5)
6565
else -> context.getString(R.string.mood1)
6666
}
67-
return result
6867
}
6968

7069
@JvmStatic

app/src/main/java/ru/dimon6018/neko11/ui/fragments/NekoLandFragment.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ class NekoLandFragment : Fragment(), PrefsListener {
192192
bottomsheet!!.dismissWithAnimation = true
193193
val bottomSheetInternal: View? = bottomsheet!!.findViewById(com.google.android.material.R.id.design_bottom_sheet)
194194
BottomSheetBehavior.from(bottomSheetInternal!!).peekHeight = resources.getDimensionPixelSize(R.dimen.bottomsheet)
195+
BottomSheetBehavior.from(bottomSheetInternal).state = BottomSheetBehavior.STATE_HALF_EXPANDED
195196
icon = cat.createIconBitmap(iconSize!!, iconSize!!, mPrefs!!.getIconBackground()).toDrawable(resources)
196197
textLayout = bottomSheetInternal.findViewById(R.id.catNameField)
197198
catEditor = bottomSheetInternal.findViewById(R.id.catEditName)
@@ -211,6 +212,7 @@ class NekoLandFragment : Fragment(), PrefsListener {
211212
catEditor!!.setText(cat.name)
212213
} catch (e: ClassCastException) {
213214
mood!!.text = getString(R.string.error)
215+
mPrefs!!.removeMood(cat)
214216
mPrefs!!.setMood(cat, 3)
215217
}
216218
catImage?.setImageDrawable(icon)
@@ -233,7 +235,7 @@ class NekoLandFragment : Fragment(), PrefsListener {
233235
.setMessage(R.string.name_changed)
234236
.setNegativeButton(android.R.string.ok, null)
235237
.show()
236-
cat.name = catEditor!!.getText().toString().trim { it <= ' ' }
238+
cat.name = catEditor!!.text.toString().trim { it <= ' ' }
237239
bottomsheet = null
238240
mPrefs!!.addCat(cat)
239241
}
@@ -259,8 +261,8 @@ class NekoLandFragment : Fragment(), PrefsListener {
259261
val item1 = v.findViewById<MaterialCardView>(R.id.luckyBooster)
260262
counter0.text = getString(R.string.booster_items, mPrefs!!.moodBoosters)
261263
counter1.text = getString(R.string.booster_items, mPrefs!!.luckyBoosters)
262-
item0.setEnabled(mPrefs!!.moodBoosters != 0)
263-
item1.setEnabled(mPrefs!!.luckyBoosters != 0)
264+
item0.isEnabled = mPrefs!!.moodBoosters != 0
265+
item1.isEnabled = mPrefs!!.luckyBoosters != 0
264266
dialog.setCancelable(true)
265267
dialog.setNegativeButton(android.R.string.cancel, null)
266268
val alertd = dialog.create()
@@ -469,12 +471,12 @@ class NekoLandFragment : Fragment(), PrefsListener {
469471

470472
private fun updateCatActions(cat: Cat, wash: View, caress: View, touch: View, actionsLimit: View) {
471473
if (mPrefs!!.isCanInteract(cat) <= 0) {
472-
wash.setEnabled(false)
473-
wash.setAlpha(0.5f)
474-
caress.setEnabled(false)
475-
caress.setAlpha(0.5f)
476-
touch.setEnabled(false)
477-
touch.setAlpha(0.5f)
474+
wash.isEnabled = false
475+
wash.alpha = 0.5f
476+
caress.isEnabled = false
477+
caress.alpha = 0.5f
478+
touch.isEnabled = false
479+
touch.alpha = 0.5f
478480
actionsLimit.visibility = View.VISIBLE
479481
}
480482
}
@@ -508,7 +510,7 @@ class NekoLandFragment : Fragment(), PrefsListener {
508510
}
509511

510512
private fun showCatFull(cat: Cat) {
511-
val context: Context = if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) ContextThemeWrapper(context, requireActivity().getTheme()) else requireActivity()
513+
val context: Context = if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) ContextThemeWrapper(context, requireActivity().theme) else requireActivity()
512514
val view = LayoutInflater.from(context).inflate(R.layout.cat_fullscreen_view, null)
513515
val ico = view.findViewById<ImageView>(R.id.cat_ico)
514516
ico.setImageBitmap(cat.createIconBitmap(EXPORT_BITMAP_SIZE, EXPORT_BITMAP_SIZE, 0))

app/src/main/java/ru/dimon6018/neko11/workers/PrefState.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package ru.dimon6018.neko11.workers
2020
import android.content.Context
2121
import android.content.SharedPreferences
2222
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
23+
import android.util.Log
2324
import androidx.appcompat.app.AppCompatActivity
2425
import ru.dimon6018.neko11.ui.activities.NekoSettingsActivity
2526
import ru.dimon6018.neko11.ui.fragments.NekoLandFragment
@@ -45,6 +46,11 @@ class PrefState(private val mContext: Context) : OnSharedPreferenceChangeListene
4546
.putInt(CAT_KEY_PREFIX_MOOD + cat.seed, mood)
4647
.apply()
4748
}
49+
fun removeMood(cat: Cat) {
50+
mPrefs.edit()
51+
.remove(CAT_KEY_PREFIX_MOOD + cat.seed)
52+
.apply()
53+
}
4854
fun setAge(cat: Cat, age: Int) {
4955
mPrefs.edit()
5056
.putInt(CAT_AGE + cat.seed, age)
@@ -142,7 +148,13 @@ class PrefState(private val mContext: Context) : OnSharedPreferenceChangeListene
142148
}
143149

144150
fun getMoodPref(cat: Cat): Int {
145-
return mPrefs.getInt(CAT_KEY_PREFIX_MOOD + cat.seed, 3)
151+
return try {
152+
mPrefs.getInt(CAT_KEY_PREFIX_MOOD + cat.seed, 3)
153+
} catch (e: ClassCastException) {
154+
removeMood(cat)
155+
setMood(cat, 3)
156+
3
157+
}
146158
}
147159
fun getCatAge(seed: Long): Int {
148160
return mPrefs.getInt(CAT_AGE + seed, 2)

0 commit comments

Comments
 (0)