SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
UI optimization for night
Keishin Yokomaku @ Drivemode, Inc.
potatotips #23
1
@KeithYokoma
• Keishin Yokomaku at Drivemode, Inc.
• Work
• Android apps
• Android Training and its publication
• Like
• Bicycle, Photography, Tumblr and Motorsport
• Preferred Hashtag: #また闇の話してる……
2
No darkness today😂
3
Using phone
in the darkness…
4
5
6
7
“My eyes!!!!!”
“Bright display is dazzling eyes”
8
“Is it enough to use
auto adjustment of display brightness?”
10
“No”
11
Brightness of colours
• Colour properties of brightness
• HSL (Hue, Saturation, Lightness; a.k.a HSB or HSV)
• Bright colours (Brightness = 100%)
• Dark colours (Brightness = 50%)
12
Theme
• Set various colours on various parts of the application with Theme.
• Separate themes between daytime and night.
• You can change your theme at runtime with
• Activity#setTheme()
• Note: Call Activity#setTheme() before calling Activity#onCreate()
13
14
“When should we change our theme?”
Changing theme
• Dark theme during nighttime(after sunset and before sunrise)
• Dark theme under dark places(using illuminance sensors)
15
Sunrise equation
• Equation to calculate sunrise and sunset time
• https://en.wikipedia.org/wiki/Sunrise_equation
• The implementation is available on AOSP
• TwilightCalculator.java (http://bit.ly/1T2A0hF)
• TwilightManager.java (http://bit.ly/1QEG8yr)
• Calculates sunrise/sunset from date(epoch), latitude and longitude
16
Using TwilightCalculator
public class ThemeManager {
private final TwilightCalculator mCalculator;
private final LocationManager mLocationManager;
public void prepare() {
Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
mCalculator.calculateTwilight(System.currentTimeMillis(),
location.getLatitude(), location.longitude());
} else {
// request location on LocationManager and get updated location to calculate twilight
}
}
public boolean isInNight() {
long now = System.currentTimeMillis();
return now > mCalculator.mSunset || now < mCalculator.mSunrise;
}
}
17
Using TwilightCalculator
public class ThemeManager {
private final TwilightCalculator mCalculator;
private final LocationManager mLocationManager;
public void prepare() {
Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
mCalculator.calculateTwilight(System.currentTimeMillis(),
location.getLatitude(), location.longitude());
} else {
// request location on LocationManager and get updated location to calculate twilight
}
}
public boolean isInNight() {
long now = System.currentTimeMillis();
return now > mCalculator.mSunset || now < mCalculator.mSunrise;
}
}
18
Using TwilightCalculator
public class ThemeManager {
private final TwilightCalculator mCalculator;
private final LocationManager mLocationManager;
public void prepare() {
Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
mCalculator.calculateTwilight(System.currentTimeMillis(),
location.getLatitude(), location.longitude());
} else {
// request location on LocationManager and get updated location to calculate twilight
}
}
public boolean isInNight() {
long now = System.currentTimeMillis();
return now > mCalculator.mSunset || now < mCalculator.mSunrise;
}
}
19
Running the calculation
• Once per day on date changed
• Intent.ACTION_DATE_CHANGED: has some bugs…
• AlarmManager#setExact() or set(): seems fine
• When timezone is changed
• If you use TwilightManager…
• It automatically calculate sunrise/sunset time so no further stuff needed
20
“Why don’t you use UiModeManager?”
21
UiModeManager
• Pros
• Easily change ui mode with sensors and location
• Be able to locate resources with qualifier for night
• Cons
• Need to enable CarMode which brings huge Android Auto logo in front.
• Steering wheel notification icon is always on the status bar.
22
UI optimization for night
Keishin Yokomaku @ Drivemode, Inc.
potatotips #23
23

Contenu connexe

Plus de Keishin Yokomaku

Plus de Keishin Yokomaku (14)

Popup view on Mortar
Popup view on MortarPopup view on Mortar
Popup view on Mortar
 
Regexp in Android and Java
Regexp in Android and JavaRegexp in Android and Java
Regexp in Android and Java
 
Deep Inside Android Hacks
Deep Inside Android HacksDeep Inside Android Hacks
Deep Inside Android Hacks
 
Make it compatible
Make it compatibleMake it compatible
Make it compatible
 
Signature
SignatureSignature
Signature
 
Android Media Hacks
Android Media HacksAndroid Media Hacks
Android Media Hacks
 
