Loading app/src/main/java/net/sourceforge/opencamera/MainActivity.java +21 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ import net.sourceforge.opencamera.cameracontroller.CameraControllerManager; import net.sourceforge.opencamera.cameracontroller.CameraControllerManager2; import net.sourceforge.opencamera.preview.Preview; import net.sourceforge.opencamera.preview.VideoProfile; import net.sourceforge.opencamera.qr.QrImageAnalyzer; import net.sourceforge.opencamera.remotecontrol.BluetoothRemoteControl; import net.sourceforge.opencamera.ui.CircleImageView; import net.sourceforge.opencamera.ui.DrawPreview; Loading @@ -109,6 +110,11 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import foundation.e.camera.R; import kotlin.coroutines.CoroutineContext; import kotlinx.coroutines.CoroutineScope; import kotlinx.coroutines.Dispatchers; import kotlinx.coroutines.Job; import kotlinx.coroutines.JobKt; /** * The main Activity for Open Camera. Loading Loading @@ -241,6 +247,11 @@ public class MainActivity extends AppCompatActivity { //public static final boolean lock_to_landscape = true; public static final boolean lock_to_landscape = false; // QRCode public QrImageAnalyzer qrImageAnalyzer; private Job job; private CoroutineScope coroutineScope; // handling for lock_to_landscape==false: public enum SystemOrientation { Loading Loading @@ -273,6 +284,16 @@ public class MainActivity extends AppCompatActivity { Log.d(TAG, "activity_count: " + activity_count); super.onCreate(savedInstanceState); //QRCode job = JobKt.Job(null); coroutineScope = new CoroutineScope() { @Override public CoroutineContext getCoroutineContext() { return Dispatchers.getMain().plus(job); } }; qrImageAnalyzer = new QrImageAnalyzer(this, coroutineScope); setContentView(R.layout.activity_main); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // initialise any unset preferences to their default values Loading app/src/main/java/net/sourceforge/opencamera/ext/AddressBookParsedResult.kt 0 → 100644 +130 −0 Original line number Diff line number Diff line /* * SPDX-FileCopyrightText: 2024 The LineageOS Project * SPDX-License-Identifier: Apache-2.0 */ package net.sourceforge.opencamera.ext import android.app.RemoteAction import android.content.Context import android.content.Intent import android.os.Build import android.provider.ContactsContract import android.view.textclassifier.TextClassification import android.view.textclassifier.TextClassifier import com.google.zxing.client.result.AddressBookParsedResult import foundation.e.camera.R fun AddressBookParsedResult.createIntent() = Intent( Intent.ACTION_INSERT, ContactsContract.Contacts.CONTENT_URI ).apply { names.firstOrNull()?.let { putExtra(ContactsContract.Intents.Insert.NAME, it) } pronunciation?.let { putExtra(ContactsContract.Intents.Insert.PHONETIC_NAME, it) } phoneNumbers?.let { phoneNumbers -> val phoneTypes = phoneTypes ?: arrayOf() for ((i, keys) in listOf( listOf( ContactsContract.Intents.Insert.PHONE, ContactsContract.Intents.Insert.PHONE_TYPE, ), listOf( ContactsContract.Intents.Insert.SECONDARY_PHONE, ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE, ), listOf( ContactsContract.Intents.Insert.TERTIARY_PHONE, ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE, ), ).withIndex()) { phoneNumbers.getOrNull(i)?.let { phone -> putExtra(keys.first(), phone) phoneTypes.getOrNull(i)?.let { putExtra(keys.last(), it) } } } } emails?.let { emails -> val emailTypes = emailTypes ?: arrayOf() for ((i, keys) in listOf( listOf( ContactsContract.Intents.Insert.EMAIL, ContactsContract.Intents.Insert.EMAIL_TYPE, ), listOf( ContactsContract.Intents.Insert.SECONDARY_EMAIL, ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE, ), listOf( ContactsContract.Intents.Insert.TERTIARY_EMAIL, ContactsContract.Intents.Insert.TERTIARY_EMAIL_TYPE, ), ).withIndex()) { emails.getOrNull(i)?.let { phone -> putExtra(keys.first(), phone) emailTypes.getOrNull(i)?.let { putExtra(keys.last(), it) } } } } instantMessenger?.let { putExtra(ContactsContract.Intents.Insert.IM_HANDLE, it) } note?.let { putExtra(ContactsContract.Intents.Insert.NOTES, it) } addresses?.let { emails -> val addressTypes = addressTypes ?: arrayOf() for ((i, keys) in listOf( listOf( ContactsContract.Intents.Insert.POSTAL, ContactsContract.Intents.Insert.POSTAL_TYPE, ), ).withIndex()) { emails.getOrNull(i)?.let { phone -> putExtra(keys.first(), phone) addressTypes.getOrNull(i)?.let { putExtra(keys.last(), it) } } } } org?.let { putExtra(ContactsContract.Intents.Insert.COMPANY, it) } } fun AddressBookParsedResult.createTextClassification( context: Context ) = TextClassification.Builder() .setText(title ?: names.firstOrNull() ?: "") .setEntityType(TextClassifier.TYPE_OTHER, 1.0f) .apply { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { addAction( RemoteAction::class.build( context, R.drawable.ic_contact_phone, R.string.qr_address_title, R.string.qr_address_content_description, createIntent() ) ) } } .build() app/src/main/java/net/sourceforge/opencamera/ext/CalendarParsedResult.kt 0 → 100644 +63 −0 Original line number Diff line number Diff line /* * SPDX-FileCopyrightText: 2024 The LineageOS Project * SPDX-License-Identifier: Apache-2.0 */ package net.sourceforge.opencamera.ext import android.app.RemoteAction import android.content.Context import android.content.Intent import android.os.Build import android.provider.CalendarContract import android.view.textclassifier.TextClassification import android.view.textclassifier.TextClassifier import androidx.core.os.bundleOf import com.google.zxing.client.result.CalendarParsedResult import foundation.e.camera.R fun CalendarParsedResult.createIntent() = Intent( Intent.ACTION_INSERT, CalendarContract.Events.CONTENT_URI ).apply { summary?.let { putExtra(CalendarContract.Events.TITLE, it) } description?.let { putExtra(CalendarContract.Events.DESCRIPTION, it) } location?.let { putExtra(CalendarContract.Events.EVENT_LOCATION, it) } organizer?.let { putExtra(CalendarContract.Events.ORGANIZER, it) } attendees?.let { putExtra(Intent.EXTRA_EMAIL, it.joinToString(",")) } putExtras( bundleOf( CalendarContract.EXTRA_EVENT_BEGIN_TIME to startTimestamp, CalendarContract.EXTRA_EVENT_END_TIME to endTimestamp, CalendarContract.EXTRA_EVENT_ALL_DAY to (isStartAllDay && isEndAllDay), ) ) } fun CalendarParsedResult.createTextClassification(context: Context) = TextClassification.Builder() .setText(summary) .setEntityType(TextClassifier.TYPE_OTHER, 1.0f) .apply { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { addAction( RemoteAction::class.build( context, R.drawable.ic_calendar_add_on, R.string.qr_calendar_title, R.string.qr_calendar_content_description, createIntent() ) ) } } .build() app/src/main/java/net/sourceforge/opencamera/ext/Context.kt 0 → 100644 +17 −0 Original line number Diff line number Diff line /* * SPDX-FileCopyrightText: 2024 The LineageOS Project * SPDX-License-Identifier: Apache-2.0 */ package net.sourceforge.opencamera.ext import android.content.Context import android.util.TypedValue import androidx.annotation.AttrRes import androidx.annotation.ColorInt @ColorInt fun Context.getThemeColor(@AttrRes attribute: Int) = TypedValue().let { theme.resolveAttribute(attribute, it, true) it.data } app/src/main/java/net/sourceforge/opencamera/ext/EmailAddressParsedResult.kt 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * SPDX-FileCopyrightText: 2024 The LineageOS Project * SPDX-License-Identifier: Apache-2.0 */ package net.sourceforge.opencamera.ext import android.app.RemoteAction import android.content.Context import android.content.Intent import android.net.Uri import android.os.Build import android.view.textclassifier.TextClassification import android.view.textclassifier.TextClassifier import androidx.core.os.bundleOf import com.google.zxing.client.result.EmailAddressParsedResult import foundation.e.camera.R fun EmailAddressParsedResult.createIntent() = Intent( Intent.ACTION_SENDTO, Uri.parse("mailto:${tos?.firstOrNull() ?: ""}") ).apply { putExtras( bundleOf( Intent.EXTRA_EMAIL to tos, Intent.EXTRA_CC to cCs, Intent.EXTRA_BCC to bcCs, Intent.EXTRA_SUBJECT to subject, Intent.EXTRA_TEXT to body, ) ) } fun EmailAddressParsedResult.createTextClassification( context: Context ) = TextClassification.Builder() .setText(tos.joinToString()) .setEntityType(TextClassifier.TYPE_EMAIL, 1.0f) .apply { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { addAction( RemoteAction::class.build( context, R.drawable.ic_email, R.string.qr_email_title, R.string.qr_email_content_description, createIntent() ) ) } } .build() Loading
app/src/main/java/net/sourceforge/opencamera/MainActivity.java +21 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ import net.sourceforge.opencamera.cameracontroller.CameraControllerManager; import net.sourceforge.opencamera.cameracontroller.CameraControllerManager2; import net.sourceforge.opencamera.preview.Preview; import net.sourceforge.opencamera.preview.VideoProfile; import net.sourceforge.opencamera.qr.QrImageAnalyzer; import net.sourceforge.opencamera.remotecontrol.BluetoothRemoteControl; import net.sourceforge.opencamera.ui.CircleImageView; import net.sourceforge.opencamera.ui.DrawPreview; Loading @@ -109,6 +110,11 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import foundation.e.camera.R; import kotlin.coroutines.CoroutineContext; import kotlinx.coroutines.CoroutineScope; import kotlinx.coroutines.Dispatchers; import kotlinx.coroutines.Job; import kotlinx.coroutines.JobKt; /** * The main Activity for Open Camera. Loading Loading @@ -241,6 +247,11 @@ public class MainActivity extends AppCompatActivity { //public static final boolean lock_to_landscape = true; public static final boolean lock_to_landscape = false; // QRCode public QrImageAnalyzer qrImageAnalyzer; private Job job; private CoroutineScope coroutineScope; // handling for lock_to_landscape==false: public enum SystemOrientation { Loading Loading @@ -273,6 +284,16 @@ public class MainActivity extends AppCompatActivity { Log.d(TAG, "activity_count: " + activity_count); super.onCreate(savedInstanceState); //QRCode job = JobKt.Job(null); coroutineScope = new CoroutineScope() { @Override public CoroutineContext getCoroutineContext() { return Dispatchers.getMain().plus(job); } }; qrImageAnalyzer = new QrImageAnalyzer(this, coroutineScope); setContentView(R.layout.activity_main); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // initialise any unset preferences to their default values Loading
app/src/main/java/net/sourceforge/opencamera/ext/AddressBookParsedResult.kt 0 → 100644 +130 −0 Original line number Diff line number Diff line /* * SPDX-FileCopyrightText: 2024 The LineageOS Project * SPDX-License-Identifier: Apache-2.0 */ package net.sourceforge.opencamera.ext import android.app.RemoteAction import android.content.Context import android.content.Intent import android.os.Build import android.provider.ContactsContract import android.view.textclassifier.TextClassification import android.view.textclassifier.TextClassifier import com.google.zxing.client.result.AddressBookParsedResult import foundation.e.camera.R fun AddressBookParsedResult.createIntent() = Intent( Intent.ACTION_INSERT, ContactsContract.Contacts.CONTENT_URI ).apply { names.firstOrNull()?.let { putExtra(ContactsContract.Intents.Insert.NAME, it) } pronunciation?.let { putExtra(ContactsContract.Intents.Insert.PHONETIC_NAME, it) } phoneNumbers?.let { phoneNumbers -> val phoneTypes = phoneTypes ?: arrayOf() for ((i, keys) in listOf( listOf( ContactsContract.Intents.Insert.PHONE, ContactsContract.Intents.Insert.PHONE_TYPE, ), listOf( ContactsContract.Intents.Insert.SECONDARY_PHONE, ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE, ), listOf( ContactsContract.Intents.Insert.TERTIARY_PHONE, ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE, ), ).withIndex()) { phoneNumbers.getOrNull(i)?.let { phone -> putExtra(keys.first(), phone) phoneTypes.getOrNull(i)?.let { putExtra(keys.last(), it) } } } } emails?.let { emails -> val emailTypes = emailTypes ?: arrayOf() for ((i, keys) in listOf( listOf( ContactsContract.Intents.Insert.EMAIL, ContactsContract.Intents.Insert.EMAIL_TYPE, ), listOf( ContactsContract.Intents.Insert.SECONDARY_EMAIL, ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE, ), listOf( ContactsContract.Intents.Insert.TERTIARY_EMAIL, ContactsContract.Intents.Insert.TERTIARY_EMAIL_TYPE, ), ).withIndex()) { emails.getOrNull(i)?.let { phone -> putExtra(keys.first(), phone) emailTypes.getOrNull(i)?.let { putExtra(keys.last(), it) } } } } instantMessenger?.let { putExtra(ContactsContract.Intents.Insert.IM_HANDLE, it) } note?.let { putExtra(ContactsContract.Intents.Insert.NOTES, it) } addresses?.let { emails -> val addressTypes = addressTypes ?: arrayOf() for ((i, keys) in listOf( listOf( ContactsContract.Intents.Insert.POSTAL, ContactsContract.Intents.Insert.POSTAL_TYPE, ), ).withIndex()) { emails.getOrNull(i)?.let { phone -> putExtra(keys.first(), phone) addressTypes.getOrNull(i)?.let { putExtra(keys.last(), it) } } } } org?.let { putExtra(ContactsContract.Intents.Insert.COMPANY, it) } } fun AddressBookParsedResult.createTextClassification( context: Context ) = TextClassification.Builder() .setText(title ?: names.firstOrNull() ?: "") .setEntityType(TextClassifier.TYPE_OTHER, 1.0f) .apply { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { addAction( RemoteAction::class.build( context, R.drawable.ic_contact_phone, R.string.qr_address_title, R.string.qr_address_content_description, createIntent() ) ) } } .build()
app/src/main/java/net/sourceforge/opencamera/ext/CalendarParsedResult.kt 0 → 100644 +63 −0 Original line number Diff line number Diff line /* * SPDX-FileCopyrightText: 2024 The LineageOS Project * SPDX-License-Identifier: Apache-2.0 */ package net.sourceforge.opencamera.ext import android.app.RemoteAction import android.content.Context import android.content.Intent import android.os.Build import android.provider.CalendarContract import android.view.textclassifier.TextClassification import android.view.textclassifier.TextClassifier import androidx.core.os.bundleOf import com.google.zxing.client.result.CalendarParsedResult import foundation.e.camera.R fun CalendarParsedResult.createIntent() = Intent( Intent.ACTION_INSERT, CalendarContract.Events.CONTENT_URI ).apply { summary?.let { putExtra(CalendarContract.Events.TITLE, it) } description?.let { putExtra(CalendarContract.Events.DESCRIPTION, it) } location?.let { putExtra(CalendarContract.Events.EVENT_LOCATION, it) } organizer?.let { putExtra(CalendarContract.Events.ORGANIZER, it) } attendees?.let { putExtra(Intent.EXTRA_EMAIL, it.joinToString(",")) } putExtras( bundleOf( CalendarContract.EXTRA_EVENT_BEGIN_TIME to startTimestamp, CalendarContract.EXTRA_EVENT_END_TIME to endTimestamp, CalendarContract.EXTRA_EVENT_ALL_DAY to (isStartAllDay && isEndAllDay), ) ) } fun CalendarParsedResult.createTextClassification(context: Context) = TextClassification.Builder() .setText(summary) .setEntityType(TextClassifier.TYPE_OTHER, 1.0f) .apply { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { addAction( RemoteAction::class.build( context, R.drawable.ic_calendar_add_on, R.string.qr_calendar_title, R.string.qr_calendar_content_description, createIntent() ) ) } } .build()
app/src/main/java/net/sourceforge/opencamera/ext/Context.kt 0 → 100644 +17 −0 Original line number Diff line number Diff line /* * SPDX-FileCopyrightText: 2024 The LineageOS Project * SPDX-License-Identifier: Apache-2.0 */ package net.sourceforge.opencamera.ext import android.content.Context import android.util.TypedValue import androidx.annotation.AttrRes import androidx.annotation.ColorInt @ColorInt fun Context.getThemeColor(@AttrRes attribute: Int) = TypedValue().let { theme.resolveAttribute(attribute, it, true) it.data }
app/src/main/java/net/sourceforge/opencamera/ext/EmailAddressParsedResult.kt 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * SPDX-FileCopyrightText: 2024 The LineageOS Project * SPDX-License-Identifier: Apache-2.0 */ package net.sourceforge.opencamera.ext import android.app.RemoteAction import android.content.Context import android.content.Intent import android.net.Uri import android.os.Build import android.view.textclassifier.TextClassification import android.view.textclassifier.TextClassifier import androidx.core.os.bundleOf import com.google.zxing.client.result.EmailAddressParsedResult import foundation.e.camera.R fun EmailAddressParsedResult.createIntent() = Intent( Intent.ACTION_SENDTO, Uri.parse("mailto:${tos?.firstOrNull() ?: ""}") ).apply { putExtras( bundleOf( Intent.EXTRA_EMAIL to tos, Intent.EXTRA_CC to cCs, Intent.EXTRA_BCC to bcCs, Intent.EXTRA_SUBJECT to subject, Intent.EXTRA_TEXT to body, ) ) } fun EmailAddressParsedResult.createTextClassification( context: Context ) = TextClassification.Builder() .setText(tos.joinToString()) .setEntityType(TextClassifier.TYPE_EMAIL, 1.0f) .apply { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { addAction( RemoteAction::class.build( context, R.drawable.ic_email, R.string.qr_email_title, R.string.qr_email_content_description, createIntent() ) ) } } .build()