Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
azizkayumov committed Dec 23, 2018
1 parent 90ddba6 commit 9bbaac6
Show file tree
Hide file tree
Showing 19 changed files with 225 additions and 66 deletions.
7 changes: 2 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId "com.piapps.flashcardpro"
minSdkVersion 17
targetSdkVersion 28
versionCode 6
versionName "v0.0.6"
versionCode 10
versionName "v0.0.10"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down Expand Up @@ -66,9 +66,6 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'

// about page
implementation 'com.github.medyo:android-about-page:1.2'

// crashlitics
compile('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
transitive = true
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":6},"path":"app-release.apk","properties":{"packageId":"com.piapps.flashcardpro","split":"","minSdkVersion":"17"}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":9},"path":"app-release.apk","properties":{"packageId":"com.piapps.flashcardpro","split":"","minSdkVersion":"17"}}]
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.piapps.flashcardpro.application

import android.app.Application
import android.support.v7.app.AppCompatDelegate
import com.blankj.utilcode.util.Utils
import com.piapps.flashcardpro.model.Card
import com.piapps.flashcardpro.model.Label
Expand All @@ -23,8 +24,9 @@ class Flashcards : Application() {

override fun onCreate() {
super.onCreate()
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
instance = this
Utils.init(this);
Utils.init(this)
db = MyObjectBox.builder().androidContext(this).build()
Fabric.with(this, Crashlytics())
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/piapps/flashcardpro/model/Card.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ class Card(@Id(assignable = true)
var trueAnswers: Int = 0, // true answers reached in Quiz mode
var totalSeen: Int = 0, // total seen by user
var totalStudied: Int = 0 // total studied in Study mode
)
){
constructor() : this(0,0)
}
9 changes: 7 additions & 2 deletions app/src/main/java/com/piapps/flashcardpro/model/Label.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@ import io.objectbox.annotation.Transient
*/

@Entity
class Label(@Id(assignable = true) var id: Long,
var title: String, @Transient var isSelected: Boolean = false)
class Label(@Id(assignable = true)
var id: Long,
var title: String,
@Transient
var isSelected: Boolean = false) {
constructor() : this(0, "")
}
6 changes: 4 additions & 2 deletions app/src/main/java/com/piapps/flashcardpro/model/Set.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import io.objectbox.annotation.Id

@Entity
class Set(@Id(assignable = true) var id: Long,
var title: String,
var title: String = "",
var count: Int = 0,
var useCount: Int = 0,
var labels: String = "",
var lastEdited: Long = 0L,
var color: String = "",
var isTrash: Boolean = false,
var isFavorite: Boolean = false)
var isFavorite: Boolean = false){
constructor() : this(0)
}
63 changes: 31 additions & 32 deletions app/src/main/java/com/piapps/flashcardpro/ui/AboutActivity.kt
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
package com.piapps.flashcardpro.ui

import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.Gravity
import android.view.View
import android.widget.Toast
import com.piapps.flashcardpro.R
import mehdi.sakout.aboutpage.AboutPage
import mehdi.sakout.aboutpage.Element
import java.util.*
import kotlinx.android.synthetic.main.activity_about.*


/**
* Created by abduaziz on 8/8/18.
*/

class AboutActivity : AppCompatActivity(){
class AboutActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val aboutPage = AboutPage(this)
.isRTL(false)
.setImage(R.drawable.art)
.setDescription(getString(R.string.description))
.addItem(Element().setTitle("Version ${packageManager.getPackageInfo(packageName,0).versionName}"))
.addGroup("Connect with us")
.addEmail("kayumovabduaziz@gmail.com")
.addWebsite("http://inha.uz")
.addFacebook("abduaziz.kayumov")
.addYoutube("UCnQ3vq3LNsxrYGlGdziTrhA")
.addPlayStore("com.piapps.flashcardpro")
.addItem(getCopyRightsElement())
.create()
setContentView(aboutPage)
}
setContentView(R.layout.activity_about)

internal fun getCopyRightsElement(): Element {
val copyRightsElement = Element()
val copyrights = String.format(getString(R.string.copy_right), Calendar.getInstance().get(Calendar.YEAR))
copyRightsElement.setTitle(copyrights)
copyRightsElement.setIconTint(mehdi.sakout.aboutpage.R.color.about_item_icon_color)
copyRightsElement.iconNightTint = android.R.color.white
copyRightsElement.gravity = Gravity.CENTER
copyRightsElement.onClickListener = View.OnClickListener { Toast.makeText(this@AboutActivity, copyrights, Toast.LENGTH_SHORT).show() }
return copyRightsElement
}
tvVersion.text = "Version ${packageManager.getPackageInfo(packageName, 0).versionName}"

llEmail.setOnClickListener {
val emailIntent = Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"))
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, arrayOf("kayumovabduaziz@gmail.com"))
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Flashcards Maker")
startActivity(emailIntent)
}

llGithub.setOnClickListener {
val url = "https://github.com/AbduazizKayumov/Flashcard-Maker-Android"
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(url)
startActivity(i)
}

