Beispiel #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.Title = Resources.GetString(Resource.String.pmetrics);
            stillAsk   = true;
            SetContentView(Resource.Layout.metrics_submenu);

            //textViewMetrics = FindViewById<TextView>(Resource.Id.textView_pms5);
            //textViewMetrics.Text += " test instancji\n";
            string[] statOnStart = new string[1];
            //statOnStart[0] = "Loading...: Please wait";
            statOnStart[0]      = Resources.GetString(Resource.String.loading);
            HardwareSeparated1D = statOnStart;

            // Recycler view
            recyclerView_statistics = FindViewById <RecyclerView>(Resource.Id.recyclerView_statistics);
            recyclerView_statistics_layoutManager = new LinearLayoutManager(this);
            recyclerView_statistics.SetLayoutManager(recyclerView_statistics_layoutManager);

            recyclerView_statistics_adapter = new AdapterForStatistics(HardwareSeparated1D);
            recyclerView_statistics.SetAdapter(recyclerView_statistics_adapter);

            client = ClientHolder.Client;
            client.PMReadyAction        = PMReadyDelegate;
            client.PMDataReceivedAction = PMDataReceivedDelegate;

            client.InstantiatePMClient();
        }
Beispiel #2
0
        public void FileReceivedDelegate(string fileName, string fileDescription, string filePath, int fileSize, TextView associatedTextView)
        {
            MimeTypeMap mime      = MimeTypeMap.Singleton;
            string      ext       = fileName.ToLower();
            string      extension = MimeTypeMap.GetFileExtensionFromUrl(ext);
            string      type      = null;

            if (extension != null)
            {
                type = MimeTypeMap.Singleton.GetMimeTypeFromExtension(extension);
            }
            if (type == null)
            {
                type = "application/octet-stream";
            }

            DownloadManager downloadManager = DownloadManager.FromContext(Android.App.Application.Context);

            downloadManager.AddCompletedDownload(fileName, fileDescription, true, type, filePath, fileSize, true);

            CommClientAndroid client2 = ClientHolder.Client;

            client2.RemoveFile(associatedTextView.Text);
            ViewGroup parent = (ViewGroup)associatedTextView.Parent;

            parent.Post(delegate
            {
                parent.RemoveView(associatedTextView);
            });

            client.currentlyDownloadingFile = false;
        }
Beispiel #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.Title = (Resources.GetString(Resource.String.file_transfer));
            SetContentView(Resource.Layout.filetransfer_submenu);

            TryGetStorage();

            transferLayout = FindViewById <LinearLayout>(Resource.Id.linearLayout_filetransfer);


            client = ClientHolder.Client;
            client.FileListReceivedAction = FileListReceivedDelegate;

            client.BrokenFileAction = delegate(string input)
            {
                transferLayout.Post(delegate
                {
                    Toast.MakeText(this, input, ToastLength.Short).Show();
                });
            };

            client.InstantiateTransfer();



            // Create your application here
        }
