Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about Android development and PDF

how to move the added text at pdf

More
10 years 1 month ago #10276 by max.pfeiffer
:( attachments seem not to work in that forum.

I will see if I can post a github snippet tomorrow.
More
10 years 1 month ago #10277 by max.pfeiffer
ok, to do it quick and dirty I just post my implemetation of onSingleTapUp() of PDFGestureListener.

I changed it so when setting m_status = STA_NONE or m_status = STA_ANNOT the tap on a text annotation causes the move.

m_status = STA_EDIT_TEXT is used to edit that text annotation. Works better for than the default behaviour of PDFLayoutView.
Code:
@Override public boolean onSingleTapUp(MotionEvent e) { if ( m_status == STA_NONE || m_status == STA_ANNOT || m_status == STA_EDIT_TEXT) { m_annot_pos = m_layout.vGetPos((int)e.getX(), (int)e.getY()); m_annot_page = m_layout.vGetPage(m_annot_pos.pageno); Page page = m_doc.GetPage(m_annot_page.GetPageNo()); if( page == null ) { m_annot = null; } else { m_annot = page.GetAnnotFromPoint(m_annot_pos.x, m_annot_pos.y); } if( m_annot == null ) { // No Annotation selected m_annot_page = null; m_annot_pos = null; m_annot_rect = null; if( m_listener != null ) { if(m_status == STA_ANNOT) m_listener.OnPDFAnnotTapped(m_annot_page, null); else m_listener.OnPDFBlankTapped(); } m_status = STA_NONE; } else { // Annotation selected page.ObjsStart(); m_annot_rect = m_annot.GetRect(); float tmp = m_annot_rect[1]; m_annot_rect[0] = m_annot_page.GetVX(m_annot_rect[0]) - m_layout.vGetX(); m_annot_rect[1] = m_annot_page.GetVY(m_annot_rect[3]) - m_layout.vGetY(); m_annot_rect[2] = m_annot_page.GetVX(m_annot_rect[2]) - m_layout.vGetX(); m_annot_rect[3] = m_annot_page.GetVY(tmp) - m_layout.vGetY(); if ( m_status == STA_EDIT_TEXT){ if( m_doc.CanSave() && m_annot.GetEditType() > 0 ) { // this annotation is a text-box. int[] location = new int[2]; getLocationOnScreen(location); m_pEdit = new PopupWindow(LayoutInflater.from(getContext()).inflate(R.layout.pop_editbox, null) ); Drawable dw = new ColorDrawable(0); m_pEdit.setFocusable(true); m_pEdit.setTouchable(true); m_pEdit.setBackgroundDrawable(dw); m_pEdit.setWidth((int)(m_annot_rect[2] - m_annot_rect[0])); m_pEdit.setHeight((int)(m_annot_rect[3] - m_annot_rect[1])); final EditText edit = (EditText)m_pEdit.getContentView().findViewById(R.id.pop_editbox_edittext); edit.setBackgroundColor(0xFFFFFFC0); float fsize = m_annot.GetEditTextSize() * m_layout.vGetScale(); edit.setTextSize(TypedValue.COMPLEX_UNIT_PX, fsize); edit.setPadding(2, 2, 2, 2); switch( m_annot.GetEditType() ) { case 1: //normal single line. edit.setSingleLine(); edit.setInputType(InputType.TYPE_CLASS_TEXT + InputType.TYPE_TEXT_VARIATION_NORMAL); break; case 2: //password. edit.setSingleLine(); edit.setInputType(InputType.TYPE_CLASS_TEXT + InputType.TYPE_TEXT_VARIATION_PASSWORD); break; case 3: //MultiLine edit area. edit.setSingleLine(false); edit.setInputType(InputType.TYPE_CLASS_TEXT + InputType.TYPE_TEXT_VARIATION_NORMAL); break; } int maxlen = m_annot.GetEditMaxlen(); if( maxlen > 0 ) edit.setFilters(new InputFilter[]{new InputFilter.LengthFilter(maxlen)}); else edit.setFilters(new InputFilter[]{new InputFilter.LengthFilter(1020)}); edit.setText(m_annot.GetEditText()); m_edit_type = 1; m_pEdit.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { if( m_edit_type == 1 )//edit box { m_annot.SetEditText(edit.getText().toString()); m_layout.vRenderSync(m_annot_page); if( m_listener != null ) m_listener.OnPDFPageModified(m_annot_page.GetPageNo()); PDFEndAnnot(); } m_edit_type = 0; } }); m_pEdit.showAtLocation(ExtendedPDFLayoutView.this, Gravity.NO_GRAVITY, (int)m_annot_rect[0] + location[0], (int)m_annot_rect[1] + location[1]); } } else if (m_status == STA_NONE) { // Annotation selected move to annotation state m_status = STA_ANNOT; if( m_doc.CanSave() && m_annot.GetComboItemCount() >= 0 ) //-1: this is not combo. otherwise: items count. { int[] location = new int[2]; getLocationOnScreen(location); String opts[] = new String[m_annot.GetComboItemCount()]; int cur = 0; while( cur < opts.length ) { opts[cur] = m_annot.GetComboItem(cur); cur++; } m_pCombo = new PopupWindow(LayoutInflater.from(getContext()).inflate(com.radaee.viewlib.R.layout.pop_combo, null)); Drawable dw = new ColorDrawable(0); m_pCombo.setFocusable(true); m_pCombo.setTouchable(true); m_pCombo.setBackgroundDrawable(dw); m_pCombo.setWidth((int)(m_annot_rect[2] - m_annot_rect[0])); if( (m_annot_rect[3] - m_annot_rect[1] - 4) * opts.length > 250 ) m_pCombo.setHeight(250); else m_pCombo.setHeight((int)(m_annot_rect[3] - m_annot_rect[1] - 4) * opts.length); ComboList combo = (ComboList)m_pCombo.getContentView().findViewById(com.radaee.viewlib.R.id.annot_combo); combo.set_opts(opts); combo.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { m_combo_item = i; m_pCombo.dismiss(); } }); m_edit_type = 2; m_combo_item = -1; m_pCombo.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { if( m_edit_type == 2 )//combo { if( m_combo_item >= 0 ) { m_annot.SetComboItem(m_combo_item); m_layout.vRenderSync(m_annot_page); if( m_listener != null ) m_listener.OnPDFPageModified(m_annot_page.GetPageNo()); } m_combo_item = -1; PDFEndAnnot(); } m_edit_type = 0; } }); m_pCombo.showAtLocation(ExtendedPDFLayoutView.this, Gravity.NO_GRAVITY, (int)m_annot_rect[0] + location[0], (int)(m_annot_rect[3] + location[1])); } } else if( m_listener != null ) { m_listener.OnPDFAnnotTapped(m_annot_page, m_annot); } invalidate(); } return true; } return false; }
More
10 years 1 month ago #10279 by support
Replied by support on topic attachments do not work!!!
You should try uploading your files right now.
The forum issue should be fixed.
More
10 years 1 month ago #10280 by ankur123987
Hey Max thank you so much.but i am getting problem that onSingleTapUp(MotionEvent e) method never calls . could you please send me your modified class file to my email id [email protected] as i could not find the attachment here .
More
10 years 1 month ago #10281 by ankur123987
Thanks support team for your initiative to fix bug of attachment. please upload files here
More
10 years 1 month ago #10283 by max.pfeiffer
ok, trying to attach my class here.


File Attachment:

File Name: ExtendedPD...iew.java
File Size:58.77 KB
Time to create page: 0.388 seconds
Powered by Kunena Forum