protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Log.Debug(TAG, "OnCreate"); //create a new kid //RandomString rString = new RandomString(); //k_id = RandomString.GetRandomString(32); //Log.Debug(TAG, "session_id = " + k_id); context = Android.App.Application.Context; //get virtual keyboard imm = (InputMethodManager)GetSystemService(Activity.InputMethodService); //get default prefs = PreferenceManager.GetDefaultSharedPreferences(this); //pda type pda_type = prefs.GetInt("PDA_TYPE", 0); //default port web_soap_port = prefs.GetString("WEB_SOAP_PORT", "8484"); //save current kid //editor = prefs.Edit(); //editor.PutString("CURRENT_K_ID", k_id); //editor.Apply(); SetContentView(Resource.Layout.activity_main); //Android.Support.V7.Widget.Toolbar toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); myToolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(myToolbar); /*FloatingActionButton fab = FindViewById<FloatingActionButton>(Resource.Id.fab); * fab.Click += FabOnClick;*/ DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, myToolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close); drawer.AddDrawerListener(toggle); toggle.SyncState(); NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); navigationView.SetNavigationItemSelectedListener(this); View headerLayout = navigationView.GetHeaderView(0); empID = headerLayout.FindViewById <TextView>(Resource.Id.empId); menuItemLogin = navigationView.Menu.FindItem(Resource.Id.nav_login); menuItemLogout = navigationView.Menu.FindItem(Resource.Id.nav_logout); //menuItemReceiveGoods = navigationView.Menu.FindItem(Resource.Id.nav_receiving); //menuItemShipment = navigationView.Menu.FindItem(Resource.Id.nav_shipment); menuItemSearch = navigationView.Menu.FindItem(Resource.Id.nav_search); menuItemAllocationSendMsg = navigationView.Menu.FindItem(Resource.Id.nav_allocation_send_msg); menuItemAllocation = navigationView.Menu.FindItem(Resource.Id.nav_allocation); menuItemEnteringWareHouse = navigationView.Menu.FindItem(Resource.Id.nav_entering_warehouse); menuItemProductionStorage = navigationView.Menu.FindItem(Resource.Id.nav_production_storage); //menuItemProductionStorage = navigationView.Menu.FindItem(Resource.Id.nav_production_storage); //menuItemReceivingInspection = navigationView.Menu.FindItem(Resource.Id.nav_receiving_inspection); if (!isLogin) { Fragment fragment = new LoginFragment(); fragmentManager = this.FragmentManager; FragmentTransaction fragmentTx = fragmentManager.BeginTransaction(); //fragmentTx.Add(Resource.Id.flContent, fragment); fragmentTx.Replace(Resource.Id.flContent, fragment); fragmentTx.Commit(); } //broadcast receiver if (!isRegister) { IntentFilter filter = new IntentFilter(); mReceiver = new MyBoradcastReceiver(); filter.AddAction(Constants.SOAP_CONNECTION_FAIL); filter.AddAction(Constants.ACTION_SOCKET_TIMEOUT); filter.AddAction(Constants.ACTION_LOGIN_FAIL); filter.AddAction(Constants.ACTION_LOGIN_SUCCESS); filter.AddAction(Constants.ACTION_LOGOUT_ACTION); filter.AddAction(Constants.ACTION_SETTING_PDA_TYPE_ACTION); filter.AddAction(Constants.ACTION_SETTING_WEB_SOAP_PORT_ACTION); //filter.AddAction(Constants.ACTION_ENTERING_WAREHOUSE_INTO_STOCK_SHOW_DIALOG); filter.AddAction(Constants.ACTION_SEARCH_MENU_SHOW_ACTION); filter.AddAction(Constants.ACTION_SEARCH_MENU_HIDE_ACTION); filter.AddAction(Constants.ACTION_RESET_TITLE_PART_IN_STOCK); RegisterReceiver(mReceiver, filter); isRegister = true; } }
public void selectDrawerItem(IMenuItem item) { Fragment fragment = null; string title = ""; if (CurrentFocus != null) { imm.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0); } /*if (item.ItemId == Resource.Id.nav_receiving) * { * fragment = new ReceiveFragment(); * * title = Resources.GetString(Resource.String.action_receiving_main); * receiving_main.SetVisible(true); * receiving_record.SetVisible(true); * receiving_board.SetVisible(true); * receiving_multi.SetVisible(true); * shipment_main.SetVisible(false); * shipment_find.SetVisible(false); * allocation_find.SetVisible(false); * allocation_replenishment.SetVisible(false); * allocation_send_msg.SetVisible(false); * allocation_msg.SetVisible(false); * allocation_area_confirm.SetVisible(false); * allocation_direct.SetVisible(false); * entering_warehouse_main.SetVisible(false); * entering_warehouse_find.SetVisible(false); * production_storage_main.SetVisible(false); * production_storage_find.SetVisible(false); * production_storage_scan.SetVisible(false); * } * else if(item.ItemId == Resource.Id.nav_shipment) * { * fragment = new ShipmentFragment(); * * title = Resources.GetString(Resource.String.action_shipment_main); * receiving_main.SetVisible(false); * receiving_record.SetVisible(false); * receiving_board.SetVisible(false); * receiving_multi.SetVisible(false); * shipment_main.SetVisible(true); * shipment_find.SetVisible(true); * allocation_find.SetVisible(false); * allocation_replenishment.SetVisible(false); * allocation_send_msg.SetVisible(false); * allocation_msg.SetVisible(false); * allocation_area_confirm.SetVisible(false); * allocation_direct.SetVisible(false); * entering_warehouse_main.SetVisible(false); * entering_warehouse_find.SetVisible(false); * production_storage_main.SetVisible(false); * production_storage_find.SetVisible(false); * production_storage_scan.SetVisible(false); * } * else*/ if (item.ItemId == Resource.Id.nav_search) { fragment = new LookupInStockFragment(); title = Resources.GetString(Resource.String.action_allocation_find); searchFilter.SetVisible(false); receiving_main.SetVisible(false); receiving_record.SetVisible(false); receiving_board.SetVisible(false); receiving_multi.SetVisible(false); shipment_main.SetVisible(false); shipment_find.SetVisible(false); allocation_find.SetVisible(false); allocation_replenishment.SetVisible(false); allocation_send_msg.SetVisible(false); allocation_msg.SetVisible(false); allocation_area_confirm.SetVisible(false); allocation_direct.SetVisible(false); entering_warehouse_main.SetVisible(false); entering_warehouse_find.SetVisible(false); production_storage_main.SetVisible(false); production_storage_find.SetVisible(false); production_storage_scan.SetVisible(false); } else if (item.ItemId == Resource.Id.nav_allocation_send_msg) { Log.Debug(TAG, "Send msg"); fragment = new AllocationSendMsgToReserveWarehouseFragment(); title = Resources.GetString(Resource.String.action_allocation_send_msg_to_reserve); searchFilter.SetVisible(false); receiving_main.SetVisible(false); receiving_record.SetVisible(false); receiving_board.SetVisible(false); receiving_multi.SetVisible(false); shipment_main.SetVisible(false); shipment_find.SetVisible(false); allocation_find.SetVisible(true); allocation_replenishment.SetVisible(true); allocation_send_msg.SetVisible(true); allocation_msg.SetVisible(true); allocation_area_confirm.SetVisible(true); allocation_direct.SetVisible(true); entering_warehouse_main.SetVisible(false); entering_warehouse_find.SetVisible(false); production_storage_main.SetVisible(false); production_storage_find.SetVisible(false); production_storage_scan.SetVisible(false); } else if (item.ItemId == Resource.Id.nav_allocation) { fragment = new AllocationMsgFragment(); title = Resources.GetString(Resource.String.action_allocation_msg); searchFilter.SetVisible(false); receiving_main.SetVisible(false); receiving_record.SetVisible(false); receiving_board.SetVisible(false); receiving_multi.SetVisible(false); shipment_main.SetVisible(false); shipment_find.SetVisible(false); allocation_find.SetVisible(true); allocation_replenishment.SetVisible(true); allocation_send_msg.SetVisible(true); allocation_msg.SetVisible(true); allocation_area_confirm.SetVisible(true); allocation_direct.SetVisible(true); entering_warehouse_main.SetVisible(false); entering_warehouse_find.SetVisible(false); production_storage_main.SetVisible(false); production_storage_find.SetVisible(false); production_storage_scan.SetVisible(false); } else if (item.ItemId == Resource.Id.nav_entering_warehouse) { fragment = new EnteringWarehouseFragment(); title = Resources.GetString(Resource.String.action_entering_warehouse_main); searchFilter.SetVisible(false); receiving_main.SetVisible(false); receiving_record.SetVisible(false); receiving_board.SetVisible(false); receiving_multi.SetVisible(false); shipment_main.SetVisible(false); shipment_find.SetVisible(false); allocation_find.SetVisible(false); allocation_replenishment.SetVisible(false); allocation_send_msg.SetVisible(false); allocation_msg.SetVisible(false); allocation_area_confirm.SetVisible(false); allocation_direct.SetVisible(false); entering_warehouse_main.SetVisible(true); entering_warehouse_find.SetVisible(true); production_storage_main.SetVisible(false); production_storage_find.SetVisible(false); production_storage_scan.SetVisible(false); } else if (item.ItemId == Resource.Id.nav_production_storage) { fragment = new ProductionStorageFragment(); title = Resources.GetString(Resource.String.action_production_storage_main); receiving_main.SetVisible(false); receiving_record.SetVisible(false); receiving_board.SetVisible(false); receiving_multi.SetVisible(false); shipment_main.SetVisible(false); shipment_find.SetVisible(false); allocation_find.SetVisible(false); allocation_replenishment.SetVisible(false); allocation_send_msg.SetVisible(false); allocation_msg.SetVisible(false); allocation_area_confirm.SetVisible(false); allocation_direct.SetVisible(false); entering_warehouse_main.SetVisible(false); entering_warehouse_find.SetVisible(false); production_storage_main.SetVisible(true); production_storage_find.SetVisible(true); production_storage_scan.SetVisible(true); }/* * else if (item.ItemId == Resource.Id.nav_receiving_inspection) * { * fragment = new ReceivingInspectionFragment(); * * title = Resources.GetString(Resource.String.action_receiving_inspection_main); * receiving_main.SetVisible(false); * receiving_record.SetVisible(false); * receiving_board.SetVisible(false); * receiving_multi.SetVisible(false); * shipment_main.SetVisible(false); * shipment_find.SetVisible(false); * allocation_find.SetVisible(false); * allocation_replenishment.SetVisible(false); * allocation_send_msg.SetVisible(false); * allocation_msg.SetVisible(false); * allocation_area_confirm.SetVisible(false); * allocation_direct.SetVisible(false); * entering_warehouse_main.SetVisible(false); * entering_warehouse_find.SetVisible(false); * production_storage_main.SetVisible(false); * production_storage_find.SetVisible(false); * production_storage_scan.SetVisible(false); * }*/ else if (item.ItemId == Resource.Id.nav_setting) { fragment = new Settingfragment(); title = Resources.GetString(Resource.String.action_settings); receiving_main.SetVisible(false); receiving_record.SetVisible(false); receiving_board.SetVisible(false); receiving_multi.SetVisible(false); shipment_main.SetVisible(false); shipment_find.SetVisible(false); allocation_find.SetVisible(false); allocation_replenishment.SetVisible(false); allocation_send_msg.SetVisible(false); allocation_msg.SetVisible(false); allocation_area_confirm.SetVisible(false); allocation_direct.SetVisible(false); entering_warehouse_main.SetVisible(false); entering_warehouse_find.SetVisible(false); production_storage_main.SetVisible(false); production_storage_find.SetVisible(false); production_storage_scan.SetVisible(false); } else if (item.ItemId == Resource.Id.nav_login) { fragment = new LoginFragment(); title = Resources.GetString(Resource.String.nav_login); receiving_main.SetVisible(false); receiving_record.SetVisible(false); receiving_board.SetVisible(false); receiving_multi.SetVisible(false); shipment_main.SetVisible(false); shipment_find.SetVisible(false); allocation_find.SetVisible(false); allocation_replenishment.SetVisible(false); allocation_send_msg.SetVisible(false); allocation_msg.SetVisible(false); allocation_area_confirm.SetVisible(false); allocation_direct.SetVisible(false); entering_warehouse_main.SetVisible(false); entering_warehouse_find.SetVisible(false); production_storage_main.SetVisible(false); production_storage_find.SetVisible(false); production_storage_scan.SetVisible(false); } else if (item.ItemId == Resource.Id.nav_logout) { fragment = new LogoutFragment(); title = Resources.GetString(Resource.String.nav_logout); receiving_main.SetVisible(false); receiving_record.SetVisible(false); receiving_board.SetVisible(false); receiving_multi.SetVisible(false); shipment_main.SetVisible(false); shipment_find.SetVisible(false); allocation_find.SetVisible(false); allocation_replenishment.SetVisible(false); allocation_send_msg.SetVisible(false); allocation_msg.SetVisible(false); allocation_area_confirm.SetVisible(false); allocation_direct.SetVisible(false); entering_warehouse_main.SetVisible(false); entering_warehouse_find.SetVisible(false); production_storage_main.SetVisible(false); production_storage_find.SetVisible(false); production_storage_scan.SetVisible(false); Intent intent = new Intent(); intent.SetAction(Constants.ACTION_LOGOUT_ACTION); context.SendBroadcast(intent); } else { fragment = new LoginFragment(); title = Resources.GetString(Resource.String.nav_login); receiving_main.SetVisible(false); receiving_record.SetVisible(false); receiving_board.SetVisible(false); receiving_multi.SetVisible(false); shipment_main.SetVisible(false); shipment_find.SetVisible(false); allocation_find.SetVisible(false); allocation_replenishment.SetVisible(false); allocation_send_msg.SetVisible(false); allocation_msg.SetVisible(false); allocation_area_confirm.SetVisible(false); allocation_direct.SetVisible(false); entering_warehouse_main.SetVisible(false); entering_warehouse_find.SetVisible(false); production_storage_main.SetVisible(false); production_storage_find.SetVisible(false); production_storage_scan.SetVisible(false); } FragmentTransaction fragmentTx = this.FragmentManager.BeginTransaction(); //fragmentTx.Add(Resource.Id.flContent, fragment); fragmentTx.Replace(Resource.Id.flContent, fragment); fragmentTx.Commit(); this.Title = title; DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); drawer.CloseDrawer(GravityCompat.Start); }
public override void OnReceive(Context context, Intent intent) { if (intent.Action == Constants.ACTION_SETTING_PDA_TYPE_ACTION) { Log.Debug(TAG, "receive ACTION_SETTING_PDA_TYPE_ACTION"); string ret = intent.GetStringExtra("MODEL_TYPE"); pda_type = Convert.ToInt32(ret); editor = prefs.Edit(); editor.PutInt("PDA_TYPE", pda_type); editor.Apply(); } else if (intent.Action == Constants.ACTION_SETTING_WEB_SOAP_PORT_ACTION) { Log.Debug(TAG, "receive ACTION_SETTING_WEB_SOAP_PORT_ACTION"); web_soap_port = intent.GetStringExtra("WEB_SOAP_PORT"); Log.Debug(TAG, "web_soap_port = " + web_soap_port); editor = prefs.Edit(); editor.PutString("WEB_SOAP_PORT", web_soap_port); editor.Apply(); } else if (intent.Action == Constants.SOAP_CONNECTION_FAIL) { Log.Debug(TAG, "receive SOAP_CONNECTION_FAIL"); //if (loadDialog != null) //{ // loadDialog.Dismiss(); // loadDialog = null; //} } else if (intent.Action == Constants.ACTION_LOGIN_SUCCESS) { string account = intent.GetStringExtra("ACCOUNT"); string password = intent.GetStringExtra("PASSWORD"); Log.Debug(TAG, "account = " + account + ", password = "******" " + account; } else { Log.Debug("empID = ", "null"); } myToolbar.Title = context.Resources.GetString(Resource.String.action_allocation_find); isLogin = true; //if (loadDialog != null) //{ // loadDialog.Dismiss(); // loadDialog = null; //} //hide virtual keyboard var currentFocus = ((Activity)context).CurrentFocus; if (currentFocus != null) { imm.HideSoftInputFromWindow(currentFocus.WindowToken, HideSoftInputFlags.None); } } /*else if (intent.Action == Constants.ACTION_LOGIN_FAIL) * { * Log.Debug(TAG, "Password mismatched!"); * //if (loadDialog != null) * //{ * // loadDialog.Dismiss(); * // loadDialog = null; * //} * } * else if (intent.Action == Constants.ACTION_LOGIN_ACTION) * { * Log.Debug(TAG, "receive ACTION_LOGIN_ACTION"); * * loadDialog = new ProgressDialog(context); * loadDialog.SetProgressStyle(ProgressDialogStyle.Spinner); * loadDialog.SetTitle(context.Resources.GetString(Resource.String.progress_login)); * //loadDialog.SetIndeterminate(false); * loadDialog.SetCancelable(false); * loadDialog.Show(); * * }*/ else if (intent.Action == Constants.ACTION_LOGOUT_ACTION) { Log.Debug(TAG, "receive ACTION_LOGOUT_ACTION"); Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(context); alert.SetTitle(Resource.String.logout_title); alert.SetIcon(Resource.Drawable.ic_warning_black_48dp); alert.SetMessage(Resource.String.logout_title_msg); alert.SetPositiveButton(Resource.String.confirm, (senderAlert, args) => { Log.Debug("MainActivity", "Logout!"); Fragment fragment = new LoginFragment(); FragmentTransaction fragmentTx = fragmentManager.BeginTransaction(); fragmentTx.Replace(Resource.Id.flContent, fragment); fragmentTx.Commit(); receiving_main.SetVisible(false); receiving_record.SetVisible(false); receiving_board.SetVisible(false); receiving_multi.SetVisible(false); shipment_main.SetVisible(false); shipment_find.SetVisible(false); allocation_find.SetVisible(false); allocation_replenishment.SetVisible(false); allocation_send_msg.SetVisible(false); allocation_msg.SetVisible(false); allocation_area_confirm.SetVisible(false); allocation_direct.SetVisible(false); entering_warehouse_main.SetVisible(false); entering_warehouse_find.SetVisible(false); production_storage_main.SetVisible(false); production_storage_find.SetVisible(false); production_storage_scan.SetVisible(false); menuItemLogin.SetVisible(true); menuItemLogout.SetVisible(false); //menuItemReceiveGoods.SetVisible(false); //menuItemShipment.SetVisible(false); menuItemSearch.SetVisible(false); menuItemAllocationSendMsg.SetVisible(false); menuItemAllocation.SetVisible(false); menuItemEnteringWareHouse.SetVisible(false); menuItemProductionStorage.SetVisible(false); //menuItemReceivingInspection.SetVisible(false); //menuItemProductionStorage.SetVisible(false); isLogin = false; empID.Text = ""; }); alert.SetNegativeButton(Resource.String.cancel, (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); }/* * else if (intent.Action == Constants.ACTION_ENTERING_WAREHOUSE_INTO_STOCK_SHOW_DIALOG) * { * Log.Debug(TAG, "receive ACTION_ENTERING_WAREHOUSE_INTO_STOCK_SHOW_DIALOG"); * * string msg = intent.GetStringExtra("MSG"); * string head = context.GetString(Resource.String.entering_warehouse_dialog_content); * * Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(context); * alert.SetTitle(Resource.String.entering_warehouse_dialog_title); * alert.SetIcon(Resource.Drawable.ic_warning_black_48dp); * alert.SetMessage(head+"\n"+msg); * alert.SetPositiveButton(Resource.String.dialog_confirm, (senderAlert, args) => { * Intent confirmIntent = new Intent(Constants.ACTION_ENTERING_WAREHOUSE_INTO_STOCK_CONFIRM); * context.SendBroadcast(confirmIntent); * }); * * alert.SetNegativeButton(Resource.String.dialog_cancel, (senderAlert, args) => { * * }); * * Dialog dialog = alert.Create(); * dialog.Show(); * * * }*/ else if (intent.Action == Constants.ACTION_SEARCH_MENU_SHOW_ACTION) { Log.Debug(TAG, "receive ACTION_SEARCH_MENU_SHOW_ACTION"); searchFilter.SetVisible(true); } else if (intent.Action == Constants.ACTION_SEARCH_MENU_HIDE_ACTION) { Log.Debug(TAG, "receive ACTION_SEARCH_MENU_HIDE_ACTION"); searchFilter.SetVisible(false); } else if (intent.Action == Constants.ACTION_RESET_TITLE_PART_IN_STOCK) { Log.Debug(TAG, "receive ACTION_RESET_TITLE_PART_IN_STOCK"); myToolbar.Title = context.Resources.GetString(Resource.String.action_allocation_find); } }
public override void OnBackPressed() { Log.Debug(TAG, "OnBackPressed"); Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle(Resource.String.exit_app_title); alert.SetIcon(Resource.Drawable.baseline_exit_to_app_black_48); alert.SetMessage(Resource.String.exit_app_msg); alert.SetPositiveButton(Resource.String.confirm, (senderAlert, args) => { Log.Debug("MainActivity", "Exit!"); Fragment fragment = new LoginFragment(); FragmentTransaction fragmentTx = fragmentManager.BeginTransaction(); fragmentTx.Replace(Resource.Id.flContent, fragment); fragmentTx.Commit(); receiving_main.SetVisible(false); receiving_record.SetVisible(false); receiving_board.SetVisible(false); receiving_multi.SetVisible(false); shipment_main.SetVisible(false); shipment_find.SetVisible(false); allocation_find.SetVisible(false); allocation_replenishment.SetVisible(false); allocation_send_msg.SetVisible(false); allocation_msg.SetVisible(false); allocation_area_confirm.SetVisible(false); allocation_direct.SetVisible(false); entering_warehouse_main.SetVisible(false); entering_warehouse_find.SetVisible(false); production_storage_main.SetVisible(false); production_storage_find.SetVisible(false); production_storage_scan.SetVisible(false); menuItemLogin.SetVisible(true); menuItemLogout.SetVisible(false); //menuItemReceiveGoods.SetVisible(false); //menuItemShipment.SetVisible(false); menuItemSearch.SetVisible(false); menuItemAllocationSendMsg.SetVisible(false); menuItemAllocation.SetVisible(false); menuItemEnteringWareHouse.SetVisible(false); menuItemProductionStorage.SetVisible(false); //menuItemReceivingInspection.SetVisible(false); //menuItemProductionStorage.SetVisible(false); isLogin = false; Finish(); }); alert.SetNegativeButton(Resource.String.cancel, (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); }