Beispiel #4
0
        public void FileListReceivedDelegate(List <string> fileList)
        {
            TextView ACTVItem;

            transferLayout = FindViewById <LinearLayout>(Resource.Id.linearLayout_filetransfer);
            transferLayout.Post(() => { int i = 2; });

            transferLayout.Post(() =>
            {
                //Toast.MakeText(this, fileList.Count.ToString(), ToastLength.Short).Show();
                transferLayout.RemoveAllViews();

                foreach (string item in fileList)
                {
                    ACTVItem = new TextView(this);
                    ACTVItem.SetTextAppearance(Android.Resource.Style.TextAppearanceSmall);
                    float factor = this.Resources.DisplayMetrics.Density;
                    LinearLayout.LayoutParams paramss = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, (int)(40 * factor));
                    paramss.SetMargins(2, 2, 2, 2);
                    ACTVItem.LayoutParameters = paramss;
                    ACTVItem.TextAlignment    = TextAlignment.Center;
                    ACTVItem.Clickable        = true;
                    ACTVItem.Focusable        = true;
                    ACTVItem.Background       = GetDrawable(Resource.Drawable.ACTextViewBackground);
                    ACTVItem.Gravity          = GravityFlags.Center;

                    ACTVItem.Text = item;

                    ACTVItem.Click += (o, e) =>
                    {
                        TextView oo = o as TextView;

                        const string permission = Android.Manifest.Permission.WriteExternalStorage;
                        if (CheckSelfPermission(permission) == (int)Permission.Granted)
                        {
                            CommClientAndroid client  = ClientHolder.Client;
                            client.FileReceivedAction = FileReceivedDelegate;
                            client.ProgressBarAction  = ProgressBarDelegate;

                            if (client.currentlyDownloadingFile == false)
                            {
                                client.DownloadFile(oo.Text, oo);
                            }

                            //client.RemoveFile(oo.Text);
                            //ViewGroup parent = (ViewGroup)oo.Parent;
                            //parent.RemoveView(oo);
                        }
                        else
                        {
                            Toast.MakeText(this, Resources.GetString(Resource.String.insufficient_permisions), ToastLength.Long).Show();
                        }
                    };

                    transferLayout.AddView(ACTVItem);
                }
            });
        }
Beispiel #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.Title = Resources.GetString(Resource.String.menu);
            SetContentView(Resource.Layout.main_menu);
            string ip = Intent.GetStringExtra("IP" ?? "not recv");

            client = ClientHolder.Client;

            var txtIP = FindViewById <TextView>(Resource.Id.textIPInfo);

            if (client != null)
            {
                txtIP.Text += " " + ip;
            }
            else
            {
                txtIP.Text = "client not inst";
            }

            var buttonVolume = FindViewById <Button>(Resource.Id.buttonVolume);

            buttonVolume.Click += (o, e) => {
                Intent volumeActivity = new Intent(this, typeof(VolumeActivity));
                StartActivity(volumeActivity);
            };

            Button buttonMetrics = FindViewById <Button>(Resource.Id.buttonMetrics);

            buttonMetrics.Click += (o, e) =>
            {
                Intent metricsActivity = new Intent(this, typeof(MetricsActivity));
                StartActivity(metricsActivity);
            };

            Button buttonFiles = FindViewById <Button>(Resource.Id.buttonFileTransfer);

            buttonFiles.Click += (o, e) =>
            {
                Intent fileActivity = new Intent(this, typeof(FileTransferActivity));
                StartActivity(fileActivity);
            };

            Button buttonNumpad = FindViewById <Button>(Resource.Id.buttonNumpad);

            buttonNumpad.Click += (o, e) =>
            {
                Intent numpadActivity = new Intent(this, typeof(NumpadActivity));
                StartActivity(numpadActivity);
            };



            // Create your application here
        }
Beispiel #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.imageview_submenu);

            client = ClientHolder.Client;



            // Create your application here
        }
Beispiel #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.Title = Resources.GetString(Resource.String.numpad);
            client     = ClientHolder.Client;
            // client.NumpadInstantiate();
            SetContentView(Resource.Layout.numpad_submenu);

            int[] tab =
            {
                Resource.Id.one,
                Resource.Id.two,
                Resource.Id.three,
                Resource.Id.four,
                Resource.Id.five,
                Resource.Id.six,
                Resource.Id.seven,
                Resource.Id.eight,
                Resource.Id.nine,
                Resource.Id.zero,
                Resource.Id.dot,
                Resource.Id.plus,
                Resource.Id.minus,
                Resource.Id.div,
                Resource.Id.razy,
                Resource.Id.equal
            };



            foreach (int id in tab)
            {
                Button b = FindViewById <Button>(id);
                b.Click += NumClick;
            }


            // Create your application here
        }
