Skip to content

Start #10

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

Open
wants to merge 8 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
29 changes: 7 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
start/.gradle/5.1.1/gc.properties
start/.gradle/5.1.1/executionHistory/executionHistory.bin
start/.gradle/5.1.1/executionHistory/executionHistory.lock
start/.gradle/5.1.1/fileChanges/last-build.bin
start/.gradle/5.1.1/fileHashes/fileHashes.bin
start/.gradle/5.1.1/fileHashes/fileHashes.lock
start/.gradle/5.4.1/gc.properties
start/.gradle/5.4.1/executionHistory/executionHistory.bin
start/.gradle/5.4.1/executionHistory/executionHistory.lock
start/.gradle/5.4.1/fileChanges/last-build.bin
start/.gradle/5.4.1/fileContent/fileContent.lock
start/.gradle/5.4.1/fileHashes/fileHashes.bin
start/.gradle/5.4.1/fileHashes/fileHashes.lock
start/.gradle/5.4.1/fileHashes/resourceHashesCache.bin
start/.gradle/5.4.1/javaCompile/classAnalysis.bin
start/.gradle/5.4.1/javaCompile/jarAnalysis.bin
start/.gradle/5.4.1/javaCompile/javaCompile.lock
start/.gradle/5.4.1/javaCompile/taskHistory.bin
start/.gradle/buildOutputCleanup/buildOutputCleanup.lock
start/.gradle/buildOutputCleanup/cache.properties
start/.gradle/buildOutputCleanup/outputFiles.bin
start/.gradle/vcs-1/gc.properties
*.iml
.gradle
/local.properties
.idea
.DS_Store
/build
/captures
Binary file added .vs/Kotlin/v16/.suo
Binary file not shown.
Binary file added .vs/Kotlin/v16/Browse.VC.db
Binary file not shown.
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
11 changes: 11 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"ExpandedNodes": [
"",
"\\app",
"\\app\\src",
"\\app\\src\\main",
"\\app\\src\\main\\res"
],
"SelectedNode": "\\app\\build.gradle",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/android-kotlin-notifications/v16/.suo
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
11 changes: 11 additions & 0 deletions Debug/Kotlin.exe.recipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\MalekPC\Documents\GitHub\android-kotlin-notifications\Debug\Kotlin.exe</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
<SatelliteDlls />
<NonRecipeFileRefs />
</Project>
1 change: 1 addition & 0 deletions Debug/Kotlin.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions Debug/Kotlin.tlog/Kotlin.lastbuildstate
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionATL=14.29.30136:VCServicingVersionCrtHeaders=14.29.30136:VCServicingVersionCompilers=14.29.30136:TargetPlatformVersion=10.0.19041.0:
Debug|Win32|C:\Users\MalekPC\Documents\GitHub\android-kotlin-notifications\|
31 changes: 31 additions & 0 deletions Kotlin.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31729.503
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Kotlin", "Kotlin.vcxproj", "{1C0CA386-EA94-4FD6-ACB0-1C63C27C8733}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1C0CA386-EA94-4FD6-ACB0-1C63C27C8733}.Debug|x64.ActiveCfg = Debug|x64
{1C0CA386-EA94-4FD6-ACB0-1C63C27C8733}.Debug|x64.Build.0 = Debug|x64
{1C0CA386-EA94-4FD6-ACB0-1C63C27C8733}.Debug|x86.ActiveCfg = Debug|Win32
{1C0CA386-EA94-4FD6-ACB0-1C63C27C8733}.Debug|x86.Build.0 = Debug|Win32
{1C0CA386-EA94-4FD6-ACB0-1C63C27C8733}.Release|x64.ActiveCfg = Release|x64
{1C0CA386-EA94-4FD6-ACB0-1C63C27C8733}.Release|x64.Build.0 = Release|x64
{1C0CA386-EA94-4FD6-ACB0-1C63C27C8733}.Release|x86.ActiveCfg = Release|Win32
{1C0CA386-EA94-4FD6-ACB0-1C63C27C8733}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ECB94911-680E-4350-9D68-D0517BA5711B}
EndGlobalSection
EndGlobal
105 changes: 105 additions & 0 deletions Kotlin.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{1C0CA386-EA94-4FD6-ACB0-1C63C27C8733}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
17 changes: 17 additions & 0 deletions Kotlin.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions Kotlin.vcxproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 29
compileSdkVersion 30
defaultConfig {
applicationId "com.example.android.eggtimernotifications"
minSdkVersion 19
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -36,20 +36,20 @@ android {
}

// Enables data binding.
dataBinding {
enabled = true
buildFeatures {
dataBinding true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0-rc01'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0-rc01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,9 @@ class AlarmReceiver: BroadcastReceiver() {

override fun onReceive(context: Context, intent: Intent) {
// TODO: Step 1.10 [Optional] remove toast
// Toast.makeText(context, context.getText(R.string.eggs_ready), Toast.LENGTH_SHORT).show()
Toast.makeText(context, context.getText(R.string.eggs_ready), Toast.LENGTH_SHORT).show()

// TODO: Step 1.9 add call to sendNotification
val notificationManager = ContextCompat.getSystemService(
context,
NotificationManager::class.java
) as NotificationManager

notificationManager.sendNotification(
context.getText(R.string.eggs_ready).toString(),
context
)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ class SnoozeReceiver: BroadcastReceiver() {
triggerTime,
notifyPendingIntent
)

val notificationManager = ContextCompat.getSystemService(
context,
NotificationManager::class.java
) as NotificationManager
notificationManager.cancelAll()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import android.view.ViewGroup
import android.widget.Toast
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.ViewModelProvider
import com.example.android.eggtimernotifications.R
import com.example.android.eggtimernotifications.databinding.FragmentEggTimerBinding
import com.google.firebase.messaging.FirebaseMessaging
Expand All @@ -45,45 +45,21 @@ class EggTimerFragment : Fragment() {
inflater, R.layout.fragment_egg_timer, container, false
)

val viewModel = ViewModelProviders.of(this).get(EggTimerViewModel::class.java)
val viewModel = ViewModelProvider(this).get(EggTimerViewModel::class.java)

binding.eggTimerViewModel = viewModel
binding.lifecycleOwner = this.viewLifecycleOwner

// TODO: Step 1.7 call create channel
createChannel(
getString(R.string.egg_notification_channel_id),
getString(R.string.egg_notification_channel_name)
)

return binding.root
}

private fun createChannel(channelId: String, channelName: String) {
// TODO: Step 1.6 START create a channel
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val notificationChannel = NotificationChannel(
channelId,
channelName,
// TODO: Step 2.4 change importance
NotificationManager.IMPORTANCE_HIGH
)// TODO: Step 2.6 disable badges for this channel
.apply {
setShowBadge(false)
}

notificationChannel.enableLights(true)
notificationChannel.lightColor = Color.RED
notificationChannel.enableVibration(true)
notificationChannel.description = getString(R.string.breakfast_notification_channel_description)

val notificationManager = requireActivity().getSystemService(
NotificationManager::class.java
)
notificationManager.createNotificationChannel(notificationChannel)

}
// TODO: Step 1.6 END create a channel

}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import androidx.core.content.ContextCompat
import androidx.lifecycle.*
import com.example.android.eggtimernotifications.receiver.AlarmReceiver
import com.example.android.eggtimernotifications.R
import com.example.android.eggtimernotifications.util.cancelNotifications
import com.example.android.eggtimernotifications.util.sendNotification
import kotlinx.coroutines.*

Expand Down Expand Up @@ -119,13 +118,9 @@ class EggTimerViewModel(private val app: Application) : AndroidViewModel(app) {
}
val triggerTime = SystemClock.elapsedRealtime() + selectedInterval

// TODO: Step 1.5 get an instance of NotificationManager and call sendNotification

// TODO: Step 1.15 call cancel notification
val notificationManager =
ContextCompat.getSystemService(
app,
NotificationManager::class.java
) as NotificationManager
notificationManager.cancelNotifications()

AlarmManagerCompat.setExactAndAllowWhileIdle(
alarmManager,
Expand Down
Loading