1941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes/* 2941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * Copyright (C) 2015 The Android Open Source Project 3941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * 4941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * Licensed under the Apache License, Version 2.0 (the "License"); 5941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * you may not use this file except in compliance with the License. 6941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * You may obtain a copy of the License at 7941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * 8941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * http://www.apache.org/licenses/LICENSE-2.0 9941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * 10941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * Unless required by applicable law or agreed to in writing, software 11941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * distributed under the License is distributed on an "AS IS" BASIS, 12941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * See the License for the specific language governing permissions and 14941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * limitations under the License. 15941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes */ 16941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes 17941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banespackage com.example.android.supportv7.app; 18941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes 19941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes 20941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banesimport android.os.Bundle; 21def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikasimport android.view.View; 22def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikas 23ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.Nullable; 24ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.appcompat.app.AppCompatActivity; 25ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.appcompat.app.AppCompatDelegate; 26def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikas 27def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikasimport com.example.android.supportv7.R; 28941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes 29941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes/** 30941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes * This demonstrates idiomatic usage of AppCompatActivity with Theme.AppCompat.DayNight 31941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes */ 32941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banespublic class AppCompatNightModeActivity extends AppCompatActivity { 33941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes 34941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes @Override 35941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes protected void onCreate(@Nullable Bundle savedInstanceState) { 36941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes super.onCreate(savedInstanceState); 37941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes setContentView(R.layout.appcompat_night_mode); 38941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes } 39941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes 40941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes public void setModeNightNo(View view) { 41941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO); 42941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes } 43941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes 44941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes public void setModeNightYes(View view) { 45941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); 46941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes } 47941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes 48941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes public void setModeNightAuto(View view) { 49941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_AUTO); 50941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes } 51941ec8ddcd762cc742ab4d71b5ac37d04666ee27Chris Banes}