Skip to content

Commit

Permalink
- Fix stylesbar crash
Browse files Browse the repository at this point in the history
- Replace in app rate with playstore link (closes #1)
- Fix categories deleting
- Layout improvements
- Update dependencies
  • Loading branch information
YahiaAngelo committed Sep 16, 2020
1 parent e7bdeb6 commit 4e4f61b
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 35 deletions.
20 changes: 10 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
applicationId "com.noted.noted"
minSdkVersion 23
targetSdkVersion 29
versionCode 6
versionName "1.1.0"
versionCode 7
versionName "1.1.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -49,17 +49,17 @@ android {

dependencies {
def nav_version = "2.3.0"
def koin_version = "2.1.5"
def koin_version = "2.2.0-alpha-1"
def lifecycle_version = "2.2.0"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // or "kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0"
implementation "androidx.work:work-runtime-ktx:2.4.0"
implementation 'androidx.preference:preference:1.1.1'// JVM dependency
implementation 'com.google.firebase:firebase-analytics-ktx:17.4.4'
implementation 'com.google.firebase:firebase-crashlytics:17.1.1'
implementation 'com.google.firebase:firebase-auth-ktx:19.3.2'
implementation 'com.google.firebase:firebase-firestore-ktx:21.5.0'
implementation 'com.google.firebase:firebase-analytics-ktx:17.5.0'
implementation 'com.google.firebase:firebase-crashlytics:17.2.1'
implementation 'com.google.firebase:firebase-auth-ktx:19.4.0'
implementation 'com.google.firebase:firebase-firestore-ktx:21.6.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.1.1'
implementation 'com.google.android.gms:play-services-auth:18.1.0'
implementation 'com.google.android.play:core:1.8.0'
Expand All @@ -70,7 +70,7 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-rc1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation "org.koin:koin-android:$koin_version"
implementation "org.koin:koin-androidx-scope:$koin_version"
implementation "org.koin:koin-androidx-viewmodel:$koin_version"
Expand All @@ -82,7 +82,7 @@ dependencies {
kapt 'org.parceler:parceler:1.1.13'
implementation "io.noties.markwon:core:4.3.1"
implementation "io.noties.markwon:ext-strikethrough:4.3.1"
implementation 'com.yahiaangelo.markdownedittext:markdownedittext:1.0.1'
implementation 'com.yahiaangelo.markdownedittext:markdownedittext:1.0.2'
implementation('dev.doubledot.doki:library:0.0.1@aar') {
transitive = true
}
Expand All @@ -101,7 +101,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0-alpha02'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/noted/noted/repositories/NoteRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class NoteRepo {
return array
}

fun QuerySnapshot.toNote():List<Note>{
private fun QuerySnapshot.toNote():List<Note>{
val notesList: MutableList<Note> = mutableListOf()
for(query in this){
val id = query.getLong("id")
Expand Down
16 changes: 13 additions & 3 deletions app/src/main/java/com/noted/noted/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ import com.google.android.material.datepicker.DateValidatorPointForward
import com.google.android.material.datepicker.MaterialDatePicker
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.noted.noted.R
import com.noted.noted.model.Note
import com.noted.noted.model.NoteCategory
import com.noted.noted.repositories.NoteRepo
import io.realm.Realm
import timber.log.Timber
import java.util.*
import kotlin.collections.HashMap

Expand Down Expand Up @@ -98,10 +101,17 @@ class Utils {
) { dialog, _ ->
itemsList.removeAt(position)
realm = Realm.getDefaultInstance()
realm.use {
it.beginTransaction()
val notesWithCategory = realm.where(Note::class.java).equalTo("categories.id", noteCategory.id).findAll()
Timber.e("Notes with this category count is ${notesWithCategory.size}")
realm.use { realm ->
realm.beginTransaction()
for (note in notesWithCategory){
note.categories.remove(noteCategory)
NoteRepo.NotesWorker.uploadNote(note)
}
noteCategory.deleteFromRealm()
it.commitTransaction()
realm.commitTransaction()
realm.close()
}
simpleAdapter.notifyDataSetChanged()
dialog.dismiss()
Expand Down
25 changes: 13 additions & 12 deletions app/src/main/java/com/noted/noted/view/activity/AboutActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.noted.noted.view.activity

import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.graphics.drawable.ColorDrawable
Expand Down Expand Up @@ -92,18 +93,18 @@ class AboutActivity : MaterialAboutActivity() {
.text("Rate this app")
.icon(R.drawable.ic_star_rate)
.setOnClickAction {
val manager = ReviewManagerFactory.create(this)
val request = manager.requestReviewFlow()
request.addOnCompleteListener { playRequest ->
if (playRequest.isSuccessful) {
// We got the ReviewInfo object
val reviewInfo = playRequest.result
val flow = manager.launchReviewFlow(this, reviewInfo)
flow.addOnCompleteListener { _ ->
}
} else {
Toast.makeText(this, "Sorry, Something went wrong", Toast.LENGTH_SHORT).show()
}
val uri: Uri = Uri.parse("market://details?id=$packageName")
val goToMarket = Intent(Intent.ACTION_VIEW, uri)
// To count with Play market backstack, After pressing back button,
// to taken back to our application, we need to add following flags to intent.
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY or
Intent.FLAG_ACTIVITY_NEW_DOCUMENT or
Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
try {
startActivity(goToMarket)
} catch (e: ActivityNotFoundException) {
startActivity(Intent(Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id=$packageName")))
}
}
.build())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.noted.noted.view.activity

import android.content.DialogInterface
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Parcelable
Expand Down Expand Up @@ -312,16 +311,22 @@ class NoteAddActivity : AppCompatActivity() {
}

private fun setupMarkwon() {
binding.noteBodyEditText.setStylesBar(binding.noteStylesBar)
KeyboardVisibilityEvent.setEventListener(this, object : KeyboardVisibilityEventListener {
override fun onVisibilityChanged(isOpen: Boolean) {
val set: TransitionSet = TransitionSet()
.addTransition(Fade())
.setInterpolator(FastOutLinearInInterpolator())

TransitionManager.beginDelayedTransition(binding.noteStylesBar, set)
binding.noteStylesBar.visibility = if (isOpen) View.VISIBLE else View.GONE
binding.noteDate.visibility = if (isOpen) View.GONE else View.VISIBLE
if(isOpen){
binding.noteStylesBar.visibility = View.VISIBLE
binding.noteDate.visibility = View.GONE
binding.noteBodyEditText.setStylesBar(binding.noteStylesBar)

}else{
binding.noteStylesBar.visibility = View.GONE
binding.noteDate.visibility = View.VISIBLE
}
}

})
Expand Down
37 changes: 34 additions & 3 deletions app/src/main/res/layout/simple_listview_layout.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand All @@ -13,8 +14,38 @@
android:id="@+id/bottom_sheet_pill"/>
<ListView
android:layout_marginTop="18dp"
android:layout_marginBottom="18dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:visibility="gone"
android:id="@+id/simple_listView"/>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:alpha="0.5"
android:background="@color/text_secondary"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="18dp"
android:layout_marginTop="12dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:orientation="horizontal">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_info_black"
app:tint="@color/text_secondary" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_secondary"
android:layout_gravity="center_vertical"
android:fontFamily="@font/roboto_light"
android:layout_marginStart="24dp"
android:textSize="14sp"
android:text="Long press on category to delete"/>
</LinearLayout>
</LinearLayout>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.3.61"
ext.kotlin_version = "1.4.10"
// Stable Koin Version
repositories {
google()
Expand All @@ -17,7 +17,7 @@ buildscript {
classpath "io.realm:realm-gradle-plugin:6.1.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0"
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'


// NOTE: Do not place your application dependencies here; they belong
Expand Down

0 comments on commit 4e4f61b

Please sign in to comment.