static int FromRealTimeSignum(Int32 offset, out Int32 rval) { if (!AndroidUtils.AreRealTimeSignalsSafe()) { throw new PlatformNotSupportedException("Real-time signals are not supported on this Android architecture"); } return(HelperFromRealTimeSignum(offset, out rval)); }
public static string ReadContentFromStreamingAssets(string fileName) { #if UNITY_EDITOR || UNITY_IOS return(File.ReadAllText(Application.streamingAssetsPath + "/" + fileName)); #elif UNITY_ANDROID return(AndroidUtils.readFromAssetsFile(fileName)); #endif }
public static void CopyDirFromStreamingAssets(string dirPath, string destDirPath) { #if UNITY_EDITOR || UNITY_IOS CopyDirectory(Application.streamingAssetsPath + "/" + dirPath, destDirPath); #elif UNITY_ANDROID AndroidUtils.copyFSResource(dirPath, destDirPath); #endif }
public static float Dpi() { #if UNITY_ANDROID && !UNITY_EDITOR return(AndroidUtils.Dpi()); #else return(Screen.dpi); #endif }
public void MarkAsRead(Action onSuccess, Action <string> onFailure) { AndroidUtils.RunOnUiThread(() => { chatRoomJavaObject.Call("markAsRead", new OperationVoidCallbackProxy(onSuccess, onFailure)); }); }
public override Animator OnCreateAnimator(int transit, bool enter, int nextAnim) { if (nextAnim == 0) { return(base.OnCreateAnimator(transit, enter, nextAnim)); } return(AndroidUtils.CreateSlideAnimator(Activity, nextAnim)); }
private void Start() { if (!AndroidUtils.IsPermitted(AndroidPermission.ACCESS_FINE_LOCATION))//test request permission { AndroidUtils.RequestPermission(AndroidPermission.ACCESS_FINE_LOCATION); } androidUtils = FindObjectOfType <AndroidUtils>(); }
private void InitializePlatformSpecificIoC() { var androidUtils = new AndroidUtils(); Mvx.RegisterSingleton <IAndroidUtils>(androidUtils); Mvx.RegisterSingleton <ISystemUtils>(androidUtils); Mvx.LazyConstructAndRegisterSingleton <TabGestureService, TabGestureService>(); Mvx.LazyConstructAndRegisterSingleton <IAppInfo>(() => new AppInfo(ApplicationContext)); }
public void SetTypingStatus(TypingStatus typingStatus, Action onSuccess, Action <string> onFailure) { AndroidUtils.RunOnUiThread(() => { chatRoomJavaObject.Call("setTypingStatus", AndroidChatUtils.GetTypingStatusAJO(typingStatus), new OperationVoidCallbackProxy(onSuccess, onFailure)); }); }
public void SendMessage(ChatMessageContent messageContent, Action onSuccess, Action <string> onFailure) { AndroidUtils.RunOnUiThread(() => { chatRoomJavaObject.Call("sendMessage", AndroidChatUtils.CreateChatMessageContentAJO(messageContent.MessageText), new OperationVoidCallbackProxy(onSuccess, onFailure)); }); }
private void Prepare() { // Check if this is editing an existing task: if so, populate fields string editJson = Intent.GetStringExtra("EDIT") ?? ""; newTask = JsonConvert.DeserializeObject <LearningTask>(editJson); if (newTask != null) { addTaskBtn.SetText(Resource.String.saveChanges); AdditionalInfoData addData = JsonConvert.DeserializeObject <AdditionalInfoData>(newTask.JsonData); infoField.Text = newTask.Description; urlField.Text = addData.ExternalUrl; taskType = newTask.TaskType; editing = true; if (!string.IsNullOrWhiteSpace(addData.ImageUrl)) { if (addData.ImageUrl.StartsWith("upload")) { string imageUrl = ServerUtils.GetUploadUrl(addData.ImageUrl); ImageService.Instance.LoadUrl(imageUrl) .Transform(new CircleTransformation()) .Into(imageView); } else { editCachePath = Path.Combine( Common.LocalData.Storage.GetCacheFolder(null), "editcache-" + DateTime.UtcNow.ToString("MM-dd-yyyy-HH-mm-ss-fff")); File.Copy(addData.ImageUrl, editCachePath, true); Java.IO.File cachedFile = new Java.IO.File(editCachePath); selectedImage = global::Android.Net.Uri.FromFile(cachedFile); ImageService.Instance.LoadFile(selectedImage.Path).Transform(new CircleTransformation()).Into(imageView); } originalPath = addData.ImageUrl; } } else { // If edit is null, get the tasktype from JSON string jsonData = Intent.GetStringExtra("JSON") ?? ""; taskType = JsonConvert.DeserializeObject <TaskType>(jsonData, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }); newTask = new LearningTask { TaskType = taskType }; } if (selectedImage == null && originalPath == null) { AndroidUtils.LoadTaskTypeIcon(taskType, imageView); } }
public static string GetDeviceID () { IUtilsDevice utilsDevice; #if UNITY_EDITOR || DEBUG utilsDevice = new EditorUtilsDevice (); #elif UNITY_ANDROID utilsDevice = new AndroidUtils (); #endif return utilsDevice.GetDeviceID (); }
void onPrivateRoomTypingStatus(AndroidJavaObject chatRoom, AndroidJavaObject userAJO, AndroidJavaObject typingStatusAJO) { var privateChatRoom = new PrivateChatRoomAndroidImpl(chatRoom); var user = AndroidUtils.UserFromJavaObj(userAJO); var typingStatus = AndroidChatUtils.TypingStatusFromAJO(typingStatusAJO); MainThreadExecutor.Queue(() => onPrivateRoomTypingStatusAction(privateChatRoom, user, typingStatus)); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); AndroidUtils.SetMainActicity(this); global::Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new App()); }
public void GetMessages(ChatMessage offsetMessage, int limit, Action <List <ChatMessage> > onSuccess, Action <string> onFailure) { AndroidUtils.RunOnUiThread(() => { chatRoomJavaObject.Call("getMessagesBeforeChatMessageByGuid", offsetMessage.Guid, limit, new OperationGenericCallbackProxy <List <ChatMessage> >(onSuccess, onFailure, AndroidChatUtils.ChatMessagesFromJavaObject)); }); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (!(holder is TaskViewHolderBtn vh)) { return; } vh.Title.Text = Data[position].DisplayName; vh.Description.Text = Data[position].Description; AndroidUtils.LoadTaskTypeIcon(Data[position], vh.TaskTypeIcon); }
private int MaximumButtonWidth() { var size = AndroidUtils.MeasureLayout(this, LayoutInflater, Resource.Layout.ChooseChapterButton, setupView: view => { var button = view.FindViewById <Button>(Resource.Id.chooseChapterButton); button.Text = (Structure.Books.Max(x => x.Chapters.Length) + 1).ToString(); }); return(size.Width); }
public void SendSMS(string port, string content) { #if UNITY_ANDROID && !UNITY_EDITOR AndroidUtils.SendSMS(port, content); #elif UNITY_IOS && !UNITY_EDITOR Application.OpenURL("sms:" + port + "?body=" + content); #else PopupAndLoadingScript.instance.messageSytem.OnShow("Soạn tin nhắn theo cú pháp: " + content + " gửi tới " + port); #endif }
private void Adapter_ItemClick(object sender, int position) { TaskType chosenType = adapter.Data[position]; Type activityType = AndroidUtils.GetTaskCreationActivityType(chosenType.IdName); Intent myIntent = new Intent(this, activityType); myIntent.PutExtra("JSON", JsonConvert.SerializeObject(chosenType)); myIntent.PutExtra("PARENT", Intent.GetStringExtra("PARENT")); // null if not a child task StartActivityForResult(myIntent, 200); }
private GetSocialChatAndroid() { using (AndroidJavaObject clazz = new AndroidJavaClass("im.getsocial.sdk.chat.unity.GetSocialChatUnityBridge")) { getSocialChatJavaObject = clazz.CallStatic <AndroidJavaObject>("getInstance"); } if (AndroidUtils.IsJavaNull(getSocialChatJavaObject)) { Debug.LogError(string.Format("Failed to initialize GetSocial Chat module. Please make sure project is configured properly")); } }
/** * UVC機器からの映像受け取り開始要求をする * 通常はStartPreview(string deviceName)経由で呼び出す * @param deviceName UVC機器識別文字列 * @param width * @param height */ private void StartPreview(string deviceName, int width, int height) { #if (!NDEBUG && DEBUG && ENABLE_LOG) Console.WriteLine($"{TAG}StartPreview:{deviceName}({width}x{height})"); #endif var info = Get(deviceName); if (info != null) { // 接続されているとき var supportedVideoSize = GetSupportedVideoSize(deviceName); if (supportedVideoSize == null) { throw new ArgumentException("fauled to get supported video size"); } // 対応解像度のチェック if (supportedVideoSize.Find(width, height /*,minFps=0.1f, maxFps=121.0f*/) == null) { // 指定した解像度に対応していない #if (!NDEBUG && DEBUG && ENABLE_LOG) Console.WriteLine($"{TAG}StartPreview:{width}x{height} is NOT supported."); Console.WriteLine($"{TAG}Info={GetDevice(deviceName)}"); Console.WriteLine($"{TAG}supportedVideoSize={supportedVideoSize}"); #endif throw new ArgumentOutOfRangeException($"{width}x{height} is NOT supported."); } if (info.IsOpen && !info.IsPreviewing) { // openされているけど映像取得中ではないとき info.SetSize(width, height); info.previewTexture = new Texture2D( width, height, TextureFormat.ARGB32, false, /* mipmap */ true /* linear */); var nativeTexPtr = info.previewTexture.GetNativeTexturePtr(); #if (!NDEBUG && DEBUG && ENABLE_LOG) Console.WriteLine($"{TAG}RequestStartPreview:tex={nativeTexPtr}"); #endif using (AndroidJavaClass clazz = new AndroidJavaClass(FQCN_PLUGIN)) { clazz.CallStatic("setPreviewTexture", AndroidUtils.GetCurrentActivity(), deviceName, nativeTexPtr.ToInt32(), -1, // PreviewMode, -1:自動選択(Open時に指定したPreferH264フラグが有効になる) width, height); } StartCoroutine(info.OnRender()); } } else { throw new ArgumentException("device name is empty/null"); } }
/** *请求开始接受UVC机器的影像 *通常通过StartPreview(string deviceName)调用 * @param deviceName UVC機器識別文字列 * @param width * @param height */ private void StartPreview(string deviceName, int width, int height) { AndroidDebug.Logd(TAG, "请求开始接受UVC机器的影像:" + deviceName + "-" + width + "-" + height); var info = Get(deviceName); if (info != null) { //连接时 var supportedVideoSize = GetSupportedVideoSize(deviceName); if (supportedVideoSize == null) { AndroidDebug.Logd(TAG, "连接时:fauled to get supported video size"); throw new ArgumentException("fauled to get supported video size"); } //对应分辨率的检查 if (supportedVideoSize.Find(width, height /*,minFps=0.1f, maxFps=121.0f*/) == null) { //不支持指定的分辨率 #if (!NDEBUG && DEBUG && ENABLE_LOG) Console.WriteLine($"{TAG}StartPreview:{width}x{height} is NOT supported."); Console.WriteLine($"{TAG}Info={GetDevice(deviceName)}"); Console.WriteLine($"{TAG}supportedVideoSize={supportedVideoSize}"); #endif AndroidDebug.Logd(TAG, "不支持指定的分辨率"); throw new ArgumentOutOfRangeException($"{width}x{height} is NOT supported."); } if (info.IsOpen && !info.IsPreviewing) { //被open,但未取得影像时 info.SetSize(width, height); info.previewTexture = new Texture2D( width, height, TextureFormat.ARGB32, false, /* mipmap */ true /* linear */); var nativeTexPtr = info.previewTexture.GetNativeTexturePtr(); AndroidDebug.Logd(TAG, "被open,但未取得影像时:" + nativeTexPtr); using (AndroidJavaClass clazz = new AndroidJavaClass(FQCN_PLUGIN)) { clazz.CallStatic("setPreviewTexture", AndroidUtils.GetCurrentActivity(), deviceName, nativeTexPtr.ToInt32(), -1, //PreviewMode,-1:自动选择(Open时指定的PreferH 264标志有效) width, height); } StartCoroutine(info.OnRender()); } } else { AndroidDebug.Logd(TAG, "StartPreview:device name is empty/null"); throw new ArgumentException("device name is empty/null"); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Check if this is editing an existing task: if so, populate fields string editJson = Intent.GetStringExtra("EDIT") ?? ""; newTask = JsonConvert.DeserializeObject <LearningTask>(editJson); // otherwise, we'll use basic tasktype info string jsonData = Intent.GetStringExtra("JSON") ?? ""; taskType = JsonConvert.DeserializeObject <TaskType>(jsonData, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }); if ((taskType != null && taskType.IdName == "SCAN_QR") || (newTask != null && newTask.TaskType.IdName == "SCAN_QR")) { SetContentView(Resource.Layout.CreateTaskScanQR); } else { SetContentView(Resource.Layout.CreateTask); } TextView taskTypeName = FindViewById <TextView>(Resource.Id.taskTypeNameText); ImageViewAsync image = FindViewById <ImageViewAsync>(Resource.Id.taskIcon); Button addTaskBtn = FindViewById <Button>(Resource.Id.addTaskBtn); addTaskBtn.Click += AddTaskBtn_Click; instructions = FindViewById <EditText>(Resource.Id.taskInstructions); if (newTask != null) { instructions.Text = newTask.Description; taskType = newTask.TaskType; editing = true; addTaskBtn.SetText(Resource.String.saveChanges); } else { // If edit is null just use the tasktype JSON taskType = JsonConvert.DeserializeObject <TaskType>(jsonData, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }); newTask = new LearningTask(); newTask.TaskType = taskType; } taskTypeName.Text = taskType.DisplayName; AndroidUtils.LoadTaskTypeIcon(taskType, image); }
public string ReadFileFromStreamingAssets(string filename) { string plainText = ""; #if UNITY_EDITOR || UNITY_IOS string filePath = Application.streamingAssetsPath + "/" + filename; plainText = File.ReadAllText(filePath); #elif UNITY_ANDROID plainText = AndroidUtils.readFromAssetsFile(filename); #endif return(plainText); }
/** *要求结束从UVC机器接收影像 * @param deviceName UVC设备识别字符串 */ private void RequestStopPreview(string deviceName) { AndroidDebug.Logd(TAG, "要求结束从UVC机器接收影像:" + deviceName); if (!String.IsNullOrEmpty(deviceName)) { using (AndroidJavaClass clazz = new AndroidJavaClass(FQCN_PLUGIN)) { clazz.CallStatic("stopPreview", AndroidUtils.GetCurrentActivity(), deviceName); } } }
public async Task <ApplicationUser> GetCurrentUser() { DatabaseManager manager = await AndroidUtils.GetDbManager().ConfigureAwait(false); if (manager.CurrentUser == null) { // Something bad has happened, log out var suppress = AndroidUtils.ReturnToSignIn(this); } return(manager.CurrentUser); }
public void LoadIfPhotoMatch(View view) { if (learningTask.TaskType.IdName != "MATCH_PHOTO") { return; } ImageViewAsync targetImageView = view.FindViewById <ImageViewAsync>(Resource.Id.targetPhoto); string imageUrl = learningTask.JsonData; AndroidUtils.LoadActivityImageIntoView(targetImageView, imageUrl, activityId, 500); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.CameraActivity); string jsonData = Intent.GetStringExtra("JSON") ?? ""; learningTask = JsonConvert.DeserializeObject <AppTask>(jsonData, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }); activityId = Intent.GetIntExtra("ACTID", -1); if (bundle == null) { if (learningTask.TaskType.IdName == "TAKE_VIDEO") { RequestedOrientation = ScreenOrientation.Landscape; if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { FragmentManager.BeginTransaction().Replace(Resource.Id.container, Camera2VideoFragment.NewInstance()).Commit(); } else { FragmentManager.BeginTransaction().Replace(Resource.Id.container, Camera1VideoFragment.NewInstance()).Commit(); } } else { if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { FragmentManager.BeginTransaction().Replace(Resource.Id.container, Camera2Fragment.NewInstance()).Commit(); } else { FragmentManager.BeginTransaction().Replace(Resource.Id.container, Camera1Fragment.NewInstance()).Commit(); } } } if (!AndroidUtils.IsGooglePlayServicesInstalled(this) || googleApiClient != null) { return; } googleApiClient = new GoogleApiClient.Builder(this) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .AddApi(LocationServices.API) .Build(); locRequest = new LocationRequest(); }
/// <summary> /// Registers the SDK license. This class method and must be called before /// creating any actual MapView instances. /// </summary> /// <param name="licenseKey">The license string provided for this application.</param> /// <param name="context">Application context for the license.</param> /// <returns>True if license is valid, false if not.</returns> public static bool RegisterLicense(string licenseKey, Context context) { // Connect context info and assets manager to native part AndroidUtils.SetContext (context); if (_assetManager == null) { _assetManager = context.ApplicationContext.Assets; AssetUtils.SetAssetManagerPointer(_assetManager); } ISharedPreferences prefs = context.GetSharedPreferences(context.PackageName + "_carto_mobile_sdk1_preferences", FileCreationMode.Private); ReadKeyDelegate readKey = (string key) => { return prefs.GetString(key, null); }; WriteKeyDelegate writeKey = (string key, string value) => { prefs.Edit().PutString(key, value); }; return RegisterLicenseInternal(licenseKey, readKey, writeKey); }
public static ChatMessage ChatMessageFromJavaObject(AndroidJavaObject chatMessageAJO) { User sender = AndroidUtils.UserFromJavaObj(chatMessageAJO.Call <AndroidJavaObject>("getSender")); string guid = chatMessageAJO.Call <string>("getGuid"); DateTime timestamp = AndroidUtils.DateTimeFromJavaUtilDate(chatMessageAJO.Call <AndroidJavaObject>("getTimestamp")); bool wasSentByMe = chatMessageAJO.Call <bool>("wasSentByMe"); // For now - only text messges supproted var msgText = chatMessageAJO.Call <AndroidJavaObject>("getContent").Call <string>("getText"); chatMessageAJO.Dispose(); return(new ChatMessage(sender, guid, timestamp, wasSentByMe, ChatMessageContent.CreateWithText(msgText))); }
private IEnumerator registerPermissions() { if (!AndroidUtils.IsPermitted(AndroidPermission.WRITE_EXTERNAL_STORAGE)) { AndroidUtils.RequestPermission(AndroidPermission.WRITE_EXTERNAL_STORAGE); } yield return(null); if (!AndroidUtils.IsPermitted(AndroidPermission.RECORD_AUDIO))//request this permission to record audio for screen record { AndroidUtils.RequestPermission(AndroidPermission.RECORD_AUDIO); } }