private TnPopupContainer createNoGPSWarning(int state) { ResourceBundle bundle = ResourceManager.getInstance().getCurrentBundle(); String noGps = bundle.getString(IStringCommon.RES_GPS_ERROR, IStringCommon.FAMILY_COMMON); TnMenu menu = UiFactory.getInstance().createMenu(); String cancel = bundle.getString(IStringCommon.RES_BTTN_OK, IStringCommon.FAMILY_COMMON); menu.add(cancel, CMD_COMMON_BACK); FrogMessageBox messageBox = UiFactory.getInstance().createMessageBox(state, noGps, menu); return messageBox; }
public View getView(int position, View convertView, ViewGroup parent) { Address addr = poiDataPublisher.getAddress(position); if (addr == null || addr.getType() != Address.TYPE_RECENT_POI || addr.getPoi() == null) { return convertView; } Poi poi = addr.getPoi(); Stop stop = addr.getStop(); if (convertView == null) { convertView = mInflater.inflate(R.layout.place_list0normalitem, null); } Context context = AndroidPersistentContext.getInstance().getContext(); PlaceListItem item = (PlaceListItem) convertView; item.init(PlaceListItem.TYPE_NORMAL); item.setIndicatorIcon(R.drawable.list_icon_see_all_unfocused); if (poi != null && poi.getBizPoi() != null) { BizPoi bizPoi = poi.getBizPoi(); if (bizPoi.getCategoryLogo() != null && bizPoi.getCategoryLogo().length() > 0) { int iconId = context .getResources() .getIdentifier( bizPoi.getCategoryLogo(), "drawable", AndroidPersistentContext.getInstance().getContext().getPackageName()); if (iconId != 0) { item.setIndicatorIcon(iconId); } } } customizeAddPlaceListItem(item); if (poi.getBizPoi() != null) { String title = poi.getBizPoi().getBrand(); item.setAddressVisibility(View.GONE); item.setBrandName(title); String distStr = UiFactory.getInstance() .getDisplayDistance(addr, poiDataPublisher.getAnchorStop(), true); item.setDistance(distStr); } String addrText = ""; if (stop != null && addr.isValid()) { addrText = stop.getFirstLine(); } item.setLastLine(addrText); return item; }
protected void addAddressEditView(ViewGroup filterContainer) { addressEditView = UiFactory.getInstance() .createCitizenTextField( "", 100, TnTextField.ANY, "", 0, null, ImageDecorator.IMG_AC_BACKSPACE.getImage()); addressEditView.setBackgroundColor( UiStyleManager.getInstance().getColor(UiStyleManager.TEXT_COLOR_WH)); addressEditView .getTnUiArgs() .put(TnUiArgs.KEY_PREFER_WIDTH, ((AddPlaceUiDecorator) uiDecorator).TEXTFIELD_WIDTH); addressEditView .getTnUiArgs() .put(TnUiArgs.KEY_PREFER_HEIGHT, ((AddPlaceUiDecorator) uiDecorator).TEXTFIELD_HEIGHT); addressEditView .getTnUiArgs() .put( CitizenTextField.KEY_PREFER_TEXTFIELD_HEIGHT, ((AddPlaceUiDecorator) uiDecorator).TEXTFIELD_HEIGHT); addressEditView.setHintTextColor( UiStyleManager.getInstance().getColor(UiStyleManager.TEXT_COLOR_FILTER)); addressEditView.setFont(UiStyleManager.getInstance().getFont(UiStyleManager.FONT_TEXT_FIELD)); addressEditView.setKeyEventListener(this); filterContainer.addView((View) addressEditView.getNativeUiComponent()); }
@SuppressWarnings("deprecation") protected TnScreen createAddPlaceMainScreen(int state) { int type = this.model.getInt(KEY_I_PLACE_OPERATION_TYPE); CitizenScreen screen = UiFactory.getInstance().createScreen(state); addPlaceMainView = AndroidCitizenUiHelper.addContentView(screen, R.layout.add_place_main); Drawable bgImage = new AssetsImageDrawable(NinePatchImageDecorator.FTUE_BG_UNFOCUSED); addPlaceMainView.setBackgroundDrawable(bgImage); TextView title = (TextView) addPlaceMainView.findViewById(R.id.commonTitle0TextView); title.setText(getScreenMainResource(state, type)); TextView promptLabel = (TextView) addPlaceMainView.findViewById(R.id.addplace_prompt_label); promptLabel.setText(getPromptLableResource(type)); final PoiDataWrapper poiDataWrapper = (PoiDataWrapper) model.get(KEY_O_POI_DATA_WRAPPER); placeListAdapter = new PlaceListAdapter(addPlaceMainView.getContext(), poiDataWrapper.getPublisher()); placeList = (TnListView) addPlaceMainView.findViewById(R.id.addplaceListView); placeList.addHeaderView(createCurrentLocationItem()); placeList.setPullRefreshEnable(false); placeList.setHitBottomLoadEnable(poiDataWrapper.getAnchorStop() != null); placeList.setAdapter(placeListAdapter); placeList.setTnListViewListener(this); placeList.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Address address = null; Context context = AndroidPersistentContext.getInstance().getContext(); if (view == currentLocationItem && !currentLocationItem .getLastLine() .equals(context.getString(R.string.addplace_current_location_loading))) { address = (Address) AddPlaceViewTouch.this.model.get(KEY_O_CURRENT_ADDRESS); if (address == null) { address = new Address(); address.setStop(poiDataWrapper.getAnchorStop()); } KontagentLogger.getInstance() .addCustomEvent( KontagentLogger.CATEGORY_CHOOSE_PLACE, KontagentLogger.CHOOSEPLACE_CURRENT_LOCATION_CLICKED); } else if (position >= placeList.getHeaderViewsCount() && position < placeList.getHeaderViewsCount() + poiDataWrapper.getAddressSize()) { poiDataWrapper.setSelectedIndex(position - placeList.getHeaderViewsCount()); address = poiDataWrapper.getSelectedAddress(); KontagentLogger.getInstance() .addCustomEvent( KontagentLogger.CATEGORY_CHOOSE_PLACE, KontagentLogger.CHOOSEPLACE_OTHER_PLACE_CLICKED); } if (address != null) { AddPlaceViewTouch.this.model.put(KEY_O_SELECTED_ADDRESS, address); AndroidCitizenUiHelper.triggerCommand(AddPlaceViewTouch.this, view, CMD_SELECT_ITEM); } } }); return screen; }
private TnScreen createCustomAddressScreen(int state) { int type = this.model.getInt(KEY_I_PLACE_OPERATION_TYPE); Address address = (Address) this.model.get(KEY_O_SELECTED_ADDRESS); final Context context = AndroidPersistentContext.getInstance().getContext(); CitizenScreen screen = UiFactory.getInstance().createScreen(state); addPlaceCustomView = AndroidCitizenUiHelper.addContentView(screen, R.layout.add_place_custom); if (address == null) { return screen; } TextView title = (TextView) addPlaceCustomView.findViewById(R.id.commonTitle0TextView); title.setText(getScreenMainResource(state, type)); Button doneButton = (Button) addPlaceCustomView.findViewById(R.id.commonTitle0TextButton); doneButton.setText(R.string.addplace_custom_done); doneButton.setVisibility(View.VISIBLE); AndroidCitizenUiHelper.setOnClickCommand(this, doneButton, CMD_CUSTOM_PLACE_DONE); ImageView icon = (ImageView) addPlaceCustomView.findViewById(R.id.addplaceCustomIcon); icon.setBackgroundResource(R.drawable.list_icon_see_all_unfocused); Poi poi = address.getPoi(); if (poi != null && poi.getBizPoi() != null) { BizPoi bizPoi = poi.getBizPoi(); if (bizPoi.getCategoryLogo() != null && bizPoi.getCategoryLogo().length() > 0) { int iconId = context .getResources() .getIdentifier( bizPoi.getCategoryLogo(), "drawable", AndroidPersistentContext.getInstance().getContext().getPackageName()); if (iconId != 0) { icon.setBackgroundResource(iconId); } } } this.model.put(KEY_S_PLACE_LABEL, address.getLabel()); ViewGroup editAddressViewGroup = (ViewGroup) addPlaceCustomView.findViewById(R.id.addplaceCustomFilterContainer); addAddressEditView(editAddressViewGroup); if (type == ICommonConstants.PLACE_OPERATION_TYPE_EDIT || type == ICommonConstants.PLACE_OPERATION_TYPE_ADD) { addressEditView.requestFocus(); } TextView firstLineView = (TextView) addPlaceCustomView.findViewById(R.id.addplaceCustomFirstLine); TextView secondLineView = (TextView) addPlaceCustomView.findViewById(R.id.addplaceCustomSecondLine); String displayText = address.getDisplayedText(); if (displayText == null || displayText.length() == 0 || containsLatLon(displayText)) // Unkown address just with lat/lon { ResourceBundle bundle = ResourceManager.getInstance().getCurrentBundle(); addressEditView.setText( bundle.getString(IStringDashboard.RES_STRING_UNKNOWN, IStringDashboard.FAMILY_DASHBOARD)); firstLineView.setText( context.getString( R.string.addplace_location_info, address.getStop().getLat() / 100000.0d, address.getStop().getLon() / 100000.0d)); } else { addressEditView.setText(address.getLabel()); firstLineView.setText(address.getStop().getFirstLine()); } secondLineView.setText( ResourceManager.getInstance().getStringConverter().convertSecondLine(address.getStop())); categoryListAdapter = new CustomPlaceCategoryAdapter(addPlaceCustomView.getContext()); categoryList = (ListView) addPlaceCustomView.findViewById(R.id.addplaceCustomCategoryList); categoryList.setOnScrollListener( new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) {} @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { resetKeyboard(); } }); categoryList.setItemsCanFocus(false); categoryList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); categoryList.addFooterView(CreateNewCategoryItem()); categoryList.setAdapter(categoryListAdapter); categoryList.setDivider(null); int selectedIndex = this.model.getInt(KEY_I_SELECTED_CATEGORY_INDEX); categoryList.setItemChecked(selectedIndex + categoryList.getHeaderViewsCount() + 1, true); return screen; }