]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blob - app/src/main/java/com/stoutner/privacybrowser/activities/DomainSettingsActivity.java
Add icons to `DomainSettingsFragment`.
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / DomainSettingsActivity.java
1 /*
2  * Copyright 2017 Soren Stoutner <soren@stoutner.com>.
3  *
4  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 package com.stoutner.privacybrowser.activities;
21
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;
27
28 import com.stoutner.privacybrowser.R;
29 import com.stoutner.privacybrowser.fragments.DomainSettingsFragment;
30
31 public class DomainSettingsActivity extends AppCompatActivity {
32     @Override
33     protected void onCreate(Bundle savedInstanceState) {
34         super.onCreate(savedInstanceState);
35         setContentView(R.layout.domain_settings_coordinatorlayout);
36
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);
40
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);
45
46         // Get the intent that started the activity.
47         final Intent launchingIntent = getIntent();
48
49         // Extract the `databaseID`.  The default value is `1`.
50         int databaseId = launchingIntent.getIntExtra(DomainSettingsFragment.DATABASE_ID, 1);
51
52         // Store `databaseId` in `argumentsBundle`.
53         Bundle argumentsBundle = new Bundle();
54         argumentsBundle.putInt(DomainSettingsFragment.DATABASE_ID, databaseId);
55
56         // Add `argumentsBundle` to `domainSettingsFragment`.
57         DomainSettingsFragment domainSettingsFragment = new DomainSettingsFragment();
58         domainSettingsFragment.setArguments(argumentsBundle);
59
60         // Display `domainSettingsFragment`.
61         getSupportFragmentManager().beginTransaction().replace(R.id.domain_settings_linearlayout, domainSettingsFragment).commit();
62     }
63 }