Example #1
0
        internal static void showDialog(FragmentManager manager, string title, EntryInfo entryInfo)
        {
            Bundle args = new Bundle();

            args.putString(KEY_TITLE, title);
            args.putParcelable(KEY_ENTRY_INFO, entryInfo);

            EntryDialogFragment dialogFragment = new EntryDialogFragment();

            dialogFragment.Arguments = args;
            dialogFragment.show(manager, typeof(EntryDialogFragment).Name);
        }
Example #2
0
        public override void onItemSelected <T1>(AdapterView <T1> parent, View view, int position, long id)
        {
            switch (parent.Id)
            {
            case R.id.spinnerDeviceBus:
                switch (position)
                {
                case 0:                 // Bluetooth
                case 4:                 // Wi-Fi Direct
                    setAddressLayout(LAYOUT_MAC_ADDRESS, true);
                    delimiter = ":";

                    string[]  deviceBuses = Resources.getStringArray(R.array.device_bus);
                    EntryInfo entryInfo   = Arguments.getParcelable(KEY_ENTRY_INFO);
                    if (entryInfo != null && entryInfo.DeviceBus.Equals(deviceBuses[position]))
                    {
                        AddressText = entryInfo.Address;
                    }
                    break;

                case 1:                 // Ethernet
                case 3:                 // Wi-Fi
                    setAddressLayout(LAYOUT_IP_ADDRESS, false);
                    delimiter = ".";

                    deviceBuses = Resources.getStringArray(R.array.device_bus);
                    entryInfo   = Arguments.getParcelable(KEY_ENTRY_INFO);
                    if (entryInfo != null && entryInfo.DeviceBus.Equals(deviceBuses[position]))
                    {
                        AddressText = entryInfo.Address;
                    }
                    break;

                case 2:                 // USB
                default:
                    setAddressLayout(LAYOUT_NONE, false);
                    break;
                }
                break;

            case R.id.spinnerProductName:
                EntryInfo entryInfo = Arguments.getParcelable(KEY_ENTRY_INFO);
                if (entryInfo == null)
                {
                    string text = ((TextView)view).Text.ToString();
                    logicalNameEditText.Text      = text;
                    logicalNameEditText.Selection = text.Length;
                }
                break;
            }
        }
Example #3
0
        public virtual void onClick(bool isModified, EntryInfo entryInfo)
        {
            string[] deviceCategories = Resources.getStringArray(R.array.device_categories);
            int      deviceCategory   = 0;

            if (entryInfo.DeviceCategory.Equals(deviceCategories[0]))
            {
                deviceCategory = BXLConfigLoader.DEVICE_CATEGORY_CASH_DRAWER;
            }
            else if (entryInfo.DeviceCategory.Equals(deviceCategories[1]))
            {
                deviceCategory = BXLConfigLoader.DEVICE_CATEGORY_MSR;
            }
            else if (entryInfo.DeviceCategory.Equals(deviceCategories[2]))
            {
                deviceCategory = BXLConfigLoader.DEVICE_CATEGORY_POS_PRINTER;
            }
            else if (entryInfo.DeviceCategory.Equals(deviceCategories[3]))
            {
                deviceCategory = BXLConfigLoader.DEVICE_CATEGORY_SMART_CARD_RW;
            }

            string[] deviceBuses = Resources.getStringArray(R.array.device_bus);
            int      deviceBus   = 0;

            if (entryInfo.DeviceBus.Equals(deviceBuses[0]))
            {
                deviceBus = BXLConfigLoader.DEVICE_BUS_BLUETOOTH;
            }
            else if (entryInfo.DeviceBus.Equals(deviceBuses[1]))
            {
                deviceBus = BXLConfigLoader.DEVICE_BUS_ETHERNET;
            }
            else if (entryInfo.DeviceBus.Equals(deviceBuses[2]))
            {
                deviceBus = BXLConfigLoader.DEVICE_BUS_USB;
            }
            else if (entryInfo.DeviceBus.Equals(deviceBuses[3]))
            {
                deviceBus = BXLConfigLoader.DEVICE_BUS_WIFI;
            }
            else if (entryInfo.DeviceBus.Equals(deviceBuses[4]))
            {
                deviceBus = BXLConfigLoader.DEVICE_BUS_WIFI_DIRECT;
            }

            if (isModified)
            {
                bxlConfigLoader.modifyEntry(entryInfo.LogicalName, deviceBus, entryInfo.Address);
            }
            else
            {
                try
                {
                    bxlConfigLoader.addEntry(entryInfo.LogicalName, deviceCategory, entryInfo.ProductName, deviceBus, entryInfo.Address);
                    arrayAdapter.add(entryInfo.LogicalName);
                }
                catch (System.ArgumentException e)
                {
                    Console.WriteLine(e.ToString());
                    Console.Write(e.StackTrace);
                    Toast.makeText(this, e.Message, Toast.LENGTH_SHORT).show();
                }
            }
        }
