2015-06-13 23:42:07 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
package org.kde.kdeconnect.UserInterface;
|
|
|
|
|
|
|
|
import android.content.res.Configuration;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.preference.PreferenceActivity;
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
2015-09-09 12:34:42 -07:00
|
|
|
import org.kde.kdeconnect.BackgroundService;
|
|
|
|
|
2018-12-27 15:40:57 +01:00
|
|
|
import androidx.annotation.LayoutRes;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.appcompat.app.ActionBar;
|
|
|
|
import androidx.appcompat.app.AppCompatDelegate;
|
|
|
|
import androidx.appcompat.widget.Toolbar;
|
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
/**
|
|
|
|
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
|
|
|
|
* to be used with AppCompat.
|
2018-03-03 16:06:52 +01:00
|
|
|
* <p>
|
2015-06-13 23:42:07 -07:00
|
|
|
* This technique can be used with an {@link android.app.Activity} class, not just
|
|
|
|
* {@link android.preference.PreferenceActivity}.
|
|
|
|
*/
|
|
|
|
public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
|
|
|
|
|
|
|
|
private AppCompatDelegate mDelegate;
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
getDelegate().installViewFactory();
|
|
|
|
getDelegate().onCreate(savedInstanceState);
|
Add a dark theme
Summary:
BUG: 375376
This revision adds dark mode support to the app ( T7044 ). It does so by injecting
theme information into each activity, and making sure that all Views
define their colors by reference to theme attributes.
In order to make this work, all of the buttons with images (like the list
of available devices) now are tinted according to the theme.
While all versions of android support the theme, only devices running
Android ICS or higher will have a toggle button in the drawer.
Test Plan: Open all the screens, both with and without the dark theme on.
Reviewers: #kde_connect, mtijink, #vdg, nicolasfella
Reviewed By: #kde_connect, mtijink, nicolasfella
Subscribers: apol, ngraham, nicolasfella, mtijink
Tags: #kde_connect
Differential Revision: https://phabricator.kde.org/D11694
2018-04-23 18:31:44 +02:00
|
|
|
// The superclass's onCreate() method calls setContentView, so this ThemeUtil call must be before that
|
|
|
|
ThemeUtil.setUserPreferredTheme(this);
|
2015-06-13 23:42:07 -07:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
@Override
|
|
|
|
protected void onPostCreate(Bundle savedInstanceState) {
|
|
|
|
super.onPostCreate(savedInstanceState);
|
|
|
|
getDelegate().onPostCreate(savedInstanceState);
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
public ActionBar getSupportActionBar() {
|
|
|
|
return getDelegate().getSupportActionBar();
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
public void setSupportActionBar(@Nullable Toolbar toolbar) {
|
|
|
|
getDelegate().setSupportActionBar(toolbar);
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-08-10 00:26:58 -07:00
|
|
|
@NonNull
|
2015-06-13 23:42:07 -07:00
|
|
|
@Override
|
|
|
|
public MenuInflater getMenuInflater() {
|
|
|
|
return getDelegate().getMenuInflater();
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
@Override
|
|
|
|
public void setContentView(@LayoutRes int layoutResID) {
|
|
|
|
getDelegate().setContentView(layoutResID);
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
@Override
|
|
|
|
public void setContentView(View view) {
|
|
|
|
getDelegate().setContentView(view);
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
@Override
|
|
|
|
public void setContentView(View view, ViewGroup.LayoutParams params) {
|
|
|
|
getDelegate().setContentView(view, params);
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
@Override
|
|
|
|
public void addContentView(View view, ViewGroup.LayoutParams params) {
|
|
|
|
getDelegate().addContentView(view, params);
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
@Override
|
|
|
|
protected void onPostResume() {
|
|
|
|
super.onPostResume();
|
|
|
|
getDelegate().onPostResume();
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
@Override
|
|
|
|
protected void onTitleChanged(CharSequence title, int color) {
|
|
|
|
super.onTitleChanged(title, color);
|
|
|
|
getDelegate().setTitle(title);
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
@Override
|
|
|
|
public void onConfigurationChanged(Configuration newConfig) {
|
|
|
|
super.onConfigurationChanged(newConfig);
|
|
|
|
getDelegate().onConfigurationChanged(newConfig);
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
@Override
|
|
|
|
protected void onDestroy() {
|
|
|
|
super.onDestroy();
|
|
|
|
getDelegate().onDestroy();
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
|
|
|
@Override
|
2015-06-13 23:42:07 -07:00
|
|
|
public void invalidateOptionsMenu() {
|
|
|
|
getDelegate().invalidateOptionsMenu();
|
|
|
|
}
|
2015-09-09 12:30:13 -07:00
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
private AppCompatDelegate getDelegate() {
|
|
|
|
if (mDelegate == null) {
|
|
|
|
mDelegate = AppCompatDelegate.create(this, null);
|
|
|
|
}
|
|
|
|
return mDelegate;
|
|
|
|
}
|
2015-09-09 12:34:42 -07:00
|
|
|
|
|
|
|
|
2015-06-13 23:42:07 -07:00
|
|
|
}
|