EditText domainNameEditText = (EditText) dialogFragment.getDialog().findViewById(R.id.domain_name_edittext);
String domainNameString = domainNameEditText.getText().toString();
- // Create the domain.
- domainsDatabaseHelper.addDomain(domainNameString);
+ // Create the domain and store the database ID in `currentDomainDatabaseId`.
+ currentDomainDatabaseId = domainsDatabaseHelper.addDomain(domainNameString);
- // Populate the `ListView`.
- populateDomainsListView();
+ // Add `currentDomainDatabaseId` to `argumentsBundle`.
+ Bundle argumentsBundle = new Bundle();
+ argumentsBundle.putInt(DomainSettingsFragment.DATABASE_ID, currentDomainDatabaseId);
+
+ // Add `argumentsBundle` to `domainSettingsFragment`.
+ DomainSettingsFragment domainSettingsFragment = new DomainSettingsFragment();
+ domainSettingsFragment.setArguments(argumentsBundle);
+
+ // Display the newly created domain.
+ if (twoPanedMode) {
+
+ } else {
+ // Hide `add_domain_fab`.
+ addDomainFAB.setVisibility(View.GONE);
+
+ // Show and enable `deleteMenuItem`.
+ DomainsActivity.deleteMenuItem.setVisible(true);
+
+ // Set `domainSettingsFragmentDisplayed`.
+ DomainsActivity.domainSettingsFragmentDisplayed = true;
+
+ // Display `domainSettingsFragment`.
+ supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
+ }
}
private void saveDomainSettings() {
return domainsDatabase.rawQuery(GET_CURSOR_FOR_DOMAIN_NAME, null);
}
- public void addDomain(String domainName) {
+ public int addDomain(String domainName) {
// Store the domain data in a `ContentValues`.
ContentValues domainContentValues = new ContentValues();
// Get a writable database handle.
SQLiteDatabase domainsDatabase = this.getWritableDatabase();
- // Insert a new row. The second argument is `null`, which makes it so that a completely null row cannot be created.
- domainsDatabase.insert(DOMAINS_TABLE, null, domainContentValues);
+ // Insert a new row and store the resulting database ID. The second argument is `null`, which makes it so that a completely null row cannot be created.
+ int newDomainDatabaseId = (int) domainsDatabase.insert(DOMAINS_TABLE, null, domainContentValues);
// Close the database handle.
domainsDatabase.close();
+
+ return newDomainDatabaseId;
}
public void saveDomain(int databaseId, String domainName, boolean javaScriptEnabled, boolean firstPartyCookiesEnabled, boolean thirdPartyCookiesEnabled, boolean domStorageEnabled, boolean formDataEnabled, String userAgent, int fontSize,