]> rtime.felk.cvut.cz Git - hornmich/skoda-qr-demo.git/commitdiff
Implement zoom value field in the layout
authorMichal Horn <hornmich@fel.cvut.cz>
Tue, 17 Feb 2015 09:30:09 +0000 (10:30 +0100)
committerMichal Horn <hornmich@fel.cvut.cz>
Tue, 17 Feb 2015 09:30:09 +0000 (10:30 +0100)
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/pdfviewer/PdfViewActivity.java
QRScanner/glass/src/main/res/layout/activity_pdf_view.xml
QRScanner/glass/src/main/res/values/strings.xml

index 2ff961a9dd3da408aeede1647ef25f2b05807468..3da70ad9a97c4d7379debeddbdc0d0f13ca869ea 100644 (file)
@@ -38,6 +38,7 @@ public class PdfViewActivity extends Activity implements ViewTreeObserver.OnGlob
        private TextView mCurrentPageNumber;
        private TextView mLastPageNumber;
        private TextView mViewerStateText;
+       private TextView mZoomValue;
        private ViewTreeObserver mPreviewImgObserver;
        private String mFilePath;
        private PdfPageView mPdfView;
@@ -61,6 +62,7 @@ public class PdfViewActivity extends Activity implements ViewTreeObserver.OnGlob
                mCurrentPageNumber = (TextView) findViewById(R.id.page_number);
                mLastPageNumber = (TextView) findViewById(R.id.total_pages_num);
                mViewerStateText = (TextView) findViewById(R.id.pdf_viewer_state);
+               mZoomValue = (TextView) findViewById(R.id.zoom_value);
                mViewStates = ViewStates.SCROLLING;
                mProgressContainer = (RelativeLayout) findViewById(R.id.progress_container);
 
@@ -180,7 +182,7 @@ public class PdfViewActivity extends Activity implements ViewTreeObserver.OnGlob
                if (event.getAction() == MotionEvent.ACTION_MOVE) {
                        dzoom = event.getRawX() - startX;
                        Log.d(TAG,"move_action, dzoom: " + dzoom);
-                       mPdfView.zoom(dzoom /1000f);
+                       zoomPage(dzoom /1000f);
                        startX = event.getRawX();
                        return false;
                }
@@ -215,6 +217,11 @@ public class PdfViewActivity extends Activity implements ViewTreeObserver.OnGlob
 
        }
 
+       private void zoomPage(float deltaZoom) {
+               mPdfView.zoom(deltaZoom);
+               mZoomValue.setText(Integer.toString(Math.round(mPdfView.getZoomRatio()*100)));
+       }
+
        private class LoadPageTask extends AsyncTask<Void, Void, Void> {
 
                @Override
@@ -235,6 +242,7 @@ public class PdfViewActivity extends Activity implements ViewTreeObserver.OnGlob
                        super.onPostExecute(aVoid);
                        mProgressContainer.setVisibility(View.INVISIBLE);
                        mPdfImageContainer.addView(mPdfView);
+                       zoomPage(0.0f); // just for update the zoom value indicator
                        Log.d(TAG, "PDF page loaded.");
                }
        }
index 159c5ae29f3227edf4ca80ac033c01057e345aea..830cfcf5ddd2279e854d617590fad4c0d78f0833 100644 (file)
         </RelativeLayout>
     </FrameLayout>
 
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:text="@string/zoom_label"
+        android:id="@+id/textView6"
+        android:layout_above="@+id/pdf_view_container"
+        android:layout_toEndOf="@+id/total_pages_num"
+        android:layout_marginStart="36dp"/>
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:text="100"
+        android:id="@+id/zoom_value"
+        android:layout_alignParentTop="true"
+        android:layout_toEndOf="@+id/textView6"/>
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:text="%"
+        android:id="@+id/textView7"
+        android:layout_above="@+id/pdf_view_container"
+        android:layout_toEndOf="@+id/zoom_value"/>
+
 </RelativeLayout>
index 80645da5e9ed186d0cd5a6383d692aa8cd05afcd..af3c2392c68772525d27e499dd6f94d9b9e70738 100644 (file)
@@ -35,4 +35,5 @@ limitations under the License.
     <string name="pdf_viewer_state_label">State:</string>
     <string name="page_state_scrolling">scrolling</string>
     <string name="loading_page">Loading...</string>
+    <string name="zoom_label">Zoom:</string>
 </resources>