Skip to content

Commit

Permalink
Added feature to pin notes and migrated to Room
Browse files Browse the repository at this point in the history
  • Loading branch information
OmGodse committed Jan 21, 2021
1 parent 59908fe commit 31d0b58
Show file tree
Hide file tree
Showing 118 changed files with 1,946 additions and 1,696 deletions.
9 changes: 4 additions & 5 deletions Post/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
plugins {
id 'com.android.library'
id 'kotlin-android'
}

android {
compileSdkVersion rootProject.ext.compileSDKVersion
Expand All @@ -10,9 +12,6 @@ android {
targetSdkVersion rootProject.ext.targetSDKVersion
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
Expand Down
Empty file removed Post/consumer-rules.pro
Empty file.
12 changes: 7 additions & 5 deletions Post/src/main/java/android/print/PostPDFPrinter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import android.os.ParcelFileDescriptor
import com.omgodse.post.PostPDFGenerator
import java.io.File

internal class PostPDFPrinter(private val file: File,
private val printDocumentAdapter: PrintDocumentAdapter,
private val printAttributes: PrintAttributes,
private val onResult: PostPDFGenerator.OnResult) {
internal class PostPDFPrinter(
private val file: File,
private val printDocumentAdapter: PrintDocumentAdapter,
private val printAttributes: PrintAttributes,
private val onResult: PostPDFGenerator.OnResult
) {

fun print() {
val onLayoutResult = object : PrintDocumentAdapter.LayoutResultCallback() {
Expand Down Expand Up @@ -42,7 +44,7 @@ internal class PostPDFPrinter(private val file: File,
}

private fun getFileDescriptor(): ParcelFileDescriptor {
if (!file.exists()){
if (!file.exists()) {
file.createNewFile()
}
return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_WRITE)
Expand Down
18 changes: 10 additions & 8 deletions Post/src/main/java/com/omgodse/post/PostPDFGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import android.webkit.WebView
import android.webkit.WebViewClient
import java.io.File

class PostPDFGenerator private constructor(private val file: File,
private val baseURL: String?,
private val content: String,
private val context: Context,
private val encoding: String,
private val mimeType: String,
private val printAttributes: PrintAttributes,
private val onResult: OnResult) {
class PostPDFGenerator private constructor(
private val file: File,
private val baseURL: String?,
private val content: String,
private val context: Context,
private val encoding: String,
private val mimeType: String,
private val printAttributes: PrintAttributes,
private val onResult: OnResult
) {

fun create() {
val webView = WebView(context)
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Well, Notally is none of these things. It's extremely light, minimalistic and el
* Material design
* Create lists to stay on track
* Support for Lollipop devices and up
* Pin notes to always keep them at the top
* APK size of 1.6 MB (2.1 MB Uncompressed)
* Add labels to your notes for quick organisation
* Archive notes to keep them around, but out of your way
Expand All @@ -29,6 +30,7 @@ Well, Notally is none of these things. It's extremely light, minimalistic and el

### Translations
* 🇬🇧 English
* 🇳🇱 Dutch by [tlmnot](https://github.com/tlmnot)
* 🇦🇩 Catalan by retiolus
* 🇵🇱 Polish by [ZiomaleQ](https://github.com/ZiomaleQ)
* 🇮🇩 Indonesian by [zmni](https://github.com/zmni)
Expand All @@ -44,6 +46,7 @@ Well, Notally is none of these things. It's extremely light, minimalistic and el
* 🇩🇪 German by Maximilian Braunschmied

If you would like to help translate the app, please contact me [here](mailto:[email protected])
(Even in few of the languages specified, there are some untranslated phrases)

### Screenshots
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/1.png" width="250"/><img src="fastlane/metadata/android/en-US/images/phoneScreenshots/2.png" width="250"/><img src="fastlane/metadata/android/en-US/images/phoneScreenshots/3.png" width="250"/>
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/1.png" width="250"/><img src="fastlane/metadata/android/en-US/images/phoneScreenshots/2.png" width="250"/><img src="fastlane/metadata/android/en-US/images/phoneScreenshots/3.png" width="250"/>
26 changes: 16 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
}

android {
Expand All @@ -11,10 +13,9 @@ android {
applicationId "com.omgodse.notally"
minSdkVersion rootProject.ext.minSDKVersion
targetSdkVersion rootProject.ext.targetSDKVersion
versionCode 27
versionName "3.2"
resConfigs 'en', 'ca', 'de', 'es', 'fr', 'in', 'it', 'nb', 'pl', 'pt-rBR', 'ru', 'sv', 'tl', 'uk'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
versionCode 28
versionName "3.3"
resConfigs 'en', 'ca', 'de', 'es', 'fr', 'in', 'it', 'nb', 'nl', 'pl', 'pt-rBR', 'ru', 'sv', 'tl', 'uk'
}

buildTypes {
Expand All @@ -30,27 +31,32 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

aaptOptions { cruncherEnabled false }

kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8.toString() }

buildFeatures { viewBinding true }

aaptOptions { cruncherEnabled false }
}

dependencies {
final def stableNavVersion = "2.3.1"
final def roomVersion = "2.2.6"
final def stableNavVersion = "2.3.2"

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'

implementation 'androidx.preference:preference-ktx:1.1.1'

implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'

kapt "androidx.room:room-compiler:$roomVersion"
implementation "androidx.room:room-ktx:$roomVersion"
implementation "androidx.room:room-runtime:$roomVersion"

implementation "androidx.navigation:navigation-ui-ktx:$stableNavVersion"
implementation "androidx.navigation:navigation-fragment-ktx:$stableNavVersion"

implementation 'org.ocpsoft.prettytime:prettytime:4.0.6.Final'
implementation 'com.google.android.material:material:1.3.0-alpha03'
implementation 'com.google.android.material:material:1.3.0-rc01'

implementation project(':Post')
}
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
android:icon="@mipmap/notally"
android:label="@string/app_name"
android:roundIcon="@mipmap/notally_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<provider
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/java/com/omgodse/notally/NotallyApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ class NotallyApplication : Application() {

override fun onCreate() {
super.onCreate()
setDarkMode()
}

private fun setDarkMode() {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
val theme = sharedPreferences.getString(getString(R.string.themeKey), getString(R.string.followSystemKey))
when (theme){
when (theme) {
getString(R.string.darkKey) -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
getString(R.string.lightKey) -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
getString(R.string.followSystemKey) -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,13 @@ class NotallyLinkMovementMethod(private var onURLClick: (span: URLSpan) -> Unit)
touchX += textView.scrollX
touchY += textView.scrollY

val layout = textView.layout
val touchedLine = layout.getLineForVertical(touchY)
val touchOffset = layout.getOffsetForHorizontal(touchedLine, touchX.toFloat())
val touchedLine = textView.layout.getLineForVertical(touchY)
val touchOffset = textView.layout.getOffsetForHorizontal(touchedLine, touchX.toFloat())

touchedLineBounds.left = layout.getLineLeft(touchedLine)
touchedLineBounds.top = layout.getLineTop(touchedLine).toFloat()
touchedLineBounds.right = layout.getLineWidth(touchedLine) + touchedLineBounds.left
touchedLineBounds.bottom = layout.getLineBottom(touchedLine).toFloat()
touchedLineBounds.left = textView.layout.getLineLeft(touchedLine)
touchedLineBounds.top = textView.layout.getLineTop(touchedLine).toFloat()
touchedLineBounds.right = textView.layout.getLineWidth(touchedLine) + touchedLineBounds.left
touchedLineBounds.bottom = textView.layout.getLineBottom(touchedLine).toFloat()

return if (touchedLineBounds.contains(touchX.toFloat(), touchY.toFloat())) {
val spans = text.getSpans(touchOffset, touchOffset, URLSpan::class.java)
Expand Down Expand Up @@ -110,8 +109,8 @@ class NotallyLinkMovementMethod(private var onURLClick: (span: URLSpan) -> Unit)
}

private fun dispatchUrlClick(urlSpan: URLSpan?) {
urlSpan?.let {
onURLClick.invoke(it)
if (urlSpan != null) {
onURLClick.invoke(urlSpan)
}
}
}
18 changes: 6 additions & 12 deletions app/src/main/java/com/omgodse/notally/activities/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.navigation.ui.setupActionBarWithNavController
import com.omgodse.notally.R
import com.omgodse.notally.databinding.ActivityMainBinding
import com.omgodse.notally.miscellaneous.Constants
import com.omgodse.notally.miscellaneous.setVisible

class MainActivity : AppCompatActivity() {

Expand Down Expand Up @@ -78,24 +79,17 @@ class MainActivity : AppCompatActivity() {

private fun handleDestinationChange(destination: NavDestination, arguments: Bundle?) {
when (destination.id) {
R.id.NotesFragment -> {
binding.TakeNoteFAB.show()
binding.EnterSearchKeyword.visibility = View.GONE
}
R.id.NotesFragment -> binding.TakeNoteFAB.show()
R.id.SearchFragment -> {
binding.TakeNoteFAB.hide()
binding.EnterSearchKeyword.text = null
binding.EnterSearchKeyword.visibility = View.VISIBLE
binding.EnterSearchKeyword.requestFocus()
}
R.id.DisplayLabelFragment -> {
binding.TakeNoteFAB.hide()
binding.EnterSearchKeyword.visibility = View.GONE
supportActionBar?.setTitle(arguments?.getString(Constants.argLabelKey))
}
else -> {
binding.TakeNoteFAB.hide()
binding.EnterSearchKeyword.visibility = View.GONE
supportActionBar?.setTitle(arguments?.getString(Constants.SelectedLabel))
}
else -> binding.TakeNoteFAB.hide()
}
binding.EnterSearchKeyword.setVisible(destination.id == R.id.SearchFragment)
}
}
Loading

0 comments on commit 31d0b58

Please sign in to comment.