Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint errors #189

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ android {

namespace 'com.secuso.privacyfriendlycodescanner.qrscanner'
lint {
abortOnError false
lintConfig = file("lint.xml")
}
}

Expand Down
10 changes: 10 additions & 0 deletions app/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<!-- Disable the NotificationPermission check for glide -->
<issue id="NotificationPermission">
<ignore regexp="com.bumptech.glide.request.target.NotificationTarget" />
</issue>

<!-- Set the severity of missing translations to warning instead of error -->
<issue id="MissingTranslation" severity="warning" />
</lint>
18 changes: 9 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,30 @@
android:maxSdkVersion="28" />

<uses-sdk tools:overrideLibrary="com.google.zxing.client.android" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />

<application
android:name=".PFACodeScannerApplication"
android:allowBackup="true"
android:fullBackupContent="false"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:name=".PFACodeScannerApplication"
android:installLocation="preferExternal"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">

<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove" />

<activity
android:name=".ui.activities.SplashActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -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">
<intent-filter>
<action android:name="android.intent.action.SEND" />
Expand Down Expand Up @@ -143,16 +144,15 @@
android:process=":backup"
tools:ignore="ExportedService">
<intent-filter>
<action
android:name="org.secuso.privacyfriendlybackup.api.pfa.PFAAuthService" />
<action android:name="org.secuso.privacyfriendlybackup.api.pfa.PFAAuthService" />
</intent-filter>
</service>

<service
android:name=".QuickTileService"
android:exported="true"
android:icon="@drawable/ic_tile"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:exported="true">
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">

<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,76 +23,76 @@ 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;
}

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;
}

Expand All @@ -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 "";
Expand All @@ -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 "";
Expand All @@ -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 "";
Expand Down Expand Up @@ -213,64 +214,79 @@ 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);
}
}

void append(String[] values, StringBuilder sb) {
if(values != null) {
for(String value : values) {
if (values != null) {
for (String value : values) {
append(value, sb);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextView>(R.id.textView)
textView.text = rawData
builder.setView(dialogView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import kotlinx.coroutines.withContext
import java.util.*

class ScannerViewModel(application: Application) : AndroidViewModel(application) {
private val scanResult: MutableLiveData<BarcodeResult> = MutableLiveData()
private val scanResult: MutableLiveData<BarcodeResult?> = MutableLiveData()
private val processingScan: MutableLiveData<Boolean> = MutableLiveData(false)
private val scanComplete: MutableLiveData<Boolean> = MutableLiveData(false)


fun getScanResult(): LiveData<BarcodeResult> {
fun getScanResult(): LiveData<BarcodeResult?> {
return scanResult
}

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/drawable/ic_sync_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01,-.25 1.97,-.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.25,-1.97.7,-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4,-4,-4,-4v3z" />
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" />
</vector>
Loading