public void CopyGuideFiles(LocalModule localModule) { if (Environment.ExternalStorageState.Equals(Environment.MediaMounted)) { string curPath = AppStorageManager.GetInstance(mContext).DefaultFolder; if (!AppFileUtil.NeedScopedStorageAdaptation()) { curPath = AppFileUtil.DefaultDocumentDirectory; Java.IO.File file = new Java.IO.File(curPath); if (!file.Exists()) { if (!file.Mkdirs()) { return; } } Java.IO.File sampleFile = new Java.IO.File(curPath + Java.IO.File.Separator + "Sample.pdf"); if (!sampleFile.Exists()) { localModule.CopyFileFromAssertsToTargetFile(sampleFile); } Java.IO.File guideFile = new Java.IO.File(curPath + Java.IO.File.Separator + "complete_pdf_viewer_guide_android.pdf"); if (!guideFile.Exists()) { localModule.CopyFileFromAssertsToTargetFile(guideFile); } } else if (!TextUtils.IsEmpty(curPath)) { Uri uri = AppFileUtil.ToDocumentUriFromPath(curPath); if (AppFileUtil.IsDocumentTreeUri(uri)) { DocumentFile directory = AppStorageManager.GetInstance(mContext).GetExistingDocumentFile(uri); if (directory == null) { return; } string fileName = "Sample.pdf"; DocumentFile file = directory.FindFile(fileName); if (file == null) { file = directory.CreateFile(AppFileUtil.GetMimeType(fileName), fileName); localModule.CopyFileFromAssertsToTargetFile(file); } fileName = "complete_pdf_viewer_guide_android.pdf"; file = directory.FindFile(fileName); if (file == null) { file = directory.CreateFile(AppFileUtil.GetMimeType(fileName), fileName); localModule.CopyFileFromAssertsToTargetFile(file); } } localModule.SetCurrentPath(curPath); } } }
public void UnloadLocalModule(string filter) { if (mLocalModules.ContainsKey(filter)) { LocalModule module = mLocalModules[filter]; module.UnloadModule(); mLocalModules.Remove(filter); } }
public LocalModule GetLocalModule(string filter) { if (!mLocalModules.ContainsKey(filter)) { LocalModule module = new LocalModule(mContext); module.LoadModule(); mLocalModules.Add(filter, module); } return(mLocalModules[filter]); }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_EXTERNAL_STORAGE_MANAGER) { AppFileUtil.UpdateIsExternalStorageManager(); if (!AppFileUtil.IsExternalStorageManager) { CheckStorageState(); } UpdateLocalModule(); } else if (resultCode == Result.Ok) { if (requestCode == AppStorageManager.OpenTreeRequestCode || requestCode == REQUEST_SELECT_DEFAULT_FOLDER) { if (data == null || data.Data == null) { return; } Uri uri = data.Data; ActivityFlags modeFlags = data.Flags & (ActivityFlags.GrantReadUriPermission | ActivityFlags.GrantWriteUriPermission); ContentResolver.TakePersistableUriPermission(uri, modeFlags); LocalModule localModule = App.Instance().GetLocalModule(filter); AppStorageManager storageManager = AppStorageManager.GetInstance(ApplicationContext); if (TextUtils.IsEmpty(storageManager.DefaultFolder)) { string defaultPath = AppFileUtil.ToPathFromDocumentTreeUri(uri); storageManager.DefaultFolder = defaultPath; App.Instance().CopyGuideFiles(localModule); localModule.SetCurrentPath(defaultPath); } else { localModule.ReloadCurrentFilePath(); } } } }
public void CopyGuideFiles(LocalModule localModule) { if (Environment.ExternalStorageState.Equals(Environment.MediaMounted)) { string curPath = Environment.ExternalStorageDirectory.Path + Java.IO.File.Separator + "FoxitSDK"; Java.IO.File file = new Java.IO.File(curPath); if (!file.Exists()) { file.Mkdirs(); } Java.IO.File sampleFile = new Java.IO.File(curPath + Java.IO.File.Separator + "Sample.pdf"); if (!sampleFile.Exists()) { localModule.CopyFileFromAssertsToTargetFile(sampleFile); } Java.IO.File guideFile = new Java.IO.File(curPath + Java.IO.File.Separator + "complete_pdf_viewer_guide_android.pdf"); if (!guideFile.Exists()) { localModule.CopyFileFromAssertsToTargetFile(guideFile); } } }
protected override void OnCreate(Bundle savedInstanceState) { RequestWindowFeature(Android.Views.WindowFeatures.NoTitle); base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); AppTheme.SetThemeFullScreen(this); AppTheme.SetThemeNeedMenuKey(this); ActManager.Instance.CurrentActivity = this; mLicenseValid = App.Instance().CheckLicense(); if (!mLicenseValid) { return; } if (this.Intent != null && this.Intent.Action != null) { filter = Intent.Action; } if (Build.VERSION.SdkInt > BuildVersionCodes.Q && !AppFileUtil.IsExternalStorageLegacy) { AppStorageManager storageManager = AppStorageManager.GetInstance(this); bool needPermission = storageManager.NeedManageExternalStoragePermission(); if (!AppStorageManager.IsExternalStorageManager && needPermission) { storageManager.RequestExternalStorageManager(this, REQUEST_EXTERNAL_STORAGE_MANAGER); } else if (!needPermission) { CheckStorageState(); } } else if (Build.VERSION.SdkInt > BuildVersionCodes.M) { CheckStorageState(); } if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.N) { StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.SetVmPolicy(builder.Build()); } AppStorageManager.OpenTreeRequestCode = REQUEST_OPEN_DOCUMENT_TREE; LocalModule local = App.Instance().GetLocalModule(filter); local.SetAttachedActivity(this); App.Instance().CopyGuideFiles(local); local.SetFileItemEventListener(this); local.SetCompareListener(this); local.SetOnFilePathChangeListener(this); View view = local.GetContentView(this.ApplicationContext); ViewGroup parent = (ViewGroup)view.Parent; if (parent != null) { parent.RemoveView(view); } SetContentView(view); HandleIntent(this.Intent); }