taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

SettingsActivity.java (2488B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2024 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 
     13   You should have received a copy of the GNU General Public License along with
     14   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 */
     16 
     17 package net.taler.donauverificator;
     18 
     19 import android.os.Bundle;
     20 import android.view.MenuItem;
     21 
     22 import androidx.annotation.Nullable;
     23 import androidx.appcompat.app.ActionBar;
     24 import androidx.appcompat.app.AppCompatActivity;
     25 import com.google.android.material.appbar.MaterialToolbar;
     26 import androidx.preference.PreferenceFragmentCompat;
     27 
     28 public class SettingsActivity extends AppCompatActivity {
     29 
     30     public static final String KEY_DEVELOPER_MODE = "pref_developer_mode";
     31     public static final String KEY_AUTO_OPEN_DONAU = "pref_auto_open_donau";
     32 
     33     @Override
     34     protected void onCreate(@Nullable Bundle savedInstanceState) {
     35         super.onCreate(savedInstanceState);
     36         setContentView(R.layout.activity_settings);
     37 
     38         MaterialToolbar toolbar = findViewById(R.id.settingsToolbar);
     39         setSupportActionBar(toolbar);
     40         toolbar.setNavigationOnClickListener(v -> finish());
     41 
     42         if (savedInstanceState == null) {
     43             getSupportFragmentManager()
     44                     .beginTransaction()
     45                     .replace(R.id.settings_container, new SettingsFragment())
     46                     .commit();
     47         }
     48 
     49         ActionBar actionBar = getSupportActionBar();
     50         if (actionBar != null) {
     51             actionBar.setDisplayHomeAsUpEnabled(true);
     52         }
     53     }
     54 
     55     @Override
     56     public boolean onOptionsItemSelected(MenuItem item) {
     57         if (item.getItemId() == android.R.id.home) {
     58             finish();
     59             return true;
     60         }
     61         return super.onOptionsItemSelected(item);
     62     }
     63 
     64     public static class SettingsFragment extends PreferenceFragmentCompat {
     65 
     66         @Override
     67         public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
     68             setPreferencesFromResource(R.xml.preferences, rootKey);
     69 
     70         }
     71     }
     72 }