Skip to content

Commit

Permalink
Merge "Add missing I/O apps section"
Browse files Browse the repository at this point in the history
  • Loading branch information
shailen authored and Gerrit Code Review committed Apr 30, 2018
2 parents f2fb7a2 + 9958ca7 commit 222a699
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

package com.google.samples.apps.iosched.ui.info

import android.arch.lifecycle.Observer
import android.arch.lifecycle.ViewModelProvider
import android.content.Intent
import android.databinding.BindingAdapter
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -75,6 +78,14 @@ class EventFragment : DaggerFragment() {
}
return binding.root
}

override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
eventInfoViewModel.openUrlEvent.observe(this, Observer {
val url = it?.getContentIfNotHandled() ?: return@Observer
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
})
}
}

@BindingAdapter("countdownVisibility")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,27 @@ import com.google.samples.apps.iosched.shared.domain.logistics.LoadWifiInfoUseCa
import com.google.samples.apps.iosched.shared.model.ConferenceWifiInfo
import com.google.samples.apps.iosched.shared.result.Event
import com.google.samples.apps.iosched.shared.result.Result
import com.google.samples.apps.iosched.shared.util.TimeUtils.ConferenceDay
import com.google.samples.apps.iosched.shared.util.map
import com.google.samples.apps.iosched.ui.SnackbarMessage
import com.google.samples.apps.iosched.ui.signin.SignInViewModelDelegate
import com.google.samples.apps.iosched.util.wifi.WifiInstaller
import org.threeten.bp.ZonedDateTime
import javax.inject.Inject

