Skip to content

Commit

Permalink
Merge pull request #12 from llastkrakw/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
llastkrakw authored Aug 10, 2021
2 parents cad5e12 + 73f1f2e commit 4063c76
Show file tree
Hide file tree
Showing 40 changed files with 619 additions and 279 deletions.
5 changes: 5 additions & 0 deletions .idea/misc.xml

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

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {

defaultConfig {
applicationId "com.llastkrakw.nevernote"
minSdkVersion 24
minSdkVersion 26
targetSdkVersion 30
versionCode appVersionCode
versionName "1.0"
Expand Down
59 changes: 29 additions & 30 deletions app/src/main/java/com/llastkrakw/nevernote/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.content.res.Configuration
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.transition.Explode
import android.util.Log
import android.view.*
import android.widget.EditText
Expand All @@ -14,6 +15,7 @@ import android.widget.TextView
import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.LinearLayoutManager
Expand Down Expand Up @@ -55,14 +57,15 @@ class MainActivity : AppCompatActivity() {

private lateinit var sheetBehavior: BottomSheetBehavior<*>


override fun onCreate(savedInstanceState: Bundle?) {
requestWindowFeature(Window.FEATURE_NO_TITLE)
super.onCreate(savedInstanceState)

binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

//setUpWindowAnimations()

setSupportActionBar(binding.myToolbar)
supportActionBar?.title = ""

Expand Down Expand Up @@ -120,6 +123,7 @@ class MainActivity : AppCompatActivity() {
sheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN

}

}


Expand All @@ -130,6 +134,14 @@ class MainActivity : AppCompatActivity() {
when(it.isEmpty()){
true -> {
menuInflater.inflate(R.menu.note_menu, menu)
(noteViewModel.isGrid.value!!).let { isGrid ->
val item = menu?.findItem(R.id.action_switch_layout)
if (isGrid)
item?.icon = ContextCompat.getDrawable(this, R.drawable.ic_list)
else
item?.icon = ContextCompat.getDrawable(this, R.drawable.ic_grid)
invalidateOptionsMenu()
}
invalidateOptionsMenu()
}
false -> {
Expand All @@ -144,7 +156,9 @@ class MainActivity : AppCompatActivity() {

override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
R.id.action_switch_layout -> {
showMenuDialog()
(noteViewModel.isGrid.value!!).let {
noteViewModel.toggleLayoutNoteManager(!it)
}
true
}

Expand Down Expand Up @@ -231,31 +245,6 @@ class MainActivity : AppCompatActivity() {
alertDialog.show()
}

private fun showMenuDialog(){

val items = arrayOf<CharSequence>("ListView", "GridView", "Setting")
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
builder.setItems(items
) { _, selected ->
when (selected) {
1 -> noteViewModel.toggleLayoutNoteManager(true)
0 -> noteViewModel.toggleLayoutNoteManager(false)
}
}

val dialog: AlertDialog = builder.create()
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
val wmlp: WindowManager.LayoutParams = dialog.window!!.attributes

wmlp.gravity = Gravity.TOP or Gravity.END
wmlp.x = 100 //x position

wmlp.y = 100 //y position


dialog.show()
dialog.window!!.setLayout(650, 550)
}

override fun onBackPressed() {
if (viewPager.currentItem == 0) {
Expand All @@ -271,9 +260,18 @@ class MainActivity : AppCompatActivity() {

override fun createFragment(position: Int): Fragment{

if(position == 0)
return NoteFragment.newInstance()
return TaskFragment.newInstance()
val slide = Explode().setDuration(2000)

if(position == 0){
val noteFragment = NoteFragment.newInstance()
noteFragment.exitTransition = slide
return noteFragment
}

val taskFragment = TaskFragment.newInstance()
taskFragment.exitTransition = slide

return taskFragment
}

}
Expand Down Expand Up @@ -337,4 +335,5 @@ class MainActivity : AppCompatActivity() {
sheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fun Context.getStorageDirectories(): Array<String> {
if (TextUtils.isEmpty(rawUserId)) {
paths.add(rawEmulatedStorageTarget!!)
} else {
paths.add(rawEmulatedStorageTarget + File.separator + rawUserId)
paths.add(rawEmulatedStorageTarget!! + File.separator + rawUserId)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.llastkrakw.nevernote.core.utilities

import android.text.*
import android.text.method.BaseMovementMethod
import android.text.style.URLSpan
import android.util.Log
import android.widget.EditText
import android.widget.TextView
import androidx.core.text.toHtml
import androidx.core.text.toSpannable
import com.llastkrakw.nevernote.core.utilities.SpanUtils.Companion.toSpannable
Expand Down Expand Up @@ -249,6 +249,17 @@ class Editor(@NotNull private var editText: EditText){
editText.setText(TextUtils.concat(string, " "))
}

fun makeBulletList(stringList: List<String>){
/* val string = SpannableString(state.content)
string.setSpan(
BulletSpan(40, Color.GREEN),
editText.selectionStart, editText.selectionEnd,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE
)*/

editText.setText(toSpannable(convertToBulletList(stringList, editText.text.toHtml())), TextView.BufferType.SPANNABLE)
}

fun alignRight(){
spanAlignmentRight(editText)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package com.llastkrakw.nevernote.core.utilities

import android.graphics.Color
import android.graphics.Typeface
import android.text.*
import android.text.method.LinkMovementMethod
import android.text.style.*
import android.text.util.Linkify
import android.util.Log
import android.view.View
import android.widget.EditText
import android.widget.TextView
import androidx.core.text.getSpans
import androidx.core.text.toHtml
import androidx.core.text.toSpannable


class SpanUtils {
Expand Down Expand Up @@ -66,20 +61,14 @@ fun url(url: String, s: SpannableString, editText: EditText) = span(s, URLSpan(u
fun normal(s: CharSequence, editText: EditText) = span(s, SpannableString(s), editText)
fun normal(s: SpannableString, editText: EditText) = span(s, SpannableString(s), editText)

fun convertToBulletList(stringList: List<String>): CharSequence {
val spannableStringBuilder = SpannableStringBuilder()
stringList.forEachIndexed { index, text ->
val line: CharSequence = text + if (index < stringList.size - 1) "\n" else ""
val spannable: Spannable = SpannableString(line)
spannable.setSpan(
BulletSpan(15, Color.GREEN),
0,
spannable.length,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE
)
spannableStringBuilder.append(spannable)
}
return spannableStringBuilder
fun convertToBulletList(stringList: List<String>, value: String): String {

var finalValue = value

for (str in stringList)
finalValue = finalValue.replaceFirst(str, "&#128995; $str </br>")

return finalValue
}

fun spanUnderline(editText: EditText) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.llastkrakw.nevernote.R
import com.llastkrakw.nevernote.feature.note.datas.entities.FolderWithNotes
import com.llastkrakw.nevernote.feature.note.viewModels.NoteViewModel
import com.llastkrakw.nevernote.views.notes.activities.FolderDetailActivity
import java.util.*

class FolderAdapter(private val noteViewModel: NoteViewModel, private val owner: LifecycleOwner) : ListAdapter<FolderWithNotes, FolderAdapter.FolderViewHolder>(FoldersComparator()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.cardview.widget.CardView
import androidx.core.view.ViewCompat
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ class OtherNoteAdapter(private val noteViewModel: NoteViewModel, private val own
}
else {
for (item in completeList) {
if (item.noteContent.toLowerCase(Locale.ROOT).contains(constraint.toString().toLowerCase(Locale.ROOT)) || item.noteTitle.toLowerCase(Locale.ROOT).contains(constraint.toString().toLowerCase(Locale.ROOT))) {
if (item.noteContent.lowercase(Locale.ROOT).contains(constraint.toString()
.lowercase(Locale.ROOT)) || item.noteTitle.lowercase(Locale.ROOT)
.contains(constraint.toString().lowercase(Locale.ROOT))) {
filteredList.add(item)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ class Events {
class RecordingStatus internal constructor(val status: Int)
class RecordingAmplitude internal constructor(val amplitude: Int)
class RecordingCompleted internal constructor()
class RecordingCanceled internal constructor()
}
Loading

0 comments on commit 4063c76

Please sign in to comment.