Example #4
0
        public override bool onContextItemSelected(MenuItem item)
        {
            AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.MenuInfo;
            string logicalName          = ((TextView)info.targetView).Text.ToString();

            switch (item.ItemId)
            {
            case R.id.context_modify_entry:
                int    deviceCategory = bxlConfigLoader.getDeviceCategory(logicalName);
                string dc             = null;
                switch (deviceCategory)
                {
                case BXLConfigLoader.DEVICE_CATEGORY_CASH_DRAWER:
                    dc = Resources.getStringArray(R.array.device_categories)[0];
                    break;

                case BXLConfigLoader.DEVICE_CATEGORY_MSR:
                    dc = Resources.getStringArray(R.array.device_categories)[1];
                    break;

                case BXLConfigLoader.DEVICE_CATEGORY_POS_PRINTER:
                    dc = Resources.getStringArray(R.array.device_categories)[2];
                    break;

                case BXLConfigLoader.DEVICE_CATEGORY_SMART_CARD_RW:
                    dc = Resources.getStringArray(R.array.device_categories)[3];
                    break;
                }

                int    deviceBus = bxlConfigLoader.getDeviceBus(logicalName);
                string db        = null;
                switch (deviceBus)
                {
                case BXLConfigLoader.DEVICE_BUS_BLUETOOTH:
                    db = Resources.getStringArray(R.array.device_bus)[0];
                    break;

                case BXLConfigLoader.DEVICE_BUS_ETHERNET:
                    db = Resources.getStringArray(R.array.device_bus)[1];
                    break;

                case BXLConfigLoader.DEVICE_BUS_USB:
                    db = Resources.getStringArray(R.array.device_bus)[2];
                    break;

                case BXLConfigLoader.DEVICE_BUS_WIFI:
                    db = Resources.getStringArray(R.array.device_bus)[3];
                    break;

                case BXLConfigLoader.DEVICE_BUS_WIFI_DIRECT:
                    db = Resources.getStringArray(R.array.device_bus)[4];
                    break;
                }

                EntryInfo entryInfo = new EntryInfo(logicalName, dc, bxlConfigLoader.getProductName(logicalName), db, bxlConfigLoader.getAddress(logicalName));
                EntryDialogFragment.showDialog(SupportFragmentManager, "Modify entry", entryInfo);
                return(true);

            case R.id.context_remove_entry:
                if (bxlConfigLoader.removeEntry(logicalName))
                {
                    arrayAdapter.remove(logicalName);
                }
                else
                {
                    Toast.makeText(this, "Remove failed", Toast.LENGTH_SHORT).show();
                }
                return(true);

            default:
                return(base.onContextItemSelected(item));
            }
        }
Example #5
0
        public override Dialog onCreateDialog(Bundle savedInstanceState)
        {
            EntryInfo entryInfo = Arguments.getParcelable(KEY_ENTRY_INFO);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final boolean isModifying = (entryInfo != null);
            bool isModifying = (entryInfo != null);

            LayoutInflater inflater = Activity.LayoutInflater;

            View view = inflater.inflate(R.layout.dialog_entry, (ViewGroup)Activity.findViewById(android.R.id.content).RootView, false);

            logicalNameEditText = (EditText)view.findViewById(R.id.editTextLogicalName);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.widget.Spinner deviceCategorySpinner = (android.widget.Spinner) view.findViewById(com.bxl.postest.R.id.spinnerDeviceCategory);
            Spinner deviceCategorySpinner = (Spinner)view.findViewById(R.id.spinnerDeviceCategory);

            deviceCategorySpinner.Selection = 2;             // POSPrinter

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.widget.Spinner productNameSpinner = (android.widget.Spinner) view.findViewById(com.bxl.postest.R.id.spinnerProductName);
            Spinner productNameSpinner = (Spinner)view.findViewById(R.id.spinnerProductName);

            productNameSpinner.OnItemSelectedListener = this;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.widget.Spinner deviceBusSpinner = (android.widget.Spinner) view.findViewById(com.bxl.postest.R.id.spinnerDeviceBus);
            Spinner deviceBusSpinner = (Spinner)view.findViewById(R.id.spinnerDeviceBus);

            deviceBusSpinner.OnItemSelectedListener = this;
            addressLinearLayout = (LinearLayout)view.findViewById(R.id.linearLayoutAddress);

            if (isModifying)
            {
                logicalNameEditText.Text      = entryInfo.LogicalName;
                logicalNameEditText.Enabled   = false;
                logicalNameEditText.InputType = InputType.TYPE_NULL;

                string[] deviceCategories = Resources.getStringArray(R.array.device_categories);
                for (int i = 0; i < deviceCategories.Length; i++)
                {
                    if (deviceCategories[i].Equals(entryInfo.DeviceCategory))
                    {
                        deviceCategorySpinner.Selection = i;
                        break;
                    }
                }
                deviceCategorySpinner.Enabled = false;

                string[] productNames = Resources.getStringArray(R.array.product_name);
                for (int i = 0; i < productNames.Length; i++)
                {
                    if (productNames[i].Equals(entryInfo.ProductName))
                    {
                        productNameSpinner.Selection = i;
                        break;
                    }
                }
                productNameSpinner.Enabled = false;

                string[] deviceBuses = Resources.getStringArray(R.array.device_bus);
                for (int i = 0; i < deviceBuses.Length; i++)
                {
                    if (deviceBuses[i].Equals(entryInfo.DeviceBus))
                    {
                        deviceBusSpinner.Selection = i;
                        break;
                    }
                }
            }

            string title = Arguments.getString(KEY_TITLE);

            AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
            builder.setView(view).setTitle(title).setPositiveButton("OK", new OnClickListenerAnonymousInnerClassHelper(this, entryInfo, isModifying, deviceCategorySpinner, productNameSpinner, deviceBusSpinner))
            .setNegativeButton("Cancel", new OnClickListenerAnonymousInnerClassHelper2(this));
            return(builder.create());
        }
Example #6
0
            public override void onClick(DialogInterface dialog, int which)
            {
                EntryInfo entryInfo = new EntryInfo(outerInstance.logicalNameEditText.Text.ToString(), (string)deviceCategorySpinner.SelectedItem, (string)productNameSpinner.SelectedItem, (string)deviceBusSpinner.SelectedItem, outerInstance.AddressText);

                outerInstance.onClickListener.onClick(isModifying, entryInfo);
            }