Skip to content

Commit

Permalink
Merge pull request #22 from XamDR/github_actions
Browse files Browse the repository at this point in the history
GitHub actions
  • Loading branch information
XamDR authored Oct 19, 2022
2 parents 8a91b38 + 5187a10 commit f49d754
Show file tree
Hide file tree
Showing 48 changed files with 904 additions and 86 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build_debug_workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Android Build Release Workflow

on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Build Project
run: ./gradlew assemble

- name: Build Debug APK
run: bash ./gradlew :app:assembleDebug

- name: Upload APK
uses: actions/upload-artifact@v2
with:
name: App
path: ${{ github.workspace}} /app/build/outputs/apk/debug/app-debug.apk
31 changes: 16 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ def versionPatch = 0

android {
namespace 'net.azurewebsites.noties'
compileSdk 31
compileSdk 32

defaultConfig {
applicationId "net.azurewebsites.noties"
minSdk 23
targetSdk 31
targetSdk 32
versionCode 1
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -47,11 +47,11 @@ android {
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = 11
}
buildFeatures {
dataBinding true
Expand All @@ -64,31 +64,32 @@ android {
dependencies {
implementation "androidx.activity:activity-ktx:1.5.0"
implementation "androidx.core:core-ktx:1.8.0"
implementation "androidx.core:core-splashscreen:1.0.0-rc01"
implementation "androidx.appcompat:appcompat:1.4.2"
implementation "androidx.core:core-splashscreen:1.0.0"
implementation "androidx.appcompat:appcompat:1.5.1"
implementation "androidx.asynclayoutinflater:asynclayoutinflater:1.0.0"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.0"
implementation "androidx.navigation:navigation-fragment-ktx:2.5.0"
implementation "androidx.navigation:navigation-ui-ktx:2.5.0"
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
implementation "androidx.navigation:navigation-fragment-ktx:2.5.2"
implementation "androidx.navigation:navigation-ui-ktx:2.5.2"
implementation "androidx.preference:preference-ktx:1.2.0"
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.recyclerview:recyclerview-selection:1.1.0"
implementation "com.google.android.material:material:1.6.1"
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.2.0"

// Room
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"

// Hilt
implementation "com.google.dagger:hilt-android:2.41"
kapt "com.google.dagger:hilt-compiler:2.41"
implementation "com.google.dagger:hilt-android:2.44"
kapt "com.google.dagger:hilt-compiler:2.44"

// Exif Interface
implementation "androidx.exifinterface:exifinterface:1.3.3"
implementation "androidx.exifinterface:exifinterface:1.3.4"

// Shimmer effect
implementation "com.facebook.shimmer:shimmer:0.5.0"
Expand Down
16 changes: 11 additions & 5 deletions app/schemas/net.azurewebsites.noties.data.AppDatabase/1.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "6d2bc5bf8e7c758c8809ddcc359478a2",
"identityHash": "115c670b9b92fd3c502b24671880b356",
"entities": [
{
"tableName": "Notebooks",
Expand Down Expand Up @@ -92,7 +92,7 @@
},
{
"tableName": "Notes",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT NOT NULL, `text` TEXT NOT NULL, `date_modification` TEXT NOT NULL, `color` INTEGER, `urls` TEXT NOT NULL, `is_protected` INTEGER NOT NULL, `is_trashed` INTEGER NOT NULL, `is_pinned` INTEGER NOT NULL, `is_todo_list` INTEGER NOT NULL, `notebook_id` INTEGER NOT NULL)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT NOT NULL, `text` TEXT NOT NULL, `modification_date` TEXT NOT NULL, `color` INTEGER, `urls` TEXT NOT NULL, `is_protected` INTEGER NOT NULL, `is_trashed` INTEGER NOT NULL, `is_pinned` INTEGER NOT NULL, `is_todo_list` INTEGER NOT NULL, `reminder_date` TEXT, `notebook_id` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
Expand All @@ -113,8 +113,8 @@
"notNull": true
},
{
"fieldPath": "dateModification",
"columnName": "date_modification",
"fieldPath": "modificationDate",
"columnName": "modification_date",
"affinity": "TEXT",
"notNull": true
},
Expand Down Expand Up @@ -154,6 +154,12 @@
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "reminderDate",
"columnName": "reminder_date",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "notebookId",
"columnName": "notebook_id",
Expand All @@ -174,7 +180,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '6d2bc5bf8e7c758c8809ddcc359478a2')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '115c670b9b92fd3c502b24671880b356')"
]
}
}
25 changes: 22 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera" android:required="false" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application
android:name="net.azurewebsites.noties.App"
Expand Down Expand Up @@ -46,6 +50,21 @@
</intent-filter>
</activity>

