Author: Adam <git@apiote.xyz>
reformat
%!v(PANIC=String method: strings: negative Repeat count)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 78208146a9ce930e23e743c01737f00d953ae327..38569329b00c22228dc59bda0840bcf4d5301eed 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,6 +7,7 @@<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + <!--suppress AndroidUnknownAttribute --> <application android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules" @@ -21,9 +22,9 @@ android:name=".feeds.FeedChooserActivity" android:exported="false" /> <activity - android:theme="@style/Theme.Bimba.Splash" android:name=".FirstRunActivity" - android:exported="true"> + android:exported="true" + android:theme="@style/Theme.Bimba.Splash"> <intent-filter> <action android:name="android.intent.action.MAIN" /> @@ -32,27 +33,32 @@ </activity> <activity android:name=".departures.DeparturesActivity" - android:exported="true" > + android:exported="true"> <intent-filter> - <action android:name="android.intent.action.VIEW"/> + <action android:name="android.intent.action.VIEW" /> + <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> + <!--suppress AndroidUnknownAttribute --> <data android:scheme="http" /> + <!--suppress AndroidUnknownAttribute --> <data android:scheme="https" /> + <!--suppress AndroidUnknownAttribute --> <data android:host="www.peka.poznan.pl" /> - <data android:pathPrefix="/vm"/> + <!--suppress AndroidUnknownAttribute --> + <data android:pathPrefix="/vm" /> <!-- todo(intents) test with ?przystanek=... --> </intent-filter> </activity> <activity android:name=".search.ResultsActivity" android:exported="false" android:label="@string/title_activity_results" /> + <!--suppress AndroidUnknownAttribute --> <activity android:name=".dashboard.MainActivity" android:exported="false" - android:windowSoftInputMode="adjustPan"> - </activity> + android:windowSoftInputMode="adjustPan" /> </application> </manifest> \ No newline at end of file diff --git a/app/src/main/java/ml/adamsprogs/bimba/api/Structs.kt b/app/src/main/java/ml/adamsprogs/bimba/api/Structs.kt index 0fb37650fd4fddbaf31805944da035af90c8c68f..b2402c5a8d1e1fff3f4d221a1ceff5915ceaf5fc 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/api/Structs.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/api/Structs.kt @@ -1,17 +1,16 @@ package ml.adamsprogs.bimba.api import android.content.Context -import android.content.res.Resources import android.graphics.* -import android.util.DisplayMetrics import androidx.appcompat.content.res.AppCompatResources import androidx.core.graphics.drawable.toBitmap import ml.adamsprogs.bimba.R +import ml.adamsprogs.bimba.dpToPixel +import ml.adamsprogs.bimba.dpToPixelI import xyz.apiote.fruchtfleisch.Reader import java.io.InputStream import kotlin.math.abs import kotlin.math.pow -import kotlin.math.roundToInt data class DateTime( val year: Int, @@ -172,10 +171,6 @@ fun icon(context: Context): Bitmap { return super.icon(context, type, colour) } - - fun textColour(): Int { - return super.textColour(colour) - } } data class Departure( @@ -269,13 +264,6 @@ } else { ((part + 0.055) / 1.055).pow(2.4) } } - - private fun dpToPixel(dp: Float): Float { - val metrics: DisplayMetrics = Resources.getSystem().displayMetrics - return dp * (metrics.densityDpi / 160f) - } - - private fun dpToPixelI(dp: Float): Int = dpToPixel(dp).roundToInt() fun icon(context: Context, type: LineType, colour: Colour): Bitmap { val drawingBitmap = Bitmap.createBitmap( diff --git a/app/src/main/java/ml/adamsprogs/bimba/dashboard/ui/home/HomeViewModel.kt b/app/src/main/java/ml/adamsprogs/bimba/dashboard/ui/home/HomeViewModel.kt index 4327e3af558a8306a823fbdd0cc554ccc881865b..b50c66cf634c39ea3fe9be0939c8ee6f29334380 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/dashboard/ui/home/HomeViewModel.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/dashboard/ui/home/HomeViewModel.kt @@ -61,9 +61,13 @@ getItems( Server( host, preferences.getString("token", "")!!, preferences.getString("${host}_feeds", "")!! - ), text) + ), text + ) } - handler.postDelayed(workRunnable, 1000) // todo(ux,low) make good time (probably between 500, 1000ms) + handler.postDelayed( + workRunnable, + 1000 + ) // todo(ux,low) make good time (probably between 500, 1000ms) } } } \ No newline at end of file diff --git a/app/src/main/java/ml/adamsprogs/bimba/departures/Departures.kt b/app/src/main/java/ml/adamsprogs/bimba/departures/Departures.kt index 30abca2865d228a9cda756829cfce9a5efb1da31..b9a9652362d0d199115d55e7745e2139b45ace81 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/departures/Departures.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/departures/Departures.kt @@ -20,7 +20,6 @@ val lineIcon: ImageView = itemView.findViewById(R.id.line_icon) val departureTime: TextView = itemView.findViewById(R.id.departure_time) val headsign: TextView = itemView.findViewById(R.id.departure_headsign) - companion object { @SuppressLint("SetTextI18n") fun bind( diff --git a/app/src/main/java/ml/adamsprogs/bimba/departures/DeparturesActivity.kt b/app/src/main/java/ml/adamsprogs/bimba/departures/DeparturesActivity.kt index c25caad89efb5b316e5fe2e7a84c149c0f698e59..666cdb9e1c0aee708183d998f3430df9e6c4eba9 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/departures/DeparturesActivity.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/departures/DeparturesActivity.kt @@ -63,6 +63,7 @@ } } private fun getCode(): String { + @Suppress("SpellCheckingInspection") return when (intent?.action) { Intent.ACTION_VIEW -> intent?.data?.getQueryParameter("przystanek") ?: "" null -> intent?.extras?.getString("code") ?: "" diff --git a/app/src/main/java/ml/adamsprogs/bimba/feeds/FeedChooserActivity.kt b/app/src/main/java/ml/adamsprogs/bimba/feeds/FeedChooserActivity.kt index be80cba347e523e88e871490b9b4f1ca371bc0e1..6fe984ea1d88a365860b6db12b579d731d14e7da 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/feeds/FeedChooserActivity.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/feeds/FeedChooserActivity.kt @@ -1,5 +1,5 @@ package ml.adamsprogs.bimba.feeds -// git:fixup feeds + import android.content.Context import android.content.Intent import android.content.SharedPreferences @@ -140,8 +140,8 @@ } binding.circularProgressIndicator.visibility = View.GONE binding.resultsRecycler.visibility = View.VISIBLE binding.feedInfo.visibility = View.VISIBLE - binding.feedInfo.text = - if(response.rateLimited) { + binding.feedInfo.text = // todo(ui) table + if (response.rateLimited) { getString(R.string.server_info_rate_limited, response.adminContact) } else { getString(R.string.server_info_not_rate_limited, response.adminContact) diff --git a/app/src/main/java/ml/adamsprogs/bimba/search/ResultsActivity.kt b/app/src/main/java/ml/adamsprogs/bimba/search/ResultsActivity.kt index 6ce9b705b3da1c076159a5bce9bb6962343f23b2..872d7d0a3fe8b43e228d4b76fe7c2a3c600a9e9f 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/search/ResultsActivity.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/search/ResultsActivity.kt @@ -20,7 +20,6 @@ import ml.adamsprogs.bimba.api.* import ml.adamsprogs.bimba.databinding.ActivityResultsBinding import java.io.InputStream -@SuppressLint("MissingPermission") class ResultsActivity : AppCompatActivity(), LocationListener { enum class Mode { MODE_LOCATION, MODE_SEARCH @@ -79,6 +78,7 @@ } } } + @SuppressLint("MissingPermission") private fun locate() { // todo also on back to this activity (onRestart?) val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager locationManager.requestLocationUpdates( @@ -89,7 +89,6 @@ ?.let { onLocationChanged(it) } } override fun onLocationChanged(location: Location) { - Log.v("Location", "found $location") val code = OpenLocationCode.encode(location.latitude, location.longitude) val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager locationManager.removeUpdates(this) @@ -116,7 +115,6 @@ // todo(error-handling) show empty state } else { updateItems(unmarshallItemResponse(itemsStream)) } - Log.v("RESPONSE", "getItemsByQuery") } } @@ -129,7 +127,6 @@ // todo(error-handling) show empty state } else { updateItems(unmarshallItemResponse(itemsStream)) } - Log.v("RESPONSE", "getItemsByLocation") } } diff --git a/app/src/main/java/ml/adamsprogs/bimba/utils.kt b/app/src/main/java/ml/adamsprogs/bimba/utils.kt new file mode 100644 index 0000000000000000000000000000000000000000..7b803dca60a6a7e64e72c03e4f4ac8f010ee3830 --- /dev/null +++ b/app/src/main/java/ml/adamsprogs/bimba/utils.kt @@ -0,0 +1,12 @@ +package ml.adamsprogs.bimba + +import android.content.res.Resources +import android.util.DisplayMetrics +import kotlin.math.roundToInt + +fun dpToPixel(dp: Float): Float { + val metrics: DisplayMetrics = Resources.getSystem().displayMetrics + return dp * (metrics.densityDpi / 160f) +} + +fun dpToPixelI(dp: Float): Int = dpToPixel(dp).roundToInt() \ No newline at end of file diff --git a/app/src/main/res/layout/departure.xml b/app/src/main/res/layout/departure.xml index cf20ee4ca1b84bf6c447bed2d9117b49abb78f96..43a0470c1377c0777089a83f3e753541630266a5 100644 --- a/app/src/main/res/layout/departure.xml +++ b/app/src/main/res/layout/departure.xml @@ -2,8 +2,8 @@ <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" - android:layout_width="match_parent" android:id="@+id/departure" + android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView @@ -13,7 +13,8 @@ android:layout_height="24dp" android:layout_marginStart="8dp" app:layout_constraintBottom_toTopOf="@+id/departure_headsign" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="@+id/departure_time" /> + app:layout_constraintTop_toTopOf="@+id/departure_time" + tools:srcCompat="@drawable/ic_bus_black_24dp" /> <TextView android:id="@+id/departure_time"