Commit fafa3bfa authored by Ayush Shrivastava's avatar Ayush Shrivastava Committed by Ayush Shrivastava
Browse files

android: Add CI for application codebase(lint + build + unit tests)

parent 5339d13c
stages:
- build
- test
- triggers
build-rust:
needs: []
tags: [ irdest-nix ]
......@@ -38,3 +38,8 @@ unittests:
- artifact: rust-gitlab-ci.yml
job: unittests-pipeline
strategy: depend
build-android-app:
stage: build
trigger:
include: 'clients/android/.gitlab-ci-android.yml'
......@@ -13,11 +13,11 @@
bin/
gen/
out/
lint/
# Gradle files
.gradle/
build/
gradle/
# Local configuration file (sdk path, etc)
api.properties
......
# Our ultimately orz docker image
image: irdest/android-build-env
# Basic android and gradle stuff
before_script:
- pwd
- cd clients/android
- ls
# Run Lint
lintDebug:
interruptible: true
stage: build
script:
- ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint
artifacts:
when: always
paths:
- clients/android/app/lint/reports/lint-results-debug.html
# Make Project
assembleDebug:
interruptible: true
stage: build
script:
- ./gradlew assembleDebug
artifacts:
paths:
- clients/android/app/build/outputs/
# Run all tests, if any fails, interrupt the pipeline(fail it)
debugTests:
interruptible: true
stage: test
script:
- ./gradlew -Pci --console=plain :app:testDebug
......@@ -40,7 +40,7 @@ class LoginActivity : AppCompatActivity() {
// TODO: Request permissions
// Start the wifi service
startService(Intent(this, WifiP2PService::class.java))
startService(Intent(this, WifiP2PService(this)::class.java))
// Handle the register screen
val register = findViewById<Button>(R.id.button_register)
......
package st.irde.app.net
import android.Manifest.permission.ACCESS_FINE_LOCATION
import android.annotation.SuppressLint
import android.app.Activity
import android.app.Service
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager.PERMISSION_GRANTED
import android.net.wifi.WpsInfo
import android.net.wifi.p2p.WifiP2pConfig
import android.net.wifi.p2p.WifiP2pInfo
......@@ -13,14 +16,15 @@ import android.net.wifi.p2p.nsd.WifiP2pDnsSdServiceInfo
import android.net.wifi.p2p.nsd.WifiP2pDnsSdServiceRequest
import android.os.IBinder
import android.util.Log
import java.lang.Exception
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import java.net.InetSocketAddress
import java.net.NoRouteToHostException
import java.net.ServerSocket
import java.net.Socket
class WifiP2PService : Service(), WifiP2pManager.ConnectionInfoListener {
class WifiP2PService constructor(private val activity: Activity) : Service(),
WifiP2pManager.ConnectionInfoListener {
private val manager: WifiP2pManager by lazy(LazyThreadSafetyMode.NONE) {
getSystemService(Context.WIFI_P2P_SERVICE) as WifiP2pManager
}
......@@ -58,9 +62,9 @@ class WifiP2PService : Service(), WifiP2pManager.ConnectionInfoListener {
Log.d("WD", "Requesting Wi-Fi P2P peers")
val serviceInfo = WifiP2pDnsSdServiceInfo.newInstance(
"d${(Math.random() * 1000).toInt()}",
"_ratman._tcp",
mapOf())
"d${(Math.random() * 1000).toInt()}",
"_ratman._tcp",
mapOf())
// Add a local "ratman" service
manager.addLocalService(channel, serviceInfo, object : WifiP2pManager.ActionListener {
......@@ -75,7 +79,8 @@ class WifiP2PService : Service(), WifiP2pManager.ConnectionInfoListener {
manager.setDnsSdResponseListeners(channel, { instanceName, registrationType, srcDevice ->
Log.d("WD", "Found service $instanceName $registrationType $srcDevice")
Log.d("WD", "can connect? " + (registrationType == "_ratman._tcp.local." && srcDevice != null).toString())
Log.d("WD",
"can connect? " + (registrationType == "_ratman._tcp.local." && srcDevice != null).toString())
if (registrationType == "_ratman._tcp.local." && srcDevice != null) {
val config = WifiP2pConfig()
config.deviceAddress = srcDevice.deviceAddress
......@@ -94,26 +99,35 @@ class WifiP2PService : Service(), WifiP2pManager.ConnectionInfoListener {
Log.d("WD", "DNS SD TXT record available: $fullDomainName $txtRecordMap $srcDevice")
})
manager.addServiceRequest(channel, WifiP2pDnsSdServiceRequest.newInstance(), object : WifiP2pManager.ActionListener {
override fun onSuccess() {
Log.d("WD", "Added service discovery request")
}
manager.addServiceRequest(channel, WifiP2pDnsSdServiceRequest.newInstance(),
object : WifiP2pManager.ActionListener {
override fun onSuccess() {
Log.d("WD", "Added service discovery request")
}
override fun onFailure(reason: Int) {
Log.d("WD", "Failed adding service discovery request")
}
})
override fun onFailure(reason: Int) {
Log.d("WD", "Failed adding service discovery request")
}
})
}
fun discoverPeers() = manager.discoverServices(channel, object : WifiP2pManager.ActionListener {
override fun onSuccess() {
Log.d("WD", "Started service discovery")
}
private val FINE_LOCATION = 0
fun discoverPeers() {
if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION) != PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(activity, arrayOf(ACCESS_FINE_LOCATION),
FINE_LOCATION)
} else {
manager.discoverServices(channel, object : WifiP2pManager.ActionListener {
override fun onSuccess() {
Log.d("WD", "Started service discovery")
}
override fun onFailure(reason: Int) {
Log.d("WD", "Service discovery failed")
override fun onFailure(reason: Int) {
Log.d("WD", "Service discovery failed")
}
})
}
})
}
// This function will be called
override fun onConnectionInfoAvailable(info: WifiP2pInfo?) {
......@@ -148,7 +162,9 @@ class WifiP2PService : Service(), WifiP2pManager.ConnectionInfoListener {
for (x in 0..10) {
try {
it.connect(InetSocketAddress(info.groupOwnerAddress.hostAddress, serverPort), 5000)
it.connect(
InetSocketAddress(info.groupOwnerAddress.hostAddress, serverPort),
5000)
Log.d("WD", "connected to leader")
it.getOutputStream().use { out ->
......
......@@ -28,10 +28,10 @@
android:pathData="M0 0h128v128h-128z" />
<path
android:fillColor="#FFE0B2"
android:pathData="M36.3 94.8c6.4 7.3 16.2 12.1 27.3 12.4 10.7,-.3 20.3,-4.7 26.7,-11.6l.2.1c-17,-13.3,-12.9,-23.4,-8.5,-28.6 1.3,-1.2 2.8,-2.5 4.4,-3.9l13.1,-11c1.5,-1.2 2.6,-3 2.9,-5.1.6,-4.4,-2.5,-8.4,-6.9,-9.1,-1.5,-.2,-3 0,-4.3.6,-.3,-1.3,-.4,-2.7,-1.6,-3.5,-1.4,-.9,-2.8,-1.7,-4.2,-2.5,-7.1,-3.9,-14.9,-6.6,-23,-7.9,-5.4,-.9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.6c-3.4,-7.1,-6.5,-12.8,-8.9,-16.9,-1.5,-2.2,-2.6,-3.8,-3.3,-5z" />
android:pathData="M105.3 106.1c-0.9,-1.3,-1.3,-1.9,-1.3,-1.9l-0.2,-0.3c-0.6,-0.9,-1.2,-1.7,-1.9,-2.4,-3.2,-3.5,-7.3,-5.4,-11.4,-5.7 0 0 0.1 0 0.1 0.1l-0.2,-0.1c-6.4 6.9,-16 11.3,-26.7 11.6,-11.2,-0.3,-21.1,-5.1,-27.5,-12.6,-0.1 0.2,-0.2 0.4,-0.2 0.5,-3.1 0.9,-6 2.7,-8.4 5.4l-0.2 0.2s-0.5 0.6,-1.5 1.7c-0.9 1.1,-2.2 2.6,-3.7 4.5,-3.1 3.9,-7.2 9.5,-11.7 16.6,-0.9 1.4,-1.7 2.8,-2.6 4.3h109.6c-3.4,-7.1,-6.5,-12.8,-8.9,-16.9,-1.5,-2.2,-2.6,-3.8,-3.3,-5z" />
<path
android:fillColor="#444"
android:pathData="M76.3,47.5 m-2.0, 0 a 2.0,2.0 0 1,1 4.0,0 a2.0,2.0 0 1,1 -4.0,0" />
......@@ -40,6 +40,6 @@
android:pathData="M50.7,47.6 m-2.0, 0 a 2.0,2.0 0 1,1 4.0,0 a2.0,2.0 0 1,1 -4.0,0" />
<path
android:fillColor="#444"
android:pathData="M48.1 27.4c4.5 5.9 15.5 12.1 42.4 8.4,-2.2,-6.9,-6.8,-12.6,-12.6,-16.4 17.2 1.5 14.1,-9.4 14.1,-9.4,-1.4 5.5,-11.1 4.4,-11.1 4.4h-18.8c-1.7,-.1,-3.4 0,-5.2.3,-12.8 1.8,-22.6 11.1,-25.7 22.9 10.6,-1.9 15.3,-7.6 16.9,-10.2z" />
android:pathData="M48.1 27.4c4.5 5.9 15.5 12.1 42.4 8.4,-2.2,-6.9,-6.8,-12.6,-12.6,-16.4 17.2 1.5 14.1,-9.4 14.1,-9.4,-1.4 5.5,-11.1 4.4,-11.1 4.4h-18.8c-1.7,-0.1,-3.4 0,-5.2 0.3,-12.8 1.8,-22.6 11.1,-25.7 22.9 10.6,-1.9 15.3,-7.6 16.9,-10.2z" />
</group>
</vector>
......@@ -78,7 +78,7 @@
android:backgroundTint="#DFDFDF"
android:text="Call"
android:textColor="#FFFFFF"
app:layout_constraintEnd_toEndOf="@+id/circularImageView"
app:layout_constraintEnd_toEndOf="@id/user_profile_avi"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/user_profile_open_chat"
app:layout_constraintTop_toTopOf="@+id/user_profile_open_chat" />
......@@ -119,4 +119,4 @@
app:layout_constraintTop_toTopOf="@+id/user_profile_name"
app:srcCompat="@drawable/ic_heart" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -20,7 +20,9 @@
android:id="@+id/chatroom_list_item_timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="@string/placeholder_chatroom_timestamp"
app:layout_constraintLeft_toLeftOf="@id/chatroom_list_item_name"
app:layout_constraintTop_toBottomOf="@+id/chatroom_list_item_name"
tools:layout_editor_absoluteX="5dp"/>
......@@ -49,4 +51,4 @@
app:layout_constraintTop_toBottomOf="@+id/chatroom_list_item_timestamp" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -2,7 +2,6 @@
<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:layout_height="wrap_content">
......@@ -28,6 +27,8 @@
android:layout_marginStart="12dp"
android:layout_marginTop="2dp"
android:text="@string/placeholder_username"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<!-- app:layout_constraintStart_toEndOf="@+id/item_users_list_avi"-->
......@@ -67,4 +68,4 @@
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/item_users_picker_id" />-->
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
</androidx.constraintlayout.widget.ConstraintLayout>
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment