/*******
 Copyright 2017 FUJITSU CLOUD TECHNOLOGIES LIMITED 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.nifty.cloud.mb.ncmbgcmplugin;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.unity3d.player.UnityPlayer;

public class UnityPlayerActivity extends com.unity3d.player.UnityPlayerActivity {
	private ActivityProxyObjectHelper _proxyHelper;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		try {
			this._proxyHelper = new ActivityProxyObjectHelper(this);
			this._proxyHelper.onCreate(savedInstanceState);
		} catch (Exception e) {
			Log.i("NCMB", "Failed to create proxyHelper: " + e.getMessage());
		}
		
	}

	protected void onNewIntent(Intent intent) {
		super.onNewIntent(intent);
		setIntent(intent);
		this._proxyHelper.onNewIntent(intent);
	}

	protected void onDestroy() {
		super.onDestroy();
		this._proxyHelper.invokeZeroParameterMethod("onDestroy");
	}

	public void onResume() {
		super.onResume();
		if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD){
			//リッチプッシュ処理
			NCMBPush.richPushHandler(this, getIntent());
			getIntent().removeExtra("com.nifty.RichUrl");        //再表示させたくない場合はintentからURLを削除します

			//開封通知処理
			String pushId = getIntent().getStringExtra("com.nifty.PushId");        //プッシュIDがあればUnityへ送る
			if (pushId != null) {
				UnityPlayer.UnitySendMessage("NCMBManager", "onAnalyticsReceived", pushId);    //Unityの開封通知メソッド呼び出し
				getIntent().removeExtra("com.nifty.PushId");
			}
		}
		this._proxyHelper.invokeZeroParameterMethod("onResume");
	}
	
	public void onCreate(){
		if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.GINGERBREAD) {
			this._proxyHelper.invokeZeroParameterMethod("onCreate");
		}
	}
}

@@ -1543,95 +1543,8 @@
 ();%0A
-%09%09if(android.os.Build.VERSION.SDK_INT %3E= android.os.Build.VERSION_CODES.GINGERBREAD)%7B%0A%09
 %09%09//
@@ -1553,17 +1553,16 @@
 %E3%83%81%E3%83%97%E3%83%83%E3%82%B7%E3%83%A5%E5%87%A6%E7%90%86%0A
-%09
 %09%09NCMBPu
@@ -1602,17 +1602,16 @@
 t());%0A%09%09
-%09
 getInten
@@ -1690,17 +1690,16 @@
 %E9%99%A4%E3%81%97%E3%81%BE%E3%81%99%0A%0A%09%09
-%09
 //%E9%96%8B%E5%B0%81%E9%80%9A%E7%9F%A5%E5%87%A6%E7%90%86
@@ -1699,17 +1699,16 @@
 /%E9%96%8B%E5%B0%81%E9%80%9A%E7%9F%A5%E5%87%A6%E7%90%86%0A
-%09
 %09%09String
@@ -1795,17 +1795,16 @@
 ty%E3%81%B8%E9%80%81%E3%82%8B%0A%09%09
-%09
 if (push
@@ -1817,17 +1817,16 @@
 null) %7B%0A
-%09
 %09%09%09Unity
@@ -1923,17 +1923,16 @@
 %E5%91%BC%E3%81%B3%E5%87%BA%E3%81%97%0A%09%09%09
-%09
 getInten
@@ -1972,13 +1972,8 @@
 %22);%0A
-%09%09%09%7D%0A
 %09%09%7D%0A
@@ -2038,186 +2038,6 @@
 %0A%09%7D%0A
-%09%0A%09public void onCreate()%7B%0A%09%09if(android.os.Build.VERSION.SDK_INT %3C android.os.Build.VERSION_CODES.GINGERBREAD) %7B%0A%09%09%09this._proxyHelper.invokeZeroParameterMethod(%22onCreate%22);%0A%09%09%7D%0A%09%7D%0A
 %7D%0A

Remove support code for Android 2.x