forked from upstream-mirrors/quik
Create drawer badge experiment
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||||
|
*
|
||||||
|
* This file is part of QKSMS.
|
||||||
|
*
|
||||||
|
* QKSMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* QKSMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.moez.QKSMS.feature.main
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.moez.QKSMS.experiment.Experiment
|
||||||
|
import com.moez.QKSMS.experiment.Variant
|
||||||
|
import com.moez.QKSMS.manager.AnalyticsManager
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class DrawerBadgesExperiment @Inject constructor(
|
||||||
|
context: Context,
|
||||||
|
analyticsManager: AnalyticsManager
|
||||||
|
) : Experiment<Boolean>(context, analyticsManager) {
|
||||||
|
|
||||||
|
override val key: String = "Drawer Badges"
|
||||||
|
|
||||||
|
override val variants: List<Variant<Boolean>> = listOf(
|
||||||
|
Variant("variant_a", false),
|
||||||
|
Variant("variant_b", true))
|
||||||
|
|
||||||
|
override val default: Boolean = false
|
||||||
|
|
||||||
|
override val qualifies: Boolean = true
|
||||||
|
|
||||||
|
}
|
||||||
@@ -64,6 +64,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
|
|
||||||
@Inject lateinit var navigator: Navigator
|
@Inject lateinit var navigator: Navigator
|
||||||
@Inject lateinit var conversationsAdapter: ConversationsAdapter
|
@Inject lateinit var conversationsAdapter: ConversationsAdapter
|
||||||
|
@Inject lateinit var drawerBadgesExperiment: DrawerBadgesExperiment
|
||||||
@Inject lateinit var searchAdapter: SearchAdapter
|
@Inject lateinit var searchAdapter: SearchAdapter
|
||||||
@Inject lateinit var itemTouchCallback: ConversationItemTouchCallback
|
@Inject lateinit var itemTouchCallback: ConversationItemTouchCallback
|
||||||
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||||
@@ -141,6 +142,8 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Miscellaneous views
|
// Miscellaneous views
|
||||||
|
plusBadge.setBackgroundTint(theme.theme)
|
||||||
|
plusBadge.setTextColor(theme.textPrimary)
|
||||||
syncingProgress.indeterminateTintList = ColorStateList.valueOf(theme.theme)
|
syncingProgress.indeterminateTintList = ColorStateList.valueOf(theme.theme)
|
||||||
plusIcon.setTint(theme.theme)
|
plusIcon.setTint(theme.theme)
|
||||||
rateIcon.setTint(theme.theme)
|
rateIcon.setTint(theme.theme)
|
||||||
@@ -193,6 +196,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
toolbar.menu.findItem(R.id.unread)?.isVisible = !markRead && selectedConversations != 0
|
toolbar.menu.findItem(R.id.unread)?.isVisible = !markRead && selectedConversations != 0
|
||||||
toolbar.menu.findItem(R.id.block)?.isVisible = selectedConversations != 0
|
toolbar.menu.findItem(R.id.block)?.isVisible = selectedConversations != 0
|
||||||
|
|
||||||
|
plusBadge.isVisible = drawerBadgesExperiment.variant && !state.upgraded
|
||||||
plus.isVisible = state.upgraded
|
plus.isVisible = state.upgraded
|
||||||
plusBanner.isVisible = !state.upgraded
|
plusBanner.isVisible = !state.upgraded
|
||||||
rateLayout.setVisible(state.showRating)
|
rateLayout.setVisible(state.showRating)
|
||||||
|
|||||||
@@ -83,6 +83,18 @@
|
|||||||
style="@style/DrawerText"
|
style="@style/DrawerText"
|
||||||
android:text="@string/drawer_scheduled" />
|
android:text="@string/drawer_scheduled" />
|
||||||
|
|
||||||
|
<com.moez.QKSMS.common.widget.QkTextView
|
||||||
|
android:id="@+id/plusBadge"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/rounded_rectangle_2dp"
|
||||||
|
android:padding="4dp"
|
||||||
|
android:text="@string/title_qksms_plus"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:textSize="tertiary"
|
||||||
|
tools:backgroundTint="@color/tools_theme"
|
||||||
|
tools:textColor="@color/textPrimaryDark" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
Reference in New Issue
Block a user