]> rtime.felk.cvut.cz Git - hornmich/skoda-qr-demo.git/commitdiff
Implement PDF preview showing, change icon, implement views and manus layout
authorMichal Horn <hornmich@fel.cvut.cz>
Fri, 13 Feb 2015 10:28:48 +0000 (11:28 +0100)
committerMichal Horn <hornmich@fel.cvut.cz>
Fri, 13 Feb 2015 10:28:48 +0000 (11:28 +0100)
38 files changed:
QRScanner/QRScanner.iml
QRScanner/glass/build.gradle
QRScanner/glass/glass.iml
QRScanner/glass/src/main/AndroidManifest.xml
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/MainActivity.java
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/PreviewActivity.java
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/Annotation.java [new file with mode: 0644]
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfo.java [new file with mode: 0644]
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfoExternal.java [new file with mode: 0644]
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfoInternal.java [new file with mode: 0644]
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfoRemote.java [new file with mode: 0644]
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfoVisitor.java [new file with mode: 0644]
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/MuPDFAlert.java [new file with mode: 0644]
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/MuPDFAlertInternal.java [new file with mode: 0644]
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/MuPDFCore.java [new file with mode: 0644]
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/OutlineItem.java [new file with mode: 0644]
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/TextChar.java [new file with mode: 0644]
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/TextWord.java [new file with mode: 0644]
QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/WidgetType.java [new file with mode: 0644]
QRScanner/glass/src/main/res/drawable-hdpi/ic_glass_logo.png [deleted file]
QRScanner/glass/src/main/res/drawable-hdpi/ic_launcher.png [new file with mode: 0644]
QRScanner/glass/src/main/res/drawable-mdpi/ic_glass_logo.png [new file with mode: 0644]
QRScanner/glass/src/main/res/drawable-mdpi/ic_launcher.png [deleted file]
QRScanner/glass/src/main/res/drawable-xhdpi/ic_launcher.png
QRScanner/glass/src/main/res/drawable-xxhdpi/ic_launcher.png
QRScanner/glass/src/main/res/drawable/ic_launcher.png [new file with mode: 0644]
QRScanner/glass/src/main/res/drawable/skoda_logo.png [new file with mode: 0644]
QRScanner/glass/src/main/res/layout/activity_main.xml [new file with mode: 0644]
QRScanner/glass/src/main/res/layout/activity_preview.xml [new file with mode: 0644]
QRScanner/glass/src/main/res/menu/menu_preview.xml [new file with mode: 0644]
QRScanner/glass/src/main/res/values/strings.xml
QRScanner/glass/src/main/res/values/styles.xml
QRScanner/glass/src/main/res/xml/voice_trigger.xml [deleted file]
QRScanner/glass/src/main/res/xml/voice_trigger_start.xml [new file with mode: 0644]
QRScanner/mobile/mobile.iml
QRScanner/mobile/src/main/java/cz/cvut/fel/dce/qrscanner/PreviewActivity.java
QRScanner/mobile/src/main/res/menu/menu_preview.xml [deleted file]
QRScanner/mobile/src/main/res/values/strings.xml

index 42f4ed552b082ca74efb6f02410d2150ccc30df6..0bb6048ae08a8e6e87a69ee6b675e1d40b6e648b 100644 (file)
@@ -8,8 +8,6 @@
     </facet>
   </component>
   <component name="NewModuleRootManager" inherit-compiler-output="true">
-    <output url="file://$MODULE_DIR$/build/classes/main" />
-    <output-test url="file://$MODULE_DIR$/build/classes/test" />
     <exclude-output />
     <content url="file://$MODULE_DIR$">
       <excludeFolder url="file://$MODULE_DIR$/.gradle" />