Beispiel #8
0
        public void OpenPasswordInputDialogDelegate(string input)
        {
            Button button = FindViewById <Button>(Resource.Id.buttonConnect);

            button.Post(() =>
            {
                Toast.MakeText(this, input, ToastLength.Short).Show();


                Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);

                //LayoutInflater inflater = this.LayoutInflater;
                //View view = inflater.Inflate(Resource.Layout.password_dialog, null);

                EditText inputEditText      = new EditText(this);
                inputEditText.InputType     = Android.Text.InputTypes.ClassNumber | Android.Text.InputTypes.NumberVariationPassword;
                FrameLayout container       = new FrameLayout(this);
                FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                // int sixteenindp = ClientUtilities.ConvertPixelsToDP(80, this);
                lp.SetMargins(40, 40, 40, 40);
                inputEditText.LayoutParameters = lp;
                container.AddView(inputEditText);

                builder.SetView(container);
                builder.SetMessage(Resources.GetString(Resource.String.password_req));
                builder.SetCancelable(false);
                builder.SetPositiveButton("OK", (o, e) =>
                {
                    string passwordString    = inputEditText.Text;
                    CommClientAndroid client = ClientHolder.Client;
                    client.SendPassword(passwordString);
                });

                Android.App.AlertDialog aletrDialog = builder.Create();
                aletrDialog.Show();
            });
        }
Beispiel #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            // TextView testView = FindViewById<TextView>(Resource.Id.textView_test);
            EditText textBoxIP        = FindViewById <EditText>(Resource.Id.textBoxIP);
            Button   buttonAutoConfig = FindViewById <Button>(Resource.Id.button_autoconfig);

            //do szybkiego wpisywania adresu mojego kompa
            //testView.Click += (o, e) =>
            //{
            //    textBoxIP.Text = testView.Text;
            //};

            //pzycisk connect
            FindViewById <Button>(Resource.Id.buttonConnect).Click += (o, e) =>
            {
                bool     isConnected     = false;
                EditText IPinputEditText = FindViewById <EditText>(Resource.Id.textBoxIP);

                try                                                                   //sprawdzam
                {
                    if (ClientUtilities.IsValidIPV4Address(IPinputEditText.Text))     //czy adres jest valid
                    {
                        iPAddress            = IPAddress.Parse(IPinputEditText.Text); //jak tak parsuje i daje pozwolenie na przejscie do menu
                        canProceedToMainMenu = true;
                    }
                    else
                    {
                        Toast.MakeText(this, Resources.GetString(Resource.String.invalid_ip), ToastLength.Short).Show();   //jak nie wyswietlam i nie daje pozwolenia
                        canProceedToMainMenu = false;
                    }
                }
                catch (Exception e2)
                {
                    Toast.MakeText(this, e2.Message, ToastLength.Short).Show(); //jak sie crashnie to tez nie pozwalam, ale nie wiem czy jest w stanie sie crashnac. zostawic i tak
                    canProceedToMainMenu = false;
                }

                if (canProceedToMainMenu == true)   //jesli pozwalam na przejscie do menu
                {
                    try
                    {
                        if (listeningFlag == false) //???
                        {
                            listeningFlag = true;

                            client = new CommClientAndroid(iPAddress, SetText2);
                            client.DisconnectAction = DisconnectDelegate;
                            client.OpenPasswordInputDialogAction = OpenPasswordInputDialogDelegate;
                            ClientHolder.Client    = client;
                            client.ConnectedAction = ConnectedDelegate;
                            client.DownloadPath    = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, Android.OS.Environment.DirectoryDownloads);

                            isConnected = true;
                        }
                        else
                        {
                            Toast.MakeText(this, Resources.GetString(Resource.String.connecting), ToastLength.Short).Show();
                            //chyba chodzi o to, ze jak nacisnie sie drugi raz connect podczas connectowania, to nie stworzy sie kolejny klient?
                        }
                    }
                    catch (Exception ex)
                    {
                        Toast.MakeText(this, ex.Message, ToastLength.Long).Show();  //jak sie nie polaczy wyswietla sie toast
                    }

                    if (isConnected == true)    //jak jest polaczony
                    {
                        //Intent nextActivity = new Intent(this, typeof(MainMenuActivity));
                        //nextActivity.PutExtra("IP", iPAddress.ToString());
                        //StartActivity(nextActivity);
                    }
                }
            };

            //do autoconfiga
            buttonAutoConfig.Click += (o, e) =>
            {
                autoConfigClient = new AutoConfigAndroid();
                autoConfigClient.FinishAction = AutoConfigFinished;
                autoConfigClient.Listen();
            };
        }
