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: 0 additions & 3 deletions .idea/codeStyles/Project.xml

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

3 changes: 2 additions & 1 deletion .idea/gradle.xml

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

30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

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

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class Contract{
const val THEME_DEFAULT = 0
const val THEME_DARK = 1
const val THEME_AMOLED = 2
const val PREF_NOTE_COLOR_TYPE = "sharedPrefs.currentNoteColorType"
const val NOTE_COLOR_TYPE_DEFAULT = 0
const val NOTE_COLOR_TYPE_LIGHT = 1
const val PREF_CLOUD_TYPE = "sharedPrefs.cloudType"
const val PREF_ACCESS_TOKEN = "sharedPrefs.accessToken"
const val PREF_ID = "sharedPrefs.userId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import com.infinitysolutions.notessync.Contracts.Contract.Companion.CLOUD_DROPBO
import com.infinitysolutions.notessync.Contracts.Contract.Companion.CLOUD_GOOGLE_DRIVE
import com.infinitysolutions.notessync.Contracts.Contract.Companion.MODE_CHANGE_PASSWORD
import com.infinitysolutions.notessync.Contracts.Contract.Companion.MODE_NEW_PASSWORD
import com.infinitysolutions.notessync.Contracts.Contract.Companion.NOTE_COLOR_TYPE_DEFAULT
import com.infinitysolutions.notessync.Contracts.Contract.Companion.NOTE_COLOR_TYPE_LIGHT
import com.infinitysolutions.notessync.Contracts.Contract.Companion.PASSWORD_MODE
import com.infinitysolutions.notessync.Contracts.Contract.Companion.PREF_ACCESS_TOKEN
import com.infinitysolutions.notessync.Contracts.Contract.Companion.PREF_APP_LOCK_CODE
Expand All @@ -43,6 +45,7 @@ import com.infinitysolutions.notessync.Contracts.Contract.Companion.PREF_DEFAULT
import com.infinitysolutions.notessync.Contracts.Contract.Companion.PREF_ENCRYPTED
import com.infinitysolutions.notessync.Contracts.Contract.Companion.PREF_MAX_PREVIEW_LINES
import com.infinitysolutions.notessync.Contracts.Contract.Companion.PREF_MOVE_CHECKED_TO_BOTTOM
import com.infinitysolutions.notessync.Contracts.Contract.Companion.PREF_NOTE_COLOR_TYPE
import com.infinitysolutions.notessync.Contracts.Contract.Companion.PREF_THEME
import com.infinitysolutions.notessync.Contracts.Contract.Companion.SHARED_PREFS_NAME
import com.infinitysolutions.notessync.Contracts.Contract.Companion.STATE_CHANGE_PIN
Expand All @@ -60,6 +63,10 @@ import kotlinx.android.synthetic.main.theme_dialog.view.*
class SettingsFragment : Fragment() {
private val TAG = "SettingsFragment"

companion object {
var COLOR_TYPE_STRING = "dark"
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val rootView = inflater.inflate(R.layout.fragment_settings, container, false)
setupViews(rootView, container)
Expand Down Expand Up @@ -109,6 +116,43 @@ class SettingsFragment : Fragment() {
dialog.show()
}

var colorTypeIndex: Int
rootView.pref_note_color_type.text =
when (prefs.getInt(PREF_NOTE_COLOR_TYPE, NOTE_COLOR_TYPE_DEFAULT)) {
NOTE_COLOR_TYPE_DEFAULT -> {
colorTypeIndex = 0
COLOR_TYPE_STRING = "dark"
"Dark"
}
NOTE_COLOR_TYPE_LIGHT -> {
colorTypeIndex = 1
COLOR_TYPE_STRING = "light"
"Light"
}
else -> {
colorTypeIndex = 0
COLOR_TYPE_STRING = "dark"
"Dark"
}
}

rootView.note_color_type_button.setOnClickListener {
val dialogView =
layoutInflater.inflate(R.layout.note_color_type_dialog, container, false)
val dialog = BottomSheetDialog(context!!)
val themeGroup = dialogView.theme_group
(themeGroup.getChildAt(colorTypeIndex) as RadioButton).isChecked = true
dialogView.light_btn.setOnClickListener {
changeNoteColorType(prefs, colorTypeIndex, NOTE_COLOR_TYPE_LIGHT, dialog)
}
dialogView.dark_btn.setOnClickListener {
changeNoteColorType(prefs, colorTypeIndex, NOTE_COLOR_TYPE_DEFAULT, dialog)
}

dialog.setContentView(dialogView)
dialog.show()
}

configureAppLockButtons(rootView, prefs)

rootView.about_button.setOnClickListener {
Expand Down Expand Up @@ -168,6 +212,22 @@ class SettingsFragment : Fragment() {
}
}

private fun changeNoteColorType(
prefs: SharedPreferences,
noteColorTypeIndex: Int,
toColorType: Int,
dialog: BottomSheetDialog
) {
dialog.dismiss()
if (noteColorTypeIndex != toColorType) {
val editor = prefs.edit()
editor.putInt(PREF_NOTE_COLOR_TYPE, toColorType)
editor.commit()
updateWidgets()
activity?.recreate()
}
}

private fun changeTheme(prefs: SharedPreferences, themeIndex: Int, toTheme: Int, dialog: BottomSheetDialog){
dialog.dismiss()
if(themeIndex != toTheme){
Expand Down Expand Up @@ -210,6 +270,19 @@ class SettingsFragment : Fragment() {
}
}

private fun configureNoteColorTypeButton(
rootView: View,
prefs: SharedPreferences,
container: ViewGroup?
) {
/*var defaultColorType = prefs.getInt(PREF_NOTE_COLOR_TYPE, 0)
val editor = prefs.edit()
editor.putInt(PREF_NOTE_COLOR_TYPE, defaultColorType)
editor.commit()
updateWidgets()
activity?.recreate()*/
}

private fun configureMaxLinesButton(rootView: View, prefs: SharedPreferences, container: ViewGroup?){
var value = prefs.getInt(PREF_MAX_PREVIEW_LINES, 32)
if(value == -1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,68 @@
package com.infinitysolutions.notessync.Util

import android.content.ContentValues.TAG
import android.util.Log
import com.infinitysolutions.notessync.Fragments.SettingsFragment

class ColorsUtil {
private val colorsList = arrayOf(
private var colorType = SettingsFragment.COLOR_TYPE_STRING

private val colorsListDark = arrayOf(
"#2196f3",// 0
"#AD1457",// 1
"#FF5722",// 2
"#9C27B0",// 3
"#607D8B",// 4
"#009688",// 5
"#00BCD4",// 1
"#009688",// 2
"#3DDC84",// 3
"#9C27B0",// 4
"#AD1457",// 5
"#E91E63",// 6
"#795548",// 7
"#263238",//8
"#3DDC84",//9
"#00bcd4",//10
"#f44336" //11
"#F44336",// 7
"#FF5722",//8
"#795548",//9
"#607D8B",//10
"#263238" //11
)

private val colorsListLight = arrayOf(
"#96ADC8",// 0
"#8B9BDC",// 1
"#D7708F",// 2
"#D792B7",// 3
"#F8A098",// 4
"#F8D9AD",// 5
"#FFE090",// 6
"#76D7A4",// 7
"#41A287",//8
"#A0796C",//9
"#3F3F3F",//10
"#181818" //11
)

fun getColorType(): String {
return colorType
}

private fun getColorType(type: String): Array<String> {
Log.d(TAG, "getColorType: $type")
return if (colorType === "dark") {
colorsListDark
} else {
colorsListLight
}
}

fun getColor(position: Int?): String {

val colors = getColorType(colorType)

if (position == null || position > getSize())
return colorsList[0]
return colorsList[position]

return colors[0]

return colors[position]
}

fun getSize(): Int{
fun getSize(): Int {
val colorsList = getColorType(colorType)
return colorsList.size
}
}
21 changes: 21 additions & 0 deletions app/src/main/res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,27 @@
android:layout_height="30dp"/>
</LinearLayout>

<LinearLayout
android:id="@+id/note_color_type_button"
style="@style/prefsContainer">

<ImageView
style="@style/prefsIcon"
android:src="@drawable/note_color_icon" />

<LinearLayout style="@style/prefsTextContainer">

<TextView
style="@style/prefsMain"
android:text="ColorType" />

<TextView
android:id="@+id/pref_note_color_type"
style="@style/prefsSummary" />
</LinearLayout>

</LinearLayout>

<LinearLayout
android:id="@+id/preview_lines_count_button"
style="@style/prefsContainer">
Expand Down
40 changes: 40 additions & 0 deletions app/src/main/res/layout/note_color_type_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/mainBackground"
android:orientation="vertical"
android:padding="20dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="App theme"
android:textColor="?attr/mainTextColor"
android:textSize="18sp" />

<RadioGroup
android:id="@+id/theme_group"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<RadioButton
android:id="@+id/dark_btn"
android:text="Dark"
android:textSize="16sp"
android:textColor="?attr/mainTextColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<RadioButton
android:id="@+id/light_btn"
android:text="Light"
android:textSize="16sp"
android:layout_marginTop="8dp"
android:textColor="?attr/mainTextColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RadioGroup>
</LinearLayout>