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
3 changes: 3 additions & 0 deletions app/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions app/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions app/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions app/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions app/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}


buildFeatures {

viewBinding true

}
}

dependencies {
Expand Down
8 changes: 8 additions & 0 deletions app/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Fri May 28 20:01:59 MSK 2021
sdk.dir=C\:\\Users\\Natalya\\AppData\\Local\\Android\\Sdk
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ class Controller(
return auth.getAuthIntent()
}

fun logOut() {
auth.logOut();

Choose a reason for hiding this comment

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

[ktlint] reported by reviewdog 🐶
Unnecessary semicolon

}

fun isAuthorized(): Boolean = auth.isAuthorized()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ru.mail.fancywork.model.fancyLib

Choose a reason for hiding this comment

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

[ktlint] reported by reviewdog 🐶
File must end with a newline (\n)


enum class Difficulty {
UNDEFINED, EASY, MEDIUM, HARD, EXTREMELY_HARD
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ru.mail.fancywork.model.fancyLib

Choose a reason for hiding this comment

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

[ktlint] reported by reviewdog 🐶
File must end with a newline (\n)


import android.graphics.Bitmap

data class FancyPicture(
val id: String,
val title: String,
val image: Bitmap,
val colors: List<List<String>>
) {
// todo id generator
// todo difficulty definer

var author: String = "unknown"
var difficulty: Difficulty = Difficulty.UNDEFINED

constructor(
id: String,
title: String,
image: Bitmap,
colors: List<List<String>>,
author: String,
difficulty: Difficulty
) : this(id, title, image, colors) {
this.author = author
this.difficulty = difficulty
}

fun getProportions(): Pair<Int, Int>? {
if (colors.isEmpty() || colors[0].isEmpty()) {
return null
}

return Pair(colors.size, colors[0].size)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class AuthRepository(private val auth: FirebaseAuth = FirebaseAuth.getInstance()
return FirebaseAuth.getInstance().currentUser != null
}

fun logOut() {
FirebaseAuth.getInstance().signOut()
}

companion object {
private const val TAG = "FirebaseRepository"
}
Expand Down
41 changes: 33 additions & 8 deletions app/src/main/java/ru/mail/fancywork/ui/primary/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,49 @@
package ru.mail.fancywork.ui.primary

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater

Choose a reason for hiding this comment

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

[ktlint] reported by reviewdog 🐶
Unused import

import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import ru.mail.fancywork.R
import ru.mail.fancywork.controller.Controller
import ru.mail.fancywork.ui.auth.AuthActivity

class MainActivity : AppCompatActivity() {

private val controller = Controller()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}

// todo google auth
public fun loginGoogle(view: View) {
// БОРЕМСЯ С КОДСТАЙЛОМ
findViewById<androidx.appcompat.widget.Toolbar>(R.id.top_bar)
.setOnMenuItemClickListener { item ->
when (item.itemId) {
R.id.logout -> {
controller.logOut()
startActivity(Intent(this, AuthActivity::class.java))
finish()
true
}
else -> false
}
}

var worksList: RecyclerView = findViewById(R.id.rv_works)
var ar: ArrayList<Int> = ArrayList()
ar.add(6)
ar.add(5)
ar.add(4)
var adapter = WorksListAdapter(ar)

worksList.adapter = adapter
worksList.layoutManager = LinearLayoutManager(this.applicationContext)
}

// todo local auth
public fun loginWithoutGoogle(view: View) {
// todo open recycle view activity
public fun add(view:View){

Choose a reason for hiding this comment

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

[ktlint] reported by reviewdog 🐶
Missing spacing after ":"

Choose a reason for hiding this comment

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

[ktlint] reported by reviewdog 🐶
Missing spacing before "{"

//todo открыть активити просмотра вышивки

Choose a reason for hiding this comment

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

[ktlint] reported by reviewdog 🐶
Missing space after //

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package ru.mail.fancywork.ui.primary

Choose a reason for hiding this comment

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

[ktlint] reported by reviewdog 🐶
File must end with a newline (\n)


import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import ru.mail.fancywork.databinding.WorkItemInRvBinding

class WorksListAdapter(
private var worksList: List<Int>//dataclasses

Choose a reason for hiding this comment

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

[ktlint] reported by reviewdog 🐶
Missing space before //

Choose a reason for hiding this comment

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

[ktlint] reported by reviewdog 🐶
Missing space after //

) : RecyclerView.Adapter<WorksListAdapter.ViewHolder>() {

inner class ViewHolder(val binding: WorkItemInRvBinding) : RecyclerView.ViewHolder(binding.root)

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val binding =
WorkItemInRvBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return ViewHolder(binding)
}

override fun onBindViewHolder(holder: ViewHolder, position: Int) {

with(holder) {
with(worksList[position]) {
binding.name.text = "ВЫЩЩЩИВКА"
binding.difficulty.rating = 4F
var str = "размер: " + worksList[position] + "x" + worksList[position] + "\nцветов: 5"

Choose a reason for hiding this comment

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

[ktlint] reported by reviewdog 🐶
Exceeded max line length (100) (cannot be auto-corrected)


binding.info.text = str

// binding.cardLayout.setOnClickListener {
// //todo открываем активити просмотра
// notifyDataSetChanged()
// }
}
}
}

override fun getItemCount(): Int {
return worksList.size
}
}
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/items_in_rv.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/lightBackground"/>

<stroke android:width="1.5dp"
android:color="@color/white"
/>

<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"
/>

<corners android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp"/>
</shape>
122 changes: 44 additions & 78 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,82 +7,48 @@
tools:context="ru.mail.fancywork.ui.primary.MainActivity"
android:theme="@style/Theme.FancyWork">

<!-- <TextView-->
<!-- android:layout_width="255dp"-->
<!-- android:layout_height="256dp"-->
<!-- android:text="@string/fancy_string"-->
<!-- android:textColor="@color/black"-->
<!-- android:backgroundTint="@color/background"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintVertical_bias="0.033"-->
<!-- android:textAppearance="@style/TextAppearance.AppCompat.Display3"-->
<!-- android:id="@+id/textView"-->
<!-- app:layout_constraintHorizontal_bias="0.134" />-->

<!-- <Button-->
<!-- android:id="@+id/button_login_google"-->
<!-- android:layout_width="120dp"-->
<!-- android:layout_height="65dp"-->
<!-- android:onClick="loginGoogle"-->
<!-- android:text="@string/google"-->
<!-- android:backgroundTint="@color/background"-->
<!-- android:textColor="@color/black"-->
<!-- android:textSize="12sp"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintHorizontal_bias="0.173"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:layout_constraintVertical_bias="0.961" />-->


<!-- <Button-->
<!-- android:id="@+id/button_login_without_google"-->
<!-- android:layout_width="120dp"-->
<!-- android:layout_height="65dp"-->
<!-- android:text="@string/without_google"-->
<!-- android:onClick="loginWithoutGoogle"-->
<!-- android:textSize="12sp"-->
<!-- android:backgroundTint="@color/background"-->
<!-- android:textColor="@color/black"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:layout_constraintVertical_bias="0.961"-->
<!-- app:layout_constraintHorizontal_bias="0.893" />-->

<!-- <ImageView-->
<!-- android:layout_width="374dp"-->
<!-- android:layout_height="315dp"-->
<!-- app:srcCompat="@drawable/main_pic"-->
<!-- android:id="@+id/imageView"-->
<!-- android:backgroundTint="@color/background"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintHorizontal_bias="0.567"-->
<!-- app:layout_constraintVertical_bias="0.437" />-->

<!-- <ImageView-->
<!-- android:layout_width="120dp"-->
<!-- android:layout_height="95dp"-->
<!-- app:srcCompat="@drawable/open_pic"-->
<!-- android:id="@+id/imageView2"-->
<!-- android:backgroundTint="@color/background"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintHorizontal_bias="0.171"-->
<!-- app:layout_constraintVertical_bias="0.849" />-->



<com.google.android.material.appbar.AppBarLayout
android:id="@+id/top_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/secondaryColor"
android:theme="@style/ToolbarStyleLight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">


<androidx.appcompat.widget.Toolbar
android:theme="@style/ToolbarStyleLight"
android:id="@+id/top_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:menu="@menu/top_main_actionbar"
android:hapticFeedbackEnabled="false"/>
</com.google.android.material.appbar.AppBarLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_works"
android:layout_width="match_parent"
android:layout_height="670dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/top_bar_layout"
app:layout_constraintVertical_bias="0.0" />


<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="add"
app:srcCompat="@android:drawable/ic_input_add"
android:id="@+id/floatingActionButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:focusable="true" />
</androidx.constraintlayout.widget.ConstraintLayout>
Loading