private void SendLocaNotification(ResponseCollectionItemViewModel response, string messageText, int iocnResId, Color colorbool, bool openApp = true) { PendingIntent pendingIntent = null; if (openApp) { var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTop); intent.PutExtra(Constants.NotificationIdLabel, Constants.NotificationId); intent.PutExtra(Constants.NotificationTagLabel, Constants.NotificationTag); pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot); } // get info from response var colorName = response.Response.Color; var title = response.Response.Name; var attributes = Constants.GetChatMessageButtonSettings(ApplicationContext, title, response.Response.Icon); var iconName = attributes.Item1; var color = attributes.Item2; var message = response.Response.ActionPlan?.Description == null ? messageText : response.Response.ActionPlan.Description; var location = response.Response.Geolocation; Color smallIconColor = new Color(ResourcesCompat.GetColor(Resources, Resource.Color.app_blue, null)); Edison.Mobile.Android.Common.Notifications.NotificationService.SendLocalNotification(this, Constants.EVENT_CHANNEL_ID, title, Resource.Drawable.ic_edison_notification, smallIconColor, NotificationCompat.CategoryMessage, NotificationCompat.VisibilityPublic, Constants.NotificationId, Constants.NotificationTag, pendingIntent, true, messageText, Resource.Drawable.edison_fox1); }
private Bitmap DrawFaceRectangle(Bitmap bitmap, Face face) { var newBitmap = bitmap.Copy(Bitmap.Config.Argb8888, true); if (face == null) { return(newBitmap); } var canvas = new Canvas(newBitmap); var paint = new Paint { AntiAlias = true }; paint.SetStyle(Paint.Style.Stroke); var green = ResourcesCompat.GetColor(_activity.Resources, Resource.Color.Green, null); paint.Color = new Color(green); const int strokeWidth = 2; paint.StrokeWidth = strokeWidth; var faceRectangle = face.FaceRectangle; canvas.DrawRect( faceRectangle.Left, faceRectangle.Top, faceRectangle.Left + faceRectangle.Width, faceRectangle.Top + faceRectangle.Height, paint); return(newBitmap); }
private void SendLocalNotification(string title, string messageText, bool openApp = true, int resId = 0, int color = -1) { PendingIntent pendingIntent = null; if (openApp) { var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTop); intent.PutExtra(Constants.NotificationIdLabel, Constants.NotificationId); intent.PutExtra(Constants.NotificationTagLabel, Constants.NotificationTag); pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot); } /* * // Create the TaskStackBuilder and add the intent, which inflates the back stack * var stackBuilder = global::Android.Support.V4.App.TaskStackBuilder.Create(this); * stackBuilder.AddNextIntentWithParentStack(intent); * // Get the PendingIntent containing the entire back stack * var pendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent); */ Color smallIconColor = new Color(ResourcesCompat.GetColor(Resources, Resource.Color.app_blue, null)); if (resId == 0) { resId = Resource.Drawable.edison_fox1; } Edison.Mobile.Android.Common.Notifications.NotificationService.SendLocalNotification(this, Constants.EVENT_CHANNEL_ID, title, Resource.Drawable.ic_edison_notification, smallIconColor, NotificationCompat.CategoryMessage, NotificationCompat.VisibilityPublic, Constants.NotificationId, Constants.NotificationTag, pendingIntent, true, messageText, resId, color); }
public static Color GetEventTypeColor(Context ctx, string colorName) { switch (colorName) { case Core.Shared.Constants.ColorName.Red: if (!_eventRedSet) { _eventRed = new Color(ResourcesCompat.GetColor(ctx.Resources, Resource.Color.icon_red, null)); } return(_eventRed); case Core.Shared.Constants.ColorName.Yellow: if (!_eventYellowSet) { _eventYellow = new Color(ResourcesCompat.GetColor(ctx.Resources, Resource.Color.app_yellow, null)); } return(_eventYellow); case Core.Shared.Constants.ColorName.Blue: if (!_eventBlueSet) { _eventBlue = new Color(ResourcesCompat.GetColor(ctx.Resources, Resource.Color.icon_blue, null)); } return(_eventBlue); default: if (!_eventBlueSet) { _eventBlue = new Color(ResourcesCompat.GetColor(ctx.Resources, Resource.Color.icon_blue, null)); } return(_eventBlue); } }
public EventButtonsAdapter(Context ctx, ObservableRangeCollection <ActionPlanListModel> buttons) { _context = ctx; _normalButtonBackgroundColor = new Color(ResourcesCompat.GetColor(_context.Resources, Resource.Color.icon_background_grey, null)); _selectedIconColor = new Color(ResourcesCompat.GetColor(_context.Resources, Resource.Color.white, null)); EventButtons = buttons; }
protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView, ViewGroup parent, Context context) { var cell = base.GetCellCore(item, convertView, parent, context); var child1 = ((LinearLayout)cell).GetChildAt(1); var label = (TextView)((LinearLayout)child1).GetChildAt(0); label.SetTextColor(new Android.Graphics.Color(ResourcesCompat.GetColor(context.Resources, Resource.Color.black_color, null))); return cell; }
private Drawable CreateUserIconDrawable() { int dp16 = PixelSizeConverter.DpToPx(16); int dp12 = PixelSizeConverter.DpToPx(12); int dp4 = PixelSizeConverter.DpToPx(4); var fillColor = new Color(ResourcesCompat.GetColor(_layout.Resources, Resource.Color.user_location, null)); var ringColor = new Color(ResourcesCompat.GetColor(_layout.Resources, Resource.Color.user_location_stroke, null)); var pointColor = new Color(ResourcesCompat.GetColor(_layout.Resources, Resource.Color.user_location_center, null)); LayerDrawable drw = new LayerDrawable(new Drawable[] { CircleDrawable(ringColor, dp16), CircleDrawable(fillColor, dp12), CircleDrawable(pointColor, dp4) }); drw.SetLayerSize(0, dp16, dp16); drw.SetLayerSize(1, dp12, dp12); drw.SetLayerSize(2, dp4, dp4); drw.SetLayerGravity(0, GravityFlags.Center); drw.SetLayerGravity(1, GravityFlags.Center); drw.SetLayerGravity(2, GravityFlags.Center); return(drw); }
/// <summary> /// NOTE: You should provide all necessary information to display the notification in the data /// sent via FCM, so that the local notification can always be constructed with the appropriate data. /// This has NOT been done in this demo, so will try to infer as much information as possible /// </summary> /// <param name="message"></param> /// <returns></returns> private async Task PerformNonSilentNotification(RemoteMessage message) { // Get and decode notification data #if DEBUG System.Diagnostics.Debug.WriteLine("**********************************************"); System.Diagnostics.Debug.WriteLine("********* NON Silent Notification **********"); System.Diagnostics.Debug.WriteLine("**********************************************"); #endif // If the message type is used to differentiate the types of payload, use a switch statement here to process them var notification = message?.GetNotification(); _smallIconColor = new Color(ResourcesCompat.GetColor(Resources, Resource.Color.app_blue, null)); // Check if notification contains a notification payload if (notification != null) { // Notification contains a notification payload // This field will be non - null if a notification message is received while the application is in the foreground. #if DEBUG System.Diagnostics.Debug.WriteLine("Template Notification:: Message body: " + notification.Body); Log.Debug(TAG, "Template Notification:: Message body: " + notification.Body); #endif // Do not have to create and send a local notification for Notification payloads, as the FCM SDK framework does this // automatically in the background //SendLocalNotification(notification.Body); } string messageBody = null; // Check if notification contains a data payload if (message?.Data != null && message.Data.Count > 0) { // This should be modified to extract data from the data platform according to your data payload model // Data is usually serialized as json and can be associated with multiple keys or with a single key // If notification data is in Data, extract it // This demo uses a simple key "messages" for the simple text data. if (message.Data.TryGetValue(Constants.MessageDataMessage, out messageBody) && !string.IsNullOrWhiteSpace(messageBody)) { // Data present so try to get from Data #if DEBUG System.Diagnostics.Debug.WriteLine("Template Notification:: Message body: " + messageBody); Log.Debug(TAG, "Template Notification:: Message body: " + messageBody); #endif // process further here as required. for the demo app this is being done below } } // This demo app uses a simple text notification. // We will process it based up the current state of the application // a) Application is in foreground: // i) Update the responses/events from the app service vis the ResponsesViewModel // ii) If there is a new event/response: Create a Snackbar indicating a new event has been received // If an event/response has been removed: Create a Snackbar indicating a new event has been closed // If the event/responses are the same and the message body contains text: Create a Snackbar containing the text // b) Application is in background: // i) Update the responses/events from the app service vis the ResponsesViewModel // ii) If there is a new event/response: Create a local notification based upon the new response/event // If an event/response has been removed: Create a local notification indicating a new event has been closed // If the event/responses are the same and the message body contains text: Create a local notification with the message // c) Application is not running: // i) Get responses/events from the app service via the ResponsesViewModel // ii) If there is a new event/response: Create a local notification based upon the new response/event // If an event/response has been removed: Create a local notification indicating a new event has been closed // If the event/responses are the same and the message body contains text: Create a local notification with the message #if DEBUG System.Diagnostics.Debug.WriteLine("Application State: " + _appState.ToString()); Log.Debug(TAG, "Application State: " + _appState.ToString()); #endif // TODO: THIS WILL CHANGE WHEN THE JSON THAT IS RETURNED IS UPDATED - WONT NEED TO GET DETAILS FROM VIEW MODEL int status = int.MinValue; string user = null; Guid responseId = Guid.Empty; string title = null; string messageText = null; List <string> tags = null; string bundleId = null; bool isResponseNotification = false; try { var data = Newtonsoft.Json.JsonConvert.DeserializeObject <TempNotificationDTO>(messageBody); if (data != null) { status = data.Status; user = data.User; responseId = data.ResponseId; title = data.Title; messageText = data.NotificationText; tags = data.Tags; isResponseNotification = true; bundleId = responseId.ToString(); } else { messageText = messageBody; } } catch (Exception ex) { messageText = messageBody; } // bool openApp = _appState == ApplicationState.Foreground ? false : true; // may need to treat background differently if (isResponseNotification) { // get an instance of the responses view model var responsesViewModel = Container.Instance.Resolve <ResponsesViewModel>(); // get the current response ids var currId = responsesViewModel?.CurrentResponseIds; // Try to get the details of this response if already existing (if doesn't exist will get null returned) var currentResponse = responsesViewModel?.GetResponseSummary(responseId); // set default for value then try to get from actual responses or infer from message _color = Constants.GetEventTypeColor(ApplicationContext, _colorName); #if DEBUG System.Diagnostics.Debug.WriteLine("********************************************"); System.Diagnostics.Debug.WriteLine("********* Initial Msg Processed **********"); System.Diagnostics.Debug.WriteLine("********************************************"); #endif // Check if the app is in the foreground if (_appState == ApplicationState.Foreground) { // in the foreground so will have already authenticated #if DEBUG System.Diagnostics.Debug.WriteLine("****************************************"); System.Diagnostics.Debug.WriteLine("********* App in Foreground **********"); System.Diagnostics.Debug.WriteLine("****************************************"); #endif // get the latest responses await UpdateResponses(responsesViewModel); // try to get the response from the updated list var newResponse = responsesViewModel?.GetResponseSummary(responseId); PendingIntent pendingIntent = null; List <NotificationCompat.Action> actions = null; if (newResponse != null) { // Managed to get the response details from service, so populate values for local notification _colorName = newResponse.Color; _responseTitle = newResponse.Name; var attributes = Constants.GetChatMessageButtonSettings(ApplicationContext, _responseTitle, newResponse.Icon); var iconName = attributes.Item1; _iconResId = GetIconResourceId(iconName); _color = attributes.Item2; _location = newResponse.Geolocation; if (currentResponse == null) { // Must be a new response/event #if DEBUG System.Diagnostics.Debug.WriteLine("***********************************"); System.Diagnostics.Debug.WriteLine("********* New Response **********"); System.Diagnostics.Debug.WriteLine("***********************************"); #endif } else { // Response details must gave changed #if DEBUG System.Diagnostics.Debug.WriteLine("***************************************"); System.Diagnostics.Debug.WriteLine("********* Updated Response **********"); System.Diagnostics.Debug.WriteLine("***************************************"); #endif // Update Title depending on response type // if(!newResponse.IsActive) if (newResponse.EndDate < DateTime.UtcNow) { // The response/event is not active (its over) _responseTitle = Resources.GetString(Resource.String.event_over) + ": " + _responseTitle; } else if (_location != currentResponse.Geolocation) { // The response/event location changed _responseTitle = Resources.GetString(Resource.String.location_changed) + ": " + _responseTitle; } else { // The response/event has a different update _responseTitle = Resources.GetString(Resource.String.event_update) + ": " + _responseTitle; } } Edison.Mobile.Android.Common.Notifications.NotificationService.SendLocalNotification(this, Constants.EVENT_CHANNEL_ID, title, Resource.Drawable.ic_edison_notification, _smallIconColor, NotificationCompat.CategoryMessage, NotificationCompat.VisibilityPublic, Constants.NotificationId, Constants.NotificationTag, pendingIntent, true, _responseTitle, messageText, _iconResId, _color, bundleId, actions); } else if (currentResponse != null) { // Response must have been deleted #if DEBUG System.Diagnostics.Debug.WriteLine("***************************************"); System.Diagnostics.Debug.WriteLine("********* Response Removed **********"); System.Diagnostics.Debug.WriteLine("***************************************"); #endif // Note: in demo system should not reach here _colorName = currentResponse.Color; _responseTitle = currentResponse.Name; var attributes = Constants.GetChatMessageButtonSettings(ApplicationContext, _responseTitle, currentResponse.Icon); var iconName = attributes.Item1; _iconResId = GetIconResourceId(iconName); _color = attributes.Item2; _location = currentResponse.Geolocation; Edison.Mobile.Android.Common.Notifications.NotificationService.SendLocalNotification(this, Constants.EVENT_CHANNEL_ID, title, Resource.Drawable.ic_edison_notification, _smallIconColor, NotificationCompat.CategoryMessage, NotificationCompat.VisibilityPublic, Constants.NotificationId, Constants.NotificationTag, pendingIntent, true, _responseTitle, messageText, _iconResId, _color, bundleId, actions); } else // (currentResponse == null) { // Response never existed, so treat as text message. #if DEBUG System.Diagnostics.Debug.WriteLine("****************************************************"); System.Diagnostics.Debug.WriteLine("********* Not a Response - Text Message **********"); System.Diagnostics.Debug.WriteLine("****************************************************"); #endif // Try to infer info from message var responseInferred = InferValuesFromMessage(ApplicationContext, messageText, false); if (responseInferred) { SendLocalNotification(title, messageText, _appState == ApplicationState.Foreground ? false : true, _iconResId, _color); } else { SendLocalNotification(title, messageText, _appState == ApplicationState.Foreground ? false : true); } } } else { // App in background or not running #if DEBUG System.Diagnostics.Debug.WriteLine("*******************************************"); System.Diagnostics.Debug.WriteLine("********* App NOT in Foreground *********"); System.Diagnostics.Debug.WriteLine("*******************************************"); #endif // Try to silently authenticate. // Note: If in Background should authenticate successfully, if not running may or may not authenticate #if DEBUG System.Diagnostics.Debug.WriteLine("********* Trying to Authenticate Silently **********"); #endif // Not in background, so need check if we are authenticated // get an instance of the login view model var loginViewModel = Container.Instance.Resolve <LoginViewModel>(); var hasToken = await loginViewModel?.AuthService?.AcquireTokenSilently(); // If valid token, then Authentication service has valid access token and can request latest responses if (hasToken) { #if DEBUG System.Diagnostics.Debug.WriteLine("****************************************"); System.Diagnostics.Debug.WriteLine("********* App Authenticated **********"); System.Diagnostics.Debug.WriteLine("****************************************"); #endif string source = Constants.IntentSourceBackgroundNotification; string authenticated = Constants.IntentAuthenticated; // get the latest responses await UpdateResponses(responsesViewModel); // try to get the response from the updated list var newResponse = responsesViewModel?.GetResponseSummary(responseId); if (newResponse != null) { // Managed to get the response details from service, so populate values for local notification _colorName = newResponse.Color; _responseTitle = newResponse.Name; var attributes = Constants.GetChatMessageButtonSettings(ApplicationContext, _responseTitle, newResponse.Icon); var iconName = attributes.Item1; _iconResId = GetIconResourceId(iconName); _color = attributes.Item2; _location = newResponse.Geolocation; if (currentResponse == null) { // Must be a new response/event #if DEBUG System.Diagnostics.Debug.WriteLine("***********************************"); System.Diagnostics.Debug.WriteLine("********* New Response **********"); System.Diagnostics.Debug.WriteLine("***********************************"); #endif } else { // Response details must gave changed #if DEBUG System.Diagnostics.Debug.WriteLine("***************************************"); System.Diagnostics.Debug.WriteLine("********* Updated Response **********"); System.Diagnostics.Debug.WriteLine("***************************************"); #endif // Update Title depending on response type // if(!newResponse.IsActive) if (newResponse.EndDate < DateTime.UtcNow) { // The response/event is not active (its over) _responseTitle = Resources.GetString(Resource.String.event_over) + ": " + _responseTitle; } else if (_location != currentResponse.Geolocation) { // The response/event location changed _responseTitle = Resources.GetString(Resource.String.location_changed) + ": " + _responseTitle; } else { // The response/event has a different update _responseTitle = Resources.GetString(Resource.String.event_update) + ": " + _responseTitle; } } Intent intent = new Intent(this, typeof(MainActivity)); CreateEdisonResponseNotification(title, messageText, intent, bundleId, source, authenticated); } else if (currentResponse != null) { // Response must have been deleted #if DEBUG System.Diagnostics.Debug.WriteLine("***************************************"); System.Diagnostics.Debug.WriteLine("********* Response Removed **********"); System.Diagnostics.Debug.WriteLine("***************************************"); #endif // Note: in demo system should not reach here _colorName = currentResponse.Color; _responseTitle = currentResponse.Name; var attributes = Constants.GetChatMessageButtonSettings(ApplicationContext, _responseTitle, currentResponse.Icon); var iconName = attributes.Item1; _iconResId = GetIconResourceId(iconName); _color = attributes.Item2; _location = currentResponse.Geolocation; _responseTitle = Resources.GetString(Resource.String.event_over) + ": " + _responseTitle; Intent intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTop); intent.PutExtra(Constants.IntentSourceLabel, source); intent.PutExtra(Constants.NotificationIdLabel, Constants.NotificationId); intent.PutExtra(Constants.NotificationTagLabel, Constants.NotificationTag); var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot | PendingIntentFlags.UpdateCurrent); Edison.Mobile.Android.Common.Notifications.NotificationService.SendLocalNotification(this, Constants.EVENT_CHANNEL_ID, title, Resource.Drawable.ic_edison_notification, _smallIconColor, NotificationCompat.CategoryMessage, NotificationCompat.VisibilityPublic, Constants.NotificationId, Constants.NotificationTag, pendingIntent, true, _responseTitle, messageText, _iconResId, _color, bundleId, null); } else // (currentResponse == null) { // Response never existed, so treat as text message. #if DEBUG System.Diagnostics.Debug.WriteLine("****************************************************"); System.Diagnostics.Debug.WriteLine("********* Not a Response - Text Message **********"); System.Diagnostics.Debug.WriteLine("****************************************************"); #endif // Try to infer info from message var responseInferred = InferValuesFromMessage(ApplicationContext, messageText, false); if (responseInferred) { SendLocalNotification(title, messageText, _appState == ApplicationState.Foreground ? false : true, _iconResId, _color); } else { SendLocalNotification(title, messageText, _appState == ApplicationState.Foreground ? false : true); } } } else { // app not authenticated so get what info we can on the referenced response #if DEBUG System.Diagnostics.Debug.WriteLine("****************************************"); System.Diagnostics.Debug.WriteLine("********* NOT Authenticated **********"); System.Diagnostics.Debug.WriteLine("****************************************"); #endif string source = Constants.IntentSourceNotRunningNotification; string authenticated = Constants.IntentNotAuthenticated; if (currentResponse == null) { // We have no info, so try to infer from the message and treat as a new response InferValuesFromMessage(ApplicationContext, messageText); } else { // The response is currently in app so pull information from there _colorName = currentResponse.Color; _responseTitle = currentResponse.Name; var attributes = Constants.GetChatMessageButtonSettings(ApplicationContext, _responseTitle, currentResponse.Icon); var iconName = attributes.Item1; _iconResId = GetIconResourceId(iconName); _color = attributes.Item2; _location = currentResponse.Geolocation; // As its already there lets treat as an update _responseTitle = Resources.GetString(Resource.String.event_update) + ": " + _responseTitle; } Intent intent = new Intent(this, typeof(LoginActivity)); CreateEdisonResponseNotification(title, messageText, intent, bundleId, source, authenticated); } } } else { #if DEBUG System.Diagnostics.Debug.WriteLine("************************************************"); System.Diagnostics.Debug.WriteLine("********* Not Response Notification **********"); System.Diagnostics.Debug.WriteLine("************************************************"); #endif // Not a Response/event notification - treat as a text message SendLocalNotification(title, messageText, _appState == ApplicationState.Foreground ? false : true); } }
public static void Init() { if (Settings.SelectedTheme == 1) { BrushAnimeItemInnerBackground = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.DarkBrushAnimeItemInnerBackground, null); BrushAnimeItemBackground = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.DarkBrushAnimeItemBackground, null); BrushAppBars = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.DarkBrushAppBars, null); BrushFlyoutBackground = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.DarkBrushFlyoutBackground, null); BrushRowAlternate1 = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.DarkBrushRowAlternate1, null); BrushRowAlternate2 = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.DarkBrushRowAlternate2, null); // BrushText = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.DarkBrushText, null); BrushSelectedDialogItem = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.DarkBrushSelectedDialogItem, null); BrushTextRes = Resource.Color.DarkBrushText; // BrushAnimeItemBackgroundRes = Resource.Color.DarkBrushAnimeItemBackground; BrushNoSearchResultsRes = Resource.Color.DarkBrushNoSearchResults; BrushNoSearchResults = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.DarkBrushNoSearchResults, null); BrushFlyoutBackgroundRes = Resource.Color.DarkBrushFlyoutBackground; BrushHamburgerBackgroundRes = Resource.Color.DarkBrushHamburgerBackground; BrushRowAlternate1Res = Resource.Color.DarkBrushRowAlternate1; BrushRowAlternate2Res = Resource.Color.DarkBrushRowAlternate2; BrushRowAlternate2LighterRes = Resource.Color.DarkBrushRowAlternate2; BrushAnimeItemInnerBackgroundRes = Resource.Color.DarkBrushAnimeItemInnerBackground; } else { BrushAnimeItemInnerBackground = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.LightBrushAnimeItemInnerBackground, null); BrushAnimeItemBackground = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.LightBrushAnimeItemBackground, null); BrushAppBars = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.LightBrushAppBars, null); BrushFlyoutBackground = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.LightBrushFlyoutBackground, null); BrushRowAlternate1 = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.LightBrushRowAlternate1, null); BrushRowAlternate2 = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.LightBrushRowAlternate2, null); // BrushText = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.LightBrushText, null); BrushSelectedDialogItem = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.LightBrushSelectedDialogItem, null); BrushTextRes = Resource.Color.LightBrushText; // BrushAnimeItemBackgroundRes = Resource.Color.LightBrushAnimeItemBackground; BrushNoSearchResultsRes = Resource.Color.LightBrushNoSearchResults; BrushNoSearchResults = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.LightBrushNoSearchResults, null); BrushFlyoutBackgroundRes = Resource.Color.LightBrushFlyoutBackground; BrushHamburgerBackgroundRes = Resource.Color.LightBrushHamburgerBackground; BrushRowAlternate1Res = Resource.Color.LightBrushRowAlternate1; BrushRowAlternate2Res = Resource.Color.LightBrushRowAlternate2; BrushRowAlternate2LighterRes = Resource.Color.LightBrushRowAlternate2Lighter; BrushAnimeItemInnerBackgroundRes = Resource.Color.LightBrushAnimeItemInnerBackground; } switch (AndroidColourThemeHelper.CurrentTheme) { case AndroidColorThemes.Orange: AccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.OrangeAccentColour, null); AccentColourDark = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.OrangeAccentColourDark, null); AccentColourContrast = Settings.SelectedTheme == 1 ? AccentColour : AccentColourDark; AccentColourHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.OrangeAccentColour); AccentColourLightHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.OrangeAccentColourLight); AccentColourDarkHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.OrangeAccentColourDark); AccentColourRes = Resource.Color.OrangeAccentColour; AccentColourDarkRes = Resource.Color.OrangeAccentColourDark; OpaqueAccentColourRes = Resource.Color.OrangeOpaqueAccentColour; OpaqueAccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.OrangeOpaqueAccentColour, null); break; case AndroidColorThemes.Purple: AccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.PurpleAccentColour, null); AccentColourDark = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.PurpleAccentColourDark, null); AccentColourContrast = Settings.SelectedTheme == 1 ? AccentColour : AccentColourDark; AccentColourHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.PurpleAccentColour); AccentColourLightHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.PurpleAccentColourLight); AccentColourDarkHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.PurpleAccentColourDark); AccentColourRes = Resource.Color.PurpleAccentColour; AccentColourDarkRes = Resource.Color.PurpleAccentColourDark; OpaqueAccentColourRes = Resource.Color.PurpleOpaqueAccentColour; OpaqueAccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.PurpleOpaqueAccentColour, null); break; case AndroidColorThemes.Blue: AccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.BlueAccentColour, null); AccentColourDark = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.BlueAccentColourDark, null); AccentColourContrast = Settings.SelectedTheme == 1 ? AccentColour : AccentColourDark; AccentColourHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.BlueAccentColour); AccentColourLightHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.BlueAccentColourLight); AccentColourDarkHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.BlueAccentColourDark); AccentColourRes = Resource.Color.BlueAccentColour; AccentColourDarkRes = Resource.Color.BlueAccentColourDark; OpaqueAccentColourRes = Resource.Color.BlueOpaqueAccentColour; OpaqueAccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.BlueOpaqueAccentColour, null); break; case AndroidColorThemes.Lime: AccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.LimeAccentColour, null); AccentColourDark = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.LimeAccentColourDark, null); AccentColourContrast = Settings.SelectedTheme == 1 ? AccentColour : AccentColourDark; AccentColourHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.LimeAccentColour); AccentColourLightHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.LimeAccentColourLight); AccentColourDarkHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.LimeAccentColourDark); AccentColourRes = Resource.Color.LimeAccentColour; AccentColourDarkRes = Resource.Color.LimeAccentColourDark; OpaqueAccentColourRes = Resource.Color.LimeOpaqueAccentColour; OpaqueAccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.LimeOpaqueAccentColour, null); break; case AndroidColorThemes.Pink: AccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.PinkAccentColour, null); AccentColourDark = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.PinkAccentColourDark, null); AccentColourContrast = Settings.SelectedTheme == 1 ? AccentColour : AccentColourDark; AccentColourHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.PinkAccentColour); AccentColourLightHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.PinkAccentColourLight); AccentColourDarkHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.PinkAccentColourDark); AccentColourRes = Resource.Color.PinkAccentColour; AccentColourDarkRes = Resource.Color.PinkAccentColourDark; OpaqueAccentColourRes = Resource.Color.PinkOpaqueAccentColour; OpaqueAccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.PinkOpaqueAccentColour, null); break; case AndroidColorThemes.Cyan: AccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.CyanAccentColour, null); AccentColourDark = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.CyanAccentColourDark, null); AccentColourContrast = Settings.SelectedTheme == 1 ? AccentColour : AccentColourDark; AccentColourHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.CyanAccentColour); AccentColourLightHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.CyanAccentColourLight); AccentColourDarkHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.CyanAccentColourDark); AccentColourRes = Resource.Color.CyanAccentColour; AccentColourDarkRes = Resource.Color.CyanAccentColourDark; OpaqueAccentColourRes = Resource.Color.CyanOpaqueAccentColour; OpaqueAccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.CyanOpaqueAccentColour, null); break; case AndroidColorThemes.SkyBlue: AccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.SkyBlueAccentColour, null); AccentColourDark = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.SkyBlueAccentColourDark, null); AccentColourContrast = Settings.SelectedTheme == 1 ? AccentColour : AccentColourDark; AccentColourHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.SkyBlueAccentColour); AccentColourLightHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.SkyBlueAccentColourLight); AccentColourDarkHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.SkyBlueAccentColourDark); AccentColourRes = Resource.Color.SkyBlueAccentColour; AccentColourDarkRes = Resource.Color.SkyBlueAccentColourDark; OpaqueAccentColourRes = Resource.Color.SkyBlueOpaqueAccentColour; OpaqueAccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.SkyBlueOpaqueAccentColour, null); break; case AndroidColorThemes.Red: AccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.RedAccentColour, null); AccentColourDark = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.RedAccentColourDark, null); AccentColourContrast = Settings.SelectedTheme == 1 ? AccentColour : AccentColourDark; AccentColourHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.RedAccentColour); AccentColourLightHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.RedAccentColourLight); AccentColourDarkHex = MainActivity.CurrentContext.Resources.GetString(Resource.Color.RedAccentColourDark); AccentColourRes = Resource.Color.RedAccentColour; AccentColourDarkRes = Resource.Color.RedAccentColourDark; OpaqueAccentColourRes = Resource.Color.RedOpaqueAccentColour; OpaqueAccentColour = ResourcesCompat.GetColor(MainActivity.CurrentContext.Resources, Resource.Color.RedOpaqueAccentColour, null); break; default: throw new ArgumentOutOfRangeException(); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { StudentCourtView = inflater.Inflate(Resource.Layout.StudentCourtFragmentLayout, container, false); #region NICK's REFRESH LAYOUT CODE /* "Pulling" down on the page will refresh the view */ /*RefreshLayout = * StudentCourtView.FindViewById<SwipeRefreshLayout>( * Resource.Id.SwipeRefreshStudentCourt);*/ /*RefreshLayout.SetColorSchemeResources(Resource.Color.primary, * Resource.Color.accent, Resource.Color.primary_text, * Resource.Color.secondary_text); * RefreshLayout.Refresh += RefreshLayoutRefresh;*/ #endregion RecyclerView _recyclerview = StudentCourtView.FindViewById <RecyclerView>(Resource.Id.PendingReportSlips); _adapter = ViewModel.StudentOffenseCard.Offenses.GetRecyclerAdapter ( BindViewHolder, Resource.Layout.StudentCourtInfractionCardLayout ); /* "Pulling" down on the page will refresh the view */ RefreshLayout = StudentCourtView.FindViewById <SwipeRefreshLayout>( Resource.Id.SwipeRefreshStudentCourt); RefreshLayout.SetColorSchemeResources(Resource.Color.primary, Resource.Color.accent, Resource.Color.primary_text, Resource.Color.secondary_text); RefreshLayout.Refresh += RefreshLayoutRefresh; _recyclerview.SetLayoutManager(new LinearLayoutManager(Activity)); _recyclerview.SetAdapter(_adapter); ParentFragment.View.FindViewById <TabLayout>(Resource.Id.MainTabLayout).TabReselected += TabReselected; /* Student court progress bars */ DemeritsProgBar = new ProgressBar(Activity); DormInfractionsProgBar = new ProgressBar(Activity); AbsencesProgBar = new ProgressBar(Activity); LateDormProgBar = new ProgressBar(Activity); DemeritsProgBar = StudentCourtView.FindViewById <ProgressBar>(Resource.Id.DemeritsProgressBar); DormInfractionsProgBar = StudentCourtView.FindViewById <ProgressBar>(Resource.Id.DormInfractionsProgressBar); AbsencesProgBar = StudentCourtView.FindViewById <ProgressBar>(Resource.Id.AbsencesProgressBar); LateDormProgBar = StudentCourtView.FindViewById <ProgressBar>(Resource.Id.LateDormProgressBar); /* Set max value for progress bars */ DemeritsProgBar.Max = App.StudentCourt.MaxDemerits; DormInfractionsProgBar.Max = App.StudentCourt.MaxDormInfractions; AbsencesProgBar.Max = App.StudentCourt.MaxAbsences; LateDormProgBar.Max = App.StudentCourt.MaxLateDormInfraction; StudentCourtView.Post(() => SetUpProgressBars()); /*****************************************************************/ /* Create Student Court Gradient */ /*****************************************************************/ int startColor = Color.Transparent; int endColor; Color startColorAndroidGraphics; TextView statusText = StudentCourtView.FindViewById <TextView>(Resource.Id.StudentCourtStatusText); ImageView studentCourtImage = StudentCourtView.FindViewById <ImageView>(Resource.Id.StudentCourtCircle); Drawable imageBackground = studentCourtImage.Background; /* Convert dp stroke width to pixels for student court circle */ int strokeWidthDp = 4; DisplayMetrics displayMetrics = Resources.DisplayMetrics; float strokeWidth = TypedValue.ApplyDimension( ComplexUnitType.Dip, strokeWidthDp, displayMetrics); switch (ViewModel.StudentOffenseCard.StudentCourtStatus) { case App.StudentCourtStatus.Green: { startColor = ResourcesCompat.GetColor( Resources, Resource.Color.green_500, null); statusText.Text = "You are not required to attend Student Court."; } break; case App.StudentCourtStatus.Gray: { startColor = ResourcesCompat.GetColor( Resources, Resource.Color.body_text_soft_light_theme, null); statusText.Text = "You are not required to attend Student Court."; } break; case App.StudentCourtStatus.Red: { startColor = ResourcesCompat.GetColor( Resources, Resource.Color.red_a700, null); statusText.Text = "You are required to attend Student Court."; } break; } /* Set color for circle image */ startColorAndroidGraphics = new Color(startColor); GradientDrawable shapeDrawable = (GradientDrawable)imageBackground; shapeDrawable.SetStroke((int)strokeWidth, startColorAndroidGraphics); /* Set text color for student court status */ StudentCourtView.FindViewById <TextView>(Resource.Id.StudentCourtStatusText) .SetTextColor(startColorAndroidGraphics); /* Get the name of the current theme */ TypedValue attrValue = new TypedValue(); Activity.Theme.ResolveAttribute( Resource.Attribute.modThemeName, attrValue, true); /* Set the end color for gradient based on the current theme */ if (attrValue.String.ToString() == "ModAppCompatLightTheme") { endColor = ResourcesCompat.GetColor( Resources, Resource.Color.window_background, null); } else { endColor = ResourcesCompat.GetColor( Resources, Resource.Color.window_background_dark_theme, null); } int[] gradientColors = { startColor, endColor }; /* Set the gradient's start and end colors */ GradientDrawable gradient = new GradientDrawable( GradientDrawable.Orientation.TopBottom, gradientColors); StudentCourtView.FindViewById <ImageView>(Resource.Id.GradientStudentCourt) .Background = gradient; /*****************************************************************/ /* Click events for info icons */ /*****************************************************************/ StudentCourtView.FindViewById <ImageView>(Resource.Id.DormInfractionsInfoIcon).Click += ShowInfoIconDialog; StudentCourtView.FindViewById <ImageView>(Resource.Id.AbsencesInfoIcon).Click += ShowInfoIconDialog; StudentCourtView.FindViewById <ImageView>(Resource.Id.LateDormInfoIcon).Click += ShowInfoIconDialog; /* Use this to return your custom view for this Fragment */ return(StudentCourtView); }
public Color GetBackgroundColor() { var intColor = ResourcesCompat.GetColor(Context.Resources, Resource.Color.pdf_page_background, null); return(Color.ParseColor("#" + Integer.ToHexString(intColor))); }
private void DataTemplateBasic(View view, int i, ComparisonItemViewModel arg3) { var holder = _comparisonViewHolders[view]; holder.ComparisonItemTitle.Text = arg3.Title; holder.ComparisonItemStatus.Text = $"{arg3.MyEntry?.MyStatusBindShort ?? "?"} - {arg3.OtherEntry?.MyStatusBindShort ?? "?"}"; if (arg3.IsOnlyOnMyList) { holder.ComparisonItemOnlyMyStateSection.Visibility = ViewStates.Visible; holder.ComparisonItemOnOtherStateSection.Visibility = ViewStates.Gone; holder.ComparisonItemOnBothStateSection.Visibility = ViewStates.Gone; holder.ComparisonItemNotOnListDescription.Text = $"{ViewModel.OtherData.User.Name} doesn't have this show on list..."; holder.ComparisonItemOnMyMyScore.Text = ScoreToString(arg3.MyEntry.MyScore); holder.ComparisonItemOnMyMyWatched.Text = arg3.MyEntry.MyEpisodesBindShort; } else if (arg3.IsOnlyOnOtherList) { holder.ComparisonItemOnlyMyStateSection.Visibility = ViewStates.Gone; holder.ComparisonItemOnOtherStateSection.Visibility = ViewStates.Visible; holder.ComparisonItemOnBothStateSection.Visibility = ViewStates.Gone; holder.ComparisonItemAddToListButton.Tag = arg3.Wrap(); holder.ComparisonItemOnlyOtherScore.Text = ScoreToString(arg3.OtherEntry.MyScore); holder.ComparisonItemOnlyOtherWatched.Text = arg3.OtherEntry.MyEpisodesBindShort; } else //comparison { holder.ComparisonItemOnlyMyStateSection.Visibility = ViewStates.Gone; holder.ComparisonItemOnOtherStateSection.Visibility = ViewStates.Gone; holder.ComparisonItemOnBothStateSection.Visibility = ViewStates.Visible; holder.ComparisonItemOnBothMyScore.Text = ScoreToString(arg3.MyEntry.MyScore); holder.ComparisonItemOnBothScoreDiff.Text = arg3.ScoreDifferenceBind; holder.ComparisonItemOnBothOtherScore.Text = ScoreToString(arg3.OtherEntry.MyScore); if (arg3.WatchedComparisonBarVisibility) { holder.ComparisonItemOnBothStateSection.WeightSum = 2f; (holder.ComparisonItemOnBothScoreSection.LayoutParameters as LinearLayout.LayoutParams).Weight = 1f; holder.ComparisonItemOnBothWatchedSection.Visibility = ViewStates.Visible; holder.ComparisonItemOnBothMyWatched.Text = arg3.MyEntry.MyEpisodes.ToString(); holder.ComparisonItemOnBothWatchedDiff.Text = arg3.WatchedDifferenceBind; holder.ComparisonItemOnBothOtherWatched.Text = arg3.OtherEntry.MyEpisodes.ToString(); } else { holder.ComparisonItemOnBothStateSection.WeightSum = 1f; (holder.ComparisonItemOnBothScoreSection.LayoutParameters as LinearLayout.LayoutParams).Weight = .5f; holder.ComparisonItemOnBothWatchedSection.Visibility = ViewStates.Gone; } holder.ComparisonItemOnBothScoreDiff.SetTextColor(new Color(ResourcesCompat.GetColor(Resources, GetColorResForDiff(arg3.ScoreDifference), Activity.Theme))); holder.ComparisonItemOnBothWatchedDiff.SetTextColor(new Color(ResourcesCompat.GetColor(Resources, GetColorResForDiff(arg3.WatchedDifference), Activity.Theme))); } int GetColorResForDiff(int diff) { if (diff > 0) { return(Resource.Color.LimeAccentColour); } if (diff < 0) { return(global::Android.Resource.Color.HoloRedDark); } return(ResourceExtension.BrushTextRes); } string ScoreToString(float score) { return(score == 0 ? "?" : score.ToString("N0")); } }