2 * Copyright (C) 2013 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.server.twilight;
19 import java.text.DateFormat;
20 import java.util.Date;
23 * Describes whether it is day or night.
24 * This object is immutable.
26 public class TwilightState {
27 private final boolean mIsNight;
28 private final float mAmount;
30 TwilightState(boolean isNight, float amount) {
36 * Returns true if it is currently night time.
38 public boolean isNight() {
43 * For twilight affects that change gradually over time, this is the amount they
44 * should currently be in effect.
46 public float getAmount() {
51 public boolean equals(Object o) {
52 return o instanceof TwilightState && equals((TwilightState)o);
55 public boolean equals(TwilightState other) {
57 && mIsNight == other.mIsNight
58 && mAmount == other.mAmount;
62 public int hashCode() {
63 return 0; // don't care
67 public String toString() {
68 DateFormat f = DateFormat.getDateTimeInstance();
69 return "{TwilightState: isNight=" + mIsNight
70 + ", mAmount=" + mAmount