Skip to content

Commit d2c65c4

Browse files
committed
Initial commit
0 parents  commit d2c65c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3441
-0
lines changed

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Gradle files
2+
.gradle/
3+
build/
4+
5+
# Local configuration file (sdk path, etc)
6+
local.properties
7+
8+
# Log/OS Files
9+
*.log
10+
11+
# Android Studio generated files and folders
12+
captures/
13+
.externalNativeBuild/
14+
.cxx/
15+
*.apk
16+
output.json
17+
18+
# IntelliJ
19+
*.iml
20+
.idea/
21+
misc.xml
22+
deploymentTargetDropDown.xml
23+
render.experimental.xml
24+
25+
# Keystore files
26+
*.jks
27+
*.keystore
28+
29+
# Google Services (e.g. APIs or Firebase)
30+
google-services.json
31+
32+
# Android Profiling
33+
*.hprof

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle.kts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
plugins {
2+
id("com.android.application")
3+
id("org.jetbrains.kotlin.android")
4+
}
5+
6+
android {
7+
namespace = "com.honz.itsvisualizer"
8+
compileSdk = 34
9+
10+
defaultConfig {
11+
applicationId = "com.honz.itsvisualizer"
12+
minSdk = 24
13+
targetSdk = 33
14+
versionCode = 1
15+
versionName = "1.0"
16+
17+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18+
}
19+
20+
buildTypes {
21+
release {
22+
isMinifyEnabled = false
23+
proguardFiles(
24+
getDefaultProguardFile("proguard-android-optimize.txt"),
25+
"proguard-rules.pro"
26+
)
27+
}
28+
}
29+
compileOptions {
30+
sourceCompatibility = JavaVersion.VERSION_1_8
31+
targetCompatibility = JavaVersion.VERSION_1_8
32+
}
33+
kotlinOptions {
34+
jvmTarget = "1.8"
35+
}
36+
}
37+
38+
dependencies {
39+
40+
implementation("androidx.core:core-ktx:1.12.0")
41+
implementation("androidx.appcompat:appcompat:1.6.1")
42+
implementation("com.google.android.material:material:1.11.0")
43+
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
44+
testImplementation("junit:junit:4.13.2")
45+
androidTestImplementation("androidx.test.ext:junit:1.1.5")
46+
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
47+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.honz.itsvisualizer
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.honz.itsvisualizer", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
7+
<application
8+
android:allowBackup="true"
9+
android:dataExtractionRules="@xml/data_extraction_rules"
10+
android:fullBackupContent="@xml/backup_rules"
11+
android:icon="@mipmap/ic_launcher"
12+
android:label="@string/app_name"
13+
android:roundIcon="@mipmap/ic_launcher_round"
14+
android:supportsRtl="true"
15+
android:theme="@style/Theme.ITSVisualizer"
16+
tools:targetApi="31">
17+
<service
18+
android:name="utils.storage.MessageCleanupService"
19+
android:exported="false" />
20+
<service
21+
android:name="utils.socket.SocketService"
22+
android:enabled="true"
23+
android:exported="true" />
24+
25+
<activity
26+
android:name=".MainActivity"
27+
android:exported="true">
28+
<intent-filter>
29+
<action android:name="android.intent.action.MAIN" />
30+
31+
<category android:name="android.intent.category.LAUNCHER" />
32+
</intent-filter>
33+
</activity>
34+
</application>
35+
36+
</manifest>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.honz.itsvisualizer
2+
3+
import android.content.ComponentName
4+
import android.content.Context
5+
import android.content.Intent
6+
import android.content.ServiceConnection
7+
import androidx.appcompat.app.AppCompatActivity
8+
import android.os.Bundle
9+
import android.os.IBinder
10+
import android.util.Log
11+
import com.google.android.material.floatingactionbutton.FloatingActionButton
12+
import utils.socket.SocketService
13+
import utils.storage.MessageCleanupService
14+
15+
class MainActivity : AppCompatActivity() {
16+
private lateinit var socketService: SocketService
17+
private lateinit var cleanerService: Intent
18+
19+
private lateinit var socketToggleFab: FloatingActionButton
20+
21+
private var socketServiceBound = false
22+
23+
private val socketServiceConnection = object : ServiceConnection {
24+
override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
25+
val binder = service as SocketService.SocketServiceBinder
26+
socketService = binder.getService()
27+
socketServiceBound = true
28+
}
29+
30+
override fun onServiceDisconnected(name: ComponentName?) {
31+
socketServiceBound = false
32+
}
33+
}
34+
35+
override fun onCreate(savedInstanceState: Bundle?) {
36+
super.onCreate(savedInstanceState)
37+
setContentView(R.layout.activity_main)
38+
39+
// Services
40+
cleanerService = Intent(this, MessageCleanupService::class.java)
41+
42+
// Start the services
43+
startService(cleanerService)
44+
startService(Intent(this, SocketService::class.java))
45+
46+
// Bind to SocketService
47+
bindService(Intent(this, SocketService::class.java), socketServiceConnection, Context.BIND_AUTO_CREATE)
48+
49+
// FAB TEST
50+
socketToggleFab = findViewById(R.id.socketToggleFab)
51+
socketToggleFab.setOnClickListener {
52+
Log.i("[FAB]", "CLICKED")
53+
54+
if(!socketService.attemptConnection) {
55+
socketService.startConnection()
56+
socketToggleFab.setImageResource(R.drawable.wifi)
57+
}
58+
else {
59+
socketService.stopConnection()
60+
socketToggleFab.setImageResource(R.drawable.wifi_off)
61+
}
62+
}
63+
}
64+
65+
override fun onDestroy() {
66+
super.onDestroy()
67+
68+
// Unbind from the service
69+
if (socketServiceBound) {
70+
unbindService(socketServiceConnection)
71+
socketServiceBound = false
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)