Skip to content

Commit

Permalink
Merge pull request #14 from babydots/add-contact
Browse files Browse the repository at this point in the history
Add your own contacts, and disable the default ones.
  • Loading branch information
pserwylo authored Feb 26, 2022
2 parents e9bd14d + 0a7076f commit ed101e7
Show file tree
Hide file tree
Showing 100 changed files with 2,078 additions and 318 deletions.
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.

1 change: 1 addition & 0 deletions .idea/gradle.xml

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

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

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

21 changes: 20 additions & 1 deletion .idea/misc.xml

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

34 changes: 29 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
}

android {

compileSdkVersion 30
compileSdkVersion 31
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.serwylo.babyphone"
minSdkVersion 22
targetSdkVersion 30
versionCode 8
versionName "0.6.0"
minSdkVersion 26
targetSdkVersion 31
versionCode 9
versionName "1.0.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

javaCompileOptions {
annotationProcessorOptions {
arguments += [
"room.schemaLocation": "$projectDir/schemas".toString(),
"room.incremental": "true",
"room.expandProjection": "true"
]
}
}
}

buildTypes {
Expand Down Expand Up @@ -58,8 +69,21 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.2.0'
implementation 'com.google.android.material:material:1.4.0'

implementation 'com.squareup.picasso:picasso:2.8'

// TODO: Use these to visualize the recorded sounds.
// implementation 'com.github.massoudss:waveformSeekBar:4.1.0'
// implementation 'com.github.lincollincol:amplituda:2.1.0'

testImplementation 'junit:junit:4.13.2'

def room_version = "2.4.1"
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"

implementation 'io.github.tonnyl:whatsnew:0.1.7'

androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

Expand Down
140 changes: 140 additions & 0 deletions app/schemas/com.serwylo.babyphone.db.AppDatabase/1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "dcf6b04473488094a535508daf201e79",
"entities": [
{
"tableName": "Contact",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `avatarPath` TEXT NOT NULL, `isEnabled` INTEGER NOT NULL, `isDefault` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "avatarPath",
"columnName": "avatarPath",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "isEnabled",
"columnName": "isEnabled",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "isDefault",
"columnName": "isDefault",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "Recording",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`contactId` INTEGER NOT NULL, `soundFilePath` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`contactId`) REFERENCES `Contact`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "contactId",
"columnName": "contactId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "soundFilePath",
"columnName": "soundFilePath",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": [
{
"table": "Contact",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"contactId"
],
"referencedColumns": [
"id"
]
}
]
},
{
"tableName": "Settings",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`currentContactId` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`currentContactId`) REFERENCES `Contact`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL )",
"fields": [
{
"fieldPath": "currentContactId",
"columnName": "currentContactId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": [
{
"table": "Contact",
"onDelete": "SET NULL",
"onUpdate": "NO ACTION",
"columns": [
"currentContactId"
],
"referencedColumns": [
"id"
]
}
]
}
],
"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, 'dcf6b04473488094a535508daf201e79')"
]
}
}
50 changes: 45 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.serwylo.babyphone">

<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-permission-sdk-23 android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand All @@ -12,20 +17,55 @@
android:theme="@style/Theme.BabyPhone.Colours"
tools:ignore="AllowBackup">

<activity android:name=".MainActivity">
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.serwylo.babyphone.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>

<activity
android:name=".settingscontactlist.SettingsContactListActivity"
android:exported="false"
android:theme="@style/Theme.BabyPhone.Light"
android:parentActivityName=".SettingsActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".SettingsActivity" />
</activity>

<activity
android:name=".editcontact.EditContactActivity"
android:exported="false"
android:theme="@style/Theme.BabyPhone.Light"
android:parentActivityName=".settingscontactlist.SettingsContactListActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".settingscontactlist.SettingsContactListActivity" />
</activity>

<activity
android:name=".dialer.MainActivity"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".SettingsActivity"
android:label="@string/settings"
android:parentActivityName=".MainActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity" />
android:exported="false"
android:parentActivityName=".dialer.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".dialer.MainActivity" />
</activity>

</application>

</manifest>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
55 changes: 55 additions & 0 deletions app/src/main/java/com/serwylo/babyphone/Changelog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.serwylo.babyphone

import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager
import io.github.tonnyl.whatsnew.WhatsNew
import io.github.tonnyl.whatsnew.item.WhatsNewItem
import io.github.tonnyl.whatsnew.util.PresentationOption

object Changelog {

@JvmStatic
fun show(activity: AppCompatActivity) {

val whatsNew = buildDialog(activity)

// Only show when upgrading Lexica for the first time, not when we first open Lexica from
// a fresh install.
whatsNew.presentationOption = if (isFirstRun(activity)) PresentationOption.NEVER else PresentationOption.IF_NEEDED
whatsNew.presentAutomatically(activity)

rememberLexicaHasRun(activity)

}

private fun buildDialog(context: Context): WhatsNew {

return WhatsNew.newInstance(
WhatsNewItem(
"Add your own contacts!",
"Personalise your baby phone via the settings to add family and friends for your baby to talk to.\n\nCompletely private, no photo or recording will ever leave your phone.",
R.drawable.ic_person_add,
),
).apply {
titleText = "What's New?"
buttonText = "Continue"
}

}

private fun isFirstRun(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
return !prefs.getBoolean(HAS_RUN, false)
}

private fun rememberLexicaHasRun(context: Context) {
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putBoolean(HAS_RUN, true)
.apply()
}

private const val HAS_RUN = "lexica-has-run-before"

}
Loading

0 comments on commit ed101e7

Please sign in to comment.