index 5d6a1db260ba727e0b0b41f003138279014c3ee3..9e9a45adf9fc079c726a5870507ee3283c40439f 100644 (file)
@@ -9,7 +9,7 @@ repositories {
 
 android {
     compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
-    buildToolsVersion "21.1.2"
+    buildToolsVersion '21.1.2'
 
     defaultConfig {
         applicationId "cz.cvut.fel.dce.qrscanner"
@@ -31,6 +31,19 @@ android {
     }
 }
 
+task nativeLibsToJar(type: Zip, description: 'create a jar archive of the native libs') {
+    destinationDir file("$buildDir/native-libs")
+    baseName 'native-libs'
+    extension 'jar'
+    from fileTree(dir: 'libs', include: '**/*.so')
+    into 'lib/'
+}
+
+tasks.withType(JavaCompile) {
+    compileTask -> compileTask.dependsOn(nativeLibsToJar)
+}
+
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
+    compile files('build/native-libs/native-libs.jar')
 }
index 6b8b3c66848fe36b5be0cacad202a72c20aa0951..b8feb8227a93adffb71a465ac57af2c500d473ef 100644 (file)
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
+      <excludeFolder url="file://$MODULE_DIR$/build/native-libs" />
       <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
       <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
     </content>
     <orderEntry type="jdk" jdkName="Android 4.4.2 Glass Development Kit Preview" jdkType="Android SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" exported="" name="native-libs" level="project" />
   </component>
 </module>
 
index f67d177568060534aa8ab08420a95cae8fe41deb..2f7340ad3e27c17c1d58e62d74e1e5d31dbfb827 100644 (file)
@@ -4,19 +4,20 @@
 
     <application
         android:allowBackup="true"
-        android:icon="@drawable/ic_launcher"
+        android:icon="@drawable/ic_glass_logo"
         android:label="@string/app_name" >
         <activity
             android:name=".MainActivity"
-            android:icon="@drawable/ic_glass_logo"
             android:label="@string/title_activity_main" >
             <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
                 <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
+                <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
 
             <meta-data
                 android:name="com.google.android.glass.VoiceTrigger"
-                android:resource="@xml/voice_trigger" />
+                android:resource="@xml/voice_trigger_start" />
         </activity>
         <activity
             android:name=".PreviewActivity"
index b5e9d3972f0c6ac52bf902694c7ad628d2b04785..6b981e306a5f22e0c78a0aae7165cf3d358279b1 100644 (file)
@@ -11,6 +11,8 @@ import android.content.Intent;
 import android.media.AudioManager;
 import android.os.Bundle;
 import android.util.Log;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
@@ -86,6 +88,10 @@ public class MainActivity extends Activity {
                IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
                if (scanResult != null) {
                        Log.i(TAG, scanResult.toString());
+                       Intent preview = new Intent(this, PreviewActivity.class);
+                       preview.putExtra("COMPONENT_ID", scanResult.getContents());
+                       startActivity(preview);
+
                }
                // else continue with any other code you need in the method
 
index 5ae8e5954ea8226b66586c58a7560f39ee5c6839..962a8a06c54b60b2fcfd7b1158b6c0b9d82eef1c 100644 (file)
@@ -6,6 +6,7 @@ import android.graphics.Bitmap;
 import android.net.Uri;
 import android.os.Bundle;
 import android.util.Log;
+import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
@@ -15,7 +16,6 @@ import android.widget.Toast;
 
 import java.io.File;
 
-import cz.cvut.fel.dce.qrscanner.mupdf.MuPDFActivity;
 import cz.cvut.fel.dce.qrscanner.mupdf.MuPDFCore;
 
 
@@ -107,32 +107,42 @@ public class PreviewActivity extends Activity implements ViewTreeObserver.OnGlob
        }
 
        /** Called when the user touches the button */
-       public void showContacts(View view) {
+       public void showContacts() {
                showPDF(mComponentRootPath + SKODA_COMP_CONTACTS);
        }
 
        /** Called when the user touches the button */
-       public void showManufacturing(View view) {
+       public void showManufacturing() {
                showPDF(mComponentRootPath + SKODA_COMP_MANUFACTURING);
        }
 
        /** Called when the user touches the button */
-       public void showManufactImages(View view) {
+       public void showManufactImages() {
                showPDF(mComponentRootPath + SKODA_COMP_MANUFACT_IMAGES);
        }
 
        /** Called when the user touches the button */
-       public void showManufactGuide(View view) {
+       public void showManufactGuide() {
                showPDF(mComponentRootPath + SKODA_COMP_MANUFACT_GUIDE);
        }
 
        private void showPDF(String filePath) {
                Uri uri = Uri.parse(filePath);
-               Intent pdfIntent = new Intent(this,MuPDFActivity.class);
-               pdfIntent.setAction(Intent.ACTION_VIEW);
+               Intent pdfIntent = new Intent("com.artifex.mupdfdemo.VIEW");
+               //pdfIntent.setAction(Intent.ACTION_VIEW);
                pdfIntent.setData(uri);
                startActivity(pdfIntent);
        }
+
+       @Override
+       public boolean onKeyDown(int keyCode, KeyEvent event) {
+               if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
+                       openOptionsMenu();
+                       return true;
+               }
+               return super.onKeyDown(keyCode, event);
+       }
+
        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
                // Handle action bar item clicks here. The action bar will
@@ -140,11 +150,28 @@ public class PreviewActivity extends Activity implements ViewTreeObserver.OnGlob
                // as you specify a parent activity in AndroidManifest.xml.
                int id = item.getItemId();
 
-               //noinspection SimplifiableIfStatement
-               if (id == R.id.action_settings) {
+               if (id == R.id.show_contacts) {
+                       showContacts();
                        return true;
                }
-
-               return super.onOptionsItemSelected(item);
+               else if (id == R.id.show_manufacturing) {
+                       showManufacturing();
+                       return true;
+               }
+               else if (id == R.id.show_pictured_manufacturing) {
+                       showManufactImages();
+                       return true;
+               }
+               else if (id == R.id.show_workshop) {
+                       showManufactGuide();
+                       return true;
+               }
+               else if (id == R.id.stop) {
+                       finish();
+                       return true;
+               }
+               else {
+                       return super.onOptionsItemSelected(item);
+               }
        }
 }
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/Annotation.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/Annotation.java
new file mode 100644 (file)
index 0000000..9c8f618
--- /dev/null
@@ -0,0 +1,18 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+import android.graphics.RectF;
+
+public class Annotation extends RectF {
+       enum Type {
+               TEXT, LINK, FREETEXT, LINE, SQUARE, CIRCLE, POLYGON, POLYLINE, HIGHLIGHT,
+               UNDERLINE, SQUIGGLY, STRIKEOUT, STAMP, CARET, INK, POPUP, FILEATTACHMENT,
+               SOUND, MOVIE, WIDGET, SCREEN, PRINTERMARK, TRAPNET, WATERMARK, A3D, UNKNOWN
+       }
+
+       public final Type type;
+
+       public Annotation(float x0, float y0, float x1, float y1, int _type) {
+               super(x0, y0, x1, y1);
+               type = _type == -1 ? Type.UNKNOWN : Type.values()[_type];
+       }
+}
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfo.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfo.java
new file mode 100644 (file)
index 0000000..7dbb179
--- /dev/null
@@ -0,0 +1,14 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+import android.graphics.RectF;
+
+public class LinkInfo {
+       final public RectF rect;
+
+       public LinkInfo(float l, float t, float r, float b) {
+               rect = new RectF(l, t, r, b);
+       }
+
+       public void acceptVisitor(LinkInfoVisitor visitor) {
+       }
+}
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfoExternal.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfoExternal.java
new file mode 100644 (file)
index 0000000..24b339a
--- /dev/null
@@ -0,0 +1,14 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+public class LinkInfoExternal extends LinkInfo {
+       final public String url;
+
+       public LinkInfoExternal(float l, float t, float r, float b, String u) {
+               super(l, t, r, b);
+               url = u;
+       }
+
+       public void acceptVisitor(LinkInfoVisitor visitor) {
+               visitor.visitExternal(this);
+       }
+}
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfoInternal.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfoInternal.java
new file mode 100644 (file)
index 0000000..fe85587
--- /dev/null
@@ -0,0 +1,14 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+public class LinkInfoInternal extends LinkInfo {
+       final public int pageNumber;
+
+       public LinkInfoInternal(float l, float t, float r, float b, int p) {
+               super(l, t, r, b);
+               pageNumber = p;
+       }
+
+       public void acceptVisitor(LinkInfoVisitor visitor) {
+               visitor.visitInternal(this);
+       }
+}
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfoRemote.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfoRemote.java
new file mode 100644 (file)
index 0000000..c794265
--- /dev/null
@@ -0,0 +1,18 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+public class LinkInfoRemote extends LinkInfo {
+       final public String fileSpec;
+       final public int pageNumber;
+       final public boolean newWindow;
+
+       public LinkInfoRemote(float l, float t, float r, float b, String f, int p, boolean n) {
+               super(l, t, r, b);
+               fileSpec = f;
+               pageNumber = p;
+               newWindow = n;
+       }
+
+       public void acceptVisitor(LinkInfoVisitor visitor) {
+               visitor.visitRemote(this);
+       }
+}
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfoVisitor.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/LinkInfoVisitor.java
new file mode 100644 (file)
index 0000000..6faf9a9
--- /dev/null
@@ -0,0 +1,7 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+abstract public class LinkInfoVisitor {
+       public abstract void visitInternal(LinkInfoInternal li);
+       public abstract void visitExternal(LinkInfoExternal li);
+       public abstract void visitRemote(LinkInfoRemote li);
+}
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/MuPDFAlert.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/MuPDFAlert.java
new file mode 100644 (file)
index 0000000..9673969
--- /dev/null
@@ -0,0 +1,21 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+public class MuPDFAlert {
+       public enum IconType {Error,Warning,Question,Status};
+       public enum ButtonPressed {None,Ok,Cancel,No,Yes};
+       public enum ButtonGroupType {Ok,OkCancel,YesNo,YesNoCancel};
+
+       public final String message;
+       public final IconType iconType;
+       public final ButtonGroupType buttonGroupType;
+       public final String title;
+       public ButtonPressed buttonPressed;
+
+       MuPDFAlert(String aMessage, IconType aIconType, ButtonGroupType aButtonGroupType, String aTitle, ButtonPressed aButtonPressed) {
+               message = aMessage;
+               iconType = aIconType;
+               buttonGroupType = aButtonGroupType;
+               title = aTitle;
+               buttonPressed = aButtonPressed;
+       }
+}
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/MuPDFAlertInternal.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/MuPDFAlertInternal.java
new file mode 100644 (file)
index 0000000..ff4848a
--- /dev/null
@@ -0,0 +1,30 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+// Version of MuPDFAlert without enums to simplify JNI
+public class MuPDFAlertInternal {
+       public final String message;
+       public final int iconType;
+       public final int buttonGroupType;
+       public final String title;
+       public int buttonPressed;
+
+       MuPDFAlertInternal(String aMessage, int aIconType, int aButtonGroupType, String aTitle, int aButtonPressed) {
+               message = aMessage;
+               iconType = aIconType;
+               buttonGroupType = aButtonGroupType;
+               title = aTitle;
+               buttonPressed = aButtonPressed;
+       }
+
+       MuPDFAlertInternal(MuPDFAlert alert) {
+               message = alert.message;
+               iconType = alert.iconType.ordinal();
+               buttonGroupType = alert.buttonGroupType.ordinal();
+               title = alert.message;
+               buttonPressed = alert.buttonPressed.ordinal();
+       }
+
+       MuPDFAlert toAlert() {
+               return new MuPDFAlert(message, MuPDFAlert.IconType.values()[iconType], MuPDFAlert.ButtonGroupType.values()[buttonGroupType], title, MuPDFAlert.ButtonPressed.values()[buttonPressed]);
+       }
+}
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/MuPDFCore.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/MuPDFCore.java
new file mode 100644 (file)
index 0000000..efe1bf3
--- /dev/null
@@ -0,0 +1,416 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.PointF;
+import android.graphics.RectF;
+
+import java.util.ArrayList;
+
+import cz.cvut.fel.dce.qrscanner.R;
+
+public class MuPDFCore
+{
+       /* load our native library */
+       static {
+               System.loadLibrary("mupdf");
+       }
+
+       /* Readable members */
+       private int numPages = -1;
+       private float pageWidth;
+       private float pageHeight;
+       private long globals;
+       private byte fileBuffer[];
+       private String file_format;
+       private boolean isUnencryptedPDF;
+       private final boolean wasOpenedFromBuffer;
+
+       /* The native functions */
+       private native long openFile(String filename);
+       private native long openBuffer(String magic);
+       private native String fileFormatInternal();
+       private native boolean isUnencryptedPDFInternal();
+       private native int countPagesInternal();
+       private native void gotoPageInternal(int localActionPageNum);
+       private native float getPageWidth();
+       private native float getPageHeight();
+       private native void drawPage(Bitmap bitmap,
+                       int pageW, int pageH,
+                       int patchX, int patchY,
+                       int patchW, int patchH,
+                       long cookiePtr);
+       private native void updatePageInternal(Bitmap bitmap,
+                       int page,
+                       int pageW, int pageH,
+                       int patchX, int patchY,
+                       int patchW, int patchH,
+                       long cookiePtr);
+       private native RectF[] searchPage(String text);
+       private native TextChar[][][][] text();
+       private native byte[] textAsHtml();
+       private native void addMarkupAnnotationInternal(PointF[] quadPoints, int type);
+       private native void addInkAnnotationInternal(PointF[][] arcs);
+       private native void deleteAnnotationInternal(int annot_index);
+       private native int passClickEventInternal(int page, float x, float y);
+       private native void setFocusedWidgetChoiceSelectedInternal(String [] selected);
+       private native String [] getFocusedWidgetChoiceSelected();
+       private native String [] getFocusedWidgetChoiceOptions();
+       private native int getFocusedWidgetSignatureState();
+       private native String checkFocusedSignatureInternal();
+       private native boolean signFocusedSignatureInternal(String keyFile, String password);
+       private native int setFocusedWidgetTextInternal(String text);
+       private native String getFocusedWidgetTextInternal();
+       private native int getFocusedWidgetTypeInternal();
+       private native LinkInfo [] getPageLinksInternal(int page);
+       private native RectF[] getWidgetAreasInternal(int page);
+       private native Annotation[] getAnnotationsInternal(int page);
+       private native OutlineItem [] getOutlineInternal();
+       private native boolean hasOutlineInternal();
+       private native boolean needsPasswordInternal();
+       private native boolean authenticatePasswordInternal(String password);
+       private native MuPDFAlertInternal waitForAlertInternal();
+       private native void replyToAlertInternal(MuPDFAlertInternal alert);
+       private native void startAlertsInternal();
+       private native void stopAlertsInternal();
+       private native void destroying();
+       private native boolean hasChangesInternal();
+       private native void saveInternal();
+       private native long createCookie();
+       private native void destroyCookie(long cookie);
+       private native void abortCookie(long cookie);
+
+       public native boolean javascriptSupported();
+
+       enum SignatureState {
+               NoSupport,
+               Unsigned,
+               Signed
+       }
+
+       abstract class PassClickResultVisitor {
+               public abstract void visitText(PassClickResultText result);
+               public abstract void visitChoice(PassClickResultChoice result);
+               public abstract void visitSignature(PassClickResultSignature result);
+       }
+
+       class PassClickResult {
+               public final boolean changed;
+
+               public PassClickResult(boolean _changed) {
+                       changed = _changed;
+               }
+
+               public void acceptVisitor(PassClickResultVisitor visitor) {
+               }
+       }
+
+       class PassClickResultText extends PassClickResult {
+               public final String text;
+
+               public PassClickResultText(boolean _changed, String _text) {
+                       super(_changed);
+                       text = _text;
+               }
+
+               public void acceptVisitor(PassClickResultVisitor visitor) {
+                       visitor.visitText(this);
+               }
+       }
+
+       class PassClickResultChoice extends PassClickResult {
+               public final String [] options;
+               public final String [] selected;
+
+               public PassClickResultChoice(boolean _changed, String [] _options, String [] _selected) {
+                       super(_changed);
+                       options = _options;
+                       selected = _selected;
+               }
+
+               public void acceptVisitor(PassClickResultVisitor visitor) {
+                       visitor.visitChoice(this);
+               }
+       }
+
+       class PassClickResultSignature extends PassClickResult {
+               public final SignatureState state;
+
+               public PassClickResultSignature(boolean _changed, int _state) {
+                       super(_changed);
+                       state = SignatureState.values()[_state];
+               }
+
+               public void acceptVisitor(PassClickResultVisitor visitor) {
+                       visitor.visitSignature(this);
+               }
+       }
+
+       public class Cookie
+       {
+               private final long cookiePtr;
+
+               public Cookie()
+               {
+                       cookiePtr = createCookie();
+                       if (cookiePtr == 0)
+                               throw new OutOfMemoryError();
+               }
+
+               public void abort()
+               {
+                       abortCookie(cookiePtr);
+               }
+
+               public void destroy()
+               {
+                       // We could do this in finalize, but there's no guarantee that
+                       // a finalize will occur before the muPDF context occurs.
+                       destroyCookie(cookiePtr);
+               }
+       }
+
+       public MuPDFCore(Context context, String filename) throws Exception
+       {
+               globals = openFile(filename);
+               if (globals == 0)
+               {
+                       throw new Exception(String.format(context.getString(R.string.cannot_open_file_Path), filename));
+               }
+               file_format = fileFormatInternal();
+               isUnencryptedPDF = isUnencryptedPDFInternal();
+               wasOpenedFromBuffer = false;
+       }
+
+       public MuPDFCore(Context context, byte buffer[], String magic) throws Exception {
+               fileBuffer = buffer;
+               globals = openBuffer(magic != null ? magic : "");
+               if (globals == 0)
+               {
+                       throw new Exception(context.getString(R.string.cannot_open_buffer));
+               }
+               file_format = fileFormatInternal();
+               isUnencryptedPDF = isUnencryptedPDFInternal();
+               wasOpenedFromBuffer = true;
+       }
+
+       public  int countPages()
+       {
+               if (numPages < 0)
+                       numPages = countPagesSynchronized();
+
+               return numPages;
+       }
+
+       public String fileFormat()
+       {
+               return file_format;
+       }
+
+       public boolean isUnencryptedPDF()
+       {
+               return isUnencryptedPDF;
+       }
+
+       public boolean wasOpenedFromBuffer()
+       {
+               return wasOpenedFromBuffer;
+       }
+
+       private synchronized int countPagesSynchronized() {
+               return countPagesInternal();
+       }
+
+       /* Shim function */
+       private void gotoPage(int page)
+       {
+               if (page > numPages-1)
+                       page = numPages-1;
+               else if (page < 0)
+                       page = 0;
+               gotoPageInternal(page);
+               this.pageWidth = getPageWidth();
+               this.pageHeight = getPageHeight();
+       }
+
+       public synchronized PointF getPageSize(int page) {
+               gotoPage(page);
+               return new PointF(pageWidth, pageHeight);
+       }
+
+       public MuPDFAlert waitForAlert() {
+               MuPDFAlertInternal alert = waitForAlertInternal();
+               return alert != null ? alert.toAlert() : null;
+       }
+
+       public void replyToAlert(MuPDFAlert alert) {
+               replyToAlertInternal(new MuPDFAlertInternal(alert));
+       }
+
+       public void stopAlerts() {
+               stopAlertsInternal();
+       }
+
+       public void startAlerts() {
+               startAlertsInternal();
+       }
+
+       public synchronized void onDestroy() {
+               destroying();
+               globals = 0;
+       }
+
+       public synchronized void drawPage(Bitmap bm, int page,
+                       int pageW, int pageH,
+                       int patchX, int patchY,
+                       int patchW, int patchH,
+                       Cookie cookie) {
+               gotoPage(page);
+               drawPage(bm, pageW, pageH, patchX, patchY, patchW, patchH, cookie.cookiePtr);
+       }
+
+       public synchronized void updatePage(Bitmap bm, int page,
+                       int pageW, int pageH,
+                       int patchX, int patchY,
+                       int patchW, int patchH,
+                       Cookie cookie) {
+               updatePageInternal(bm, page, pageW, pageH, patchX, patchY, patchW, patchH, cookie.cookiePtr);
+       }
+
+       public synchronized PassClickResult passClickEvent(int page, float x, float y) {
+               boolean changed = passClickEventInternal(page, x, y) != 0;
+
+               switch (WidgetType.values()[getFocusedWidgetTypeInternal()])
+               {
+               case TEXT:
+                       return new PassClickResultText(changed, getFocusedWidgetTextInternal());
+               case LISTBOX:
+               case COMBOBOX:
+                       return new PassClickResultChoice(changed, getFocusedWidgetChoiceOptions(), getFocusedWidgetChoiceSelected());
+               case SIGNATURE:
+                       return new PassClickResultSignature(changed, getFocusedWidgetSignatureState());
+               default:
+                       return new PassClickResult(changed);
+               }
+
+       }
+
+       public synchronized boolean setFocusedWidgetText(int page, String text) {
+               boolean success;
+               gotoPage(page);
+               success = setFocusedWidgetTextInternal(text) != 0 ? true : false;
+
+               return success;
+       }
+
+       public synchronized void setFocusedWidgetChoiceSelected(String [] selected) {
+               setFocusedWidgetChoiceSelectedInternal(selected);
+       }
+
+       public synchronized String checkFocusedSignature() {
+               return checkFocusedSignatureInternal();
+       }
+
+       public synchronized boolean signFocusedSignature(String keyFile, String password) {
+               return signFocusedSignatureInternal(keyFile, password);
+       }
+
+       public synchronized LinkInfo [] getPageLinks(int page) {
+               return getPageLinksInternal(page);
+       }
+
+       public synchronized RectF [] getWidgetAreas(int page) {
+               return getWidgetAreasInternal(page);
+       }
+
+       public synchronized Annotation [] getAnnoations(int page) {
+               return getAnnotationsInternal(page);
+       }
+
+       public synchronized RectF [] searchPage(int page, String text) {
+               gotoPage(page);
+               return searchPage(text);
+       }
+
+       public synchronized byte[] html(int page) {
+               gotoPage(page);
+               return textAsHtml();
+       }
+
+       public synchronized TextWord [][] textLines(int page) {
+               gotoPage(page);
+               TextChar[][][][] chars = text();
+
+               // The text of the page held in a hierarchy (blocks, lines, spans).
+               // Currently we don't need to distinguish the blocks level or
+               // the spans, and we need to collect the text into words.
+               ArrayList<TextWord[]> lns = new ArrayList<TextWord[]>();
+
+               for (TextChar[][][] bl: chars) {
+                       if (bl == null)
+                               continue;
+                       for (TextChar[][] ln: bl) {
+                               ArrayList<TextWord> wds = new ArrayList<TextWord>();
+                               TextWord wd = new TextWord();
+
+                               for (TextChar[] sp: ln) {
+                                       for (TextChar tc: sp) {
+                                               if (tc.c != ' ') {
+                                                       wd.Add(tc);
+                                               } else if (wd.w.length() > 0) {
+                                                       wds.add(wd);
+                                                       wd = new TextWord();
+                                               }
+                                       }
+                               }
+
+                               if (wd.w.length() > 0)
+                                       wds.add(wd);
+
+                               if (wds.size() > 0)
+                                       lns.add(wds.toArray(new TextWord[wds.size()]));
+                       }
+               }
+
+               return lns.toArray(new TextWord[lns.size()][]);
+       }
+
+       public synchronized void addMarkupAnnotation(int page, PointF[] quadPoints, Annotation.Type type) {
+               gotoPage(page);
+               addMarkupAnnotationInternal(quadPoints, type.ordinal());
+       }
+
+       public synchronized void addInkAnnotation(int page, PointF[][] arcs) {
+               gotoPage(page);
+               addInkAnnotationInternal(arcs);
+       }
+
+       public synchronized void deleteAnnotation(int page, int annot_index) {
+               gotoPage(page);
+               deleteAnnotationInternal(annot_index);
+       }
+
+       public synchronized boolean hasOutline() {
+               return hasOutlineInternal();
+       }
+
+       public synchronized OutlineItem [] getOutline() {
+               return getOutlineInternal();
+       }
+
+       public synchronized boolean needsPassword() {
+               return needsPasswordInternal();
+       }
+
+       public synchronized boolean authenticatePassword(String password) {
+               return authenticatePasswordInternal(password);
+       }
+
+       public synchronized boolean hasChanges() {
+               return hasChangesInternal();
+       }
+
+       public synchronized void save() {
+               saveInternal();
+       }
+}
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/OutlineItem.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/OutlineItem.java
new file mode 100644 (file)
index 0000000..d31d238
--- /dev/null
@@ -0,0 +1,14 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+public class OutlineItem {
+       public final int    level;
+       public final String title;
+       public final int    page;
+
+       OutlineItem(int _level, String _title, int _page) {
+               level = _level;
+               title = _title;
+               page  = _page;
+       }
+
+}
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/TextChar.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/TextChar.java
new file mode 100644 (file)
index 0000000..6920378
--- /dev/null
@@ -0,0 +1,12 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+import android.graphics.RectF;
+
+public class TextChar extends RectF {
+       public char c;
+
+       public TextChar(float x0, float y0, float x1, float y1, char _c) {
+               super(x0, y0, x1, y1);
+               c = _c;
+       }
+}
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/TextWord.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/TextWord.java
new file mode 100644 (file)
index 0000000..f318716
--- /dev/null
@@ -0,0 +1,17 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+import android.graphics.RectF;
+
+public class TextWord extends RectF {
+       public String w;
+
+       public TextWord() {
+               super();
+               w = new String();
+       }
+
+       public void Add(TextChar tc) {
+               super.union(tc);
+               w = w.concat(new String(new char[]{tc.c}));
+       }
+}
diff --git a/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/WidgetType.java b/QRScanner/glass/src/main/java/cz/cvut/fel/dce/qrscanner/mupdf/WidgetType.java
new file mode 100644 (file)
index 0000000..cf22c7d
--- /dev/null
@@ -0,0 +1,9 @@
+package cz.cvut.fel.dce.qrscanner.mupdf;
+
+public enum WidgetType {
+       NONE,
+       TEXT,
+       LISTBOX,
+       COMBOBOX,
+       SIGNATURE
+}
diff --git a/QRScanner/glass/src/main/res/drawable-hdpi/ic_glass_logo.png b/QRScanner/glass/src/main/res/drawable-hdpi/ic_glass_logo.png
deleted file mode 100644 (file)
index 2f17b96..0000000
Binary files a/QRScanner/glass/src/main/res/drawable-hdpi/ic_glass_logo.png and /dev/null differ
diff --git a/QRScanner/glass/src/main/res/drawable-hdpi/ic_launcher.png b/QRScanner/glass/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..c8dd628
Binary files /dev/null and b/QRScanner/glass/src/main/res/drawable-hdpi/ic_launcher.png differ
diff --git a/QRScanner/glass/src/main/res/drawable-mdpi/ic_glass_logo.png b/QRScanner/glass/src/main/res/drawable-mdpi/ic_glass_logo.png
new file mode 100644 (file)
index 0000000..e63a697
Binary files /dev/null and b/QRScanner/glass/src/main/res/drawable-mdpi/ic_glass_logo.png differ
diff --git a/QRScanner/glass/src/main/res/drawable-mdpi/ic_launcher.png b/QRScanner/glass/src/main/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644 (file)
index 359047d..0000000
Binary files a/QRScanner/glass/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ
index 71c6d760f05183ef8a47c614d8d13380c8528499..e613affd98a1ed4bd7544b9350d365562eb4a97f 100644 (file)
Binary files a/QRScanner/glass/src/main/res/drawable-xhdpi/ic_launcher.png and b/QRScanner/glass/src/main/res/drawable-xhdpi/ic_launcher.png differ
index 4df18946442ed763bd52cf3adca31617848656fa..37ea1fec3a7c4caa91fcb2060c461763d6369add 100644 (file)
Binary files a/QRScanner/glass/src/main/res/drawable-xxhdpi/ic_launcher.png and b/QRScanner/glass/src/main/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/QRScanner/glass/src/main/res/drawable/ic_launcher.png b/QRScanner/glass/src/main/res/drawable/ic_launcher.png
new file mode 100644 (file)
index 0000000..5f934ba
Binary files /dev/null and b/QRScanner/glass/src/main/res/drawable/ic_launcher.png differ
diff --git a/QRScanner/glass/src/main/res/drawable/skoda_logo.png b/QRScanner/glass/src/main/res/drawable/skoda_logo.png
new file mode 100644 (file)
index 0000000..eb28971
Binary files /dev/null and b/QRScanner/glass/src/main/res/drawable/skoda_logo.png differ
diff --git a/QRScanner/glass/src/main/res/layout/activity_main.xml b/QRScanner/glass/src/main/res/layout/activity_main.xml
new file mode 100644 (file)
index 0000000..c505b1c
--- /dev/null
@@ -0,0 +1,20 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                xmlns:tools="http://schemas.android.com/tools"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                tools:context=".MainActivity">
+
+    <ImageView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:id="@+id/imageView"
+        android:src="@drawable/skoda_logo"
+        android:layout_alignParentLeft="true"
+        android:layout_alignParentStart="true"
+        android:layout_alignParentTop="true"
+        android:layout_alignParentBottom="true"
+        android:layout_toLeftOf="@+id/button"
+        android:onClick="findComponent"
+        android:layout_toStartOf="@+id/button"/>
+
+</RelativeLayout>
diff --git a/QRScanner/glass/src/main/res/layout/activity_preview.xml b/QRScanner/glass/src/main/res/layout/activity_preview.xml
new file mode 100644 (file)
index 0000000..bda0690
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="horizontal"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent">
+
+    <ImageView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:id="@+id/imgComponent"
+        android:layout_weight="0.95"
+        android:layout_gravity="center_horizontal"
+        android:scaleType="center"/>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/QRScanner/glass/src/main/res/menu/menu_preview.xml b/QRScanner/glass/src/main/res/menu/menu_preview.xml
new file mode 100644 (file)
index 0000000..a51c359
--- /dev/null
@@ -0,0 +1,20 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:app="http://schemas.android.com/apk/res-auto"
+      xmlns:tools="http://schemas.android.com/tools"
+      tools:context="cz.cvut.fel.dce.qrscanner.PreviewActivity">
+    <item android:id="@+id/show_contacts"
+          android:title="@string/show_contacts"
+          android:orderInCategory="100"/>
+    <item android:id="@+id/show_manufacturing"
+          android:title="@string/show_manufacturing"
+          android:orderInCategory="100"/>
+    <item android:id="@+id/show_pictured_manufacturing"
+          android:title="@string/show_pictured_manufacturing"
+          android:orderInCategory="100"/>
+    <item android:id="@+id/show_workshop"
+          android:title="@string/show_workshop"
+          android:orderInCategory="100"/>
+    <item android:id="@+id/stop"
+          android:title="@string/action_stop"
+          android:orderInCategory="100"/>
+</menu>
index e277cdf33c4f42a8c2119a3b48a55644ec26060c..09435042265485dcc46e8d9858cb3f8f22db234d 100644 (file)
@@ -22,5 +22,11 @@ limitations under the License.
   <string name="hello_world">Skoda Demo</string>
     <string name="action_stop">Stop</string>
     <string name="action_scan">Scan code</string>
-
+    <string name="cannot_open_file_Path">Cannot open file: %1$s</string>
+    <string name="cannot_open_buffer">Cannot open buffer</string>
+    <string name="show_contacts">Contacts</string>
+    <string name="show_manufacturing">Manufacturing</string>
+    <string name="show_pictured_manufacturing">Pictured manuf</string>
+    <string name="show_workshop">Workshow guide</string>
+    <string name="glass_voice_trigger">Skoda Manufacturer Helper</string>
 </resources>
index 65a325de2ebfbce932fbb75d7ea36faa0ff99680..045e125f3d8dad8668061d471dd9869e29e4713a 100644 (file)
@@ -1,5 +1,3 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-    <style name="AppTheme" parent="android:Theme.Holo.Light">
-    </style>
 </resources>
diff --git a/QRScanner/glass/src/main/res/xml/voice_trigger.xml b/QRScanner/glass/src/main/res/xml/voice_trigger.xml
deleted file mode 100644 (file)
index d9283e1..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-<!-- For more information about voice trigger, check out: https://developers.google.com/glass/develop/gdk/starting-glassware -->
-<trigger command="SHOW_ME_A_DEMO"/>
diff --git a/QRScanner/glass/src/main/res/xml/voice_trigger_start.xml b/QRScanner/glass/src/main/res/xml/voice_trigger_start.xml
new file mode 100644 (file)
index 0000000..33b8938
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+
+<trigger keyword="@string/glass_voice_trigger">
+
+    <constraints network="false" /> // asi neni nutne, a asi tam nemusi byt android: prefix
+
+</trigger>
\ No newline at end of file
index d81bd082513ded60e0e4cbc6df0b41bf4f3b1925..f8f199bcd7a50cb2c14c2747f48c9eaa27f4a572 100644 (file)
@@ -89,9 +89,7 @@
     <orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
     <orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
     <orderEntry type="library" exported="" name="native-libs" level="project" />
-    <orderEntry type="library" exported="" name="iocommons" level="project" />
     <orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
-    <orderEntry type="library" exported="" name="PdfViewer" level="project" />
   </component>
 </module>
 
index 9539e07610f9edc0ae8ba42cf35ace8a511fdc56..ff5cfe71d4256da2ea6190404d0c4109fd89095d 100644 (file)
@@ -79,7 +79,6 @@ public class PreviewActivity extends ActionBarActivity implements ViewTreeObserv
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
                // Inflate the menu; this adds items to the action bar if it is present.
-               getMenuInflater().inflate(R.menu.menu_preview, menu);
                return true;
        }
 
diff --git a/QRScanner/mobile/src/main/res/menu/menu_preview.xml b/QRScanner/mobile/src/main/res/menu/menu_preview.xml
deleted file mode 100644 (file)
index 315a85a..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<menu xmlns:android="http://schemas.android.com/apk/res/android"
-      xmlns:app="http://schemas.android.com/apk/res-auto"
-      xmlns:tools="http://schemas.android.com/tools"
-      tools:context="cz.cvut.fel.dce.qrscanner.PreviewActivity">
-</menu>
index ecd78869434dd3a505d82d91f72ec216a42cfd13..99c1eb1102970e72a3c35a029ff42f530dc6d0c1 100644 (file)
@@ -66,4 +66,5 @@
     <string name="butManufacturingGuide">Workshop manual</string>
     <string name="previewHeading">Select document to view</string>
 
+
 </resources>