2 * Copyright 2017 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
6 * Privacy Browser is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Privacy Browser is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
20 package com.stoutner.privacybrowser.activities;
22 import android.content.Intent;
23 import android.os.Bundle;
24 import android.support.v7.app.ActionBar;
25 import android.support.v7.app.AppCompatActivity;
26 import android.support.v7.widget.Toolbar;
28 import com.stoutner.privacybrowser.R;
29 import com.stoutner.privacybrowser.fragments.DomainSettingsFragment;
31 public class DomainSettingsActivity extends AppCompatActivity {
33 protected void onCreate(Bundle savedInstanceState) {
34 super.onCreate(savedInstanceState);
35 setContentView(R.layout.domain_settings_coordinatorlayout);
37 // We ned to use `SupportActionBar` from `android.support.v7.app.ActionBar` until the minimum API is >= 21.
38 Toolbar domainSettingsAppBar = (Toolbar) findViewById(R.id.domain_settings_toolbar);
39 setSupportActionBar(domainSettingsAppBar);
41 // Display the home arrow on `appBar`.
42 final ActionBar appBar = getSupportActionBar();
43 assert appBar != null; // This assert removes the incorrect lint warning in Android Studio on the following line that `appBar` might be `null`.
44 appBar.setDisplayHomeAsUpEnabled(true);
46 // Get the intent that started the activity.
47 final Intent launchingIntent = getIntent();
49 // Extract the `databaseID`. The default value is `0`.
50 int databaseId = launchingIntent.getIntExtra(DomainSettingsFragment.DATABASE_ID, 0);
52 // Store `databaseId` in `argumentsBundle`.
53 Bundle argumentsBundle = new Bundle();
54 argumentsBundle.putInt(DomainSettingsFragment.DATABASE_ID, databaseId);
56 // Add `argumentsBundle` to `domainSettingsFragment`.
57 DomainSettingsFragment domainSettingsFragment = new DomainSettingsFragment();
58 domainSettingsFragment.setArguments(argumentsBundle);
60 // Display `domainSettingsFragment`.
61 getSupportFragmentManager().beginTransaction().replace(R.id.domain_settings_linearlayout, domainSettingsFragment).commit();