/* * Copyright (C) 2016 Google Inc. All Rights Reserved. * * 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 * * http://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. */ package com.google.android.apps.santatracker.launch; import android.content.Intent; import android.view.View; import com.google.android.apps.santatracker.games.SplashActivity; import com.google.android.apps.santatracker.presentquest.MapsActivity; import com.google.android.apps.santatracker.R; /** * Launcher to launch the Present Quest game. */ public class LaunchPresentQuest extends AbstractLaunch { /** * Constructs a new Present Quest launch (marker). * * @param context The application (Santa) context */ public LaunchPresentQuest(SantaContext context, LauncherDataChangedCallback adapter) { super(context, adapter, R.string.present_quest, R.drawable.android_game_cards_present_quest); } @Override public void onClick(View v) { switch (mState) { case STATE_READY: case STATE_FINISHED: Intent intent = SplashActivity.getIntent(mContext.getActivityContext(), R.drawable.android_game_cards_present_quest, R.string.present_quest, false /* portrait */, MapsActivity.class); mContext.launchActivity(intent); break; case STATE_DISABLED: notify(mContext.getApplicationContext(), getDisabledString(R.string.present_quest)); break; case STATE_LOCKED: default: notify(mContext.getApplicationContext(), R.string.present_quest_locked); break; } } @Override public boolean onLongClick(View v) { switch (mState) { case STATE_READY: case STATE_FINISHED: notify(mContext.getApplicationContext(), R.string.present_quest); break; case STATE_DISABLED: notify(mContext.getApplicationContext(), getDisabledString(R.string.present_quest)); break; case STATE_LOCKED: default: notify(mContext.getApplicationContext(), R.string.present_quest_locked); break; } return true; } @Override public boolean handleVoiceAction(Intent intent) { return clickIfMatchesDescription(intent, VoiceAction.ACTION_PLAY_GAME, VoiceAction.ACTION_PLAY_GAME_EXTRA); } }