llPlayStore.setOnClickListener {
val appPackageName = packageName
try {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$appPackageName")))
} catch (anfe: android.content.ActivityNotFoundException) {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$appPackageName")))
}
}
}
}
4 changes: 3 additions & 1 deletion app/src/main/java/com/piapps/flashcardpro/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MainActivity : AppCompatActivity(), FilterLabelsController.OnLabelClickedL

/*
*
* LOTS OF HARDCODED LINES, BE CAREFUL
* LOTS OF HARDCODING, BE CAREFUL
* YOU JUST NEED TO FUCK OFF && ACCEPT THAT IT WORKS
*
* */
Expand Down Expand Up @@ -312,6 +312,8 @@ class MainActivity : AppCompatActivity(), FilterLabelsController.OnLabelClickedL
R.id.action_filter -> {
if (rvLabels.visibility == View.VISIBLE) {
activeLabel = Label(-1L, "")
labelsController.labels.forEach { it.isSelected = false }
labelsController.notifyDataSetChanged()
rvLabels.visibility = View.GONE
loadAdapter(bottomNavigationViewMain.currentItem)
} else {
Expand Down
15 changes: 6 additions & 9 deletions app/src/main/java/com/piapps/flashcardpro/ui/SetActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SetActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListener {
lateinit var setController: SetController
lateinit var labelController: LabelsController
lateinit var bottomSheet: BottomSheetBehavior<View>
// is user editing the back side of the current flash card?
// is user editing the back side of the current flashcard?
var isEditingBack = false

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -156,13 +156,11 @@ class SetActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListener {
bottomSheet.state = BottomSheetBehavior.STATE_EXPANDED
KeyboardUtils.showSoftInput(editText)

if (isEditingBack) {
editText.setText(setController.list[viewPager.currentItem].card.back)
textViewCounter.text = "${setController.list[viewPager.currentItem].card.front.length}/250"
} else {
editText.setText(setController.list[viewPager.currentItem].card.front)
textViewCounter.text = "${setController.list[viewPager.currentItem].card.front.length}/250"
}
var currentText = if (isEditingBack) setController.list[viewPager.currentItem].card.back else setController.list[viewPager.currentItem].card.front
if (currentText.equals(getString(R.string.example_back)) || currentText.equals(getString(R.string.example_front)))
currentText = ""
editText.setText(currentText)
textViewCounter.text = "${currentText.length}/250"
}

editText.addTextChangedListener(object : TextWatcher {
Expand Down Expand Up @@ -532,5 +530,4 @@ class SetActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListener {
} else
super.onBackPressed()
}

}
4 changes: 2 additions & 2 deletions app/src/main/java/com/piapps/flashcardpro/ui/StudyActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.piapps.flashcardpro.application.Flashcards
import com.piapps.flashcardpro.model.Set
import com.piapps.flashcardpro.ui.controller.SetController
import com.piapps.flashcardpro.util.Extensions
import com.piapps.flashcardpro.util.rand
import com.piapps.flashcardpro.util.random
import com.piapps.flashcardpro.util.toColor
import kotlinx.android.synthetic.main.activity_study.*

Expand Down Expand Up @@ -73,7 +73,7 @@ class StudyActivity : AppCompatActivity() {

fabShuffle.setOnClickListener {
if (setController.list.isEmpty()) return@setOnClickListener
val random = Int.rand(0, setController.list.size - 1)
val random = (0 until setController.list.size).random()
viewPager.currentItem = random
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class CardFragment : Fragment() {
var isFlippable: Boolean = true
lateinit var flip: FlipAnimation
lateinit var flipBack: FlipAnimation
lateinit var card: Card
var card: Card = Card().apply {
this.front = ""
this.back = ""
}
var isEditingBack = false

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -95,7 +98,7 @@ class CardFragment : Fragment() {
}

// set images if they are present
if (!card.frontImage.isBlank()) {
if (card.frontImage.isNotBlank()) {
Glide.with(this).load(card.frontImage).listener(object : RequestListener<Drawable> {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
e?.printStackTrace()
Expand All @@ -109,7 +112,7 @@ class CardFragment : Fragment() {
}).into(imageViewFront)
}

if (!card.backImage.isBlank()) {
if (card.backImage.isNotBlank()) {
Glide.with(this).load(card.backImage).listener(object : RequestListener<Drawable> {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
e?.printStackTrace()
Expand Down Expand Up @@ -180,7 +183,7 @@ class CardFragment : Fragment() {

// used to identify which side we are editing, see SetActivity.kt
fun side(): Int {
if (relativeLayoutBack.visibility == View.GONE) {
if (relativeLayoutBack?.visibility == View.GONE) {
return 0
} else {
return 1
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/java/com/piapps/flashcardpro/util/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,5 @@ fun Bitmap.save(setId: Long, currentItem: Int, context: Context): String {
return if (isSaved) file.absolutePath else ""
}

fun Int.Companion.rand(from: Int, to: Int): Int {
if (from <= 0 || to - from <= 0) return 0
return (Random().nextInt(to - from) + from)
}
fun IntRange.random() =
Random().nextInt((endInclusive + 1) - start) + start
Binary file removed app/src/main/res/drawable/art.png
Binary file not shown.
Binary file added app/src/main/res/drawable/github_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_email_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#E57373"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z"/>
</vector>
Binary file added app/src/main/res/drawable/playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9bbaac6

Please sign in to comment.