// Copyright 2016 Google Inc.
//
// 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.androidexperiments.sprayscape.unitydriveplugin;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Window;
import com.google.android.gms.auth.GoogleAuthException;
import com.google.android.gms.auth.GoogleAuthUtil;
import com.google.android.gms.auth.UserRecoverableAuthException;
import com.google.android.gms.common.AccountPicker;
import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.extensions.android.json.AndroidJsonFactory;
import com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential;
import com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.FileContent;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.util.ExponentialBackOff;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.File;
import com.google.api.services.drive.model.Permission;
import com.unity3d.player.UnityPlayer;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class GoogleDriveUnityPlayerActivity extends FragmentActivity {
protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
private static final String TAG = "GoogleDriveUPA";
private static final int REQUEST_CODE_ACCOUNT_SELECTED = 10000;
private static final int REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR = 10001;
private static final int REQUEST_CODE_RECOVER_FROM_DRIVE_UPLOAD_ERROR = 10002;
private static final int REQUEST_CODE_RECOVER_FROM_TOKEN_AUTHENTICATE = 10003;
private static final String CALLBACK_METHOD_DRIVE_ACCOUNT_SELECTED = "DriveAccountSelected";
private static final String CALLBACK_METHOD_DRIVE_ACCOUNT_TOKEN_OBTAINED = "DriveTokenObtained";
private static final String CALLBACK_METHOD_DRIVE_ACCOUNT_SELECTION_CANCELED = "DriveAccountSelectionCanceled";
private static final String CALLBACK_METHOD_DRIVE_IS_READY = "DriveIsReady";
private static final String CALLBACK_METHOD_DRIVE_FILE_UPLOADED = "DriveFileUploaded";
private static final String CALLBACK_METHOD_DRIVE_AUTH_FAILED = "DriveAuthFailed";
private static final String CALLBACK_METHOD_DRIVE_AUTH_CANCELED = "DriveAuthCanceled";
private static final String CALLBACK_METHOD_DRIVE_PERMISSION_CHANGE_FAILED = "DrivePermissionChangeFailed";
private static final String CALLBACK_METHOD_NOT_ONLINE = "DriveNotOnline";
private static final String CALLBACK_METHOD_DRIVE_UPLOAD_FAILED = "DriveUploadFailed";
private static final String DRIVE_FILE_SCOPE = "https://www.googleapis.com/auth/drive.file";
private static final String DRIVE_APPFOLDER_SCOPE = "https://www.googleapis.com/auth/drive.appfolder";
private static final String PLUS_EMAIL_SCOPE = "https://www.googleapis.com/auth/userinfo.email";
private static final String GOOGLE_ACCOUNT_NAME = "GOOGLE_ACCOUNT_NAME";
private static final String GOOGLE_ACCOUNT_ID = "GOOGLE_ACCOUNT_ID";
public static GoogleDriveUnityPlayerActivity activityInstance;
private GoogleAccountCredential credential;
private Drive driveService;
private Account account;
private String lastDriveFolderName;
private String lastDriveFileName;
private String lastLocalPath;
private String lastCallbackObjectName;
public GoogleDriveUnityPlayerActivity() {
activityInstance = this;
}
// Setup activity layout
@Override protected void onCreate (Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
getWindow().setFormat(PixelFormat.RGBX_8888); // <--- This makes xperia play happy
mUnityPlayer = new UnityPlayer(this);
setContentView(mUnityPlayer);
mUnityPlayer.requestFocus();
credential = GoogleAccountCredential.usingOAuth2(
getApplicationContext(),
Arrays.asList(DRIVE_FILE_SCOPE, DRIVE_APPFOLDER_SCOPE, PLUS_EMAIL_SCOPE))
.setBackOff(new ExponentialBackOff());
}
// Quit Unity
@Override protected void onDestroy ()
{
mUnityPlayer.quit();
super.onDestroy();
}
// Pause Unity
@Override protected void onPause()
{
super.onPause();
mUnityPlayer.pause();
}
// Resume Unity
@Override protected void onResume()
{
super.onResume();
mUnityPlayer.resume();
}
// This ensures the layout will be correct.
@Override public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
mUnityPlayer.configurationChanged(newConfig);
}
// Notify Unity of the focus change.
@Override public void onWindowFocusChanged(boolean hasFocus)
{
super.onWindowFocusChanged(hasFocus);
mUnityPlayer.windowFocusChanged(hasFocus);
}
// For some reason the multiple keyevent type is not supported by the ndk.
// Force event injection by overriding dispatchKeyEvent().
@Override public boolean dispatchKeyEvent(KeyEvent event)
{
if (event.getAction() == KeyEvent.ACTION_MULTIPLE)
return mUnityPlayer.injectEvent(event);
return super.dispatchKeyEvent(event);
}
// Pass any events not handled by (unfocused) views straight to UnityPlayer
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { return mUnityPlayer.injectEvent(event); }
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { return mUnityPlayer.injectEvent(event); }
@Override public boolean onTouchEvent(MotionEvent event) { return mUnityPlayer.injectEvent(event); }
/*API12*/ public boolean onGenericMotionEvent(MotionEvent event) { return mUnityPlayer.injectEvent(event); }
public boolean isDeviceOnline() {
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
return (networkInfo != null && networkInfo.isConnected());
}
private Account getLastUsedAccount() {
String accountName = getPreferences(MODE_PRIVATE).getString(GOOGLE_ACCOUNT_NAME, null);
if (accountName == null) {
account = null;
return null;
}
account = getAccountByName(accountName);
return account;
}
private Account getAccountByName(String name) {
for (Account a: AccountManager.get(this).getAccountsByType("com.google")) {
if (a.name.equals(name)) {
return a;
}
}
return null;
}
private void clearAccount()
没有合适的资源?快使用搜索试试~ 我知道了~
小程序源码 APP源码 62_Sprayscape-master(仿版).zip
共2000个文件
meta:1311个
h:356个
m:266个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 48 浏览量
2023-03-11
09:35:38
上传
评论
收藏 44.53MB ZIP 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序源码 APP源码 62_Sprayscape-master(仿版).zip (2000个子文件)
libvrunity.a 62.47MB
libGoogleAnalyticsServices.a 11.03MB
support-v4-23.4.0.aar 1.17MB
support-v4-23.4.0.aar 1.17MB
play-services-base-9.2.1.aar 622KB
play-services-base-9.2.1.aar 622KB
play-services-basement-9.2.1.aar 527KB
play-services-basement-9.2.1.aar 527KB
play-services-vision-9.2.1.aar 100KB
play-services-auth-9.2.1.aar 90KB
play-services-auth-9.2.1.aar 90KB
play-services-auth-base-9.2.1.aar 37KB
play-services-auth-base-9.2.1.aar 37KB
support-v13-23.4.0.aar 20KB
support-v13-23.4.0.aar 20KB
play-services-tasks-9.2.1.aar 20KB
play-services-tasks-9.2.1.aar 20KB
Generic Slide.anim 4KB
Generic Slide Delay.anim 2KB
ProjectSettings.asset 43KB
ProjectSettings.asset 17KB
InputManager.asset 6KB
InputManager.asset 5KB
QualitySettings.asset 5KB
GraphicsSettings.asset 4KB
NavMeshAreas.asset 4KB
Physics2DSettings.asset 4KB
TagManager.asset 4KB
DynamicsManager.asset 4KB
EditorSettings.asset 4KB
UnityConnectSettings.asset 4KB
AudioManager.asset 4KB
EditorBuildSettings.asset 4KB
UnityAdsSettings.asset 4KB
TimeManager.asset 4KB
NetworkManager.asset 4KB
ClusterInputManager.asset 4KB
GraphicsSettings.asset 2KB
Physics2DSettings.asset 1KB
QualitySettings.asset 915B
NavMeshAreas.asset 884B
DynamicsManager.asset 661B
UnityConnectSettings.asset 481B
EditorSettings.asset 479B
TagManager.asset 389B
AudioManager.asset 328B
UnityAdsSettings.asset 223B
EditorBuildSettings.asset 191B
TimeManager.asset 168B
NetworkManager.asset 151B
ClusterInputManager.asset 114B
gradlew.bat 2KB
gradlew.bat 2KB
audiopluginvrunity.bundle 4.5MB
CardboardDistortionPhoto.cginc 2KB
CardboardDistortion.cginc 2KB
SprayInclude.cginc 93B
Generic Slide (delayed x3).controller 3KB
Generic Slide (delayed x1).controller 3KB
Generic Slide (delayed x2).controller 3KB
Generic Slide.controller 3KB
ViewManager.cs 33KB
SprayCam.cs 28KB
Cardboard.cs 25KB
StereoController.cs 18KB
GoogleAnalyticsAndroidV3.cs 17KB
CardboardProfile.cs 17KB
GoogleAnalyticsV3.cs 15KB
GoogleAnalyticsMPV3.cs 15KB
CardboardAudio.cs 15KB
CardboardEye.cs 13KB
CardboardPostRender.cs 13KB
PermissionCallbackReceiver.cs 13KB
DriveReceiver.cs 13KB
OnboardingController.cs 12KB
CardboardSetup.cs 12KB
GazeInputModule.cs 12KB
DefaultResolver.cs 11KB
CardboardAudioSource.cs 11KB
PhotoIO.cs 10KB
BaseVRDevice.cs 9KB
BaseCardboardDevice.cs 9KB
LibraryController.cs 9KB
CameraCapture.cs 9KB
SkyboxMesh.cs 9KB
Smoothing.cs 8KB
CardboardAudioSourceEditor.cs 8KB
GAIHandler.cs 8KB
CardboardReticle.cs 7KB
LibraryListElement.cs 6KB
CardboardOnGUI.cs 6KB
PlayServicesResolver.cs 6KB
CardboardEditor.cs 6KB
ResolverVer1_1.cs 5KB
CardboardHead.cs 5KB
NativeShare.cs 5KB
CardboardAudioRoomEditor.cs 5KB
LockedDragHandler.cs 5KB
Fields.cs 5KB
CardboardOnGUIMouse.cs 5KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
金枝玉叶9
- 粉丝: 137
- 资源: 7640
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 本科毕业设计基于C# wpf人脸识别的考勤系统的设计与实现源码.zip
- 基于Ruoyi+uniapp实现学生考勤系统 学生考勤源码+项目说明.zip
- feae6bc968ca68a099455d8b8a8dea35
- 基于Pytorch训练CIRAR10上分类算法.zip
- Pytorch-pytorch深度学习教程之Tensorboard.zip
- 基于C++和Python开发yolov8-face作为人脸检测器dlib作为人脸识别器的人脸考勤系统源码+项目说明.zip
- Pytorch-pytorch深度学习教程之变分自动编码器.zip
- Pytorch-pytorch深度学习教程之神经风格迁移.zip
- Pytorch-pytorch深度学习教程之深度残差网络.zip
- Pytorch-pytorch深度学习教程之循环神经网络.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功