Null, the Abyss
Null, the AbyssNull, the Abyss
Null, the Abyss
 
?
??
?
 
Building stable and flexible libraries
Building stable and flexible librariesBuilding stable and flexible libraries
Building stable and flexible libraries
 
Typeface
TypefaceTypeface
Typeface
 
Version Management
Version ManagementVersion Management
Version Management
 
イカしたライブラリを作った話
イカしたライブラリを作った話イカしたライブラリを作った話
イカしたライブラリを作った話
 
Google I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と GradleGoogle I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と Gradle
 
自己組織化
自己組織化自己組織化
自己組織化
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

UI optimization for night

  • 1. UI optimization for night Keishin Yokomaku @ Drivemode, Inc. potatotips #23 1
  • 2. @KeithYokoma • Keishin Yokomaku at Drivemode, Inc. • Work • Android apps • Android Training and its publication • Like • Bicycle, Photography, Tumblr and Motorsport • Preferred Hashtag: #また闇の話してる…… 2
  • 4. Using phone in the darkness… 4
  • 5. 5
  • 6. 6
  • 8. “Bright display is dazzling eyes” 8
  • 9.
  • 10. “Is it enough to use auto adjustment of display brightness?” 10
  • 12. Brightness of colours • Colour properties of brightness • HSL (Hue, Saturation, Lightness; a.k.a HSB or HSV) • Bright colours (Brightness = 100%) • Dark colours (Brightness = 50%) 12
  • 13. Theme • Set various colours on various parts of the application with Theme. • Separate themes between daytime and night. • You can change your theme at runtime with • Activity#setTheme() • Note: Call Activity#setTheme() before calling Activity#onCreate() 13
  • 14. 14 “When should we change our theme?”
  • 15. Changing theme • Dark theme during nighttime(after sunset and before sunrise) • Dark theme under dark places(using illuminance sensors) 15
  • 16. Sunrise equation • Equation to calculate sunrise and sunset time • https://en.wikipedia.org/wiki/Sunrise_equation • The implementation is available on AOSP • TwilightCalculator.java (http://bit.ly/1T2A0hF) • TwilightManager.java (http://bit.ly/1QEG8yr) • Calculates sunrise/sunset from date(epoch), latitude and longitude 16
  • 17. Using TwilightCalculator public class ThemeManager { private final TwilightCalculator mCalculator; private final LocationManager mLocationManager; public void prepare() { Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location != null) { mCalculator.calculateTwilight(System.currentTimeMillis(), location.getLatitude(), location.longitude()); } else { // request location on LocationManager and get updated location to calculate twilight } } public boolean isInNight() { long now = System.currentTimeMillis(); return now > mCalculator.mSunset || now < mCalculator.mSunrise; } } 17
  • 18. Using TwilightCalculator public class ThemeManager { private final TwilightCalculator mCalculator; private final LocationManager mLocationManager; public void prepare() { Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location != null) { mCalculator.calculateTwilight(System.currentTimeMillis(), location.getLatitude(), location.longitude()); } else { // request location on LocationManager and get updated location to calculate twilight } } public boolean isInNight() { long now = System.currentTimeMillis(); return now > mCalculator.mSunset || now < mCalculator.mSunrise; } } 18
  • 19. Using TwilightCalculator public class ThemeManager { private final TwilightCalculator mCalculator; private final LocationManager mLocationManager; public void prepare() { Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location != null) { mCalculator.calculateTwilight(System.currentTimeMillis(), location.getLatitude(), location.longitude()); } else { // request location on LocationManager and get updated location to calculate twilight } } public boolean isInNight() { long now = System.currentTimeMillis(); return now > mCalculator.mSunset || now < mCalculator.mSunrise; } } 19
  • 20. Running the calculation • Once per day on date changed • Intent.ACTION_DATE_CHANGED: has some bugs… • AlarmManager#setExact() or set(): seems fine • When timezone is changed • If you use TwilightManager… • It automatically calculate sunrise/sunset time so no further stuff needed 20
  • 21. “Why don’t you use UiModeManager?” 21
  • 22. UiModeManager • Pros • Easily change ui mode with sensors and location • Be able to locate resources with qualifier for night • Cons • Need to enable CarMode which brings huge Android Auto logo in front. • Steering wheel notification icon is always on the status bar. 22
  • 23. UI optimization for night Keishin Yokomaku @ Drivemode, Inc. potatotips #23 23