Skip to content

Commit

Permalink
updates webserver
Browse files Browse the repository at this point in the history
  • Loading branch information
vicktor committed Jun 7, 2023
1 parent ad0f8c2 commit 1709492
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "xyz.bauber.vampire"
minSdk 28
targetSdk 33
versionCode 2
versionName "1.0.1"
versionCode 3
versionName "1.0.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WebServerService : Service() {

val notification = NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle(getString(R.string.webserver))
.setContentText(getString(R.string.ws_running))
.setContentText("$URL:$PORT")
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setSmallIcon(R.drawable.ic_notification)
.build()
Expand All @@ -49,7 +49,7 @@ class WebServerService : Service() {
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val name = getString(R.string.webserver)
val descriptionText = getString(R.string.ws_running)
val descriptionText = "$URL:$PORT"
val importance = NotificationManager.IMPORTANCE_DEFAULT
val channel = NotificationChannel(CHANNEL_ID, name, importance).apply {
description = descriptionText
Expand All @@ -63,5 +63,7 @@ class WebServerService : Service() {
companion object {
const val CHANNEL_ID = "VampireWebServerHttpChannel"
const val NOTIFICATION_ID = 19701506
const val PORT = 5566
const val URL = "http://localhost"
}
}
4 changes: 3 additions & 1 deletion app/src/main/java/xyz/bauber/vampire/webserver/WebServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import com.google.gson.Gson
import xyz.bauber.vampire.BaseApplication
import xyz.bauber.vampire.database.DatabaseManager
import fi.iki.elonen.NanoHTTPD
import xyz.bauber.vampire.services.WebServerService.Companion.PORT

class WebServer : NanoHTTPD(5566) {

class WebServer : NanoHTTPD(PORT) {
override fun serve(session: IHTTPSession): Response {
val mimeType = "text/json"

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@

<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@mipmap/ic_launcher_adaptive_fore"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down Expand Up @@ -105,6 +104,7 @@
app:layout_constraintEnd_toStartOf="@+id/save"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
android:background="#eee"
android:focusableInTouchMode="true">
<requestFocus />
</EditText>
Expand Down

0 comments on commit 1709492

Please sign in to comment.