Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folio branch merge #18

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion .idea/compiler.xml

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

33 changes: 20 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId "com.jskaleel.fte"
minSdkVersion versions.androidMinSdk
targetSdkVersion versions.androidTargetSdk
versionCode 32
versionName "8.0"
versionCode 37
versionName "8.1.0"
multiDexEnabled true
}
buildTypes {
Expand All @@ -40,44 +40,51 @@ android {
buildFeatures {
viewBinding true
}

defaultConfig {
resConfigs "en", "ta"
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'androidx.appcompat:appcompat:1.3.0-beta01'
implementation 'androidx.core:core-ktx:1.5.0-beta01'
implementation 'androidx.appcompat:appcompat:1.3.0-rc01'
implementation 'androidx.core:core-ktx:1.6.0-alpha02'
implementation 'com.google.android.material:material:1.3.0'

//Retrofit for REST
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"

implementation 'androidx.room:room-runtime:2.3.0-beta01'
kapt 'androidx.room:room-compiler:2.3.0-beta01'
implementation 'androidx.room:room-runtime:2.4.0-alpha01'
kapt 'androidx.room:room-compiler:2.4.0-alpha01'

implementation 'androidx.multidex:multidex:2.0.1'
implementation project(':folioreader')

implementation 'com.google.firebase:firebase-core:18.0.2'
implementation 'com.google.firebase:firebase-crashlytics:17.3.1'
implementation 'com.google.firebase:firebase-crashlytics:17.4.0'

implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
implementation 'com.google.firebase:firebase-messaging:21.0.1'

implementation 'np.com.susanthapa.curved_bottom_navigation:curved_bottom_navigation:0.6.3'
implementation 'np.com.susanthapa:curved_bottom_navigation:0.6.5'
// Koin for Android
implementation "org.koin:koin-android:$versions.koin"
// or Koin for Lifecycle scoping
implementation "org.koin:koin-androidx-scope:$versions.koin"
// or Koin for Android Architecture ViewModel
implementation "org.koin:koin-androidx-viewmodel:$versions.koin"
implementation "io.insert-koin:koin-android:$versions.koin"
// Koin AndroidX Scope features
implementation "io.insert-koin:koin-androidx-scope:$versions.koin"
// Koin AndroidX ViewModel features
implementation "io.insert-koin:koin-androidx-viewmodel:$versions.koin"

//Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2'

implementation 'io.coil-kt:coil:1.1.1'
implementation "com.vorlonsoft:androidrate:1.2.1"
implementation 'androidx.constraintlayout:constraintlayout:2.1.0-beta01'
}

repositories {
Expand Down
3 changes: 2 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile
-keepattributes LineNumberTable,SourceFile
15 changes: 10 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
android:name="com.jskaleel.fte.ui.splash.SplashActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/Splash_Theme">
android:theme="@style/Splash_Theme"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -36,20 +37,24 @@
</activity>
<activity
android:name=".ui.main.MainLandingActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".ui.search.SearchActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustPan" />
android:windowSoftInputMode="stateHidden|adjustPan"
tools:ignore="LockedOrientationActivity" />

<activity
android:name=".ui.webview.WebViewActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustPan" />
android:windowSoftInputMode="stateHidden|adjustPan"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".ui.feedback.FeedbackActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize" />
android:windowSoftInputMode="stateHidden|adjustResize"
tools:ignore="LockedOrientationActivity" />

<provider
android:name="androidx.core.content.FileProvider"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/jskaleel/fte/FTEApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class FTEApp : MultiDexApplication(), ImageLoaderFactory {

startKoin {
androidLogger()
modules(listOf(networkModule, fteModule))
androidContext(this@FTEApp)
modules(listOf(networkModule, fteModule))
}

createFolder()
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/jskaleel/fte/data/dao/LocalBooksDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ interface LocalBooksDao {

@Query("SELECT * from localBooks WHERE title LIKE (:key) OR author LIKE (:key)")
fun getBooksByKey(key: String): List<LocalBooks>

@Query("SELECT author from localBooks")
fun getAuthors(): List<String>
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/jskaleel/fte/data/local/AppDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import com.jskaleel.fte.data.dao.SavedBooksDao
import com.jskaleel.fte.data.entities.LocalBooks
import com.jskaleel.fte.data.entities.SavedBooks

@Database(entities = [LocalBooks::class, SavedBooks::class], version = 1, exportSchema = false)
@Database(entities = [LocalBooks::class, SavedBooks::class], version = 4, exportSchema = false)
abstract class AppDatabase : RoomDatabase() {

abstract fun localBooksDao(): LocalBooksDao
abstract fun savedBooksDao(): SavedBooksDao
abstract fun localBooksDao(): LocalBooksDao

companion object {
private var instance: AppDatabase? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ class FeedbackActivity : AppCompatActivity() {
binding = ActivityFeedbackBinding.inflate(layoutInflater)
setContentView(binding.root)

binding.ivSend.setOnClickListener {
binding.btnSend.setOnClickListener {
val name = binding.edtName.text.toString()
val email = binding.edtEmail.text.toString()
val comments = binding.edtComments.text.toString()
submitFeedBack(name, email, comments)
}
binding.toolBar.title = getString(R.string.feedback)
binding.toolBar.setNavigationOnClickListener {
onBackPressed()
}
}

private fun submitFeedBack(name: String, email: String, comments: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class DashboardFragment : Fragment() {
binding.mcvReleaseBooks.setOnClickListener {
launchWebActivity(WebViewActivity.TYPE_PUBLISH)
}
binding.mcvWriters.setOnClickListener {
launchWebActivity(WebViewActivity.TYPE_AUTHORS)
}
}

private fun launchWebActivity(type: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.jskaleel.fte.BuildConfig
import com.jskaleel.fte.R
import com.jskaleel.fte.databinding.FragmentSettingsBinding
import com.jskaleel.fte.ui.main.MainLandingActivity
import com.jskaleel.fte.ui.webview.WebViewActivity
import com.jskaleel.fte.utils.AppPreference
import com.jskaleel.fte.utils.AppPreference.get
import com.jskaleel.fte.utils.AppPreference.set
Expand Down Expand Up @@ -75,12 +76,7 @@ class SettingsFragment : Fragment() {
}

binding.rlSourceCodeLayout.setOnClickListener {
val url = "https://github.com/khaleeljageer/FreeTamilEBooks"
val shareIntent: Intent = Intent().apply {
action = Intent.ACTION_VIEW
data = Uri.parse(url)
}
startActivity(shareIntent)
openUrl("https://github.com/khaleeljageer/FreeTamilEBooks")
}

binding.llShareApp.setOnClickListener {
Expand All @@ -98,6 +94,20 @@ class SettingsFragment : Fragment() {

}

binding.llPrivacyPolicy.setOnClickListener {
val intent = Intent(requireContext(), WebViewActivity::class.java)
intent.putExtra(WebViewActivity.KEY_TYPE, WebViewActivity.TYPE_PRIVACY_POLICY)
startActivity(intent)
}

binding.layoutKaniyam.setOnClickListener {
openUrl("https://kaniyam.com")
}

binding.layoutVglug.setOnClickListener {
openUrl("https://vglug.org")
}

binding.txtAppVersion.text =
String.format(getString(R.string.version, BuildConfig.VERSION_NAME))

Expand All @@ -110,4 +120,12 @@ class SettingsFragment : Fragment() {
HtmlCompat.FROM_HTML_MODE_LEGACY
)
}

private fun openUrl(url: String) {
val shareIntent: Intent = Intent().apply {
action = Intent.ACTION_VIEW
data = Uri.parse(url)
}
startActivity(shareIntent)
}
}
39 changes: 39 additions & 0 deletions app/src/main/java/com/jskaleel/fte/ui/main/MainLandingActivity.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
package com.jskaleel.fte.ui.main

import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import com.google.android.material.snackbar.Snackbar
import com.jskaleel.fte.R
import com.jskaleel.fte.databinding.ActivityMainLandingBinding
import com.jskaleel.fte.ui.fragments.DashboardFragment
import com.jskaleel.fte.ui.fragments.SettingsFragment
import com.jskaleel.fte.ui.main.download.DownloadsFragment
import com.jskaleel.fte.ui.main.home.HomeFragment
import com.vorlonsoft.android.rate.AppRate
import com.vorlonsoft.android.rate.StoreType
import com.vorlonsoft.android.rate.Time
import np.com.susanthapa.curved_bottom_navigation.CbnMenuItem


class MainLandingActivity : AppCompatActivity() {

private val mainLandingViewModel: MainLandingViewModel by viewModels()

private lateinit var binding: ActivityMainLandingBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -56,8 +65,38 @@ class MainLandingActivity : AppCompatActivity() {
}
}
}

mainLandingViewModel.message.observe(this, {
Snackbar.make(binding.container2, it, Snackbar.LENGTH_LONG).show()
})

Handler(Looper.getMainLooper()).postDelayed({
setupRateUI()
}, 2000)
}

private fun setupRateUI() {
AppRate.with(this).apply {
storeType = StoreType.GOOGLEPLAY
setTimeToWait(Time.DAY, 3.toShort())
setLaunchTimes(3.toByte())
setRemindTimeToWait(Time.DAY, 3.toShort())
setShowLaterButton(true)
setVersionCodeCheck(true)
setVersionNameCheck(true)
setCancelable(false)
setTitle(R.string.new_rate_dialog_title)
setTextLater(R.string.new_rate_dialog_later)
setMessage(R.string.new_rate_dialog_message)
setTextNever(R.string.new_rate_dialog_never)
setTextRateNow(R.string.new_rate_dialog_ok)
monitor()
}

AppRate.showRateDialogIfMeetsConditions(this)
}


private fun loadFragment(fragment: Fragment, tag: String) {
val transaction = supportFragmentManager.beginTransaction()
val existingFrag = supportFragmentManager.findFragmentByTag(tag)
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/jskaleel/fte/ui/main/MainLandingViewModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.jskaleel.fte.ui.main

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class MainLandingViewModel : ViewModel() {
private val _message: MutableLiveData<String> = MutableLiveData()
val message: MutableLiveData<String> = _message

fun showToast(message: String) {
_message.value = message
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.jskaleel.fte.data.entities.DownloadResult
Expand All @@ -14,6 +15,7 @@ import com.jskaleel.fte.data.entities.SavedBooks
import com.jskaleel.fte.data.local.AppDatabase
import com.jskaleel.fte.databinding.FragmentHomeBinding
import com.jskaleel.fte.ui.base.BookListAdapter
import com.jskaleel.fte.ui.main.MainLandingViewModel
import com.jskaleel.fte.ui.search.SearchActivity
import com.jskaleel.fte.utils.FileUtils
import com.jskaleel.fte.utils.PrintLog
Expand All @@ -29,6 +31,7 @@ class HomeFragment : Fragment(), CoroutineScope, (Int, LocalBooks) -> Unit {
}

private lateinit var bookListAdapter: BookListAdapter
private val mainLandingViewModel: MainLandingViewModel by activityViewModels()

override fun onCreateView(
inflater: LayoutInflater,
Expand Down Expand Up @@ -76,10 +79,11 @@ class HomeFragment : Fragment(), CoroutineScope, (Int, LocalBooks) -> Unit {
book.savedPath = result.filePath.absolutePath
bookListAdapter.successUiUpdate(position, book)
updateDatabase(book)
mainLandingViewModel.showToast("${book.title} பதிவிறக்கப்பட்டது...")
}
is DownloadResult.Error -> {
bookListAdapter.errorUiUpdate(position)
//Show Snack bar. if needed
mainLandingViewModel.showToast(result.errorMessage)
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions app/src/main/java/com/jskaleel/fte/ui/search/SearchActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.jskaleel.fte.data.local.AppDatabase
import com.jskaleel.fte.databinding.ActivitySearchBinding
import com.jskaleel.fte.ui.base.BookListAdapter
import com.jskaleel.fte.utils.FileUtils
import com.jskaleel.fte.utils.PrintLog
import com.jskaleel.fte.utils.openBook
import kotlinx.coroutines.*
import org.koin.android.ext.android.inject
Expand Down Expand Up @@ -86,10 +85,17 @@ class SearchActivity : AppCompatActivity(), CoroutineScope, (Int, LocalBooks) ->
val key = it.toString().trim()
launch {
val searchResult = appDataBase.localBooksDao().getBooksByKey("%$key%")
PrintLog.info("Search Key : $key Result : ${searchResult.size}")

runOnUiThread {
searchListAdapter.clearBooks()
searchListAdapter.loadBooks(searchResult)
if (searchResult.isEmpty()) {
binding.rvBookList.visibility = View.GONE
binding.txtNoResult.visibility = View.VISIBLE
} else {
binding.rvBookList.visibility = View.VISIBLE
binding.txtNoResult.visibility = View.GONE
searchListAdapter.loadBooks(searchResult)
}
}
}
}
Expand Down
Loading