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

Commit

Permalink
2.3_10
Browse files Browse the repository at this point in the history
  • Loading branch information
queuejw committed Feb 5, 2024
1 parent a331c18 commit 9aedbf4
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 93 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ android {
}
defaultConfig {
applicationId "ru.dimon6018.neko11"
minSdk 23
minSdk 21
targetSdk = 34
versionCode 8
versionName '2.3_08'
versionCode 9
versionName '2.3_10'
multiDexEnabled false
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/ru/dimon6018/neko11/NekoGeneralActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ class NekoGeneralActivity : AppCompatActivity(), PrefsListener {
}

private fun showPromoDialog() {
val context: Context
context = ContextThemeWrapper(this, theme)
val context: Context = if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) ContextThemeWrapper(this, theme) else this
val view = LayoutInflater.from(context).inflate(R.layout.edit_text_promo, null)
val text = view.findViewById<EditText>(R.id.editpromo)
MaterialAlertDialogBuilder(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,17 @@ class NekoAboutActivity : AppCompatActivity() {
return
}
} else {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
requestPermissions(arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
NekoLandFragment.STORAGE_PERM_REQUEST)
return
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
requestPermissions(arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
NekoLandFragment.STORAGE_PERM_REQUEST)
return
}
saveAllCatsToGalleryContinue(context)
} else {
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE), 1)
}
saveAllCatsToGalleryContinue(context)
}
}
private fun saveAllCatsToGalleryContinue(context: Context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ class NekoAchievementsActivity : AppCompatActivity(), PrefsListener {
gift4!!.setText(R.string.gift_not_enabled)
}
}
if (progress5dstatus >= 100) {
if (progress5dstatus >= 100 || !nekoprefs!!.getBoolean("code5availability", true)) {
progress5dstatus = 100
gift5!!.setEnabled(true)
if (!gift5Enabled) {
gift5!!.setText(R.string.gift_not_enabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class NekoSettingsActivity : AppCompatActivity(), PrefsListener {
mPrefs!!.catIconSize = valueNew
})
details!!.setOnClickListener {
val context: Context = ContextThemeWrapper(this, getTheme())
val context: Context = if(VERSION.SDK_INT >= Build.VERSION_CODES.M) ContextThemeWrapper(this, getTheme()) else this
val view = LayoutInflater.from(context).inflate(R.layout.neko_info_dialog, null)
val androidtxt = view.findViewById<MaterialTextView>(R.id.neko_info_android_ver)
val codetxt = view.findViewById<MaterialTextView>(R.id.neko_info_ver_code)
Expand Down
115 changes: 57 additions & 58 deletions app/src/main/java/ru/dimon6018/neko11/ui/fragments/NekoLandFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.graphics.drawable.Icon
import android.media.MediaScannerConnection
import android.os.Build
import android.os.Bundle
Expand All @@ -44,6 +43,7 @@ import android.widget.Toast
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.toDrawable
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.GridLayoutManager
Expand Down Expand Up @@ -171,43 +171,39 @@ class NekoLandFragment : Fragment(), PrefsListener {

private fun onCatClick(cat: Cat) {
val context = requireActivity()
var icon: Icon?
var iconDrawable: Drawable? = null
var textLayout: TextInputLayout? = null
var catEditor: EditText? = null
var catImage: ImageView? = null
var status: MaterialTextView? = null
var age: MaterialTextView? = null
var mood: MaterialTextView? = null
var actionsLimit: MaterialTextView? = null
var wash: MaterialCardView? = null
var caress: MaterialCardView? = null
var touch: MaterialCardView? = null
var skins: MaterialCardView? = null
var bottomSheetInternal: View? = null
val icon: Drawable?
val textLayout: TextInputLayout?
val catEditor: EditText?
val catImage: ImageView?
val status: MaterialTextView?
val age: MaterialTextView?
val mood: MaterialTextView?
val actionsLimit: MaterialTextView?
val wash: MaterialCardView?
val caress: MaterialCardView?
val touch: MaterialCardView?
val skins: MaterialCardView?

var catMood: Int = mPrefs!!.getMoodPref(cat)
Runnable {
if (bottomsheet == null) {
bottomsheet = BottomSheetDialog(requireContext())
bottomsheet = BottomSheetDialog(context)
}
bottomsheet!!.setContentView(R.layout.neko_cat_bottomsheet)
bottomsheet!!.dismissWithAnimation = true
bottomSheetInternal = bottomsheet!!.findViewById(com.google.android.material.R.id.design_bottom_sheet)
BottomSheetBehavior.from(bottomSheetInternal!!).peekHeight = context.resources.getDimensionPixelSize(R.dimen.bottomsheet)
icon = cat.createIcon(iconSize!!, iconSize!!, mPrefs!!.getIconBackground())
iconDrawable = icon?.loadDrawable(context)
textLayout = bottomSheetInternal!!.findViewById(R.id.catNameField)
catEditor = bottomSheetInternal!!.findViewById(R.id.catEditName)
catImage = bottomSheetInternal!!.findViewById(R.id.cat_icon)
status = bottomSheetInternal!!.findViewById(R.id.status_title)
age = bottomSheetInternal!!.findViewById(R.id.cat_age)
mood = bottomSheetInternal!!.findViewById(R.id.mood_title)
actionsLimit = bottomSheetInternal!!.findViewById(R.id.actionsLimitTip)
wash = bottomSheetInternal!!.findViewById(R.id.wash_cat_sheet)
caress = bottomSheetInternal!!.findViewById(R.id.caress_cat_sheet)
touch = bottomSheetInternal!!.findViewById(R.id.touch_cat_sheet)
skins = bottomSheetInternal!!.findViewById(R.id.skins_sheet)
val bottomSheetInternal: View? = bottomsheet!!.findViewById(com.google.android.material.R.id.design_bottom_sheet)
BottomSheetBehavior.from(bottomSheetInternal!!).peekHeight = resources.getDimensionPixelSize(R.dimen.bottomsheet)
icon = cat.createIconBitmap(iconSize!!, iconSize!!, mPrefs!!.getIconBackground()).toDrawable(resources)
textLayout = bottomSheetInternal.findViewById(R.id.catNameField)
catEditor = bottomSheetInternal.findViewById(R.id.catEditName)
catImage = bottomSheetInternal.findViewById(R.id.cat_icon)
status = bottomSheetInternal.findViewById(R.id.status_title)
age = bottomSheetInternal.findViewById(R.id.cat_age)
mood = bottomSheetInternal.findViewById(R.id.mood_title)
actionsLimit = bottomSheetInternal.findViewById(R.id.actionsLimitTip)
wash = bottomSheetInternal.findViewById(R.id.wash_cat_sheet)
caress = bottomSheetInternal.findViewById(R.id.caress_cat_sheet)
touch = bottomSheetInternal.findViewById(R.id.touch_cat_sheet)
skins = bottomSheetInternal.findViewById(R.id.skins_sheet)
try {
mood!!.text = context.getString(R.string.mood, NekoApplication.getCatMood(context, cat))
age!!.text = getString(R.string.cat_age, cat.age)
Expand All @@ -216,27 +212,24 @@ class NekoLandFragment : Fragment(), PrefsListener {
} catch (e: ClassCastException) {
mood!!.text = getString(R.string.error)
mPrefs!!.setMood(cat, 3)
mood!!.text = context.getString(R.string.mood, NekoApplication.getCatMood(context, cat))
}
requireActivity().runOnUiThread {
catImage?.setImageIcon(icon)
mood.text = context.getString(R.string.mood, NekoApplication.getCatMood(context, cat))
}
}.run()
catImage?.setImageDrawable(icon)
if (coloredText!!) {
age!!.setTextColor(NekoApplication.getTextColor(context))
mood!!.setTextColor(NekoApplication.getTextColor(context))
catEditor!!.setTextColor(NekoApplication.getTextColor(context))
status!!.setTextColor(NekoApplication.getTextColor(context))
}
updateCatActions(cat, wash!!, caress!!, touch!!, actionsLimit!!)
bottomSheetInternal!!.findViewById<View>(R.id.delete_sheet).setOnClickListener {
bottomSheetInternal.findViewById<View>(R.id.delete_sheet).setOnClickListener {
bottomsheet!!.dismiss()
showCatRemoveDialog(cat, context)
}
textLayout!!.setEndIconOnClickListener {
bottomsheet!!.dismiss()
MaterialAlertDialogBuilder(context)
.setIcon(iconDrawable)
.setIcon(icon)
.setTitle(R.string.rename_title)
.setMessage(R.string.name_changed)
.setNegativeButton(android.R.string.ok, null)
Expand All @@ -249,11 +242,11 @@ class NekoLandFragment : Fragment(), PrefsListener {
bottomsheet!!.dismiss()
showCatFull(cat)
}
bottomSheetInternal!!.findViewById<View>(R.id.save_sheet).setOnClickListener {
bottomSheetInternal.findViewById<View>(R.id.save_sheet).setOnClickListener {
bottomsheet!!.dismiss()
checkPerms(cat, context)
}
bottomSheetInternal!!.findViewById<View>(R.id.boosters_sheet).setOnClickListener {
bottomSheetInternal.findViewById<View>(R.id.boosters_sheet).setOnClickListener {
val dialog = MaterialAlertDialogBuilder(context)
val v = this.getLayoutInflater().inflate(R.layout.cat_boosters_dialog, null)
dialog.setView(v)
Expand All @@ -268,7 +261,7 @@ class NekoLandFragment : Fragment(), PrefsListener {
dialog.setCancelable(true)
dialog.setNegativeButton(android.R.string.cancel, null)
val alertd = dialog.create()
updateCatActions(cat, wash!!, caress!!, touch!!, actionsLimit!!)
updateCatActions(cat, wash, caress, touch, actionsLimit)
item0.setOnClickListener {
mPrefs!!.removeMoodBooster(1)
mPrefs!!.setMood(cat, 5)
Expand All @@ -288,7 +281,7 @@ class NekoLandFragment : Fragment(), PrefsListener {
alertd.dismiss()
} else {
MaterialAlertDialogBuilder(context)
.setIcon(iconDrawable)
.setIcon(icon)
.setTitle(R.string.ops)
.setMessage(R.string.booster_actived_sub)
.setNegativeButton(android.R.string.ok, null)
Expand All @@ -297,9 +290,9 @@ class NekoLandFragment : Fragment(), PrefsListener {
}
alertd.show()
}
wash!!.setOnClickListener {
wash.setOnClickListener {
mPrefs!!.setCanInteract(cat, mPrefs!!.isCanInteract(cat) - 1)
updateCatActions(cat, wash!!, caress!!, touch!!, actionsLimit!!)
updateCatActions(cat, wash, caress, touch, actionsLimit)
val r = Random()
val result = r.nextInt(5 + 1)
if (result != 1) {
Expand All @@ -316,18 +309,18 @@ class NekoLandFragment : Fragment(), PrefsListener {
catMood -= 1
mPrefs!!.setMood(cat, catMood)
MaterialAlertDialogBuilder(context)
.setIcon(iconDrawable)
.setIcon(icon)
.setTitle(R.string.ops)
.setMessage(R.string.action1_fail)
.setNegativeButton(android.R.string.ok, null)
.show()
}
mood!!.text = context.getString(R.string.mood, NekoApplication.getCatMood(context, cat))
refreshBottomSheetIcon(cat, catImage!!, mPrefs!!)
refreshBottomSheetIcon(cat, catImage, mPrefs!!)
}
caress!!.setOnClickListener {
caress.setOnClickListener {
mPrefs!!.setCanInteract(cat, mPrefs!!.isCanInteract(cat) - 1)
updateCatActions(cat, wash!!, caress!!, touch!!, actionsLimit!!)
updateCatActions(cat, wash, caress, touch, actionsLimit)
val r = Random()
val result = r.nextInt(5 + 1)
if (result != 1) {
Expand All @@ -343,17 +336,17 @@ class NekoLandFragment : Fragment(), PrefsListener {
catMood -= 1
mPrefs!!.setMood(cat, catMood)
MaterialAlertDialogBuilder(context)
.setIcon(iconDrawable)
.setIcon(icon)
.setTitle(R.string.ops)
.setMessage(R.string.action2_fail)
.setNegativeButton(android.R.string.ok, null)
.show()
}
mood!!.text = context.getString(R.string.mood, NekoApplication.getCatMood(context, cat))
}
touch!!.setOnClickListener {
touch.setOnClickListener {
mPrefs!!.setCanInteract(cat, mPrefs!!.isCanInteract(cat) - 1)
updateCatActions(cat, wash!!, caress!!, touch!!, actionsLimit!!)
updateCatActions(cat, wash, caress, touch, actionsLimit)
val r = Random()
val result = r.nextInt(5 + 1)
if (result != 1) {
Expand All @@ -370,7 +363,7 @@ class NekoLandFragment : Fragment(), PrefsListener {
mPrefs!!.setMood(cat, catMood)
NekoWorker.notifyCat(requireContext(), cat, resources.getString(R.string.shh))
MaterialAlertDialogBuilder(context)
.setIcon(iconDrawable)
.setIcon(icon)
.setTitle(R.string.ops)
.setMessage(R.string.touch_cat_error)
.setNegativeButton(android.R.string.ok, null)
Expand All @@ -385,6 +378,7 @@ class NekoLandFragment : Fragment(), PrefsListener {
bottomsheet!!.show()
}
private fun skinsBottomSheet(context: Context, cat: Cat) {
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
skinsSheet!!.setContentView(R.layout.cat_skins_dialog)
skinsSheet!!.dismissWithAnimation = true
val bottomSheetInternal = skinsSheet!!.findViewById<View>(com.google.android.material.R.id.design_bottom_sheet)
Expand All @@ -397,7 +391,7 @@ class NekoLandFragment : Fragment(), PrefsListener {
val recyclerViewHats: RecyclerView = bottomSheetInternal.findViewById(R.id.recyclerViewHats)
val suitAdapter = SkinSuitsAdapter(suitList!!, requireContext(), cat, catPreview, coins)
val hatAdapter = SkinHatsAdapter(hatList!!, requireContext(), cat, catPreview, coins)
catPreview.setImageIcon(cat.createIcon(iconSize!!, iconSize!!, mPrefs!!.getIconBackground()))
catPreview.setImageBitmap(cat.createIconBitmap(iconSize!!, iconSize!!, mPrefs!!.getIconBackground()))
coins.text = getString(R.string.coins, mPrefs!!.nCoins)
recyclerViewSuit.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
recyclerViewSuit.adapter = suitAdapter
Expand Down Expand Up @@ -487,16 +481,18 @@ class NekoLandFragment : Fragment(), PrefsListener {
if (ContextCompat.checkSelfPermission(activity, permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(activity, permission.MANAGE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED ) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
ActivityCompat.requestPermissions(activity, arrayOf(permission.WRITE_EXTERNAL_STORAGE, permission.READ_EXTERNAL_STORAGE, permission.MANAGE_EXTERNAL_STORAGE), 1)
return
} else {
ActivityCompat.requestPermissions(activity, arrayOf(permission.WRITE_EXTERNAL_STORAGE, permission.READ_EXTERNAL_STORAGE), 1)
return
}
}
shareCat(requireActivity(), cat, true)
}
private fun showCatRemoveDialog(cat: Cat, context: Context) {
val size = context.resources.getDimensionPixelSize(android.R.dimen.app_icon_size)
MaterialAlertDialogBuilder(context)
.setIcon(cat.createIcon(size, size, mPrefs!!.getIconBackground()).loadDrawable(context))
.setIcon(cat.createIconBitmap(size, size, mPrefs!!.getIconBackground()).toDrawable(resources))
.setTitle(R.string.delete_cat_title)
.setMessage(R.string.delete_cat_message)
.setPositiveButton(R.string.delete_cat_title) { _: DialogInterface?, _: Int -> onCatRemove(cat) }
Expand All @@ -511,8 +507,7 @@ class NekoLandFragment : Fragment(), PrefsListener {
}

private fun showCatFull(cat: Cat) {
val context: Context = ContextThemeWrapper(context,
requireActivity().getTheme())
val context: Context = if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) ContextThemeWrapper(context, requireActivity().getTheme()) else requireActivity()
val view = LayoutInflater.from(context).inflate(R.layout.cat_fullscreen_view, null)
val ico = view.findViewById<ImageView>(R.id.cat_ico)
ico.setImageBitmap(cat.createIconBitmap(EXPORT_BITMAP_SIZE, EXPORT_BITMAP_SIZE, 0))
Expand Down Expand Up @@ -544,7 +539,11 @@ class NekoLandFragment : Fragment(), PrefsListener {
}

override fun onBindViewHolder(holder: CatHolder, position: Int) {
holder.imageView.setImageIcon(mCats[position].createIcon(mPrefs!!.catIconSize, mPrefs!!.catIconSize, mPrefs!!.getIconBackground()))
if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
holder.imageView.setImageBitmap(mCats[position].createIconBitmap(mPrefs!!.catIconSize, mPrefs!!.catIconSize, mPrefs!!.getIconBackground()))
} else {
holder.imageView.setImageIcon(mCats[position].createIcon(mPrefs!!.catIconSize, mPrefs!!.catIconSize, mPrefs!!.getIconBackground()))
}
holder.textView.text = mCats[position].name
if (coloredText!!) {
holder.textView.setTextColor(NekoApplication.getTextColor(context!!))
Expand Down
Loading

0 comments on commit 9aedbf4

Please sign in to comment.