diff options
Diffstat (limited to 'samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/SettingsActivity.java')
-rw-r--r-- | samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/SettingsActivity.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/SettingsActivity.java b/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/SettingsActivity.java new file mode 100644 index 000000000..3cc1aaf62 --- /dev/null +++ b/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/SettingsActivity.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2023 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 com.example.android.vdmdemo.host; + +import android.os.Bundle; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.preference.PreferenceFragmentCompat; + +import dagger.hilt.android.AndroidEntryPoint; + +import javax.inject.Inject; + +/** VDM Host Settings activity. */ +@AndroidEntryPoint(AppCompatActivity.class) +public class SettingsActivity extends Hilt_SettingsActivity { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_settings); + Toolbar toolbar = requireViewById(R.id.main_tool_bar); + setSupportActionBar(toolbar); + toolbar.setNavigationOnClickListener(v -> finish()); + setTitle(getTitle() + " " + getString(R.string.settings)); + } + + @AndroidEntryPoint(PreferenceFragmentCompat.class) + public static final class SettingsFragment extends Hilt_SettingsActivity_SettingsFragment { + + @Inject PreferenceController mPreferenceController; + + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { + setPreferencesFromResource(R.xml.preferences, rootKey); + mPreferenceController.evaluate(getPreferenceManager()); + } + } +} |