summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk18
-rwxr-xr-xAndroidManifest.xml5
-rw-r--r--quickReader/libs/core-1.9.3.aarbin0 -> 20669 bytes
-rw-r--r--quickReader/libs/zxing-1.9.3.aarbin0 -> 6430 bytes
-rw-r--r--quickReader/libs/zxing-core-g-2.3.1.jarbin0 -> 544403 bytes
-rw-r--r--quickReader/res/drawable/bg_circle.xml18
-rw-r--r--quickReader/res/drawable/ic_close.xml24
-rw-r--r--quickReader/res/drawable/ic_contact.xml24
-rw-r--r--quickReader/res/drawable/ic_email.xml24
-rw-r--r--quickReader/res/drawable/ic_event.xml24
-rw-r--r--quickReader/res/drawable/ic_flash_off.xml24
-rw-r--r--quickReader/res/drawable/ic_flash_on.xml24
-rw-r--r--quickReader/res/drawable/ic_http.xml24
-rw-r--r--quickReader/res/drawable/ic_location.xml24
-rw-r--r--quickReader/res/drawable/ic_phone.xml24
-rw-r--r--quickReader/res/drawable/ic_sms.xml24
-rw-r--r--quickReader/res/drawable/ic_text.xml24
-rw-r--r--quickReader/res/layout/activity_scanner.xml68
-rw-r--r--quickReader/res/values/colors.xml34
-rw-r--r--quickReader/res/values/strings.xml47
-rw-r--r--quickReader/res/values/styles.xml29
-rw-r--r--quickReader/src/org/lineageos/quickreader/ScannerActivity.java321
-rw-r--r--quickReader/src/org/lineageos/quickreader/ScannerIntentHelper.java238
23 files changed, 1042 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
index c5ba6226e..8778cf91e 100644
--- a/Android.mk
+++ b/Android.mk
@@ -7,20 +7,29 @@ LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES += xmp_toolkit
+LOCAL_STATIC_JAVA_LIBRARIES += zxing-core
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SRC_FILES += $(call all-java-files-under, src_pd)
LOCAL_SRC_FILES += $(call all-java-files-under, src_pd_gcam)
LOCAL_SRC_FILES += $(call all-java-files-under, src_wrapper)
+LOCAL_SRC_FILES += $(call all-java-files-under, quickReader/src)
LOCAL_SRC_FILES += $(call all-renderscript-files-under, rs)
LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/res
+LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/quickReader/res
include $(LOCAL_PATH)/version.mk
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--version-name "$(version_name_package)" \
--version-code $(version_code_package) \
+ --extra-packages me.dm7.barcodescanner.core \
+ --extra-packages me.dm7.barcodescanner.zxing
+
+LOCAL_STATIC_JAVA_AAR_LIBRARIES += \
+ qreader-core \
+ qreader-zxing
LOCAL_JAVA_LIBRARIES := org.lineageos.platform.internal
@@ -48,4 +57,13 @@ endif
include $(BUILD_PACKAGE)
+include $(CLEAR_VARS)
+
+LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += \
+ qreader-core:quickReader/libs/core-1.9.3.aar \
+ qreader-zxing:quickReader/libs/zxing-1.9.3.aar \
+ zxing-core:quickReader/libs/zxing-core-g-2.3.1.jar
+
+include $(BUILD_MULTI_PREBUILT)
+
include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5d1cbdcca..fd52e4845 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -174,6 +174,11 @@
android:configChanges="keyboardHidden|orientation|screenSize">
</activity>
+ <activity
+ android:name="org.lineageos.quickreader.ScannerActivity"
+ android:label="@string/quick_reader_name"
+ android:theme="@style/AppTheme" />
+
<receiver android:name="com.android.camera.DisableCameraReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
diff --git a/quickReader/libs/core-1.9.3.aar b/quickReader/libs/core-1.9.3.aar
new file mode 100644
index 000000000..a604341c8
--- /dev/null
+++ b/quickReader/libs/core-1.9.3.aar
Binary files differ
diff --git a/quickReader/libs/zxing-1.9.3.aar b/quickReader/libs/zxing-1.9.3.aar
new file mode 100644
index 000000000..89ca043d9
--- /dev/null
+++ b/quickReader/libs/zxing-1.9.3.aar
Binary files differ
diff --git a/quickReader/libs/zxing-core-g-2.3.1.jar b/quickReader/libs/zxing-core-g-2.3.1.jar
new file mode 100644
index 000000000..05d7cda7e
--- /dev/null
+++ b/quickReader/libs/zxing-core-g-2.3.1.jar
Binary files differ
diff --git a/quickReader/res/drawable/bg_circle.xml b/quickReader/res/drawable/bg_circle.xml
new file mode 100644
index 000000000..658e9ef67
--- /dev/null
+++ b/quickReader/res/drawable/bg_circle.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="oval"
+ android:tint="@color/identify_background" />
diff --git a/quickReader/res/drawable/ic_close.xml b/quickReader/res/drawable/ic_close.xml
new file mode 100644
index 000000000..0f836bb1e
--- /dev/null
+++ b/quickReader/res/drawable/ic_close.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@color/identify_foreground"
+ android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" />
+</vector>
diff --git a/quickReader/res/drawable/ic_contact.xml b/quickReader/res/drawable/ic_contact.xml
new file mode 100644
index 000000000..b702c09a8
--- /dev/null
+++ b/quickReader/res/drawable/ic_contact.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@color/identify_contact"
+ android:pathData="M22,3L2,3C0.9,3 0,3.9 0,5v14c0,1.1 0.9,2 2,2h20c1.1,0 1.99,-0.9 1.99,-2L24,5c0,-1.1 -0.9,-2 -2,-2zM8,6c1.66,0 3,1.34 3,3s-1.34,3 -3,3 -3,-1.34 -3,-3 1.34,-3 3,-3zM14,18L2,18v-1c0,-2 4,-3.1 6,-3.1s6,1.1 6,3.1v1zM17.85,14h1.64L21,16l-1.99,1.99c-1.31,-0.98 -2.28,-2.38 -2.73,-3.99 -0.18,-0.64 -0.28,-1.31 -0.28,-2s0.1,-1.36 0.28,-2c0.45,-1.62 1.42,-3.01 2.73,-3.99L21,8l-1.51,2h-1.64c-0.22,0.63 -0.35,1.3 -0.35,2s0.13,1.37 0.35,2z" />
+</vector>
diff --git a/quickReader/res/drawable/ic_email.xml b/quickReader/res/drawable/ic_email.xml
new file mode 100644
index 000000000..78a278a37
--- /dev/null
+++ b/quickReader/res/drawable/ic_email.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@color/identify_email"
+ android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z" />
+</vector>
diff --git a/quickReader/res/drawable/ic_event.xml b/quickReader/res/drawable/ic_event.xml
new file mode 100644
index 000000000..fc0525714
--- /dev/null
+++ b/quickReader/res/drawable/ic_event.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@color/identify_event"
+ android:pathData="M17,12h-5v5h5v-5zM16,1v2L8,3L8,1L6,1v2L5,3c-1.11,0 -1.99,0.9 -1.99,2L3,19c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2h-1L18,1h-2zM19,19L5,19L5,8h14v11z" />
+</vector>
diff --git a/quickReader/res/drawable/ic_flash_off.xml b/quickReader/res/drawable/ic_flash_off.xml
new file mode 100644
index 000000000..92c256f6b
--- /dev/null
+++ b/quickReader/res/drawable/ic_flash_off.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@color/identify_foreground"
+ android:pathData="M3.27,3L2,4.27l5,5V13h3v9l3.58,-6.14L17.73,20 19,18.73 3.27,3zM17,10h-4l4,-8H7v2.18l8.46,8.46L17,10z" />
+</vector>
diff --git a/quickReader/res/drawable/ic_flash_on.xml b/quickReader/res/drawable/ic_flash_on.xml
new file mode 100644
index 000000000..143e4a18e
--- /dev/null
+++ b/quickReader/res/drawable/ic_flash_on.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@color/identify_foreground"
+ android:pathData="M7,2v11h3v9l7,-12h-4l4,-8z" />
+</vector>
diff --git a/quickReader/res/drawable/ic_http.xml b/quickReader/res/drawable/ic_http.xml
new file mode 100644
index 000000000..12f394946
--- /dev/null
+++ b/quickReader/res/drawable/ic_http.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@color/identify_http"
+ android:pathData="M4.5,11h-2L2.5,9L1,9v6h1.5v-2.5h2L4.5,15L6,15L6,9L4.5,9v2zM7,10.5h1.5L8.5,15L10,15v-4.5h1.5L11.5,9L7,9v1.5zM12.5,10.5L14,10.5L14,15h1.5v-4.5L17,10.5L17,9h-4.5v1.5zM21.5,9L18,9v6h1.5v-2h2c0.8,0 1.5,-0.7 1.5,-1.5v-1c0,-0.8 -0.7,-1.5 -1.5,-1.5zM21.5,11.5h-2v-1h2v1z" />
+</vector>
diff --git a/quickReader/res/drawable/ic_location.xml b/quickReader/res/drawable/ic_location.xml
new file mode 100644
index 000000000..c3fa70c5c
--- /dev/null
+++ b/quickReader/res/drawable/ic_location.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@color/identify_location"
+ android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zM12,11.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z" />
+</vector>
diff --git a/quickReader/res/drawable/ic_phone.xml b/quickReader/res/drawable/ic_phone.xml
new file mode 100644
index 000000000..3616ce1a6
--- /dev/null
+++ b/quickReader/res/drawable/ic_phone.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@color/identify_phone"
+ android:pathData="M6.62,10.79c1.44,2.83 3.76,5.14 6.59,6.59l2.2,-2.2c0.27,-0.27 0.67,-0.36 1.02,-0.24 1.12,0.37 2.33,0.57 3.57,0.57 0.55,0 1,0.45 1,1V20c0,0.55 -0.45,1 -1,1 -9.39,0 -17,-7.61 -17,-17 0,-0.55 0.45,-1 1,-1h3.5c0.55,0 1,0.45 1,1 0,1.25 0.2,2.45 0.57,3.57 0.11,0.35 0.03,0.74 -0.25,1.02l-2.2,2.2z" />
+</vector>
diff --git a/quickReader/res/drawable/ic_sms.xml b/quickReader/res/drawable/ic_sms.xml
new file mode 100644
index 000000000..be1f5da91
--- /dev/null
+++ b/quickReader/res/drawable/ic_sms.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@color/identify_sms"
+ android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM18,14L6,14v-2h12v2zM18,11L6,11L6,9h12v2zM18,8L6,8L6,6h12v2z" />
+</vector>
diff --git a/quickReader/res/drawable/ic_text.xml b/quickReader/res/drawable/ic_text.xml
new file mode 100644
index 000000000..ecbd76893
--- /dev/null
+++ b/quickReader/res/drawable/ic_text.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@color/identify_text"
+ android:pathData="M2.5,4v3h5v12h3L10.5,7h5L15.5,4h-13zM21.5,9h-9v3h3v7h3v-7h3L21.5,9z" />
+</vector>
diff --git a/quickReader/res/layout/activity_scanner.xml b/quickReader/res/layout/activity_scanner.xml
new file mode 100644
index 000000000..6b72ec19f
--- /dev/null
+++ b/quickReader/res/layout/activity_scanner.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <me.dm7.barcodescanner.zxing.ZXingScannerView
+ android:id="@+id/scanner_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+<!-- Enable when bumping library version to 1.9.8 and api 25
+ app:borderColor="@color/viewfinder_border"
+ app:borderWidth="4dp"
+ app:cornerRadius="4dp"
+ app:laserColor="@color/viewfinder_laser"
+ app:maskColor="@color/viewfinder_bg"
+ app:roundedCorner="true"
+ app:squaredFinder="true"
+-->
+
+ <ImageView
+ android:id="@+id/action_close"
+ style="@style/AppTheme.ActionIcon"
+ android:layout_gravity="start|top"
+ android:src="@drawable/ic_close" />
+
+ <ImageView
+ android:id="@+id/action_flash"
+ style="@style/AppTheme.ActionIcon"
+ android:layout_gravity="end|top"
+ android:src="@drawable/ic_flash_off" />
+
+ <FrameLayout
+ android:id="@+id/identify_layout"
+ android:layout_width="64dp"
+ android:layout_height="64dp"
+ android:layout_gravity="center_horizontal|bottom"
+ android:layout_marginBottom="72dp"
+ android:layout_marginEnd="16dp"
+ android:layout_marginStart="16dp"
+ android:background="@drawable/bg_circle"
+ android:scaleX="0"
+ android:scaleY="0"
+ android:transformPivotX="32dp"
+ android:transformPivotY="32dp">
+
+ <ImageView
+ android:id="@+id/identify_icon"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:layout_gravity="center" />
+ </FrameLayout>
+</FrameLayout>
diff --git a/quickReader/res/values/colors.xml b/quickReader/res/values/colors.xml
new file mode 100644
index 000000000..1ef5eb102
--- /dev/null
+++ b/quickReader/res/values/colors.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <color name="colorAccent">#167c80</color>
+
+ <color name="identify_background">#333333</color>
+ <color name="identify_foreground">#f5f5f5</color>
+
+ <color name="viewfinder_bg">#401b1b1b</color>
+ <color name="scan_laser">#F44336</color>
+ <color name="scan_border">#4CAF50</color>
+
+ <color name="identify_contact">#03A9F4</color>
+ <color name="identify_email">#FFC107</color>
+ <color name="identify_event">#E91E63</color>
+ <color name="identify_http">#f5f5f5</color>
+ <color name="identify_location">#F44336</color>
+ <color name="identify_phone">#3F51B5</color>
+ <color name="identify_sms">#8BC34A</color>
+ <color name="identify_text">#167c80</color>
+</resources> \ No newline at end of file
diff --git a/quickReader/res/values/strings.xml b/quickReader/res/values/strings.xml
new file mode 100644
index 000000000..7be2b6f91
--- /dev/null
+++ b/quickReader/res/values/strings.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <string name="quick_reader_name" translatable="false">QReader</string>
+
+ <!-- QuickReader: dismiss button for dialogs -->
+ <string name="quick_reader_action_dismiss">Dismiss</string>
+ <!-- QuickReader: toast shown when there's no app installed to open the qr code content -->
+ <string name="quick_reader_no_activity_found">No installed app can open this content</string>
+
+ <!-- QuickReader: permission error dialog title -->
+ <string name="quick_reader_permission_error_title">Permission error</string>
+ <!-- QuickReader: permission error dialog message when permission can be asked again -->
+ <string name="quick_reader_permission_rationale_message">Camera access is needed to scan the barcode</string>
+ <!-- QuickReader: permission error dialog positive action when permission can be asked again -->
+ <string name="quick_reader_permission_rationale_positive">Ask again</string>
+ <!-- QuickReader: permission error dialog message when permission can't be asked again -->
+ <string name="quick_reader_permission_fatal_message">Camera access was denied. Please allow it from the app\'s settings</string>
+ <!-- QuickReader: permission error dialog positive action when permission can't be asked again -->
+ <string name="quick_reader_permission_fatal_positive">Open settings</string>
+
+
+ <!-- QuickReader: scanned text dialog title -->
+ <string name="quick_reader_scanned_text_title">Scanned text</string>
+ <!-- QuickReader: scanned text dialog positive button (copy to clipboard) -->
+ <string name="quick_reader_scanned_text_positive">Copy</string>
+ <!-- QuickReader: scanned text dialog negative button (share) -->
+ <string name="quick_reader_scanned_text_negative">Share</string>
+
+ <!-- QuickReader: scanned text shared activity selector title -->
+ <string name="quick_reader_share_title">Share with\u2026</string>
+ <!-- QuickReader: toast shown when the scanned text has been copied to the clipboard -->
+ <string name="quick_reader_copied_message">Copied to clipboard</string>
+</resources>
diff --git a/quickReader/res/values/styles.xml b/quickReader/res/values/styles.xml
new file mode 100644
index 000000000..e02d4c878
--- /dev/null
+++ b/quickReader/res/values/styles.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+
+ <style name="AppTheme" parent="@android:style/Theme.Material.Light.NoActionBar">
+ <item name="android:colorAccent">@color/colorAccent</item>
+ <item name="android:statusBarColor">@android:color/black</item>
+ <item name="android:windowBackground">@android:color/black</item>
+ </style>
+
+ <style name="AppTheme.ActionIcon">
+ <item name="android:layout_width">56dp</item>
+ <item name="android:layout_height">56dp</item>
+ <item name="android:padding">16dp</item>
+ </style>
+</resources>
diff --git a/quickReader/src/org/lineageos/quickreader/ScannerActivity.java b/quickReader/src/org/lineageos/quickreader/ScannerActivity.java
new file mode 100644
index 000000000..fb583a24a
--- /dev/null
+++ b/quickReader/src/org/lineageos/quickreader/ScannerActivity.java
@@ -0,0 +1,321 @@
+/*
+ * Copyright (C) 2017 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.lineageos.quickreader;
+
+import android.Manifest;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.text.TextUtils;
+import android.util.Log;
+import android.util.Patterns;
+import android.webkit.URLUtil;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+
+import com.google.zxing.Result;
+
+import java.util.concurrent.ExecutionException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.android.camera.CameraActivity;
+import me.dm7.barcodescanner.zxing.ZXingScannerView;
+
+import org.codeaurora.snapcam.R;
+
+public class ScannerActivity extends Activity implements ZXingScannerView.ResultHandler {
+ private static final String TAG = "QuickReader";
+ private static final int REQUEST_CAMERA = 391;
+ public static final Pattern ACCEPTED_URI_SCHEMA = Pattern.compile(
+ "(?i)" + // switch on case insensitive matching
+ "(" + // begin group for schema
+ "(?:http|https|file|chrome)://" +
+ "|(?:inline|data|about|javascript):" +
+ ")" +
+ "(.*)"
+ );
+
+ private static ScannerIntentHelper sHelper;
+
+ private AnalyzeTask task;
+
+ private ZXingScannerView mScanView;
+ private FrameLayout mIdentifyLayout;
+ private ImageView mIdentifyIcon;
+ private ImageView mFlashIcon;
+
+ private boolean allowReading = true;
+
+ @Override
+ protected void onCreate(Bundle savedInstance) {
+ super.onCreate(savedInstance);
+
+ setContentView(R.layout.activity_scanner);
+
+ mScanView = (ZXingScannerView) findViewById(R.id.scanner_view);
+ mIdentifyLayout = (FrameLayout) findViewById(R.id.identify_layout);
+ mIdentifyIcon = (ImageView) findViewById(R.id.identify_icon);
+ mFlashIcon = (ImageView) findViewById(R.id.action_flash);
+ ImageView closeIcon = (ImageView) findViewById(R.id.action_close);
+
+ mIdentifyLayout.setOnClickListener(v -> sHelper.run(this));
+ mFlashIcon.setOnClickListener(v -> toggleFlash());
+ closeIcon.setOnClickListener(v -> finish());
+
+ if (!hasCameraPermission()) {
+ requestPermission();
+ }
+
+ sHelper = ScannerIntentHelper.getInstance();
+ task = new AnalyzeTask();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ mScanView.setResultHandler(this);
+ mScanView.startCamera();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+
+ try {
+ if (mScanView.getFlash()) {
+ mScanView.setFlash(false);
+ mFlashIcon.setImageResource(R.drawable.ic_flash_off);
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+
+ mScanView.stopCamera();
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String[] permissions,
+ int[] grantResults) {
+ if (requestCode != REQUEST_CAMERA || permissions.length == 0 || grantResults.length == 0) {
+ return;
+ }
+
+ if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
+ if (shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) {
+ showRationaleErrorDialog();
+ } else {
+ showFatalErrorDialog();
+ }
+ }
+ }
+
+ @Override
+ public void handleResult(Result rawResult) {
+ mScanView.resumeCameraPreview(this);
+
+ if (!allowReading) {
+ return;
+ }
+
+ if (task.getStatus() == AsyncTask.Status.RUNNING) {
+ return;
+ }
+
+ allowReading = false;
+ task = new AnalyzeTask();
+ task.execute(rawResult.getText());
+
+ try {
+ int result = task.get();
+ postAnalyze(result);
+ allowReading = true;
+ } catch (InterruptedException | ExecutionException e) {
+ Log.e(TAG, e.getMessage());
+ }
+ }
+
+ private boolean hasCameraPermission() {
+ return checkSelfPermission(Manifest.permission.CAMERA) ==
+ PackageManager.PERMISSION_GRANTED;
+ }
+
+ private void requestPermission() {
+ requestPermissions(new String[] { Manifest.permission.CAMERA }, REQUEST_CAMERA);
+ }
+
+ private void openSettings() {
+ Uri uri = Uri.fromParts("package", getPackageName(), null);
+ Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, uri);
+ startActivity(intent);
+ }
+
+ private void showRationaleErrorDialog() {
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.quick_reader_permission_error_title)
+ .setMessage(R.string.quick_reader_permission_rationale_message)
+ .setPositiveButton(R.string.quick_reader_permission_rationale_positive,
+ (dialog, i) -> requestPermission())
+ .setNegativeButton(R.string.quick_reader_action_dismiss,
+ (dialog, i) -> finish())
+ .show();
+ }
+
+ private void showFatalErrorDialog() {
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.quick_reader_permission_error_title)
+ .setMessage(R.string.quick_reader_permission_fatal_message)
+ .setPositiveButton(R.string.quick_reader_permission_fatal_positive,
+ (dialog, i) -> openSettings())
+ .setNegativeButton(R.string.quick_reader_action_dismiss,
+ (dialog, i) -> finish())
+ .show();
+ }
+
+ private void postAnalyze(int result) {
+ if (result == 0 || !sHelper.isValid()) {
+ return;
+ }
+
+ showScanResult(result);
+ }
+
+ private void showScanResult(int imageResource) {
+ mIdentifyIcon.setImageResource(imageResource);
+
+ if (mIdentifyLayout.getScaleX() == 0) {
+ // First shown, animate
+ mIdentifyLayout.animate()
+ .scaleX(1)
+ .scaleY(1)
+ .start();
+ }
+ }
+
+ private void toggleFlash() {
+ boolean isEnabled = mScanView.getFlash();
+ mScanView.setFlash(!isEnabled);
+ mFlashIcon.setImageResource(isEnabled ? R.drawable.ic_flash_off : R.drawable.ic_flash_on);
+ }
+
+ private static class AnalyzeTask extends AsyncTask<String, Void, Integer> {
+ private static final String ID_SMS = "smsto:";
+ private static final String ID_EMAIL = "mailto:";
+ private static final String ID_PHONE = "tel:";
+ private static final String ID_LOCATION = "geo:";
+ private static final String ID_VCARD = "BEGIN:VCARD";
+ private static final String ID_VEVENT = "BEGIN:VEVENT";
+ private static final String ID_MECARD = "MECARD:";
+ private static final String ID_MEBKM_URL = "MEBKM:TITLE:";
+
+ @Override
+ protected Integer doInBackground(String... params) {
+ if (params.length == 0) {
+ return null;
+ }
+
+ String content = params[0];
+ int icon;
+
+ if (TextUtils.isEmpty(content)) {
+ return null;
+ }
+
+ sHelper.reset();
+
+ if (content.startsWith(ID_SMS)) {
+ icon = R.drawable.ic_sms;
+ sHelper.setSMSIntent(content);
+ } else if (content.startsWith(ID_EMAIL)) {
+ icon = R.drawable.ic_email;
+ } else if (content.startsWith(ID_PHONE)) {
+ icon = R.drawable.ic_phone;
+ sHelper.setUriIntent(content);
+ } else if (content.startsWith(ID_LOCATION)) {
+ sHelper.setUriIntent(content);
+ icon = R.drawable.ic_location;
+ } else if (content.startsWith(ID_VEVENT)) {
+ sHelper.setCalendarIntent(content);
+ icon = R.drawable.ic_event;
+ } else if (content.startsWith(ID_MECARD)) {
+ sHelper.setContactIntent(content.replace(ID_MECARD, ""), false);
+ icon = R.drawable.ic_contact;
+ } else if (content.startsWith(ID_VCARD)) {
+ sHelper.setContactIntent(content, true);
+ icon = R.drawable.ic_contact;
+ } else if (content.startsWith(ID_MEBKM_URL)) {
+ sHelper.setMeBkmUrl(content);
+ icon = R.drawable.ic_http;
+ } else {
+ String properContent = smartUrlFilter(content);
+
+ if (TextUtils.isEmpty(properContent)) {
+ // Fallback to plain text
+ sHelper.setText(content);
+ return R.drawable.ic_text;
+ }
+
+ sHelper.setUriIntent(properContent);
+ icon = R.drawable.ic_http;
+ }
+
+ return icon;
+ }
+
+ /**
+ * Attempts to determine whether user input is a URL or search
+ * terms. Anything with a space is passed to search if canBeSearch is true.
+ *
+ * Converts to lowercase any mistakenly uppercased schema (i.e.,
+ * "Http://" converts to "http://"
+ *
+ * @return Original or modified URL
+ *
+ */
+ private String smartUrlFilter(String url) {
+ String inUrl = url.trim();
+ boolean hasSpace = inUrl.indexOf(' ') != -1;
+
+ Matcher matcher = ACCEPTED_URI_SCHEMA.matcher(inUrl);
+ if (matcher.matches()) {
+ // force scheme to lowercase
+ String scheme = matcher.group(1);
+ String lcScheme = scheme.toLowerCase();
+ if (!lcScheme.equals(scheme)) {
+ inUrl = lcScheme + matcher.group(2);
+ }
+ if (hasSpace && Patterns.WEB_URL.matcher(inUrl).matches()) {
+ inUrl = inUrl.replace(" ", "%20");
+ }
+ return inUrl;
+ }
+ if (!hasSpace && Patterns.WEB_URL.matcher(inUrl).matches()) {
+ return URLUtil.guessUrl(inUrl);
+ }
+ return null;
+ }
+ }
+} \ No newline at end of file
diff --git a/quickReader/src/org/lineageos/quickreader/ScannerIntentHelper.java b/quickReader/src/org/lineageos/quickreader/ScannerIntentHelper.java
new file mode 100644
index 000000000..c8fa500c1
--- /dev/null
+++ b/quickReader/src/org/lineageos/quickreader/ScannerIntentHelper.java
@@ -0,0 +1,238 @@
+/*
+ * Copyright (C) 2017 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.lineageos.quickreader;
+
+import android.app.AlertDialog;
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.provider.CalendarContract;
+import android.provider.ContactsContract;
+import android.text.TextUtils;
+import android.widget.Toast;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import org.codeaurora.snapcam.R;
+
+class ScannerIntentHelper {
+ private static final String EVENT_SUMMARY = "SUMMARY:";
+ private static final String EVENT_DESCRIPTION = "DESCRIPTION:";
+ private static final String EVENT_START = "DTSTART:";
+ private static final String EVENT_END = "DTEND:";
+ private static final String EVENT_LOCATION = "LOCATION:";
+ private static final String EVENT_DATE_FORMAT = "yyyyMMdd";
+
+ private static final String SMS_URI = "smsto:";
+ private static final String SMS_BODY = "sms_body";
+
+ private static final String CONTACT_NAME = "N:";
+ private static final String CONTACT_ORG = "ORG:";
+ private static final String CONTACT_TITLE = "TITLE:";
+ private static final String CONTACT_TEL = "TEL:";
+ private static final String CONTACT_EMAIL = "EMAIL:";
+ private static final String CONTACT_NOTE = "NOTE:";
+
+ private static final String MEBKM_URL = "URL:";
+
+ private static ScannerIntentHelper INSTANCE;
+
+ private Intent mIntent;
+
+ private String mScannedText;
+
+ private ScannerIntentHelper() {
+ }
+
+ static ScannerIntentHelper getInstance() {
+ if (INSTANCE == null) {
+ INSTANCE = new ScannerIntentHelper();
+ }
+
+ return INSTANCE;
+ }
+
+ void run(Context context) {
+ if (mIntent == null) {
+ showScannedText(context);
+ } else {
+ runIntent(context);
+ }
+ }
+
+ void reset() {
+ mIntent = null;
+ mScannedText = null;
+ }
+
+ boolean isValid() {
+ return mIntent != null || !TextUtils.isEmpty(mScannedText);
+ }
+
+ void setUriIntent(String uri) {
+ mIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
+ }
+
+ void setCalendarIntent(String text) {
+ String[] data = text.split("\n");
+ String summary = "";
+ String description = "";
+ String location = "";
+ Date start = new Date();
+ Date end = new Date();
+
+ for (String item : data) {
+ if (item.startsWith(EVENT_SUMMARY)) {
+ summary = item.replace(EVENT_SUMMARY, "");
+ } else if (item.startsWith(EVENT_DESCRIPTION)) {
+ summary = item.replace(EVENT_DESCRIPTION, "");
+ } else if (item.startsWith(EVENT_LOCATION)) {
+ location = item.replace(EVENT_LOCATION, "");
+ } else if (item.startsWith(EVENT_START)) {
+ start = parseDate(item.replace(EVENT_START, ""));
+ } else if (item.startsWith(EVENT_END)) {
+ start = parseDate(item.replace(EVENT_END, ""));
+ }
+ }
+
+ mIntent = new Intent(Intent.ACTION_INSERT, CalendarContract.Events.CONTENT_URI);
+ mIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, start)
+ .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, end)
+ .putExtra(CalendarContract.Events.TITLE, summary)
+ .putExtra(CalendarContract.Events.DESCRIPTION, description)
+ .putExtra(CalendarContract.Events.EVENT_LOCATION, location);
+ }
+
+ void setSMSIntent(String text) {
+ String[] data = text.split(":");
+
+ mIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse(SMS_URI + data[1]));
+ if (data.length > 2) {
+ mIntent.putExtra(SMS_BODY, data[2]);
+ }
+ }
+
+ void setContactIntent(String text, boolean isVCard) {
+ String[] data = text.split(isVCard ? "\n" : ";");
+ String name = "";
+ String org = "";
+ String title = "";
+ String telephone = "";
+ String email = "";
+ String notes = "";
+
+
+ for (String item : data) {
+ if (item.startsWith(CONTACT_NAME)) {
+ name = item.replace(CONTACT_NAME, "");
+ } else if (item.startsWith(CONTACT_ORG)) {
+ org = item.replace(CONTACT_ORG, "");
+ } else if (item.startsWith(CONTACT_TITLE)) {
+ title = item.replace(CONTACT_TITLE, "");
+ } else if (item.startsWith(CONTACT_TEL)) {
+ telephone = item.replace(CONTACT_TEL, "");
+ } else if (item.startsWith(CONTACT_EMAIL)) {
+ email = item.replace(CONTACT_EMAIL, "");
+ } else if (item.startsWith(CONTACT_NOTE)) {
+ notes = item.replace(CONTACT_NOTE, "");
+ }
+ }
+
+ mIntent = new Intent(ContactsContract.Intents.Insert.ACTION);
+ mIntent.setType(ContactsContract.RawContacts.CONTENT_TYPE)
+ .putExtra(ContactsContract.Intents.Insert.NAME, name)
+ .putExtra(ContactsContract.Intents.Insert.COMPANY, org)
+ .putExtra(ContactsContract.Intents.Insert.JOB_TITLE, title)
+ .putExtra(ContactsContract.Intents.Insert.PHONE, telephone)
+ .putExtra(ContactsContract.Intents.Insert.PHONE_TYPE,
+ ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE)
+ .putExtra(ContactsContract.Intents.Insert.EMAIL, email)
+ .putExtra(ContactsContract.Intents.Insert.EMAIL_TYPE,
+ ContactsContract.CommonDataKinds.Email.TYPE_WORK)
+ .putExtra(ContactsContract.Intents.Insert.NOTES, notes);
+ }
+
+ void setMeBkmUrl(String text) {
+ String[] data = text.split(":");
+
+ for (String item : data) {
+ if (!item.startsWith(MEBKM_URL)) {
+ continue;
+ }
+
+ setUriIntent(item.replace(MEBKM_URL, "").replace("\\", "").replace(";", ""));
+ }
+ }
+
+ void setText(String text) {
+ mScannedText = text;
+ }
+
+ private Date parseDate(String item) {
+ SimpleDateFormat format = new SimpleDateFormat(EVENT_DATE_FORMAT, Locale.getDefault());
+ String formattedDate = item.split("T")[0];
+
+ try {
+ return format.parse(formattedDate);
+ } catch (ParseException e) {
+ return new Date();
+ }
+ }
+
+ private void runIntent(Context context) {
+ if (mIntent.resolveActivity(context.getPackageManager()) == null) {
+ Toast.makeText(context, context.getString(R.string.quick_reader_no_activity_found),
+ Toast.LENGTH_LONG).show();
+ } else {
+ context.startActivity(mIntent);
+ }
+ }
+
+ private void showScannedText(Context context) {
+ new AlertDialog.Builder(context)
+ .setTitle(R.string.quick_reader_scanned_text_title)
+ .setMessage(mScannedText)
+ .setNeutralButton(R.string.quick_reader_action_dismiss, null)
+ .setPositiveButton(R.string.quick_reader_scanned_text_positive,
+ (dialog, i) -> copyScanned(context))
+ .setNegativeButton(R.string.quick_reader_scanned_text_negative,
+ (dialog, i) -> shareScanned(context))
+ .show();
+ }
+
+ private void copyScanned(Context context) {
+ ClipboardManager manager = (ClipboardManager)
+ context.getSystemService(Context.CLIPBOARD_SERVICE);
+ if (manager != null) {
+ manager.setPrimaryClip(ClipData.newPlainText("", mScannedText));
+ Toast.makeText(context, context.getString(R.string.quick_reader_copied_message),
+ Toast.LENGTH_LONG).show();
+ }
+ }
+
+ private void shareScanned(Context context) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType("text/plain");
+ intent.putExtra(Intent.EXTRA_TEXT, mScannedText);
+ context.startActivity(Intent.createChooser(intent,
+ context.getString(R.string.quick_reader_share_title)));
+ }
+} \ No newline at end of file