From a4d5cd6f22d5f5da05317dfc7f66ad0013229214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=A4nge?= Date: Thu, 9 Nov 2023 18:25:38 +0100 Subject: [PATCH] Fix lint errors - Replace WorkManagerInitializer with InitializationProvider in AndroidManifest.xml - Fix missing resource identifiers in layout files - Add `` to AndroidManifest.xml - Add lint config file `lint.xml` - Ignore `NotificationPermission` for glide in lint.xml - Set severity of missing translations to warning in lint.xml - Fix indentation in ContactResultWrapper.java - Delete unused fragment_result_mms.xml - Fix pathData in ic_sync_black_24dp.xml - Enable abortOnError in build.gradle --- app/build.gradle | 2 +- app/lint.xml | 10 ++ app/src/main/AndroidManifest.xml | 18 ++-- .../qrscanner/database/AppDatabase.java | 4 +- .../resultwrapper/ContactResultWrapper.java | 98 +++++++++++-------- .../dialogfragments/RawDataDialogFragment.kt | 6 +- .../ui/viewmodel/ScannerViewModel.kt | 4 +- .../main/res/drawable/ic_sync_black_24dp.xml | 6 +- .../main/res/layout/activity_tel_enter.xml | 1 + .../main/res/layout/activity_wifi_enter.xml | 1 - .../main/res/layout/fragment_result_mms.xml | 60 ------------ .../main/res/layout/fragment_result_tel.xml | 14 +-- .../main/res/layout/fragment_result_url.xml | 24 ++--- .../main/res/layout/fragment_result_wifi.xml | 24 ++--- app/src/main/res/values/strings.xml | 2 +- 15 files changed, 116 insertions(+), 158 deletions(-) create mode 100644 app/lint.xml delete mode 100644 app/src/main/res/layout/fragment_result_mms.xml diff --git a/app/build.gradle b/app/build.gradle index 208961d4..21ce25fd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -59,7 +59,7 @@ android { namespace 'com.secuso.privacyfriendlycodescanner.qrscanner' lint { - abortOnError false + lintConfig = file("lint.xml") } } diff --git a/app/lint.xml b/app/lint.xml new file mode 100644 index 00000000..1b66a254 --- /dev/null +++ b/app/lint.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ab4d2342..27929d11 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,13 +11,16 @@ android:maxSdkVersion="28" /> + @@ -43,7 +45,6 @@ android:name=".ui.activities.ScannerActivity" android:clearTaskOnLaunch="true" android:exported="true" - android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar"> @@ -143,16 +144,15 @@ android:process=":backup" tools:ignore="ExportedService"> - + + android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> diff --git a/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/database/AppDatabase.java b/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/database/AppDatabase.java index f0952e45..b5842bb4 100644 --- a/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/database/AppDatabase.java +++ b/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/database/AppDatabase.java @@ -56,8 +56,8 @@ public void migrate(@NonNull SupportSQLiteDatabase database) { while (!c.isAfterLast()) { items[i] = new HistoryItem(); - items[i].set_id(c.getInt(c.getColumnIndex("_id"))); - items[i].setText(c.getString(c.getColumnIndex("text"))); + items[i].set_id(c.getInt(c.getColumnIndexOrThrow("_id"))); + items[i].setText(c.getString(c.getColumnIndexOrThrow("text"))); items[i].setImage(Utils.generateCode(items[i].getText(), BarcodeFormat.QR_CODE, null)); i++; diff --git a/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/adapter/resultwrapper/ContactResultWrapper.java b/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/adapter/resultwrapper/ContactResultWrapper.java index 8df2a19c..785b0cd1 100644 --- a/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/adapter/resultwrapper/ContactResultWrapper.java +++ b/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/adapter/resultwrapper/ContactResultWrapper.java @@ -23,17 +23,17 @@ public AddressBookParsedResult getResult() { public int getDataCount() { int itemCount = 0; - if(hasNames() || hasNickNames() || hasPronunciation()) itemCount ++; - itemCount += getPhoneNumberCount(); - itemCount += getEmailCount(); - if(hasInstantMessenger()) itemCount ++; - if(hasNote()) itemCount ++; - itemCount += getAddressCount(); - if(hasOrganisation()) itemCount ++; - if(hasBirthday()) itemCount ++; - if(hasTitle()) itemCount ++; - itemCount += getUrlCount(); - itemCount += getGeoCount(); + if (hasNames() || hasNickNames() || hasPronunciation()) itemCount++; + itemCount += getPhoneNumberCount(); + itemCount += getEmailCount(); + if (hasInstantMessenger()) itemCount++; + if (hasNote()) itemCount++; + itemCount += getAddressCount(); + if (hasOrganisation()) itemCount++; + if (hasBirthday()) itemCount++; + if (hasTitle()) itemCount++; + itemCount += getUrlCount(); + itemCount += getGeoCount(); return itemCount; } @@ -41,58 +41,58 @@ public int getDataCount() { public int getDataIndex(int position) { int itemCount = 0; - if(hasNames() || hasNickNames() || hasPronunciation()) itemCount++; - if(position < itemCount) { + if (hasNames() || hasNickNames() || hasPronunciation()) itemCount++; + if (position < itemCount) { return itemCount - position - 1; } itemCount += getPhoneNumberCount(); - if(position < itemCount) { + if (position < itemCount) { return itemCount - position - 1; } itemCount += getEmailCount(); - if(position < itemCount) { + if (position < itemCount) { return itemCount - position - 1; } - if(hasInstantMessenger()) itemCount ++; - if(position < itemCount) { + if (hasInstantMessenger()) itemCount++; + if (position < itemCount) { return itemCount - position - 1; } - if(hasNote()) itemCount ++; - if(position < itemCount) { + if (hasNote()) itemCount++; + if (position < itemCount) { return itemCount - position - 1; } itemCount += getAddressCount(); - if(position < itemCount) { + if (position < itemCount) { return itemCount - position - 1; } - if(hasOrganisation()) itemCount ++; - if(position < itemCount) { + if (hasOrganisation()) itemCount++; + if (position < itemCount) { return itemCount - position - 1; } - if(hasBirthday()) itemCount ++; - if(position < itemCount) { + if (hasBirthday()) itemCount++; + if (position < itemCount) { return itemCount - position - 1; } - if(hasTitle()) itemCount ++; - if(position < itemCount) { + if (hasTitle()) itemCount++; + if (position < itemCount) { return itemCount - position - 1; } itemCount += getUrlCount(); - if(position < itemCount) { + if (position < itemCount) { return itemCount - position - 1; } itemCount += getGeoCount(); - if(position < itemCount) { + if (position < itemCount) { return itemCount - position - 1; } @@ -109,48 +109,49 @@ public String getName() { } public String getPronunciation() { - if(hasPronunciation() && !result.getPronunciation().isEmpty()) { + if (hasPronunciation() && !result.getPronunciation().isEmpty()) { return result.getPronunciation(); } return ""; } public String getAddressType(int index) { - if(hasAddressType(index)) { + if (hasAddressType(index)) { return result.getAddressTypes()[index]; } return ""; } public String getPhoneNumber(int index) { - if(hasPhoneNumbers() && result.getPhoneNumbers().length > 0) { + if (hasPhoneNumbers() && result.getPhoneNumbers().length > 0) { return result.getPhoneNumbers()[index]; } return ""; } public String getUrl(int index) { - if(hasUrls() && result.getURLs().length > 0) { + if (hasUrls() && result.getURLs().length > 0) { return result.getURLs()[index]; } return ""; } + public String getGeo(int index) { - if(hasGeo() && result.getGeo().length > 0) { + if (hasGeo() && result.getGeo().length > 0) { return result.getGeo()[index]; } return ""; } public String getEmail(int index) { - if(hasEmails() && result.getEmails().length > 0) { + if (hasEmails() && result.getEmails().length > 0) { return result.getEmails()[index]; } return ""; } public String getEmailType(int index) { - if(hasEmailType(index)) { + if (hasEmailType(index)) { return result.getEmailTypes()[index]; } return ""; @@ -165,7 +166,7 @@ public boolean hasAddressType(int index) { } public String getPhoneNumberType(int index) { - if(hasPhoneNumberType(index)) { + if (hasPhoneNumberType(index)) { return result.getPhoneTypes()[index]; } return ""; @@ -176,7 +177,7 @@ public boolean hasPhoneNumberType(int index) { } public String getAddress(int index) { - if(hasAddresses() && result.getAddresses().length > 0) { + if (hasAddresses() && result.getAddresses().length > 0) { return result.getAddresses()[index]; } return ""; @@ -213,55 +214,70 @@ public int getUrlCount() { public boolean hasNames() { return result.getNames() != null; } + public boolean hasNickNames() { return result.getNicknames() != null; } + public boolean hasPronunciation() { return result.getPronunciation() != null; } + public boolean hasPhoneNumbers() { return result.getPhoneNumbers() != null; } + public boolean hasPhoneTypes() { return result.getPhoneTypes() != null; } + public boolean hasEmails() { return result.getEmails() != null; } + public boolean hasEmailTypes() { return result.getEmailTypes() != null; } + public boolean hasInstantMessenger() { return result.getInstantMessenger() != null; } + public boolean hasNote() { return result.getNote() != null; } + public boolean hasAddresses() { return result.getAddresses() != null; } + public boolean hasAddressTypes() { return result.getAddressTypes() != null; } + public boolean hasOrganisation() { return result.getOrg() != null; } + public boolean hasBirthday() { return result.getBirthday() != null; } + public boolean hasTitle() { return result.getTitle() != null; } + public boolean hasUrls() { return result.getURLs() != null; } + public boolean hasGeo() { return result.getGeo() != null; } void append(String value, StringBuilder sb) { - if(value != null) { - if(sb.length() > 0) { + if (value != null) { + if (sb.length() > 0) { sb.append(" "); } sb.append(value); @@ -269,8 +285,8 @@ void append(String value, StringBuilder sb) { } void append(String[] values, StringBuilder sb) { - if(values != null) { - for(String value : values) { + if (values != null) { + for (String value : values) { append(value, sb); } } diff --git a/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/dialogfragments/RawDataDialogFragment.kt b/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/dialogfragments/RawDataDialogFragment.kt index b79f5a1f..d8d930f9 100644 --- a/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/dialogfragments/RawDataDialogFragment.kt +++ b/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/dialogfragments/RawDataDialogFragment.kt @@ -15,9 +15,9 @@ class RawDataDialogFragment : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return activity?.let { - val builder = MaterialAlertDialogBuilder(context!!) - val rawData: String = arguments!!.getString("rawDataString") ?: "" - val dialogView = activity!!.layoutInflater.inflate(R.layout.dialog_raw_data, null) + val builder = MaterialAlertDialogBuilder(requireContext()) + val rawData: String = requireArguments().getString("rawDataString") ?: "" + val dialogView = requireActivity().layoutInflater.inflate(R.layout.dialog_raw_data, null) val textView = dialogView.findViewById(R.id.textView) textView.text = rawData builder.setView(dialogView) diff --git a/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/viewmodel/ScannerViewModel.kt b/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/viewmodel/ScannerViewModel.kt index 64cadd76..d4dea8e0 100644 --- a/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/viewmodel/ScannerViewModel.kt +++ b/app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/viewmodel/ScannerViewModel.kt @@ -21,12 +21,12 @@ import kotlinx.coroutines.withContext import java.util.* class ScannerViewModel(application: Application) : AndroidViewModel(application) { - private val scanResult: MutableLiveData = MutableLiveData() + private val scanResult: MutableLiveData = MutableLiveData() private val processingScan: MutableLiveData = MutableLiveData(false) private val scanComplete: MutableLiveData = MutableLiveData(false) - fun getScanResult(): LiveData { + fun getScanResult(): LiveData { return scanResult } diff --git a/app/src/main/res/drawable/ic_sync_black_24dp.xml b/app/src/main/res/drawable/ic_sync_black_24dp.xml index 5a283aa7..715d5a3c 100644 --- a/app/src/main/res/drawable/ic_sync_black_24dp.xml +++ b/app/src/main/res/drawable/ic_sync_black_24dp.xml @@ -1,9 +1,9 @@ + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + android:pathData="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01,-0.25 1.97,-0.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0,-4.42,-3.58,-8,-8,-8zm0 14c-3.31 0,-6,-2.69,-6,-6 0,-1.01 0.25,-1.97 0.7,-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4,-4,-4,-4v3z" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_tel_enter.xml b/app/src/main/res/layout/activity_tel_enter.xml index 4190bcb1..0f54e8b9 100644 --- a/app/src/main/res/layout/activity_tel_enter.xml +++ b/app/src/main/res/layout/activity_tel_enter.xml @@ -54,6 +54,7 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_result_tel.xml b/app/src/main/res/layout/fragment_result_tel.xml index 54e81178..7e5c0b8b 100644 --- a/app/src/main/res/layout/fragment_result_tel.xml +++ b/app/src/main/res/layout/fragment_result_tel.xml @@ -4,18 +4,18 @@ android:orientation="vertical"> + android:padding="16dp"> + android:textIsSelectable="true" + android:textSize="20sp" /> diff --git a/app/src/main/res/layout/fragment_result_url.xml b/app/src/main/res/layout/fragment_result_url.xml index dbbaec6a..ee9d1e01 100644 --- a/app/src/main/res/layout/fragment_result_url.xml +++ b/app/src/main/res/layout/fragment_result_url.xml @@ -4,19 +4,19 @@ android:orientation="vertical"> + android:nestedScrollingEnabled="false"> + android:padding="16dp"> + android:textIsSelectable="true" + android:textSize="15sp" /> + android:enabled="true" + android:focusable="true" + android:linksClickable="true" + android:text="@string/further_info" + android:textSize="15sp" /> diff --git a/app/src/main/res/layout/fragment_result_wifi.xml b/app/src/main/res/layout/fragment_result_wifi.xml index 8b2bbfb6..9c581322 100644 --- a/app/src/main/res/layout/fragment_result_wifi.xml +++ b/app/src/main/res/layout/fragment_result_wifi.xml @@ -4,22 +4,18 @@ android:orientation="vertical"> + android:layout_alignParentEnd="true" + android:fillViewport="true"> + android:padding="16dp"> + android:textIsSelectable="true" + android:textSize="20sp" /> + android:gravity="center_vertical|center_horizontal" + android:textSize="20sp" /> + android:textSize="20sp" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 994d15b3..431e3ef5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,4 @@ - + QR Scanner Open navigation drawer