static void ExtractProjectZip(out string projectDir) { StartupTiming.CounterStart("Extract project files from the archive"); //string projectDir; { var storageDir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); //var storageDir = global::Android.OS.Environment.GetExternalStoragePublicDirectory( global::Android.OS.Environment.DirectoryDownloads ).AbsolutePath; //var storageDir = global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath; projectDir = Path.Combine(storageDir, "Project"); } var projectZipHashFileName = Path.Combine(projectDir, "Project.zip.hash"); var currentProjectZipHash = ""; { if (File.Exists(projectZipHashFileName)) { currentProjectZipHash = File.ReadAllText(projectZipHashFileName); currentProjectZipHash = currentProjectZipHash.Replace("\r", "").Replace("\n", "").Trim(); } } var newProjectZipHash = ""; { using (var stream = activity.Assets.Open("Project.zip.hash")) using (var r = new StreamReader(stream)) newProjectZipHash = r.ReadToEnd(); newProjectZipHash = newProjectZipHash.Replace("\r", "").Replace("\n", "").Trim(); } var alreadyExtracted = !string.IsNullOrEmpty(newProjectZipHash) && newProjectZipHash == currentProjectZipHash; //extract Project.zip if (!alreadyExtracted) { //global::Android.Manifest.Permission.WriteExternalStorage //global::Android.Support.V4.App.ActivityCompat.RequestPermissions( this, new string[] { global::Android.Manifest.Permission.WriteExternalStorage, global::Android.Manifest.Permission.WriteExternalStorage }, int xxx ); //ActivityCompat.requestPermissions( this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, REQUEST_CODE ); //delete old directory if (Directory.Exists(projectDir)) { Directory.Delete(projectDir, true); } //extract Project.zip { Directory.CreateDirectory(projectDir); using (var stream = activity.Assets.Open("Project.zip")) UnzipFromStream(stream, projectDir); //write Project.zip.hash File.WriteAllText(projectZipHashFileName, newProjectZipHash); } } StartupTiming.CounterEnd("Extract project files from the archive", alreadyExtracted ? "The archive is already extracted." : ""); }
// protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Engine.activity = this; //apply general settings if (fullscreen) { Window.AddFlags(WindowManagerFlags.Fullscreen); } if (keepScreenOn) { Window.AddFlags(WindowManagerFlags.KeepScreenOn); } StartupTiming.TotalStart(); SetContentView(Resource.Layout.activity_main); //Android.Support.V7.Widget.Toolbar toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>( Resource.Id.toolbar ); //SetSupportActionBar( toolbar ); #if VULKAN surfaceView = new VulkanView(this); //!!!!LinearLayout? RelativeLayout sceneHolder = (RelativeLayout)this.FindViewById(Resource.Id.sceneHolder); sceneHolder.AddView(surfaceView); surfaceView.SetOnTouchListener(this); #else glSurfaceView = new GLSurfaceView(this); glSurfaceView.SetEGLContextClientVersion(3); //it's just recommendation, is not works for any device glSurfaceView.PreserveEGLContextOnPause = true; //!!!!hdr //glSurfaceView.SetEGLConfigChooser( 8, 8, 8, 8, 24, 8 ); var renderer = new Renderer(); glSurfaceView.SetRenderer(renderer); RelativeLayout sceneHolder = (RelativeLayout)this.FindViewById(Resource.Id.sceneHolder); sceneHolder.AddView(glSurfaceView); glSurfaceView.SetOnTouchListener(this); #endif //engineMainThread = new Thread( EngineMainThreadMethod ); //engineMainThread.Start(); }