This commit is contained in:
Phillip Thelen 2022-04-21 13:31:33 +02:00
parent ce76c40eec
commit caa0804cc3
6 changed files with 124 additions and 20 deletions

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginHorizontal="@dimen/spacing_xlarge"
android:layout_marginVertical="@dimen/spacing_large">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/enchanted_armoire_drop_rates"
style="@style/Title1"
android:textAlignment="center"
android:textColor="@color/text_primary"
android:layout_marginBottom="18dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/text_primary"
android:text="@string/armoire_rate_equipment_title"
style="@style/Subheader1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/text_secondary"
android:text="@string/armoire_rate_equipment_description"
style="@style/Caption2"
android:layout_marginBottom="12dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/text_primary"
android:text="@string/armoire_rate_food_title"
style="@style/Subheader1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/text_secondary"
android:text="@string/armoire_rate_food_description"
style="@style/Caption2"
android:layout_marginBottom="12dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/text_primary"
android:text="@string/armoire_rate_experience_title"
style="@style/Subheader1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/text_secondary"
android:text="@string/armoire_rate_experience_description"
style="@style/Caption2"
/>
</LinearLayout>

View file

@ -1233,4 +1233,12 @@
<string name="available_in">Available in %s</string>
<string name="watch_ad_to_open">Watch ad to open again</string>
<string name="watch_ad_to_revive">Watch Ad to revive</string>
<string name="enchanted_armoire_drop_rates">Enchanted Armoire Drop Rates</string>
<string name="armoire_rate_equipment_description">New Equipment pieces are added every month. If you own all pieces of equipment, then you\'ll get Food or Ezperience, 50/50 odds.</string>
<string name="armoire_rate_equipment_title">60% Piece of Equipment</string>
<string name="armoire_rate_food_title">20% Piece of Food</string>
<string name="armoire_rate_food_description">During special events, normal food items will change to their cake or candy counterparts.</string>
<string name="armoire_rate_experience_title">20% Experience points</string>
<string name="armoire_rate_experience_description">The amount gained varies randomly from 10 to 50</string>
<string name="day_start_adjustment">Day Start Adjustment</string>
</resources>

View file

@ -28,6 +28,39 @@
<item>1</item>
</string-array>
<string-array name="cds_labels">
<item>Default (12:00 AM)</item>
<item>+1 Hour (01:00 AM)</item>
<item>+2 Hours (02:00 AM)</item>
<item>+3 Hours (03:00 AM)</item>
<item>+4 Hours (04:00 AM)</item>
<item>+5 Hours (05:00 AM)</item>
<item>+6 Hours (06:00 AM)</item>
<item>+7 Hours (07:00 AM)</item>
<item>+8 Hours (08:00 AM)</item>
<item>+9 Hours (09:00 AM)</item>
<item>+10 Hours (10:00 AM)</item>
<item>+11 Hours (11:00 AM)</item>
<item>+12 Hours (12:00 PM)</item>
</string-array>
<string-array name="cds_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
<item>11</item>
<item>12</item>
</string-array>
<string-array name="avatar_sizes">
<item>@string/avatar_size_slim</item>
<item>@string/avatar_size_broad</item>

View file

@ -182,6 +182,13 @@
android:layout="@layout/preference_child_summary"
android:summary="@string/pref_first_day_of_the_week_summary"
android:title="@string/pref_first_day_of_the_week_title" />
<ListPreference
android:key="cds_time"
android:entries="@array/cds_labels"
android:entryValues="@array/cds_values"
android:layout="@layout/preference_child_summary"
android:title="@string/day_start_adjustment"/>
</PreferenceCategory>
<PreferenceCategory
@ -202,17 +209,6 @@
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_cds_header"
android:layout="@layout/preference_category">
<com.habitrpg.android.habitica.prefs.TimePreference
android:key="cds_time"
android:defaultValue="00:00"
android:layout="@layout/preference_child_summary" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/push_notifications"
android:layout="@layout/preference_category">

View file

@ -8,6 +8,7 @@ import android.view.animation.AccelerateInterpolator
import android.widget.FrameLayout
import androidx.core.content.ContextCompat
import androidx.lifecycle.lifecycleScope
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.components.UserComponent
import com.habitrpg.android.habitica.data.InventoryRepository
@ -96,7 +97,7 @@ class ArmoireActivity: BaseActivity() {
finish()
}
binding.dropRateButton.setOnClickListener {
showDropRateDialog()
}
intent.extras?.let {
val args = ArmoireActivityArgs.fromBundle(it)
@ -163,4 +164,10 @@ class ArmoireActivity: BaseActivity() {
}
}
}
fun showDropRateDialog() {
val dialog = BottomSheetDialog(this)
dialog.setContentView(R.layout.armoire_drop_rate_dialog)
dialog.show()
}
}

View file

@ -204,12 +204,11 @@ class PreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnShare
emailNotificationsPreference?.isEnabled = useEmailNotifications
}
"cds_time" -> {
val timeval = sharedPreferences.getString("cds_time", "00:00")
val pieces = timeval?.split(":".toRegex())?.dropLastWhile { it.isEmpty() }?.toTypedArray()
if (pieces != null) {
val hour = Integer.parseInt(pieces[0])
userRepository.changeCustomDayStart(hour).subscribe({ }, RxErrorHandler.handleEmptyError())
}
val timeval = sharedPreferences.getString("cds_time", "0") ?: "0"
val hour = Integer.parseInt(timeval)
userRepository.changeCustomDayStart(hour).subscribe({ }, RxErrorHandler.handleEmptyError())
val preference = findPreference<ListPreference>(key)
preference?.summary = preference?.entry
}
"language" -> {
val languageHelper = LanguageHelper(sharedPreferences.getString(key, "en"))
@ -316,8 +315,9 @@ class PreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnShare
} else {
classSelectionPreference?.isVisible = false
}
val cdsTimePreference = findPreference("cds_time") as? TimePreference
cdsTimePreference?.text = user?.preferences?.dayStart.toString() + ":00"
val cdsTimePreference = findPreference("cds_time") as? ListPreference
cdsTimePreference?.value = user?.preferences?.dayStart.toString()
cdsTimePreference?.summary = cdsTimePreference?.entry
findPreference<Preference>("dailyDueDefaultView")?.setDefaultValue(user?.preferences?.dailyDueDefaultView)
val languagePreference = findPreference("language") as? ListPreference
languagePreference?.value = user?.preferences?.language