Skip to content

Commit

Permalink
color complete
Browse files Browse the repository at this point in the history
  • Loading branch information
anandarpit committed Dec 26, 2020
1 parent f79ed9e commit 4a5a27d
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 12 deletions.
77 changes: 67 additions & 10 deletions app/src/main/java/com/arpit/notify/activity/CreateNotesActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.arpit.notify.activity

import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.os.AsyncTask
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
Expand All @@ -9,6 +11,7 @@ import android.os.Looper
import android.util.Log
import android.view.View
import android.widget.LinearLayout
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.arpit.notify.R
Expand All @@ -25,6 +28,8 @@ import java.util.*

class CreateNotesActivity : AppCompatActivity() {

lateinit var selectedNoteColor: String

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_create_notes)
Expand All @@ -37,20 +42,22 @@ class CreateNotesActivity : AppCompatActivity() {

initMiscellaneou();

selectedNoteColor = "#333333"

setSubTitleIndicatorColor()

}

private fun setSubTitleIndicatorColor() {
var gradientDrawable:GradientDrawable = view.background as GradientDrawable
gradientDrawable.setColor(Color.parseColor(selectedNoteColor))
}

private fun initMiscellaneou() {

val llBottomSheet = findViewById<LinearLayout>(R.id.layout_misc)
val bottomSheetBehavior = BottomSheetBehavior.from(llBottomSheet)

// bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
//
// bottomSheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
// override fun onStateChanged(bottomSheet: View, newState: Int) {}
// override fun onSlide(bottomSheet: View, slideOffset: Float) {}
// })

layout_misc.setOnClickListener{
if(bottomSheetBehavior.state != BottomSheetBehavior.STATE_EXPANDED){
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
Expand All @@ -59,6 +66,58 @@ class CreateNotesActivity : AppCompatActivity() {
bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
}
}

tick_one.setOnClickListener{
selectedNoteColor = "#333333"

tick_one.setImageResource(R.drawable.ic_single_done)
tick_two.setImageResource(0)
tick_three.setImageResource(0)
tick_four.setImageResource(0)
tick_five.setImageResource(0)
setSubTitleIndicatorColor()
}

tick_two.setOnClickListener{
selectedNoteColor = "#FDBE3B"

tick_one.setImageResource(0)
tick_two.setImageResource(R.drawable.ic_single_done)
tick_three.setImageResource(0)
tick_four.setImageResource(0)
tick_five.setImageResource(0)
setSubTitleIndicatorColor()
}
tick_three.setOnClickListener{
selectedNoteColor = "#FF4842"

tick_one.setImageResource(0)
tick_two.setImageResource(0)
tick_three.setImageResource(R.drawable.ic_single_done)
tick_four.setImageResource(0)
tick_five.setImageResource(0)
setSubTitleIndicatorColor()
}
tick_four.setOnClickListener{
selectedNoteColor = "#3A52Fc"

tick_one.setImageResource(0)
tick_two.setImageResource(0)
tick_three.setImageResource(0)
tick_four.setImageResource(R.drawable.ic_single_done)
tick_five.setImageResource(0)
setSubTitleIndicatorColor()
}
tick_five.setOnClickListener{
selectedNoteColor = "#4CAF50"

tick_one.setImageResource(0)
tick_two.setImageResource(0)
tick_three.setImageResource(0)
tick_four.setImageResource(0)
tick_five.setImageResource(R.drawable.ic_single_done)
setSubTitleIndicatorColor()
}
}

private fun saveNote() {
Expand All @@ -79,6 +138,7 @@ class CreateNotesActivity : AppCompatActivity() {
note.setSubtitle(subtitle)
note.setNoteText(notes)
note.setDateTime(datetime.text.toString())
note.setColor(selectedNoteColor)

class SaveNotes: AsyncTask<Void, Void, Void>() {

Expand Down Expand Up @@ -109,7 +169,4 @@ class CreateNotesActivity : AppCompatActivity() {
Snackbar.make(this, message, duration).show()
}




}
14 changes: 14 additions & 0 deletions app/src/main/java/com/arpit/notify/adapter/NoteAdapter.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.arpit.notify.adapter;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -49,13 +52,15 @@ public int getItemViewType(int position) {
public static class myAdapter extends RecyclerView.ViewHolder {

TextView textTitle, textSubtitle, textDate;
LinearLayout layoutContaier;

public myAdapter(@NonNull View itemView) {
super(itemView);

textTitle = itemView.findViewById(R.id.textTitle);
textSubtitle = itemView.findViewById(R.id.textSubtitle);
textDate = itemView.findViewById(R.id.textDate);
layoutContaier = itemView.findViewById(R.id.item_container_layout);

}

Expand All @@ -71,6 +76,15 @@ public void bind(Note note) {
textSubtitle.setText(note.getSubtitle());
}

GradientDrawable gradientDrawable = (GradientDrawable) layoutContaier.getBackground();

if(note.getColor() != null){
gradientDrawable.setColor(Color.parseColor(note.getColor()));
}
else{
gradientDrawable.setColor(Color.parseColor("#333333"));
}

}
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_baseline_done.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<vector android:height="24dp" android:tint="@color/colorAccent"
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19.77,5.03l1.4,1.4L8.43,19.17l-5.6,-5.6 1.4,-1.4 4.2,4.2L19.77,5.03m0,-2.83L8.43,13.54l-4.2,-4.2L0,13.57 8.43,22 24,6.43 19.77,2.2z"/>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/text_cursor_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="@dimen/_1sdp" android:height="@dimen/_10sdp" />
<corners android:radius="@dimen/_10sdp"/>
<solid android:color="#FFFFFF" />
</shape>
7 changes: 6 additions & 1 deletion app/src/main/res/layout/activity_create_notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/CreateNoteLayout"
android:background="#333333"
android:background="#2B2A2A"
tools:context=".activity.CreateNotesActivity">
<ScrollView
android:layout_width="match_parent"
Expand Down Expand Up @@ -55,6 +55,7 @@
android:fontFamily="@font/ubuntu_bold"
android:hint="Note Title"
android:imeOptions="actionDone"
android:textCursorDrawable="@drawable/text_cursor_color"
android:textColor="#ffffff"
android:textColorHint="#7b7b7b"
android:background="@null"
Expand Down Expand Up @@ -84,6 +85,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/_12sdp"
android:textCursorDrawable="@drawable/text_cursor_color"

android:background="@null"
android:fontFamily="@font/ubuntu_medium"
android:hint="Note Subtitle"
Expand Down Expand Up @@ -117,6 +120,8 @@
android:layout_marginVertical="@dimen/_15sdp"
android:background="@null"
android:fontFamily="@font/ubuntu_regular"
android:textCursorDrawable="@drawable/text_cursor_color"

android:gravity="top"
android:hint="Type Note here..."
android:importantForAutofill="no"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/layout/layout_miscellaneous.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
android:background="@drawable/background_note_color_1"/>

<ImageView
android:id="@+id/tick_one"
android:layout_width="@dimen/_35sdp"
android:layout_height="@dimen/_35sdp"
android:padding="@dimen/_10sdp"
Expand All @@ -60,6 +61,7 @@
android:background="@drawable/background_note_color_2"/>

<ImageView
android:id="@+id/tick_two"
android:layout_width="@dimen/_35sdp"
android:layout_height="@dimen/_35sdp"
android:padding="@dimen/_10sdp"
Expand All @@ -75,6 +77,7 @@
android:background="@drawable/background_note_color_3"/>

<ImageView
android:id="@+id/tick_three"
android:layout_width="@dimen/_35sdp"
android:layout_height="@dimen/_35sdp"
android:padding="@dimen/_10sdp"
Expand All @@ -90,6 +93,7 @@
android:background="@drawable/background_note_color_4"/>

<ImageView
android:id="@+id/tick_four"
android:layout_width="@dimen/_35sdp"
android:layout_height="@dimen/_35sdp"
android:padding="@dimen/_10sdp"
Expand All @@ -105,6 +109,7 @@
android:background="@drawable/background_note_color_5"/>

<ImageView
android:id="@+id/tick_five"
android:layout_width="@dimen/_35sdp"
android:layout_height="@dimen/_35sdp"
android:padding="@dimen/_10sdp"
Expand Down

0 comments on commit 4a5a27d

Please sign in to comment.