Implement fall and spooky promo

This commit is contained in:
Phillip Thelen 2020-09-01 12:53:46 +02:00
parent d94645e436
commit be51217b65
112 changed files with 2253 additions and 325 deletions

View file

@ -158,7 +158,7 @@ android {
multiDexEnabled true
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
versionCode 2518
versionCode 2519
versionName "2.8"
}
@ -343,4 +343,4 @@ gradle.projectsEvaluated {
check { findbugs { skip true } }
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.gms.google-services'

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#FF6165"
android:centerColor="#FA8537"
android:endColor="#FFB445"
android:angle="135"/>
<corners android:radius="@dimen/rounded_button_radius"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#FF6165"
android:centerColor="#FA8537"
android:endColor="#FFB445"
android:angle="135"/>
<corners android:radius="10dp"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/gray_1" />
<corners android:radius="@dimen/rounded_button_radius"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/orange_50"/>
<corners android:radius="@dimen/rounded_button_radius"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/orange_50"/>
<corners android:radius="10dp"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

View file

@ -49,6 +49,61 @@
android:layout_marginBottom="12dp"
android:layout_centerInParent="true"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/promo_banner"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/g1g1_box"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="10dp"
android:clipChildren="true"
android:clipToPadding="true"
android:visibility="gone">
<ImageView
android:id="@+id/promo_banner_left_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="false"/>
<ImageView
android:id="@+id/promo_banner_right_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"/>
<LinearLayout
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/promo_banner_title_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"/>
<TextView
android:id="@+id/promo_banner_duration_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Subheader2"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:gravity="center_horizontal"
android:textColor="@color/white"
android:textSize="16sp"
android:fontFamily="@string/font_family_medium"
android:layout_marginBottom="12dp"
android:layout_centerInParent="true"/>
</RelativeLayout>
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="16dp">
<RelativeLayout
android:id="@+id/promo_banner"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="16dp"
android:clipChildren="true"
android:clipToPadding="true">
<ImageView
android:id="@+id/promo_banner_left_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="false"/>
<ImageView
android:id="@+id/promo_banner_right_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"/>
<LinearLayout
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/promo_banner_title_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"/>
<TextView
android:id="@+id/promo_banner_subtitle_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Caption2"
android:textAllCaps="true"
/>
<TextView
android:id="@+id/promo_banner_duration_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Subheader2"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:gravity="center_horizontal"
android:textColor="@color/white"
android:textSize="16sp"
android:fontFamily="@string/font_family_medium"
android:layout_marginBottom="12dp"
android:layout_centerInParent="true"/>
</RelativeLayout>
<TextView
android:id="@+id/prompt_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="15sp"
android:fontFamily="@string/font_family_medium"
android:layout_marginBottom="@dimen/spacing_large"/>
<Button
android:id="@+id/prompt_button"
android:layout_width="match_parent"
android:layout_height="38dp" />
<TextView
android:id="@+id/instructions_title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:fontFamily="@string/font_family_medium"
android:textSize="15sp"
android:textColor="@color/gray_100"
android:text="@string/how_it_works"
android:layout_marginTop="22dp"
android:layout_marginBottom="7dp"/>
<TextView
android:id="@+id/instruction_description_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="15sp"
android:textColor="@color/gray_300"
android:lineSpacingExtra="2dp"/>
<TextView
android:id="@+id/limitations_title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:fontFamily="@string/font_family_medium"
android:textSize="15sp"
android:textColor="@color/gray_100"
android:text="@string/limitations"
android:layout_marginTop="22dp"
android:layout_marginBottom="7dp"/>
<TextView
android:id="@+id/limitations_description_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="15sp"
android:textColor="@color/gray_300"
tools:text="This is some text"
android:lineSpacingExtra="2dp"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:parentTag="android.widget.RelativeLayout"
android:background="@color/gray_700">
<LinearLayout
android:id="@+id/contentWrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="vertical"
android:gravity="center"
android:paddingStart="@dimen/spacing_large"
android:paddingEnd="@dimen/spacing_large">
<ImageView
android:id="@+id/title_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"/>
<TextView
android:id="@+id/title_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/gray_100"
android:textSize="14sp"
android:textStyle="bold"/>
<ImageView
android:id="@+id/description_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/description_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/gray_100"
android:textSize="12sp"
android:textAlignment="center"
android:maxWidth="240dp"/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:minWidth="110dp"
style="@style/HabiticaButton.Purple"
android:layout_marginTop="14dp"/>
</LinearLayout>
<ImageView
android:id="@+id/left_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<ImageView
android:id="@+id/right_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
</merge>

View file

@ -15,16 +15,28 @@
android:contentDescription="@string/gems"
android:layout_marginTop="20dp"/>
<FrameLayout
android:id="@+id/amount_text_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/amount_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/gem_amount"
android:textColor="@color/blue_10"
android:gravity="center"
android:layout_gravity="center"
android:textSize="36sp"
tools:text="21" />
</FrameLayout>
<TextView
android:id="@+id/gems_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/gems"
@ -34,10 +46,22 @@
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="38dp"
android:id="@+id/purchase_button"
android:background="@drawable/purchase_button_background"
android:layout_marginHorizontal="8dp"
android:textColor="@color/white"
style="@style/Body1"
tools:text="$ 4.99"/>
<TextView
android:id="@+id/footer_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#CAC7CE"
android:visibility="gone"
android:layout_marginTop="2dp"
android:layout_marginBottom="4dp"
android:layout_gravity="center"
android:gravity="center"
style="@style/Caption1"/>
</LinearLayout>

View file

@ -431,4 +431,8 @@
android:id="@+id/adventureGuideActivity"
android:name="com.habitrpg.android.habitica.ui.activities.AdventureGuideActivity"
android:label="" />
<fragment
android:id="@+id/promoInfoFragment"
android:name="com.habitrpg.android.habitica.ui.fragments.PromoInfoFragment"
android:label="PromoInfoFragment" />
</navigation>

View file

@ -56,6 +56,7 @@
<color name="blue_5">#217AA6</color>
<color name="gray_1">#1A181D</color>
<color name="gray_10">#34313a</color>
<color name="gray_50">#4e4a57</color>
<color name="gray_100">#686274</color>

View file

@ -86,7 +86,7 @@
<dimen name="diamond_button_height">40dp</dimen>
<dimen name="setup_customization_size">56dp</dimen>
<dimen name="outer_inset">16dp</dimen>
<dimen name="rounded_button_radius">6dp</dimen>
<dimen name="rounded_button_radius">8dp</dimen>
<dimen name="content_border">18dp</dimen>
<dimen name="content_section_spacing">21dp</dimen>
<dimen name="header_spacing">6dp</dimen>

View file

@ -1092,4 +1092,15 @@
<string name="disablePrivateMessages">Disable Private Messages</string>
<string name="pms_disabled">Private Messages are disabled</string>
<string name="pms_disabled_description">You can still send messages, but no one can send them to you. You can enable again from Settings.</string>
<string name="usually_x_gems">Usually %d Gems</string>
<string name="x_to_y">%s to %s</string>
<string name="how_it_works">How it works</string>
<string name="limitations">Limitations</string>
<string name="fall_promo_info_instructions">Between September 22nd and 30th, simply purchase any Gem bundle like usual and your account will be credited with the promotional amount of Gems. More Gems to spend, share, or save for any future releases!</string>
<string name="fall_promo_info_limitations">This promotion only applies during the limited time event. This event starts on September 22nd at 8:00 AM EDT (12:00 UTC) and will end September 30th at 8:00 PM EDT (00:00 UTC). The promo offer is only available when buying Gems for yourself.</string>
<string name="fall_promo_info_prompt">The Fall Gala is in full swing so we thought it was the perfect time to introduce our first ever Gem Sale! Now you will get more Gems with each purchase than ever before.</string>
<string name="view_gem_bundles">View Gem Bundles</string>
<string name="spooky_promo_info_instructions">Between October 29th and November 2nd, simply purchase any Gem bundle like usual and your account will be credited with the promotional amount of Gems. More Gems to spend, share, or save for any future releases!</string>
<string name="spooky_promo_info_limitations">This promotion only applies during the limited time event. This event starts on October 29th at 8:00 AM EDT (12:00 UTC) and will end November 2nd at 8:00 PM EDT (00:00 UTC). The promo offer is only available when buying Gems for yourself.</string>
<string name="spooky_promo_info_prompt">The Gem Sale is back to haunt the very end of this years Fall Gala! This is one last chance to get more Gems than ever, so stock up while it lasts!</string>
</resources>

View file

@ -92,5 +92,9 @@
<key>enableAdventureGuide</key>
<value>false</value>
</entry>
<entry>
<key>activePromo</key>
<value> </value>
</entry>
</defaultsMap>
<!-- END xml_defaults -->

Binary file not shown.

View file

@ -45,6 +45,7 @@ import com.habitrpg.android.habitica.ui.fragments.AboutFragment;
import com.habitrpg.android.habitica.ui.fragments.AchievementsFragment;
import com.habitrpg.android.habitica.ui.fragments.NavigationDrawerFragment;
import com.habitrpg.android.habitica.ui.fragments.NewsFragment;
import com.habitrpg.android.habitica.ui.fragments.PromoInfoFragment;
import com.habitrpg.android.habitica.ui.fragments.StatsFragment;
import com.habitrpg.android.habitica.ui.fragments.inventory.customization.AvatarCustomizationFragment;
import com.habitrpg.android.habitica.ui.fragments.inventory.customization.AvatarEquipmentFragment;
@ -343,4 +344,6 @@ public interface UserComponent {
void inject(@NotNull FAQDetailFragment faqDetailFragment);
void inject(@NotNull AdventureGuideActivity adventureGuideFragment);
void inject(@NotNull PromoInfoFragment promoInfoFragment);
}

View file

@ -15,6 +15,18 @@ class DateUtils {
fun hoursInMs(hours: Int): Int {
return hours * minutesInMs(60)
}
fun createDate(year: Int, month: Int, day: Int): Date {
val cal = Calendar.getInstance()
cal.set(Calendar.YEAR, year)
cal.set(Calendar.MONTH, month)
cal.set(Calendar.DAY_OF_MONTH, day)
cal.set(Calendar.HOUR_OF_DAY, 0)
cal.set(Calendar.MINUTE, 0)
cal.set(Calendar.SECOND, 0)
cal.set(Calendar.MILLISECOND, 0)
return cal.time
}
}
}

