Skip to content

Commit

Permalink
Merge pull request #44 from SecUSo/fix-lint-errors
Browse files Browse the repository at this point in the history
Fix some lint errors
  • Loading branch information
udenr authored Apr 8, 2024
2 parents 524a072 + 377bbeb commit 31a757a
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 34 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
}
namespace 'org.secuso.privacyfriendlypaindiary'
lint {
abortOnError false
lintConfig = file("lint.xml")
}

compileOptions {
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>
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
Expand Down Expand Up @@ -138,5 +139,4 @@
</provider>

</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ License, or (at your option) any later version.
*/
package org.secuso.privacyfriendlypaindiary.activities;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.FragmentManager;
import android.content.DialogInterface;
Expand Down Expand Up @@ -1156,6 +1157,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
}


@SuppressLint("MissingSuperCall")
@Override
public void onBackPressed() {
if (changesMade) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
*/
package org.secuso.privacyfriendlypaindiary.activities

import android.Manifest
import android.app.AlertDialog
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.preference.Preference.OnPreferenceClickListener
import android.preference.PreferenceFragment
import android.preference.PreferenceManager
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -56,6 +61,10 @@ class SettingsActivity : BaseActivity() {
}

class GeneralPreferenceFragment : PreferenceFragment(), OnSharedPreferenceChangeListener {
companion object {
const val REQUEST_CODE_POST_NOTIFICATION = 3
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initPreferences()
Expand Down Expand Up @@ -87,6 +96,7 @@ class SettingsActivity : BaseActivity() {
}

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
checkPermission()
if (key == KEY_PREF_REMINDER) {
val enabled = sharedPreferences.getBoolean(KEY_PREF_REMINDER, false)
if (enabled) {
Expand All @@ -103,6 +113,25 @@ class SettingsActivity : BaseActivity() {
}
}

private fun checkPermission(): Boolean {
//Check for notification permission and exact alarm permission
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
&& ContextCompat.checkSelfPermission(this.context, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED)
) {
AlertDialog.Builder(this.context)
.setMessage(R.string.dialog_need_permission_for_notifications)
.setPositiveButton(android.R.string.ok) { _, _ ->
ActivityCompat.requestPermissions(this.activity, arrayOf(Manifest.permission.POST_NOTIFICATIONS), REQUEST_CODE_POST_NOTIFICATION)
}
.setTitle(R.string.dialog_need_permission_for_notifications_title)
.setCancelable(true)
.create()
.show()
return false
}
return true
}

private fun resetApp() {
runBlocking {
launch(Dispatchers.IO) {
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout-land/diaryentry_slide3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:tint="@color/yellow"
app:srcCompat="@drawable/paindiary_person_fullbody"
android:visibility="gone"/>
android:visibility="gone"
app:tint="@color/yellow" />

</RelativeLayout>

Expand Down Expand Up @@ -109,9 +109,9 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:tint="@color/yellow"
app:srcCompat="@drawable/paindiary_person_fullbody"
android:visibility="gone"/>
android:visibility="gone"
app:tint="@color/yellow" />

</RelativeLayout>

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/diaryentry_slide3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:tint="@color/yellow"
app:srcCompat="@drawable/paindiary_person_fullbody"
android:visibility="gone"/>
android:visibility="gone"
app:tint="@color/yellow" />

</RelativeLayout>

Expand Down Expand Up @@ -100,9 +100,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:tint="@color/yellow"
app:srcCompat="@drawable/paindiary_person_fullbody"
android:visibility="gone"/>
android:visibility="gone"
app:tint="@color/yellow" />

</RelativeLayout>

Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/diaryentry_summary.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
<ScrollView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/diaryentry"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
Expand Down Expand Up @@ -170,9 +170,9 @@
android:layout_width="90dp"
android:layout_height="220dp"
android:scaleType="centerCrop"
android:tint="@color/yellow"
app:srcCompat="@drawable/paindiary_person_fullbody"
android:visibility="gone" />
android:visibility="gone"
app:tint="@color/yellow" />

</RelativeLayout>

Expand All @@ -193,9 +193,9 @@
android:layout_width="90dp"
android:layout_height="220dp"
android:scaleType="centerCrop"
android:tint="@color/yellow"
app:srcCompat="@drawable/paindiary_person_fullbody"
android:visibility="gone" />
android:visibility="gone"
app:tint="@color/yellow" />
</RelativeLayout>

</LinearLayout>
Expand Down
35 changes: 17 additions & 18 deletions app/src/main/res/layout/pdf_person.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/bodyregion"
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bodyregion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
android:orientation="vertical">

<ImageView
android:id="@+id/person"
android:layout_width="100dp"
android:layout_height="200dp"
android:scaleType="centerCrop"
app:srcCompat="@drawable/paindiary_person_fullbody" />
<ImageView
android:id="@+id/person"
android:layout_width="100dp"
android:layout_height="200dp"
android:scaleType="centerCrop"
app:srcCompat="@drawable/paindiary_person_fullbody" />

<ImageView
android:id="@+id/bodyregion_value"
android:layout_width="100dp"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:tint="@color/yellow"
app:srcCompat="@drawable/paindiary_person_fullbody"
android:visibility="gone" />
<ImageView
android:id="@+id/bodyregion_value"
android:layout_width="100dp"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:visibility="gone"
app:srcCompat="@drawable/paindiary_person_fullbody"
app:tint="@color/yellow" />

</RelativeLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@
<string name="export_success">PDF wurde im Dokumenten-Ordner gespeichert.</string>
<string name="export_failure">Unbekannter Fehler: PDF konnte nicht gespeichert werden.</string>
<string name="share_caution">Seien Sie vorsichtig, mit wem Sie Ihre medizinischen Informationen teilen.</string>
<string name="dialog_need_permission_for_notifications">Für diese Funktion ist die Berechtigung zum Senden von Benachrichtigungen erforderlich.</string>
<string name="dialog_need_permission_for_notifications_title">Benachrichtigungen aktivieren</string>


</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,7 @@
<string name="export_success">PDF was saved to documents folder.</string>
<string name="export_failure">Unknown Error: PDF could not be saved.</string>
<string name="share_caution">Be careful who you share your medical information with.</string>
<string name="dialog_need_permission_for_notifications">Permission to send notifications is needed for this feature.</string>
<string name="dialog_need_permission_for_notifications_title">Enable notifications</string>

</resources>

0 comments on commit 31a757a

Please sign in to comment.