/** Crystal: add the plus button to the bottom bar */ public void plusButtonSetUp(int position) { LinearLayout bottomBar = (LinearLayout) findViewById(R.id.bottom_bar); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(Values.privateSpaceButtonW, Values.privateSpaceButtonW); lp.setMargins(0, 0, Values.iconBorderPaddingH, 0); ImageView plus = PrivateSpaceIconView.plusSpaceButton(getResources().getColor(R.color.off_white), this); plus.setBackgroundColor(getResources().getColor(R.color.dark_grey)); plus.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO NORA - might need to change to mainspace in Space class try { // Space.getMainSpace().getSpaceController().addSpace(Space.getMainSpace().getContext()); Space newSpace = SpaceController.addSpace(Space.getMainSpace().getContext()); PrivateSpaceIconView psIcon = new PrivateSpaceIconView(Space.getMainSpace().getContext(), newSpace); newSpace.getSpaceController().setPSIV(psIcon); } catch (XMPPException e) { Log.d("MainApplication plusButtonSetUp()", "Could not add a Space"); } // MainApplication.this.init_createPrivateSpace(false); } }); bottomBar.addView(plus, position, lp); bottomBar.invalidate(); }
/** * Removes all UI traces of a privatespace/sidechat 1) Removes space from hashmap of all spaces 2) * Removes the corresponding privatespaceButton 3) Changes the space to the Mainspace (but only if * wasn't a mainspace) However, if you are leaving the mainspace, then start a new activity and go * ack to the dashboard */ public void delPrivateSpaceUI(Space space, boolean isMainSpace) { if (isMainSpace) { Intent i = new Intent(MainApplication.screen.getSpace().getContext(), DashboardView.class); MainApplication.screen.getSpace().getContext().startActivity(i); } else { // 1 Space.allSpaces.remove(space.getRoomID()); // 2 PrivateSpaceIconView foundIcon = null; for (PrivateSpaceIconView ps : PrivateSpaceIconView.allPSIcons) { if (ps.getSpace() == space) foundIcon = ps; } if (foundIcon != null) delPrivateSpaceButton(foundIcon); // 3 screen.getSpaceViewController().changeSpace(Space.getMainSpace()); } }
/** Need to add the new PrivateSpace button to the bottom GUI by altering the XML code */ public void addPrivateSpaceButton(PrivateSpaceIconView psv) { Log.v("Crystal", "addPrivateSpaceButton"); LinearLayout bottomBar = (LinearLayout) findViewById(R.id.bottom_bar); // Crystal LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(Values.privateSpaceButtonW, Values.privateSpaceButtonW); lp.setMargins(Values.iconBorderPaddingH, 0, Values.iconBorderPaddingH, 0); psv.setLayoutParams( new LinearLayout.LayoutParams(Values.privateSpaceButtonW, Values.privateSpaceButtonW)); psv.setPadding( Values.iconBorderPaddingH, Values.iconBorderPaddingV, Values.iconBorderPaddingH, Values.iconBorderPaddingV); // bottomBar.removeViewAt(PrivateSpaceIconView.allPSIcons.size()-1); bottomBar.addView(psv, lp); // plusButtonSetUp(PrivateSpaceIconView.allPSIcons.size()); bottomBar.invalidate(); }