Esempio n. 1
0
        public static string getDeviceInfo(string p_seperator)
        {
            string m_data = "";

            Java.Lang.StringBuilder m_builder = new Java.Lang.StringBuilder();
            m_builder.Append("RELEASE " + Android.OS.Build.VERSION.Release + p_seperator);
            m_builder.Append("DEVICE " + Android.OS.Build.Device + p_seperator);
            m_builder.Append("MODEL " + Android.OS.Build.Model + p_seperator);
            m_builder.Append("PRODUCT " + Android.OS.Build.Product + p_seperator);
            m_builder.Append("BRAND " + Android.OS.Build.Brand + p_seperator);
            m_builder.Append("DISPLAY " + Android.OS.Build.Display + p_seperator);
            // TODO : Android.OS.Build.CPU_ABI is deprecated
            //m_builder.Append("CPU_ABI " + Android.OS.Build.CpuAbi + p_seperator);
            m_builder.Append("CPU_ABI " + Android.OS.Build.SupportedAbis + p_seperator);
            // TODO : Android.OS.Build.CPU_ABI2 is deprecated
            //m_builder.Append("CPU_ABI2 " + Android.OS.Build.CpuAbi2 + p_seperator);
            m_builder.Append("CPU_ABI " + Android.OS.Build.SupportedAbis + p_seperator);
            m_builder.Append("UNKNOWN " + Android.OS.Build.Unknown + p_seperator);
            m_builder.Append("HARDWARE " + Android.OS.Build.Hardware + p_seperator);
            m_builder.Append("ID " + Android.OS.Build.Id + p_seperator);
            m_builder.Append("MANUFACTURER " + Android.OS.Build.Manufacturer + p_seperator);
            m_builder.Append("SERIAL " + Android.OS.Build.Serial + p_seperator);
            //m_builder.Append("SERIAL " + Android.OS.Build.GetSerial() + p_seperator);
            m_builder.Append("USER " + Android.OS.Build.User + p_seperator);
            m_builder.Append("HOST " + Android.OS.Build.Host + p_seperator);
            m_data = m_builder.ToString();
            return(m_data);
        }
Esempio n. 2
0
        private string getDate()
        {
            Java.Lang.StringBuilder strCurrentDate = new Java.Lang.StringBuilder();
            int month = datePicker.Month + 1;

            strCurrentDate.Append("Date: " + month + "/" + datePicker.DayOfMonth + "/" + datePicker.Year);
            return(strCurrentDate.ToString());
        }
Esempio n. 3
0
 protected override FileEntry GetFileEntry(string filename, Java.Lang.StringBuilder errorMessageBuilder)
 {
     try
     {
         return(ConvertFileDescription(App.Kp2a.GetFileStorage(filename).GetFileDescription(ConvertPathToIoc(filename))));
     }
     catch (Exception e)
     {
         if (errorMessageBuilder != null)
         {
             errorMessageBuilder.Append(e.Message);
         }
         Kp2aLog.Log(e.ToString());
         return(null);
     }
 }
Esempio n. 4
0
        private byte[] EncodeParameters(Dictionary <String, String> param, String paramsEncoding)
        {
            var encoderParams = new Java.Lang.StringBuilder();

            try
            {
                foreach (KeyValuePair <String, String> entry in param)
                {
                    encoderParams.Append(Java.Net.URLEncoder.Encode(entry.Key, paramsEncoding));
                    encoderParams.Append('=');
                    encoderParams.Append(Java.Net.URLEncoder.Encode(entry.Value, paramsEncoding));
                    encoderParams.Append('&');
                }
                return(new Java.Lang.String(encoderParams).GetBytes(paramsEncoding));
            }
            catch (Java.IO.UnsupportedEncodingException)
            {
                throw new InvalidOperationException("Encoding not supported:" + paramsEncoding);
            }
        }
    //PostString is Append All parameters
    public string getPostString()
    {
        string TxtStr  = Generate();
        string strHash = Generatehash512(TxtStr + DateTime.Now);
        string txnid   = strHash.ToString().Substring(0, 20);

        string key  = "W5bPaX";             //Key gtKFFx
        string salt = "H7b5NDWN";           //salt eCwWELxi



        Java.Lang.StringBuilder post        = new Java.Lang.StringBuilder();
        Java.Lang.StringBuilder checkSumStr = new Java.Lang.StringBuilder();

        try
        {
            checkSumStr.Append(key);
            checkSumStr.Append("|");
            checkSumStr.Append(txnid);
            checkSumStr.Append("|");
            checkSumStr.Append(1);
            checkSumStr.Append("|");
            checkSumStr.Append(productInfo);
            checkSumStr.Append("|");
            checkSumStr.Append(firstname);
            checkSumStr.Append("|");
            checkSumStr.Append(email);
            checkSumStr.Append("|||||||||||");
            checkSumStr.Append(salt);
            var ss = Generatehash512(checkSumStr.ToString());
            post.Append("key=");
            post.Append(key);
            post.Append("&");
            post.Append("txnid=");
            post.Append(txnid);
            post.Append("&");
            post.Append("amount=");
            post.Append(1);
            post.Append("&");
            post.Append("productinfo=");
            post.Append(productInfo);
            post.Append("&");
            post.Append("firstname=");
            post.Append(firstname);
            post.Append("&");
            post.Append("email=");
            post.Append(email);
            post.Append("&");
            post.Append("phone=");
            post.Append(mobile);
            post.Append("&");
            post.Append("surl=");
            post.Append(SUCCESS_URL);
            post.Append("&");
            post.Append("furl=");
            post.Append(FAILED_URL);
            post.Append("&");
            post.Append("hash=");
            post.Append(ss);
        }
        catch (NoSuchAlgorithmException e1)
        {
            // TODO Auto-generated catch block
            e1.PrintStackTrace();
        }
        return(post.ToString());
    }
