using System;
+using Clock.Abstractions;
using Tizen;
using Tizen.Applications;
+using Xamarin.Forms;
namespace Clock.Tizen.Mobile
{
protected override void OnCreate()
{
base.OnCreate();
- LoadApplication(new App());
+ LoadApplication(new App(ApplicationInfo.ApplicationId));
}
protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
{
base.OnAppControlReceived(e);
- if (int.TryParse(e.ReceivedAppControl.ExtraData.Get(APP_CONTROL_DATA_ALARM_ID).ToString(), out var id))
- {
- //DependencyService.Get<IPlatformAlarmsService>().OnPlatformAlarmTriggered(id);
- }
+ //if (int.TryParse(e.ReceivedAppControl.ExtraData.Get(APP_CONTROL_DATA_ALARM_ID).ToString(), out var id))
+ //{
+ // DependencyService.Get<IPlatformAlarmsService>().OnPlatformAlarmTriggered(id);
+ //}
}
static void Main(string[] args)
{
public const string Tag = "d";
- public App()
+ public string ApplicationId { get;}
+
+ public App(string applicationId)
{
+ ApplicationId = applicationId;
+
try
{
var view = new MainView();
- view.BindingContext = ViewModelFactory.CreateMain(view.Navigation);
+ //view.BindingContext = ViewModelFactory.CreateMain(view.Navigation);
MainPage = new NavigationPage(view);
}
catch (Exception e)
}
}
}
-}
+}
\ No newline at end of file
</DataTemplate>
</ListView.HeaderTemplate>
- <ListView.WrapperTemplate>
+ <!--<ListView.WrapperTemplate>
<DataTemplate>
<StackLayout BindingContext="{Binding Item}" x:Name="stackLayout" Orientation="Horizontal"
HorizontalOptions="FillAndExpand">
HorizontalOptions="End" VerticalOptions="Center" Margin="8,8,16,8" />
</StackLayout>
</DataTemplate>
- </ListView.WrapperTemplate>
+ </ListView.WrapperTemplate>-->
</ListView>
\ No newline at end of file
--- /dev/null
+/*
+* Copyright 2017 Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://floralicense.org/license/
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using Clock.Abstractions;
+using Clock.Model;
+using Clock.Tizen.Mobile.Tools;
+using Alarm = Tizen.Applications.Alarm;
+
+namespace Clock.Tizen.Mobile.Services
+{
+ internal class PlatformAlarm : IPlatformAlarm
+ {
+ private readonly Alarm _alarm;
+
+ public int Id => _alarm.AlarmId;
+
+ public PlatformAlarm(Alarm alarm)
+ {
+ _alarm = alarm;
+ }
+
+ public void Cancel()
+ {
+ _alarm.Cancel();
+ }
+
+ public DateTime GetScheduledDateTime()
+ {
+ return _alarm.ScheduledDate;
+ }
+
+ public DaysOfWeek GetDaysOfWeek()
+ {
+ return _alarm.WeekFlag.ConvertToApiFlag();
+ }
+ }
+}
\ No newline at end of file
-using System;
+/*
+* Copyright 2017 Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://floralicense.org/license/
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
using System.Collections.Generic;
+using System.Linq;
using Clock.Abstractions;
using Clock.Model;
+using Clock.Tizen.Mobile.Tools;
+using Tizen.Applications;
+using AlarmManager = Tizen.Applications.AlarmManager;
+using Application = Xamarin.Forms.Application;
namespace Clock.Tizen.Mobile.Services
{
public IPlatformAlarm CreateNewPlatformAlarm(DateTime time, DaysOfWeek days)
{
- throw new NotImplementedException();
+ var appControl = new AppControl {ApplicationId = ((App)Application.Current).ApplicationId};
+
+ var alarm = days == DaysOfWeek.Never
+ ? AlarmManager.CreateAlarm(time, appControl)
+ : AlarmManager.CreateAlarm(time, days.ConvertToPlatformFlag(), appControl);
+
+ return new PlatformAlarm(alarm);
}
public IEnumerable<IPlatformAlarm> GetPlatformAlarms()
{
- throw new NotImplementedException();
+ return AlarmManager.GetAllScheduledAlarms().Select(alarm => new PlatformAlarm(alarm));
}
public IPlatformAlarm GetPlatformAlarm(int id)
{
- throw new NotImplementedException();
+ var alarm = AlarmManager.GetAllScheduledAlarms().FirstOrDefault(a => a.AlarmId == id);
+ return alarm != null ? new PlatformAlarm(alarm) : null;
}
public DateTime GetCurrentPlatformTime()
{
- throw new NotImplementedException();
+ return DateTime.Now;
}
public void OnPlatformAlarmTriggered(int id)
--- /dev/null
+/*
+* Copyright 2017 Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://floralicense.org/license/
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using Clock.Model;
+using Tizen.Applications;
+
+namespace Clock.Tizen.Mobile.Tools
+{
+ public static class WeekFlagsExtensions
+ {
+ public static AlarmWeekFlag ConvertToPlatformFlag(this DaysOfWeek daysOfWeek)
+ {
+ AlarmWeekFlag weekFlag = 0;
+
+ if (daysOfWeek.HasFlag(DaysOfWeek.Sunday))
+ {
+ weekFlag |= AlarmWeekFlag.Sunday;
+ }
+
+ if (daysOfWeek.HasFlag(DaysOfWeek.Monday))
+ {
+ weekFlag |= AlarmWeekFlag.Monday;
+ }
+
+ if (daysOfWeek.HasFlag(DaysOfWeek.Tuesday))
+ {
+ weekFlag |= AlarmWeekFlag.Tuesday;
+ }
+
+ if (daysOfWeek.HasFlag(DaysOfWeek.Wednesday))
+ {
+ weekFlag |= AlarmWeekFlag.Wednesday;
+ }
+
+ if (daysOfWeek.HasFlag(DaysOfWeek.Thursday))
+ {
+ weekFlag |= AlarmWeekFlag.Thursday;
+ }
+
+ if (daysOfWeek.HasFlag(DaysOfWeek.Friday))
+ {
+ weekFlag |= AlarmWeekFlag.Friday;
+ }
+
+ if (daysOfWeek.HasFlag(DaysOfWeek.Saturday))
+ {
+ weekFlag |= AlarmWeekFlag.Saturday;
+ }
+
+ return weekFlag;
+ }
+
+ public static DaysOfWeek ConvertToApiFlag(this AlarmWeekFlag alarmWeekFlag)
+ {
+ DaysOfWeek daysOfWeek = 0;
+
+ if (alarmWeekFlag.HasFlag(AlarmWeekFlag.Sunday))
+ {
+ daysOfWeek |= DaysOfWeek.Sunday;
+ }
+
+ if (alarmWeekFlag.HasFlag(AlarmWeekFlag.Monday))
+ {
+ daysOfWeek |= DaysOfWeek.Monday;
+ }
+
+ if (alarmWeekFlag.HasFlag(AlarmWeekFlag.Tuesday))
+ {
+ daysOfWeek |= DaysOfWeek.Tuesday;
+ }
+
+ if (alarmWeekFlag.HasFlag(AlarmWeekFlag.Wednesday))
+ {
+ daysOfWeek |= DaysOfWeek.Wednesday;
+ }
+
+ if (alarmWeekFlag.HasFlag(AlarmWeekFlag.Thursday))
+ {
+ daysOfWeek |= DaysOfWeek.Thursday;
+ }
+
+ if (alarmWeekFlag.HasFlag(AlarmWeekFlag.Friday))
+ {
+ daysOfWeek |= DaysOfWeek.Friday;
+ }
+
+ if (alarmWeekFlag.HasFlag(AlarmWeekFlag.Saturday))
+ {
+ daysOfWeek |= DaysOfWeek.Saturday;
+ }
+
+ return daysOfWeek;
+ }
+ }
+}
\ No newline at end of file
return await navigation.NavigateAndPop(deletingPage, taskSource);
}
- return new WorldClockViewModel(DS.Get<IAppControl>(), NavigateToDeletingPlaces, NavigateToReorderingPlaces
- , DS.Get<ILogger>());
+ return new WorldClockViewModel(DS.Get<IAppControl>(), NavigateToDeletingPlaces, NavigateToReorderingPlaces,
+ DS.Get<ILogger>());
}
public static ReorderingPlacesViewModel CreateReorderingPlaces(IEnumerable<ClockLocation> locations,
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:Clock.Tizen.Mobile.Views;assembly=Clock.Tizen.Mobile"
- x:Class="Clock.Tizen.Mobile.Views.MainView">
+ x:Class="Clock.Tizen.Mobile.Views.MainView"
+ Title="Test">
<TabbedPage.Children>
- <pages:AlarmView Title="Alarm" Icon="tabs/clock_tabs_ic_alarm.png" />
+ <ContentPage Title="Test">
+ <StackLayout>
+ <Label Text="label1"/>
+ <Label Text="label2"/>
+ </StackLayout>
+ </ContentPage>
+ <!--<pages:AlarmView Title="Alarm" Icon="tabs/clock_tabs_ic_alarm.png" />
<pages:WorldClockView Title="World clock" Icon="tabs/clock_tabs_ic_worldclock.png"
BindingContext="{Binding WorldClockViewModel}" />
<pages:StopWatchView Title="Stopwatch" Icon="tabs/clock_tabs_ic_stopwatch.png" />
- <pages:TimerView Title="Timer" Icon="tabs/clock_tabs_ic_timer.png" />
+ <pages:TimerView Title="Timer" Icon="tabs/clock_tabs_ic_timer.png" />-->
</TabbedPage.Children>
using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+
+[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
namespace Clock.Tizen.Mobile.Views
{
public MainView()
{
InitializeComponent();
-
NavigationPage.SetHasNavigationBar(this, false);
}
}
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:Clock.Tizen.Mobile.Controls;assembly=Clock.Tizen.Mobile"
- xmlns:viewmodels="clr-namespace:Clock.ViewModel;assembly=Clock"
+ xmlns:viewmodels="clr-namespace:Clock.ViewModels;assembly=Clock"
xmlns:converters="clr-namespace:Clock.Tools.Converters;assembly=Clock"
x:Class="Clock.Tizen.Mobile.Views.TimerView">
/// <summary>
/// Unique id of the alarm.
/// </summary>
- int Id { get; set; }
+ int Id { get; }
/// <summary>
/// Cancels this alarm.
{
Never = 0,
Sunday = 1,
- Monday = 2,
- Tuesday = 4,
- Wednesday = 8,
- Thursday = 16,
- Friday = 32,
- Saturday = 64
+ Monday = 1 << 2,
+ Tuesday = 1 << 3,
+ Wednesday = 1 << 4,
+ Thursday = 1 << 5,
+ Friday = 1 << 6,
+ Saturday = 1 << 7
}
}
\ No newline at end of file
namespace Clock.Tools.Converters
{
- class CollectionToBooleanConverter : IValueConverter
+ public class CollectionToBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{