mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-29 13:17:43 +00:00
Set user preferred theme when activities are created
BUG: 422473
This commit is contained in:
parent
791c82b91a
commit
8e09936692
@ -47,6 +47,7 @@ public class BigscreenActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
|
|
||||||
setContentView(R.layout.activity_bigscreen);
|
setContentView(R.layout.activity_bigscreen);
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ public class FindMyPhoneActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
|
|
||||||
setContentView(R.layout.activity_find_my_phone);
|
setContentView(R.layout.activity_find_my_phone);
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import org.kde.kdeconnect.BackgroundService;
|
import org.kde.kdeconnect.BackgroundService;
|
||||||
|
import org.kde.kdeconnect.UserInterface.ThemeUtil;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
public class MousePadActivity extends AppCompatActivity implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener, MousePadGestureDetector.OnGestureListener {
|
public class MousePadActivity extends AppCompatActivity implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener, MousePadGestureDetector.OnGestureListener {
|
||||||
@ -85,6 +86,7 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
|
|
||||||
setContentView(R.layout.activity_mousepad);
|
setContentView(R.layout.activity_mousepad);
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ import org.kde.kdeconnect.BackgroundService;
|
|||||||
import org.kde.kdeconnect.Helpers.VideoUrlsHelper;
|
import org.kde.kdeconnect.Helpers.VideoUrlsHelper;
|
||||||
import org.kde.kdeconnect.NetworkPacket;
|
import org.kde.kdeconnect.NetworkPacket;
|
||||||
import org.kde.kdeconnect.Plugins.SystemvolumePlugin.SystemvolumeFragment;
|
import org.kde.kdeconnect.Plugins.SystemvolumePlugin.SystemvolumeFragment;
|
||||||
|
import org.kde.kdeconnect.UserInterface.ThemeUtil;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@ -377,6 +378,7 @@ public class MprisActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
setContentView(R.layout.activity_mpris);
|
setContentView(R.layout.activity_mpris);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ import android.widget.CheckedTextView;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import org.kde.kdeconnect.BackgroundService;
|
import org.kde.kdeconnect.BackgroundService;
|
||||||
|
import org.kde.kdeconnect.UserInterface.ThemeUtil;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -103,6 +104,7 @@ public class NotificationFilterActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
setContentView(R.layout.activity_notification_filter);
|
setContentView(R.layout.activity_notification_filter);
|
||||||
appDatabase = new AppDatabase(NotificationFilterActivity.this, false);
|
appDatabase = new AppDatabase(NotificationFilterActivity.this, false);
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ import androidx.core.content.ContextCompat;
|
|||||||
import androidx.media.VolumeProviderCompat;
|
import androidx.media.VolumeProviderCompat;
|
||||||
|
|
||||||
import org.kde.kdeconnect.BackgroundService;
|
import org.kde.kdeconnect.BackgroundService;
|
||||||
|
import org.kde.kdeconnect.UserInterface.ThemeUtil;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
public class PresenterActivity extends AppCompatActivity implements SensorEventListener {
|
public class PresenterActivity extends AppCompatActivity implements SensorEventListener {
|
||||||
@ -92,6 +93,7 @@ public class PresenterActivity extends AppCompatActivity implements SensorEventL
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
|
|
||||||
setContentView(R.layout.activity_presenter);
|
setContentView(R.layout.activity_presenter);
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.kde.kdeconnect.BackgroundService;
|
import org.kde.kdeconnect.BackgroundService;
|
||||||
import org.kde.kdeconnect.UserInterface.List.ListAdapter;
|
import org.kde.kdeconnect.UserInterface.List.ListAdapter;
|
||||||
|
import org.kde.kdeconnect.UserInterface.ThemeUtil;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -93,6 +94,7 @@ public class RunCommandActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
setContentView(R.layout.activity_runcommand);
|
setContentView(R.layout.activity_runcommand);
|
||||||
|
|
||||||
deviceId = getIntent().getStringExtra("deviceId");
|
deviceId = getIntent().getStringExtra("deviceId");
|
||||||
|
@ -9,6 +9,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.kde.kdeconnect.BackgroundService;
|
import org.kde.kdeconnect.BackgroundService;
|
||||||
import org.kde.kdeconnect.Device;
|
import org.kde.kdeconnect.Device;
|
||||||
|
import org.kde.kdeconnect.UserInterface.ThemeUtil;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -18,6 +19,7 @@ public class RunCommandUrlActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
if (getIntent().getAction() != null) {
|
if (getIntent().getAction() != null) {
|
||||||
|
@ -10,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import org.kde.kdeconnect.BackgroundService;
|
import org.kde.kdeconnect.BackgroundService;
|
||||||
import org.kde.kdeconnect.Device;
|
import org.kde.kdeconnect.Device;
|
||||||
import org.kde.kdeconnect.UserInterface.List.ListAdapter;
|
import org.kde.kdeconnect.UserInterface.List.ListAdapter;
|
||||||
|
import org.kde.kdeconnect.UserInterface.ThemeUtil;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -21,6 +22,7 @@ public class RunCommandWidgetDeviceSelector extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle bundle) {
|
protected void onCreate(Bundle bundle) {
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
|
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
setContentView(R.layout.widget_remotecommandplugin_dialog);
|
setContentView(R.layout.widget_remotecommandplugin_dialog);
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import android.util.Log;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.kde.kdeconnect.BackgroundService;
|
import org.kde.kdeconnect.BackgroundService;
|
||||||
|
import org.kde.kdeconnect.UserInterface.ThemeUtil;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -44,6 +45,7 @@ public class SendFileActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
|
|
||||||
mDeviceId = getIntent().getStringExtra("deviceId");
|
mDeviceId = getIntent().getStringExtra("deviceId");
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ import org.kde.kdeconnect.Device;
|
|||||||
import org.kde.kdeconnect.UserInterface.List.EntryItem;
|
import org.kde.kdeconnect.UserInterface.List.EntryItem;
|
||||||
import org.kde.kdeconnect.UserInterface.List.ListAdapter;
|
import org.kde.kdeconnect.UserInterface.List.ListAdapter;
|
||||||
import org.kde.kdeconnect.UserInterface.List.SectionItem;
|
import org.kde.kdeconnect.UserInterface.List.SectionItem;
|
||||||
|
import org.kde.kdeconnect.UserInterface.ThemeUtil;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -123,6 +124,7 @@ public class ShareActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
|
|
||||||
setContentView(R.layout.devices_list);
|
setContentView(R.layout.devices_list);
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
|
|||||||
getDelegate().installViewFactory();
|
getDelegate().installViewFactory();
|
||||||
getDelegate().onCreate(savedInstanceState);
|
getDelegate().onCreate(savedInstanceState);
|
||||||
// The superclass's onCreate() method calls setContentView, so this ThemeUtil call must be before that
|
// The superclass's onCreate() method calls setContentView, so this ThemeUtil call must be before that
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ public class CustomDevicesActivity extends AppCompatActivity implements CustomDe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.activity_custom_devices);
|
setContentView(R.layout.activity_custom_devices);
|
||||||
|
@ -69,6 +69,7 @@ public class MainActivity extends AppCompatActivity implements SharedPreferences
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
@ -44,6 +44,7 @@ public class PluginSettingsActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.activity_plugin_settings);
|
setContentView(R.layout.activity_plugin_settings);
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package org.kde.kdeconnect.UserInterface;
|
package org.kde.kdeconnect.UserInterface;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,4 +38,13 @@ public class ThemeUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an activity is created for the first time to reliably load correct theme.
|
||||||
|
**/
|
||||||
|
public static void setUserPreferredTheme(Activity activity) {
|
||||||
|
String appTheme = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||||
|
.getString("theme_pref", DEFAULT_MODE);
|
||||||
|
applyTheme(appTheme);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ public class TrustedNetworksActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
ThemeUtil.setUserPreferredTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.trusted_network_list);
|
setContentView(R.layout.trusted_network_list);
|
||||||
trustedNetworksView = findViewById(android.R.id.list);
|
trustedNetworksView = findViewById(android.R.id.list);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user