class EventInfoViewModel @Inject constructor(
loadWifiInfoUseCase: LoadWifiInfoUseCase,
private val wifiInstaller: WifiInstaller
private val wifiInstaller: WifiInstaller,
signInViewModelDelegate: SignInViewModelDelegate
) : ViewModel() {

companion object {
private const val SCAVENGER_HUNT_URL =
"https://androidthings.withgoogle.com/iosearch"
private const val ASSISTANT_APP_URL =
"https://assistant.google.com/services/a/uid/000000449633043c"
}

private val _wifiConfig = MutableLiveData<Result<ConferenceWifiInfo>>()
val wifiSsid: LiveData<String?>
val wifiPassword: LiveData<String?>
Expand All @@ -43,6 +54,13 @@ class EventInfoViewModel @Inject constructor(
val snackBarMessage: LiveData<Event<SnackbarMessage>>
get() = _snackbarMessage

val showScavengerHunt: LiveData<Boolean>

private val _openUrlEvent = MutableLiveData<Event<String>>()
val openUrlEvent: LiveData<Event<String>>
get() = _openUrlEvent


init {
loadWifiInfoUseCase(Unit, _wifiConfig)
wifiSsid = _wifiConfig.map {
Expand All @@ -51,6 +69,9 @@ class EventInfoViewModel @Inject constructor(
wifiPassword = _wifiConfig.map {
(it as? Result.Success)?.data?.password
}
showScavengerHunt = signInViewModelDelegate.observeRegisteredUser().map {
checkShowScavengerHunt(it)
}
}

fun onWifiConnect() {
Expand All @@ -73,4 +94,22 @@ class EventInfoViewModel @Inject constructor(

_snackbarMessage.postValue(Event(snackbarMessage))
}

private fun checkShowScavengerHunt(isRegistered: Boolean): Boolean {
if (isRegistered) {
// Show scavenger hunt to attendees during the conference
val now = ZonedDateTime.now()
return now.isAfter(ConferenceDay.DAY_1.start) && now.isBefore(ConferenceDay.DAY_3.end)
} else {
return false
}
}

fun onClickScavengerHunt() {
_openUrlEvent.value = Event(SCAVENGER_HUNT_URL)
}

fun onClickAssistantApp() {
_openUrlEvent.value = Event(ASSISTANT_APP_URL)
}
}
41 changes: 41 additions & 0 deletions mobile/src/main/res/drawable/ic_logo_assistant.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2018 Google LLC
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="60dp"
android:height="60dp"
android:viewportWidth="60"
android:viewportHeight="60">
<path
android:pathData="M30,12l-8,35"
android:strokeColor="@color/yellow"
android:strokeLineCap="square"
android:strokeWidth="3" />
<path
android:fillColor="@color/indigo"
android:pathData="M4,18.5a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0M14,28.5a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0M4,38.5a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0M14,18.5a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0M4,28.5a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0M14,38.5a2.5,2.5 0,1 1,5 0a2.5,2.5 0,1 1,-5 0" />
<path
android:pathData="M32,29a13,13 0,1 1,26 0a13,13 0,1 1,-26 0"
android:strokeColor="@color/teal"
android:strokeWidth="3" />
<path
android:pathData="M40,29a5,5 0,1 1,10 0a5,5 0,1 1,-10 0"
android:strokeColor="@color/orange"
android:strokeWidth="3" />

</vector>
97 changes: 97 additions & 0 deletions mobile/src/main/res/drawable/ic_logo_scavenger_hunt.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!--
~ Copyright 2018 Google LLC
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="200"
android:viewportHeight="200">
<path
android:fillColor="#fabfa9"
android:pathData="m48.13,136.677c0,-4.642 3.706,-8.404 8.278,-8.404 4.572,0 8.278,3.762 8.278,8.404v39.919c0,4.642 -3.706,8.404 -8.278,8.404 -4.572,0 -8.278,-3.762 -8.278,-8.404z"
android:strokeWidth="1" />
<path
android:fillColor="#27e5fd"
android:pathData="M96,82.609C96,60.976 78.539,43.439 57,43.439c-21.539,0 -39,17.537 -39,39.169 0,21.633 17.461,39.169 39,39.169 21.539,0 39,-17.537 39,-39.169zM98,82.609c0,22.742 -18.356,41.178 -41,41.178 -22.644,0 -41,-18.436 -41,-41.178 0,-22.742 18.356,-41.178 41,-41.178 22.644,0 41,18.436 41,41.178z" />
<path
android:fillColor="#27e5fd"
android:pathData="M76,82.609C76,72.07 67.493,63.526 57,63.526c-10.493,0 -19,8.544 -19,19.083 0,10.539 8.507,19.083 19,19.083 10.493,0 19,-8.544 19,-19.083zM78,82.609c0,11.648 -9.402,21.091 -21,21.091 -11.598,0 -21,-9.443 -21,-21.091 0,-11.648 9.402,-21.091 21,-21.091 11.598,0 21,9.443 21,21.091z" />
<path
android:fillColor="#27e5fd"
android:fillType="nonZero"
android:pathData="m66,82.609c0,-4.992 -4.029,-9.039 -9,-9.039 -4.971,0 -9,4.047 -9,9.039 0,4.992 4.029,9.039 9,9.039 4.971,0 9,-4.047 9,-9.039zM68,82.609c0,6.102 -4.925,11.048 -11,11.048 -6.075,0 -11,-4.946 -11,-11.048 0,-6.102 4.925,-11.048 11,-11.048 6.075,0 11,4.946 11,11.048z" />
<path
android:fillColor="#27e5fd"
android:pathData="M106,82.609C106,55.429 84.062,33.396 57,33.396c-27.062,0 -49,22.033 -49,49.213 0,27.18 21.938,49.213 49,49.213 27.062,0 49,-22.033 49,-49.213zM108,82.609c0,28.289 -22.833,51.221 -51,51.221 -28.167,0 -51,-22.932 -51,-51.221C6,54.32 28.833,31.387 57,31.387c28.167,0 51,22.932 51,51.221z" />
<path
android:fillColor="#27e5fd"
android:pathData="M86,82.609C86,66.523 73.016,53.483 57,53.483c-16.016,0 -29,13.04 -29,29.126 0,16.086 12.984,29.126 29,29.126 16.016,0 29,-13.04 29,-29.126zM88,82.609c0,17.195 -13.879,31.135 -31,31.135 -17.121,0 -31,-13.939 -31,-31.135 0,-17.195 13.879,-31.135 31,-31.135 17.121,0 31,13.939 31,31.135z" />
<path
android:fillColor="#fcd230"
android:pathData="m5.557,31.364c28.085,0 50.852,23.281 50.852,52 -16.527,0 -33.901,0 -50.852,0 -0,-17.333 -0,-34.667 -0,-52z" />
<path
android:fillColor="#fcd230"
android:pathData="m108.443,31.364c-28.085,0 -50.852,23.281 -50.852,52 16.527,0 33.901,0 50.852,0 0,-17.333 0,-34.667 0,-52z" />
<path
android:pathData="m72.68,32.646c0,9.08 -7.04,16.44 -15.724,16.44 -8.684,0 -15.724,-7.361 -15.724,-16.44 0,-9.08 7.04,-16.44 15.724,-16.44 8.684,0 15.724,7.361 15.724,16.44z"
android:strokeColor="#fabfa9"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
<path
android:pathData="m61.673,32.646c0,2.724 -2.112,4.932 -4.717,4.932 -2.605,0 -4.717,-2.208 -4.717,-4.932 0,-2.724 2.112,-4.932 4.717,-4.932 2.605,0 4.717,2.208 4.717,4.932z"
android:strokeColor="#fabfa9"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
<path
android:pathData="m67.176,32.646c0,5.902 -4.576,10.686 -10.221,10.686 -5.645,0 -10.221,-4.784 -10.221,-10.686 0,-5.902 4.576,-10.686 10.221,-10.686 5.645,0 10.221,4.784 10.221,10.686z"
android:strokeColor="#fabfa9"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
<path
android:fillColor="#fdd108"
android:pathData="m156.473,137.336c0,-3.761 2.922,-6.809 6.527,-6.809 3.605,0 6.527,3.048 6.527,6.809L169.527,178.191C169.527,181.952 166.605,185 163,185c-3.605,0 -6.527,-3.048 -6.527,-6.809z" />
<path
android:fillColor="#fdd108"
android:pathData="m176.956,64.211c0,2.132 -1.732,3.86 -3.868,3.86 -2.136,0 -3.868,-1.728 -3.868,-3.86 0,-2.132 1.732,-3.86 3.868,-3.86 2.136,0 3.868,1.728 3.868,3.86z"
android:strokeColor="#fdd108"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
<path
android:pathData="m181.469,64.211c0,4.619 -3.752,8.363 -8.381,8.363 -4.629,0 -8.381,-3.744 -8.381,-8.363 0,-4.619 3.752,-8.363 8.381,-8.363 4.629,0 8.381,3.744 8.381,8.363z"
android:strokeColor="#fdd108"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
<path
android:fillColor="#1ce8b4"
android:pathData="m146.385,77.237c-7.538,0 -13.648,-6.097 -13.648,-13.618L132.736,50h13.648c7.538,0 13.648,6.097 13.648,13.618v13.618z" />
<path
android:fillColor="#1ce8b4"
android:pathData="m146.385,111.579c-7.538,0 -13.648,-6.097 -13.648,-13.618L132.736,84.342h13.648c7.538,0 13.648,6.097 13.648,13.618v13.618z" />
<path
android:fillColor="#1ce8b4"
android:pathData="m146.385,144.737c-7.538,0 -13.648,-6.097 -13.648,-13.618L132.736,117.5h13.648c7.538,0 13.648,6.097 13.648,13.618v13.618z" />
<path
android:fillColor="#1ce8b4"
android:pathData="m179.615,104.474c7.538,0 13.648,-6.097 13.648,-13.618L193.264,77.237l-13.648,0c-7.538,0 -13.648,6.097 -13.648,13.618l-0,13.618z" />
<path
android:fillColor="#1ce8b4"
android:pathData="m179.615,137.632c7.538,0 13.648,-6.097 13.648,-13.618L193.264,110.395l-13.648,0c-7.538,0 -13.648,6.097 -13.648,13.618l-0,13.618z" />
</vector>
Loading

0 comments on commit 222a699

Please sign in to comment.