View file

@ -6,6 +6,8 @@ import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.habitrpg.android.habitica.BuildConfig
import com.habitrpg.android.habitica.models.promotions.HabiticaPromotion
import com.habitrpg.android.habitica.models.promotions.getHabiticaPromotionFromKey
import java.util.*
class AppConfigManager {
@ -105,4 +107,12 @@ class AppConfigManager {
fun enableAdventureGuide(): Boolean {
return remoteConfig.getBoolean("enableAdventureGuide")
}
fun activePromo(): HabiticaPromotion? {
val key = remoteConfig.getString("activePromo")
if (key.isNotBlank()) {
return getHabiticaPromotionFromKey(key)
}
return null
}
}

View file

@ -0,0 +1,141 @@
package com.habitrpg.android.habitica.models.promotions
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.graphics.drawable.ShapeDrawable
import android.view.View
import androidx.core.content.ContextCompat
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.databinding.FragmentGemPurchaseBinding
import com.habitrpg.android.habitica.databinding.PurchaseGemViewBinding
import com.habitrpg.android.habitica.extensions.DateUtils
import com.habitrpg.android.habitica.helpers.MainNavigationController
import com.habitrpg.android.habitica.ui.fragments.PromoInfoFragment
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
import com.habitrpg.android.habitica.ui.views.promo.PromoMenuView
import java.text.SimpleDateFormat
import java.util.*
class FallExtraGemsHabiticaPromotion: HabiticaPromotion() {
override val identifier: String
get() = "fall_extra_gems"
override val promoType: PromoType
get() = PromoType.GEMS_AMOUNT
override val startDate: Date
get() = DateUtils.createDate(2020, 9, 22)
override val endDate: Date
get() = DateUtils.createDate(2020, 9, 30)
override fun pillBackgroundDrawable(context: Context): Drawable {
return ContextCompat.getDrawable(context, R.drawable.fall_promo_pill_bg) ?: ShapeDrawable()
}
override fun backgroundColor(context: Context): Int {
return ContextCompat.getColor(context, R.color.gray_10)
}
override fun promoBackgroundDrawable(context: Context): Drawable {
return ContextCompat.getDrawable(context, R.drawable.layout_rounded_bg_gray_10)
?: ShapeDrawable()
}
override fun buttonDrawable(context: Context): Drawable {
return ContextCompat.getDrawable(context, R.drawable.fall_promo_button_bg)
?: ShapeDrawable()
}
override fun configurePromoMenuView(view: PromoMenuView) {
val context = view.context
view.setBackgroundColor(backgroundColor(context))
view.setTitleImage(ContextCompat.getDrawable(context, R.drawable.fall_promo_title))
view.setTitleText(null)
view.setSubtitleImage(ContextCompat.getDrawable(context, R.drawable.fall_promo_menu_description))
view.setSubtitleText(null)
view.setDecoration(
ContextCompat.getDrawable(context, R.drawable.fall_promo_menu_left),
ContextCompat.getDrawable(context, R.drawable.fall_promo_menu_right)
)
view.binding.button.background = ContextCompat.getDrawable(context, R.drawable.layout_rounded_bg_gray_1)
view.binding.button.setText(R.string.learn_more)
view.binding.button.setTextColor(ContextCompat.getColor(context, R.color.white))
view.binding.button.setOnClickListener {
menuOnNavigation(context)
}
}
override fun menuOnNavigation(context: Context) {
MainNavigationController.navigate(R.id.promoInfoFragment)
}
override fun configurePurchaseBanner(binding: FragmentGemPurchaseBinding) {
val context = binding.root.context
binding.promoBanner.visibility = View.VISIBLE
binding.promoBanner.background = promoBackgroundDrawable(context)
binding.promoBannerLeftImage.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.fall_promo_banner_left))
binding.promoBannerRightImage.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.fall_promo_banner_right))
binding.promoBannerTitleImage.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.fall_promo_title))
val formatter = SimpleDateFormat("MMM d", Locale.getDefault())
binding.promoBannerDurationView.text = context.getString(R.string.x_to_y,
formatter.format(startDate),
formatter.format(endDate))
binding.promoBannerDurationView.setTextColor(Color.parseColor("#FEE2B6"))
}
override fun configureGemView(binding: PurchaseGemViewBinding, regularAmount: Int) {
val context = binding.root.context
binding.root.background = promoBackgroundDrawable(context)
binding.purchaseButton.background = buttonDrawable(context)
val colors = listOf(
ContextCompat.getColor(context, R.color.red_10),
ContextCompat.getColor(context, R.color.blue_50),
ContextCompat.getColor(context, R.color.green_50),
ContextCompat.getColor(context, R.color.brand_300)
).shuffled()
binding.amountBackground.background = BitmapDrawable(context.resources,
HabiticaIconsHelper.imageOfFallGemPromoBG(
colors[0],
colors[1],
colors[2],
colors[3]
))
binding.gemAmount.setTextColor(Color.parseColor("#FEE2B6"))
binding.gemsTextView.setTextColor(Color.parseColor("#FEE2B6"))
binding.footerTextView.visibility = View.VISIBLE
binding.footerTextView.text = context.getString(R.string.usually_x_gems, regularAmount)
binding.gemAmount.text = when (regularAmount) {
4 -> "5"
21 -> "30"
42 -> "60"
84 -> "125"
else -> regularAmount.toString()
}
}
override fun configureInfoFragment(fragment: PromoInfoFragment) {
val context = fragment.context ?: return
fragment.binding.promoBanner.background = promoBackgroundDrawable(context)
fragment.binding.promoBannerLeftImage.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.fall_promo_info_left))
fragment.binding.promoBannerRightImage.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.fall_promo_info_right))
fragment.binding.promoBannerTitleImage.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.fall_promo_title))
fragment.binding.promoBannerSubtitleView.setText(R.string.limited_event)
fragment.binding.promoBannerDurationView.setTextColor(Color.parseColor("#FEE2B6"))
val formatter = SimpleDateFormat("MMM d", Locale.getDefault())
fragment.binding.promoBannerDurationView.text = context.getString(R.string.x_to_y,
formatter.format(startDate),
formatter.format(endDate))
fragment.binding.promoBannerDurationView.setTextColor(ContextCompat.getColor(context, R.color.white))
fragment.binding.promptText.setText(R.string.fall_promo_info_prompt)
fragment.binding.promptText.setTextColor(Color.parseColor("#F78E2F"))
fragment.binding.promptButton.background = buttonDrawable(context)
fragment.binding.promptButton.setText(R.string.view_gem_bundles)
fragment.binding.promptButton.setTextColor(ContextCompat.getColor(context, R.color.white))
fragment.binding.promptButton.setOnClickListener { MainNavigationController.navigate(R.id.gemPurchaseActivity) }
fragment.binding.instructionDescriptionView.setText(R.string.fall_promo_info_instructions)
fragment.binding.limitationsDescriptionView.setText(R.string.fall_promo_info_limitations)
}
}

Some files were not shown because too many files have changed in this diff Show more