<receiver
android:name=".ui.reminders.AlarmReceiver"
android:enabled="true"
android:exported="false"/>

<receiver
android:name=".ui.reminders.BootCompletedReceiver"
android:enabled="true"
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="net.azurewebsites.noties"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ data class NoteEntity(
@PrimaryKey(autoGenerate = true) val id: Long = 0,
val title: String = String.Empty,
val text: String = String.Empty,
@ColumnInfo(name = "date_modification") val dateModification: ZonedDateTime = ZonedDateTime.now(),
@ColumnInfo(name = "modification_date") val modificationDate: ZonedDateTime = ZonedDateTime.now(),
@ColumnInfo(name = "color") val color: Int? = null,
@ColumnInfo(name = "urls") val urls: List<String> = emptyList(),
@ColumnInfo(name = "is_protected") val isProtected: Boolean = false,
@ColumnInfo(name = "is_trashed") val isTrashed: Boolean = false,
@ColumnInfo(name = "is_pinned") val isPinned: Boolean = false,
@ColumnInfo(name = "is_todo_list") val isTodoList: Boolean = false,
@ColumnInfo(name = "reminder_date") val reminderDate: ZonedDateTime? = null,
@ColumnInfo(name = "notebook_id") val notebookId: Int = 0) : Parcelable {

fun getUrlCount() = urls.size
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/kotlin/net/azurewebsites/noties/data/NoteDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ interface NoteDao {

@Query("DELETE FROM Notes WHERE is_trashed = 1")
suspend fun deleteTrashedNotes(): Int

@Transaction
@Query("SELECT * FROM notes WHERE reminder_date IS NOT NULL")
suspend fun getNotesWithReminderAsync(): List<Note>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import java.time.format.DateTimeFormatter
class ZonedDateTimeToStringConverter {

@TypeConverter
fun fromZonedDateTime(dateTime: ZonedDateTime): String {
fun fromZonedDateTime(dateTime: ZonedDateTime?): String? {
val formatter = DateTimeFormatter.ofPattern(pattern).withZone(ZoneId.systemDefault())
return formatter.format(dateTime)
return if (dateTime != null) formatter.format(dateTime) else null
}

@TypeConverter
fun toZonedDateTime(value: String): ZonedDateTime {
fun toZonedDateTime(value: String?): ZonedDateTime? {
val formatter = DateTimeFormatter.ofPattern(pattern).withZone(ZoneId.systemDefault())
return ZonedDateTime.parse(value, formatter)
return if (value != null) ZonedDateTime.parse(value, formatter) else null
}

companion object {
Expand Down
41 changes: 38 additions & 3 deletions app/src/main/kotlin/net/azurewebsites/noties/ui/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.azurewebsites.noties.ui

import android.content.Intent
import android.os.Bundle
import android.view.MenuItem
import android.widget.ImageView
Expand All @@ -21,15 +22,17 @@ import com.google.android.material.appbar.AppBarLayout.LayoutParams
import com.google.android.material.navigation.NavigationView
import dagger.hilt.android.AndroidEntryPoint
import net.azurewebsites.noties.R
import net.azurewebsites.noties.core.Note
import net.azurewebsites.noties.core.NoteEntity
import net.azurewebsites.noties.core.Notebook
import net.azurewebsites.noties.core.NotebookEntity
import net.azurewebsites.noties.databinding.ActivityMainBinding
import net.azurewebsites.noties.ui.helpers.findNavController
import net.azurewebsites.noties.ui.helpers.setNightMode
import net.azurewebsites.noties.ui.helpers.tryNavigate
import net.azurewebsites.noties.ui.editor.EditorViewModel
import net.azurewebsites.noties.ui.helpers.*
import net.azurewebsites.noties.ui.notebooks.*
import net.azurewebsites.noties.ui.notes.FabScrollingBehavior
import net.azurewebsites.noties.ui.settings.PreferenceStorage
import java.time.ZonedDateTime
import javax.inject.Inject

@AndroidEntryPoint
Expand All @@ -49,6 +52,34 @@ class MainActivity : AppCompatActivity(), NavController.OnDestinationChangedList
setContentView(binding.root)
setSupportActionBar(binding.toolbar)
setupNavigation()
handleIntent()
}

private fun handleIntent() {
if (intent.action == Intent.ACTION_SEND) {
if (intent.type == "text/plain") {
val sharedText = intent.getStringExtra(Intent.EXTRA_TEXT) ?: return
val entity = NoteEntity(
text = sharedText,
modificationDate = ZonedDateTime.now(),
urls = extractUrls(sharedText),
notebookId = 1
)
val args = bundleOf(EditorViewModel.NOTE to Note(entity = entity))
navController.tryNavigate(R.id.action_notes_to_editor, args)
}
}
else {
val uri = intent.data ?: return
val entity = readUriContent(this, uri)
if (entity != null) {
val args = bundleOf(EditorViewModel.NOTE to Note(entity = entity))
navController.tryNavigate(R.id.action_notes_to_editor, args)
}
else {
showToast(R.string.error_open_file)
}
}
}

override fun onStart() {
Expand Down Expand Up @@ -199,4 +230,8 @@ class MainActivity : AppCompatActivity(), NavController.OnDestinationChangedList
}

private var onFabClickCallback: () -> Unit = {}

companion object {
const val CHANNEL_ID = "NOTIES_CHANNEL"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import net.azurewebsites.noties.ui.editor.todos.TodoItemAdapter
import net.azurewebsites.noties.ui.helpers.*
import net.azurewebsites.noties.ui.image.*
import net.azurewebsites.noties.ui.notes.NotesFragment
import net.azurewebsites.noties.ui.reminders.DateTimePickerDialogFragment
import net.azurewebsites.noties.ui.urls.JsoupHelper
import java.io.FileNotFoundException
import java.time.ZonedDateTime
Expand Down Expand Up @@ -243,6 +244,7 @@ class EditorFragment : Fragment(), AttachImagesListener, LinkClickedListener,
setOnActivityResultListener { pickImagesLauncher.launch(arrayOf(MIME_TYPE_IMAGE)) }
setOnTakePictureListener { takePictureOrRequestPermission() }
setOnMakeTodoListListener { makeTodoList() }
setOnShowDateTimePickerListener { showDateTimePickerDialog() }
}
showDialog(menuDialog, MENU_DIALOG_TAG)
}
Expand Down Expand Up @@ -319,7 +321,7 @@ class EditorFragment : Fragment(), AttachImagesListener, LinkClickedListener,
}
if (note != tempNote) {
note.entity = note.entity.copy(
dateModification = ZonedDateTime.now(),
modificationDate = ZonedDateTime.now(),
urls = extractUrls(note.entity.text)
)
if (note.entity.id == 0L) {
Expand Down Expand Up @@ -434,6 +436,11 @@ class EditorFragment : Fragment(), AttachImagesListener, LinkClickedListener,
}
}

private fun showDateTimePickerDialog() {
val dateTimePickerDialog = DateTimePickerDialogFragment()
showDialog(dateTimePickerDialog, DATE_TIME_PICKER_DIALOG_TAG)
}

private fun addChildHeadlessFragments() {
if (childFragmentManager.findFragmentByTag(ADD_IMAGES_TAG) == null &&
childFragmentManager.findFragmentByTag(SHARE_CONTENT_TAG) == null) {
Expand Down Expand Up @@ -476,6 +483,7 @@ class EditorFragment : Fragment(), AttachImagesListener, LinkClickedListener,
const val MIME_TYPE_TEXT = "text/plain"
private const val MENU_DIALOG_TAG = "MENU_DIALOG"
private const val COLOR_DIALOG_TAG = "COLOR_DIALOG"
private const val DATE_TIME_PICKER_DIALOG_TAG = "DATE_TIME_PICKER"
private const val ALT_TEXT_DIALOG_TAG = "ALT_TEXT_DIALOG"
private const val DELETE_IMAGES_DIALOG_TAG = "DELETE_IMAGES"
private const val ADD_IMAGES_TAG = "ADD_IMAGES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ class EditorMenuFragment : BottomSheetDialogFragment() {
dismiss()
}

fun invokeShowDateTimePickerCallback() {
onShowDateTimePickerCallback()
dismiss()
}

fun setOnActivityResultListener(callback: () -> Unit) {
onActivityResultCallback = callback
}
Expand All @@ -56,9 +61,15 @@ class EditorMenuFragment : BottomSheetDialogFragment() {
onMakeTodoListCallback = callback
}

fun setOnShowDateTimePickerListener(callback: () -> Unit) {
onShowDateTimePickerCallback = callback
}

private var onActivityResultCallback: () -> Unit = {}

private var onTakePictureCallback: () -> Unit = {}

private var onMakeTodoListCallback: () -> Unit = {}

private var onShowDateTimePickerCallback: () -> Unit = {}
}
Loading

0 comments on commit f49d754

Please sign in to comment.