Init.
This commit is contained in:
105
androidApp/build.gradle.kts
Normal file
105
androidApp/build.gradle.kts
Normal file
@ -0,0 +1,105 @@
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
fun Project.execWithOutput(cmd: String): String {
|
||||
val byteOut: ByteArrayOutputStream = ByteArrayOutputStream()
|
||||
project.exec {
|
||||
commandLine = cmd.split(" ")
|
||||
standardOutput = byteOut
|
||||
}
|
||||
return byteOut.toByteArray().toString()
|
||||
}
|
||||
|
||||
fun gitVersion(): String {
|
||||
var process = ""
|
||||
val maybeTagOfCurrentCommit = execWithOutput("git describe --contains HEAD")
|
||||
process = if (maybeTagOfCurrentCommit.isEmpty()) {
|
||||
println("No tag on current commit. Will take the latest one.")
|
||||
execWithOutput("git for-each-ref refs/tags --sort=-authordate --format='%(refname:short)' --count=1")
|
||||
} else {
|
||||
println("Tag found on current commit")
|
||||
execWithOutput("git describe --contains HEAD")
|
||||
}
|
||||
return process.replace("'", "").substring(1).replace("\\.", "").trim()
|
||||
}
|
||||
|
||||
fun versionCodeFromGit(): Int {
|
||||
println("version code " + gitVersion())
|
||||
return gitVersion().toInt()
|
||||
}
|
||||
|
||||
fun versionNameFromGit(): String {
|
||||
println("version name " + gitVersion())
|
||||
return gitVersion()
|
||||
}
|
||||
|
||||
android {
|
||||
compileOptions {
|
||||
// Flag to enable support for the new language APIs
|
||||
isCoreLibraryDesugaringEnabled = true
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
compileSdk = 31
|
||||
buildToolsVersion = "31.0.0"
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
}
|
||||
defaultConfig {
|
||||
applicationId = "bou.amine.apps.readerforselfossv2.android"
|
||||
minSdk = 21
|
||||
targetSdk = 31
|
||||
versionCode = versionCodeFromGit()
|
||||
versionName = versionNameFromGit()
|
||||
|
||||
multiDexEnabled = true
|
||||
lint {
|
||||
abortOnError = true
|
||||
}
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
// tests
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments += mapOf("room.schemaLocation" to "$projectDir/schemas")
|
||||
}
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
getByName("release") {
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
|
||||
}
|
||||
getByName("debug") {
|
||||
buildConfigField("String", "LOGIN_URL", properties["appLoginUrl"] as String)
|
||||
buildConfigField("String", "LOGIN_PASSWORD", properties["appLoginPassword"] as String)
|
||||
buildConfigField("String", "LOGIN_USERNAME", properties["appLoginUsername"] as String)
|
||||
}
|
||||
}
|
||||
flavorDimensions.add("build")
|
||||
productFlavors {
|
||||
create("github") {
|
||||
versionNameSuffix = "-github"
|
||||
dimension = "build"
|
||||
}
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":shared"))
|
||||
implementation("com.google.android.material:material:1.4.0")
|
||||
implementation("androidx.appcompat:appcompat:1.3.1")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.1.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0")
|
||||
}
|
21
androidApp/src/main/AndroidManifest.xml
Normal file
21
androidApp/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="bou.amine.apps.readerforselfossv2.android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
@ -0,0 +1,30 @@
|
||||
package bou.amine.apps.readerforselfossv2.android
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import bou.amine.apps.readerforselfossv2.Greeting
|
||||
import android.widget.TextView
|
||||
import bou.amine.apps.readerforselfossv2.rest.SelfossApi
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.logging.Logger
|
||||
|
||||
fun greet(): String {
|
||||
return Greeting().greeting()
|
||||
}
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val s = SelfossApi().getItems("unread", 300, 0).forEach { i -> println(i.getImages()) }
|
||||
Logger.getLogger(")").info(s.toString())
|
||||
}
|
||||
|
||||
val tv: TextView = findViewById(R.id.text_view)
|
||||
tv.text = greet()
|
||||
}
|
||||
}
|
19
androidApp/src/main/res/layout/activity_main.xml
Normal file
19
androidApp/src/main/res/layout/activity_main.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-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:id="@+id/main_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Hello World!" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
6
androidApp/src/main/res/values/colors.xml
Normal file
6
androidApp/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#6200EE</color>
|
||||
<color name="colorPrimaryDark">#3700B3</color>
|
||||
<color name="colorAccent">#03DAC5</color>
|
||||
</resources>
|
9
androidApp/src/main/res/values/styles.xml
Normal file
9
androidApp/src/main/res/values/styles.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
Reference in New Issue
Block a user