Esempio n. 6
0
        public void SaveToFile()
        {
            AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
            dialogBuilder.SetTitle("Save to file");

            View     views = LayoutInflater.Inflate(Resource.Layout.AlertDialog_Save, null);
            EditText input = (EditText)views.FindViewById(Resource.Id.edit);

            int counter = 0;

            Java.Lang.StringBuilder tempName = new Java.Lang.StringBuilder(curSaveName);
            while (true)
            {
                File file = new File(global::Android.OS.Environment.ExternalStorageDirectory + "/ChineseReader/", tempName.ToString() + ".txt");
                if (file.Exists())
                {
                    counter++;
                    tempName.SetLength(0);
                    tempName.Append(curSaveName).Append('(').Append(Convert.ToChar(counter)).Append(')');
                }
                else
                {
                    input.SetText(tempName, TextView.BufferType.Spannable);
                    break;
                }
            }

            dialogBuilder.SetView(views);
            dialogBuilder.SetPositiveButton("Save", delegate { });
            dialogBuilder.SetNegativeButton("Cancel", delegate { });

            AlertDialog alert = dialogBuilder.Show();

            dumpStartButton        = alert.GetButton((int)DialogButtonType.Positive);
            dumpStartButton.Click += (sender, e) =>
            {
                try
                {
                    View view = (View)sender;

                    File dir = new File(global::Android.OS.Environment.ExternalStorageDirectory + "/ChineseReader/");
                    if (!dir.Exists())
                    {
                        dir.Mkdirs();
                    }

                    if (((RadioButton)views.FindViewById(Resource.Id.radio_text)).Checked)
                    {
                        string path = dir.AbsolutePath + "/" + input.Text.ToString() + ".txt";

                        if (annoMode == ANNOTATE_FILE)
                        {
                            System.IO.FileStream fis = new System.IO.FileStream(curFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                            System.IO.FileStream fos = new System.IO.FileStream(path, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                            CopyFile(fis, fos);
                            fis.Close();
                            fos.Close();
                        }
                        else
                        {
                            System.IO.StreamWriter fw = new System.IO.StreamWriter(path);
                            fw.Write(pastedText.Substring(0, pastedText.Length));
                            fw.Flush();
                            fw.Close();
                        }

                        Toast.MakeText(Application, "Saved to " + path, ToastLength.Long).Show();
                    }
                    else if (((RadioButton)views.FindViewById(Resource.Id.radio_pinyin)).Checked)
                    {
                        string path = dir.AbsolutePath + "/" + input.Text.ToString() + ".txt";

                        view.Enabled                = false;
                        dumpFilePath                = path;
                        dumpFileWriter              = new System.IO.StreamWriter(path);
                        dumpProgress                = (ProgressBar)views.FindViewById(Resource.Id.progress);
                        dumpProgressText            = (TextView)views.FindViewById(Resource.Id.progress_text);
                        dumpProgress.Visibility     = ViewStates.Visible;
                        dumpProgressText.Visibility = ViewStates.Visible;
                        dumpCancelled               = false;
                        DumpPinyin(0, 0);
                    }
                    else if (((RadioButton)views.FindViewById(Resource.Id.radio_both)).Checked)
                    {
                        string path = dir.AbsolutePath + "/" + input.Text.ToString() + ".tsv";

                        view.Enabled                = false;
                        dumpFilePath                = path;
                        dumpFileWriter              = new System.IO.StreamWriter(path);
                        dumpProgress                = (ProgressBar)views.FindViewById(Resource.Id.progress);
                        dumpProgressText            = (TextView)views.FindViewById(Resource.Id.progress_text);
                        dumpProgress.Visibility     = ViewStates.Visible;
                        dumpProgressText.Visibility = ViewStates.Visible;
                        dumpCancelled               = false;
                        DumpBoth(0, 0);
                    }
                }
                catch (Exception ex)
                {
                    Toast.MakeText(Application, ex.Message, ToastLength.Long).Show();
                }
            };

            Button dumpCancelButton = alert.GetButton((int)DialogButtonType.Negative);

            dumpCancelButton.Click += (sender, e) =>
            {
                dumpCancelled = true;

                alert.Dismiss();
            };
        }