Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM eclipse-temurin:17-jdk-jammy

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не будет ли контейнер больше, чем при openjdk?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

пробовали его использовать? Мне кажется что будет ругаться на недостачу пакетов


ENV ANDROID_SDK_ROOT /opt/android-sdk
ENV PATH $PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools

RUN apt-get update && \
apt-get install -y wget unzip git && \
rm -rf /var/lib/apt/lists/*

RUN wget -O cmdline-tools.zip "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip" && \
mkdir -p $ANDROID_SDK_ROOT/cmdline-tools && \
unzip -q cmdline-tools.zip -d $ANDROID_SDK_ROOT/cmdline-tools && \
mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest && \
rm cmdline-tools.zip

RUN yes | sdkmanager --licenses && \
sdkmanager "platforms;android-35" "build-tools;35.0.0" "platform-tools"

RUN curl -Ls "https://sh.jbang.dev" | bash -s - app install --fresh --force jbang

WORKDIR /app
69 changes: 69 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
pipeline {
agent {
dockerfile true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нужно указать название image и параметры

}
parameters {
booleanParam(name: 'RUN_PROFILER', defaultValue: false, description: 'Запустить gradle-profiler для анализа производительности сборки?')
}

stages {
stage('Checkout') {
steps {
checkout scm
}
}

stage('Grant execution permission') {
steps {
sh 'chmod +x gradlew'
}
}

stage('Build') {
steps {
script {
if (env.BRANCH_NAME == 'master') {
echo "Building for master branch..."
sh './gradlew assembleRelease'
} else {
echo "Building for branch ${env.BRANCH_NAME}..."
sh './gradlew assembleDebug'
}
}
}
}

stage('Unit Tests') {
steps {
sh './gradlew test'
}
}

stage('Static Analysis') {
steps {
sh './gradlew lint'
}
}

stage('Profiling') {
when {
// Запускать только если параметр RUN_PROFILER установлен в true
expression { params.RUN_PROFILER }
}
steps {
script {
echo "Starting Gradle profiler..."
sh "jbang dev.gradle.profiler.tool.Main --benchmark --project-dir . --scenario-file profiler.scenarios"
archiveArtifacts artifacts: 'profile-out/', followSymlinks: false
}
}
}
}

post {
always {
echo 'Build finished.'
cleanWs()
}
}
}
38 changes: 22 additions & 16 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'org.jetbrains.kotlin.android'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
namespace 'otus.homework.customview'
compileSdk 35

defaultConfig {
applicationId "otus.homework.customview"
minSdkVersion 23
targetSdkVersion 30
minSdk 23
targetSdk 34
versionCode 1
versionName "1.0"

Expand All @@ -23,23 +23,29 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}

buildFeatures {
viewBinding true
}
}

dependencies {
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.code.gson:gson:2.10.1'

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import org.junit.Assert.*
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("otus.homework.customview", appContext.packageName)
}
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="otus.homework.customview">

<application
Expand All @@ -10,7 +9,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CustomView">
<activity android:name=".MainActivity">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
55 changes: 53 additions & 2 deletions app/src/main/java/otus/homework/customview/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,62 @@
package otus.homework.customview

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import otus.homework.customview.databinding.ActivityMainBinding
import otus.homework.customview.view.PieChartView
import android.graphics.Color

class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

val data = loadExpenses()
initPieChartView(data)
initLineChartView(data)
}

private fun loadExpenses(): List<PriceData> {
val json = resources.openRawResource(R.raw.payload)
.bufferedReader()
.use { it.readText() }
val type = object : TypeToken<List<PriceData>>() {}.type
return Gson().fromJson(json, type)
}

private fun initLineChartView(data: List<PriceData>) {
binding.lineChart.setData(data, getColorsForGradient())
}

private fun initPieChartView(data: List<PriceData>) {
binding.pieChart.setData(data, getColorsForGradient())
binding.pieChart.applyCallback(object : PieChartView.Callback {
override fun onSectorClick(priceData: PriceData) {
Toast.makeText(
this@MainActivity,
"${priceData.name} - ${priceData.amount} USD",
Toast.LENGTH_SHORT
).show()
}
})
}

private fun getColorsForGradient() = listOf(
Color.RED to Color.rgb(255, 165, 0),
Color.BLUE to Color.CYAN,
Color.rgb(138, 43, 226) to Color.rgb(255, 105, 180),
Color.GREEN to Color.rgb(50, 205, 50),
Color.YELLOW to Color.rgb(255, 215, 0),
Color.rgb(255, 0, 0) to Color.rgb(255, 182, 193),
Color.rgb(64, 224, 208) to Color.rgb(0, 191, 255),
Color.BLACK to Color.rgb(169, 169, 169),
Color.rgb(0, 0, 139) to Color.rgb(135, 206, 250),
Color.rgb(128, 0, 128) to Color.rgb(230, 230, 250)
).shuffled()
}
9 changes: 9 additions & 0 deletions app/src/main/java/otus/homework/customview/PriceData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package otus.homework.customview

data class PriceData(
val id: Long,
val name: String,
val amount: Long,
val category: String,
val time: Long,
)
Loading