<commit_before>/*
 ThetaFeatureActivity.java
 Copyright (c) 2015 NTT DOCOMO,INC.
 Released under the MIT license
 http://opensource.org/licenses/mit-license.php
 */
package org.deviceconnect.android.deviceplugin.theta.activity;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.KeyEvent;

import org.deviceconnect.android.deviceplugin.theta.ThetaDeviceApplication;
import org.deviceconnect.android.deviceplugin.theta.fragment.ThetaShootingModeFragment;
import org.deviceconnect.android.deviceplugin.theta.fragment.ThetaVRModeFragment;

/**
 * Activity for the transition from the gallery to the function screen of THETA.
 * 
 * @author NTT DOCOMO, INC.
 */
public class ThetaFeatureActivity extends FragmentActivity {

    /**
     * Feature Mode.
     */
    public static final String FEATURE_MODE = "org.deviceconnect.android.feature.MODE";

    /**
     * Mode VR.
     */
    public static final int MODE_VR = 0;

    /**
     * Mode Shooting.
     */
    public static final int MODE_SHOOTING = 1;

    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        int mode = getIntent().getIntExtra(FEATURE_MODE, -1);
        if (null == savedInstanceState) {
            startApp(mode, null);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);

    }

    @Override
    public boolean dispatchKeyEvent(final KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            switch (event.getKeyCode()) {
                case KeyEvent.KEYCODE_BACK:
                    finish();
                    break;
                default:
                    break;
            }
        }
        return super.dispatchKeyEvent(event);
    }
    /**
     * Move Page.
     * @param pageId pageId
     * @param serviceId TODO Theta Object?
     */
    public void startApp(final int pageId, final String serviceId) {
        if (pageId == MODE_SHOOTING) {
            ThetaShootingModeFragment f = new ThetaShootingModeFragment();
            moveFragment(f);
        } else if (pageId == MODE_VR) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            ThetaVRModeFragment f = new ThetaVRModeFragment();
            moveFragment(f);
        }
    }

    /**
     * Fragment の遷移.<commit_msg>Fix VR mode 2d portrait.<commit_after>/*
 ThetaFeatureActivity.java
 Copyright (c) 2015 NTT DOCOMO,INC.
 Released under the MIT license
 http://opensource.org/licenses/mit-license.php
 */
package org.deviceconnect.android.deviceplugin.theta.activity;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.KeyEvent;

import org.deviceconnect.android.deviceplugin.theta.ThetaDeviceApplication;
import org.deviceconnect.android.deviceplugin.theta.fragment.ThetaShootingModeFragment;
import org.deviceconnect.android.deviceplugin.theta.fragment.ThetaVRModeFragment;

/**
 * Activity for the transition from the gallery to the function screen of THETA.
 * 
 * @author NTT DOCOMO, INC.
 */
public class ThetaFeatureActivity extends FragmentActivity {

    /**
     * Feature Mode.
     */
    public static final String FEATURE_MODE = "org.deviceconnect.android.feature.MODE";

    /**
     * Mode VR.
     */
    public static final int MODE_VR = 0;

    /**
     * Mode Shooting.
     */
    public static final int MODE_SHOOTING = 1;

    /** mode. */
    private int mMode = -1;
    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mMode = getIntent().getIntExtra(FEATURE_MODE, -1);
        startApp(mMode, null);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
    }

    @Override
    public boolean dispatchKeyEvent(final KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            switch (event.getKeyCode()) {
                case KeyEvent.KEYCODE_BACK:
                    finish();
                    break;
                default:
                    break;
            }
        }
        return super.dispatchKeyEvent(event);
    }

    @Override
    public void onResume() {
        super.onResume();
        if (mMode == MODE_VR) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        }
    }

    /**
     * Move Page.
     * @param pageId pageId
     * @param serviceId TODO Theta Object?
     */
    public void startApp(final int pageId, final String serviceId) {
        if (pageId == MODE_SHOOTING) {
            ThetaShootingModeFragment f = new ThetaShootingModeFragment();
            moveFragment(f);
        } else if (pageId == MODE_VR) {
            ThetaVRModeFragment f = new ThetaVRModeFragment();
            moveFragment(f);
        }
    }


    /**
     * Fragment の遷移.
{'fraction_non_alphanumeric': 0.09517552093110569, 'fraction_numerical': 0.004129904261310306, 'mean_word_length': 2.530815109343936, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5534119', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1486, 'n_words': 328}