Skip to content

Commit

Permalink
Add tip for new settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
vickychijwani committed Jun 25, 2017
1 parent b0dc4dd commit 317b7f9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
13 changes: 13 additions & 0 deletions app/src/main/code/me/vickychijwani/kotlinkoans/KoanActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.Toast
import com.getkeepsafe.taptargetview.TapTarget
import com.getkeepsafe.taptargetview.TapTargetView
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.progress_widget.*
import me.vickychijwani.kotlinkoans.analytics.Analytics
Expand All @@ -47,7 +49,9 @@ class KoanActivity : BaseActivity(),
private val mKoanIds = mutableListOf<String>()

private val APP_STATE_INTRO_SEEN = "state:intro-seen"
private val APP_STATE_TIP1_SEEN = "state:seen:tip1"
private var mIsIntroSeen: Boolean = false
private var mIsTip1Seen: Boolean = false

private val APP_STATE_LAST_VIEWED_KOAN = "state:last-viewed-koan"
private var mSelectedKoanId: String? = null
Expand Down Expand Up @@ -146,6 +150,7 @@ class KoanActivity : BaseActivity(),
.observe(this, mViewKoanObserver)

mIsIntroSeen = Prefs.with(this).getBoolean(APP_STATE_INTRO_SEEN, false)
mIsTip1Seen = Prefs.with(this).getBoolean(APP_STATE_TIP1_SEEN, false)

// hide/show UI when keyboard is opened on phones in landscape mode
val MIN_CONTENT_HEIGHT = (getSizeDimen(this, R.dimen.toolbar_height)
Expand Down Expand Up @@ -323,6 +328,14 @@ class KoanActivity : BaseActivity(),
Prefs.with(this).edit().putBoolean(APP_STATE_INTRO_SEEN, true).apply()
}).startTour()
}, 100)
} else if (!mIsTip1Seen) {
// FIXME remove this tip after a few weeks
Handler(mainLooper).postDelayed({
TapTargetView.showFor(this,
TapTarget.forToolbarOverflow(toolbar, "New settings: auto-indent and bracket auto-pairing", "These are enabled by default")
.styleWithDefaults())
Prefs.with(this).edit().putBoolean(APP_STATE_TIP1_SEEN, true).apply()
}, 100)
}
}
logInfo { "Koan selected: ${koan.name}" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import me.vickychijwani.kotlinkoans.R
import me.vickychijwani.kotlinkoans.util.dp
import me.vickychijwani.kotlinkoans.util.getScreenHeight
import me.vickychijwani.kotlinkoans.util.getScreenWidth
import me.vickychijwani.kotlinkoans.util.styleWithDefaults


internal typealias TapTargetCallback = (index: Int) -> Unit
Expand Down Expand Up @@ -83,12 +84,7 @@ class IntroTour(val ctx: Activity, val toolbar: Toolbar, val tabbar: TabLayout,
// set custom fonts
tourSteps.forEach { t ->
t.textTypeface(Typekit.getInstance().get(Typekit.Style.Normal))
.outerCircleColor(R.color.tour_lime)
.titleTextColor(R.color.text_primary)
.titleTextSize(18)
.descriptionTextColor(R.color.text_primary)
.descriptionTextSize(15)
.outerCircleAlpha(1f)
.styleWithDefaults()
}

sequence = TapTargetSequence(ctx)
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/code/me/vickychijwani/kotlinkoans/util/app_utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.net.Uri
import android.os.Build
import android.widget.Toast
import com.crashlytics.android.Crashlytics
import com.getkeepsafe.taptargetview.TapTarget
import me.vickychijwani.kotlinkoans.R


Expand Down Expand Up @@ -46,6 +47,16 @@ fun getAppVersion(context: Context): String {
}
}

fun TapTarget.styleWithDefaults(): TapTarget {
return this
.outerCircleColor(R.color.tip_background)
.titleTextColor(R.color.text_primary)
.titleTextSize(18)
.descriptionTextColor(R.color.text_primary)
.descriptionTextSize(15)
.outerCircleAlpha(1f)
}

fun openPlayStore(context: Context) {
val appPackageName = context.packageName
try {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
<!-- one-off colors -->
<color name="run_results_background">#fafafa</color>

<!-- intro tour -->
<!-- intro tour & tips -->
<color name="tip_background">@color/tour_lime</color>
<color name="tour_indigo">#3F51B5</color>
<color name="tour_purple">#783393</color>
<color name="tour_blue">#2196F3</color>
Expand Down

0 comments on commit 317b7f9

Please sign in to comment.