Beispiel #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.Title         = Resources.GetString(Resource.String.volume);
            client             = ClientHolder.Client;
            client.volumeReady = false;

            //instantiate sliders
            client.InstantiateVolumeClient();

            while (client.volumeReady == false)
            {
                Thread.Sleep(10);
            }

            SetContentView(Resource.Layout.volume_submenu);

            //inst buttons
            Button playpausebutton = FindViewById <Button>(Resource.Id.button_play_pause);
            Button nextmediaButton = FindViewById <Button>(Resource.Id.button_skip_right);
            Button prevmediaButton = FindViewById <Button>(Resource.Id.button_skip_left);

            playpausebutton.Click += (o, e) =>
            {
                client.SendKey("PP");
            };

            nextmediaButton.Click += (o, e) =>
            {
                client.SendKey("NEXT");
            };

            prevmediaButton.Click += (o, e) =>
            {
                client.SendKey("PREV");
            };

            var linearLayoutVolume = FindViewById <LinearLayout>(Resource.Id.linearLayoutVolume);

            foreach (VolumeAndroid volume in client.VolumeListForAndroid)
            {
                LinearLayout layout2 = new LinearLayout(this);          //horizontal layout = ikona + text
                LinearLayout.LayoutParams layout2Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, 100);
                layout2.LayoutParameters = layout2Params;
                layout2.Orientation      = Orientation.Horizontal;

                ImageView iv = new ImageView(this);                     //imageView ikony
                iv.LayoutParameters = new LinearLayout.LayoutParams(100, 100);

                if (volume.ProcessName != "System Volume")
                {
                    Bitmap bmp = BitmapFactory.DecodeByteArray(volume.IconByteArray, 0, volume.IconByteArray.Length);
                    iv.SetImageBitmap(bmp);                                 //wbijanie ikony do imageview
                }
                else
                {
                    Drawable drawable = GetDrawable(Resource.Drawable.baseline_volume_up_white_48);
                    iv.SetImageDrawable(drawable);
                }

                TextView textView = new TextView(this);                 //opis sesji
                LinearLayout.LayoutParams paramss = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, 100);
                textView.LayoutParameters = paramss;

                Slider2 slider = new Slider2(this);

                if (volume.DisplayName != "null" && volume.DisplayName != "")   //ustalanie ktory name bedzie wybrany do opisu sesji
                {
                    textView.Text = volume.DisplayName;
                }
                else if (volume.ProcessName != "null")
                {
                    textView.Text = volume.ProcessName;
                }
                else
                {
                    textView.Text = "unknown process";
                }
                // textView.Text += " " + volume.ProcessID;

                if (textView.Text.Contains("AudioSrv", StringComparison.InvariantCultureIgnoreCase))
                {
                    textView.Text = "System sounds";
                }

                //linearLayoutVolume.AddView(textView);
                linearLayoutVolume.AddView(layout2);        //inner horizontal layout
                layout2.AddView(iv);
                layout2.AddView(textView);

                slider.MASTER_ID    = volume.ProcessID;     //slider insta
                slider.PROCESS_NAME = volume.ProcessName;

                slider.DISPLAY_NAME = volume.DisplayName;

                slider.Progress = (int)volume.Volume;

                slider.ProgressChanged += Slider_ProgressChanged; //slider event

                linearLayoutVolume.AddView(slider);               //slider po layout2
            }
        }