content: package com.google.samples.smartlock.sms_verify.ui;
  
  
  import android.os.Bundle;
  import android.preference.Preference;
  import android.preference.PreferenceActivity;
  import android.preference.PreferenceScreen;
  import androidx.appcompat.app.ActionBar;
  import android.preference.PreferenceFragment;
  import android.view.MenuItem;
  
  import com.google.samples.smartlock.sms_verify.AppSignatureHelper;
  import com.google.samples.smartlock.sms_verify.R;
  
  import java.util.ArrayList;
  
  /**
   * A {@link PreferenceActivity} that presents a set of application settings. On
   * handset devices, settings are presented as a single list. On tablets,
   * settings are split by category, with category headers shown to the left of
   * the list of settings.
   * <p>
   * See <a href="http://developer.android.com/design/patterns/settings.html">
   * Android Design: Settings</a> for design guidelines and the <a
   * href="http://developer.android.com/guide/topics/ui/settings.html">Settings
   * API Guide</a> for more information on developing a Settings UI.
   */
  public class SettingsActivity extends AppCompatPreferenceActivity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setupActionBar();
          getFragmentManager().beginTransaction().replace(android.R.id.content,
                  new SettingsFragment()).commit();
      }
  
      /**
       * Set up the {@link android.app.ActionBar}, if the API is available.
       */
      private void setupActionBar() {
          ActionBar actionBar = getSupportActionBar();
          if (actionBar != null) {
              // Show the Up button in the action bar.
              actionBar.setDisplayHomeAsUpEnabled(true);
          }
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
              case android.R.id.home:
                  onBackPressed();
                  return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
      public static class SettingsFragment extends PreferenceFragment {
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
  
              addPreferencesFromResource(R.xml.pref_main);
  
              PreferenceScreen screen = getPreferenceScreen();
              AppSignatureHelper signatureHelper = new AppSignatureHelper(getActivity());
  
              ArrayList<String> appSignatures = signatureHelper.getAppSignatures();
              Preference pref = screen.findPreference("app_signature");
              if (!appSignatures.isEmpty() && pref != null) {
                  pref.setSummary(appSignatures.get(0));
              }
          }
  
      }
  }
  