From: Soren Stoutner Date: Sat, 11 Mar 2017 22:41:00 +0000 (-0700) Subject: Add icons to `DomainSettingsFragment`. X-Git-Tag: v2.0~6 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=30199e211f320d781774a8cfa683317c71635871;p=PrivacyBrowserAndroid.git Add icons to `DomainSettingsFragment`. --- diff --git a/.idea/dictionaries/soren.xml b/.idea/dictionaries/soren.xml index 84598132..4833f591 100644 --- a/.idea/dictionaries/soren.xml +++ b/.idea/dictionaries/soren.xml @@ -23,6 +23,7 @@ cname commitdiff coordinatorlayout + customuseragent didn displayorder dname @@ -32,12 +33,18 @@ dwallach eadd edittext + enabledomstorage + enablefirstpartycookies + enableformdata + enablejavascript + enablethirdpartycookies exynos favoriteicon fbee fdfilter fdid firebase + fontsize framelayout gerlach intl @@ -86,6 +93,9 @@ torproject uids uname + useragent + useragentname + useragentstring webkay webkitversion whatismyip diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 429fa66e..2d572fa7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -129,7 +129,8 @@ + `tools:ignore="unusedAttribute"` removes the lint warning that `persistableMode` does not apply to API < 21. + `android:windowSoftInputMode="stateAlwaysHidden"` removes the keyboard from the screen, which is displayed because `ScrollViews` always focus the first `EditText` despite being told not to. --> diff --git a/app/src/main/assets/de/about_licenses.html b/app/src/main/assets/de/about_licenses.html index ecbb9b5d..dab96de5 100644 --- a/app/src/main/assets/de/about_licenses.html +++ b/app/src/main/assets/de/about_licenses.html @@ -65,6 +65,7 @@

ic_chrome_reader_mode.

ic_close.

ic_create_new_folder.

+

ic_devices_other.

ic_download.

ic_dns.

ic_edit.

@@ -84,6 +85,7 @@

ic_select_all.

ic_settings.

ic_subtitles.

+

ic_text_fields.

ic_vertical_align_bottom.

ic_vertical_align_top.

ic_web.

diff --git a/app/src/main/assets/en/about_licenses.html b/app/src/main/assets/en/about_licenses.html index 45d31095..290ef38f 100644 --- a/app/src/main/assets/en/about_licenses.html +++ b/app/src/main/assets/en/about_licenses.html @@ -63,6 +63,7 @@

ic_chrome_reader_mode.

ic_close.

ic_create_new_folder.

+

ic_devices_other.

ic_download.

ic_dns.

ic_edit.

@@ -82,6 +83,7 @@

ic_select_all.

ic_settings.

ic_subtitles.

+

ic_text_fields.

ic_vertical_align_bottom.

ic_vertical_align_top.

ic_web.

diff --git a/app/src/main/assets/en/images/ic_devices_other.png b/app/src/main/assets/en/images/ic_devices_other.png new file mode 100644 index 00000000..dcf7e12e Binary files /dev/null and b/app/src/main/assets/en/images/ic_devices_other.png differ diff --git a/app/src/main/assets/en/images/ic_text_fields.png b/app/src/main/assets/en/images/ic_text_fields.png new file mode 100644 index 00000000..de558366 Binary files /dev/null and b/app/src/main/assets/en/images/ic_text_fields.png differ diff --git a/app/src/main/assets/es/about_licenses.html b/app/src/main/assets/es/about_licenses.html index 8cc49e4d..0ffc6ab8 100644 --- a/app/src/main/assets/es/about_licenses.html +++ b/app/src/main/assets/es/about_licenses.html @@ -63,6 +63,7 @@

ic_chrome_reader_mode.

ic_close.

ic_create_new_folder.

+

ic_devices_other.

ic_download.

ic_dns.

ic_edit.

@@ -82,6 +83,7 @@

ic_select_all.

ic_settings.

ic_subtitles.

+

ic_text_fields.

ic_vertical_align_bottom.

ic_vertical_align_top.

ic_web.

diff --git a/app/src/main/assets/it/about_licenses.html b/app/src/main/assets/it/about_licenses.html index 60b4a600..43b94350 100644 --- a/app/src/main/assets/it/about_licenses.html +++ b/app/src/main/assets/it/about_licenses.html @@ -69,6 +69,7 @@

ic_chrome_reader_mode.

ic_close.

ic_create_new_folder.

+

ic_devices_other.

ic_download.

ic_dns.

ic_edit.

@@ -88,6 +89,7 @@

ic_select_all.

ic_settings.

ic_subtitles.

+

ic_text_fields.

ic_vertical_align_bottom.

ic_vertical_align_top.

ic_web.

diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/DomainSettingsActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/DomainSettingsActivity.java index ae3afa96..eba5f321 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/DomainSettingsActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/DomainSettingsActivity.java @@ -46,8 +46,8 @@ public class DomainSettingsActivity extends AppCompatActivity { // Get the intent that started the activity. final Intent launchingIntent = getIntent(); - // Extract the `databaseID`. The default value is `0`. - int databaseId = launchingIntent.getIntExtra(DomainSettingsFragment.DATABASE_ID, 0); + // Extract the `databaseID`. The default value is `1`. + int databaseId = launchingIntent.getIntExtra(DomainSettingsFragment.DATABASE_ID, 1); // Store `databaseId` in `argumentsBundle`. Bundle argumentsBundle = new Bundle(); diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.java index 0cc4d506..7cbe8d05 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.java @@ -67,7 +67,7 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo domainsDatabaseHelper = new DomainsDatabaseHelper(this, null, null, 0); // Determine if we are in two pane mode. `domains_settings_linearlayout` is only populated if two panes are present. - final boolean twoPaneMode = ((findViewById(R.id.domain_settings_linearlayout)) != null); + final boolean twoPaneMode = ((findViewById(R.id.domain_settings_scrollview)) != null); // Initialize `domainsListView`. domainsListView = (ListView) findViewById(R.id.domains_listview); @@ -80,9 +80,6 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo // Display the Domain Settings. if (twoPaneMode) { // Display a fragment in two paned mode. - // Highlight the selected domain. - domainsListView.setItemChecked(position, true); - // Store `databaseId` in `argumentsBundle`. Bundle argumentsBundle = new Bundle(); argumentsBundle.putInt(DomainSettingsFragment.DATABASE_ID, databaseId); @@ -92,7 +89,7 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo domainSettingsFragment.setArguments(argumentsBundle); // Display `domainSettingsFragment`. - getSupportFragmentManager().beginTransaction().replace(R.id.domain_settings_linearlayout, domainSettingsFragment).commit(); + getSupportFragmentManager().beginTransaction().replace(R.id.domain_settings_scrollview, domainSettingsFragment).commit(); } else { // Load the second activity on smaller screens. // Get a handle for the context. Context context = view.getContext(); diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutTabFragment.java b/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutTabFragment.java index b3e9e5a4..fec8d70c 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutTabFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/AboutTabFragment.java @@ -37,7 +37,7 @@ import com.stoutner.privacybrowser.R; public class AboutTabFragment extends Fragment { private int tabNumber; - // AboutTabFragment.createTab stores the tab number in the bundle arguments so it can be referenced from onCreate(). + // `AboutTabFragment.createTab` stores the tab number in the bundle arguments so it can be referenced from `onCreate()`. public static AboutTabFragment createTab(int tab) { Bundle thisTabArguments = new Bundle(); thisTabArguments.putInt("Tab", tab); @@ -51,7 +51,7 @@ public class AboutTabFragment extends Fragment { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Store the tab number in tabNumber. + // Store the tab number in `tabNumber`. tabNumber = getArguments().getInt("Tab"); } diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java b/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java index 3e28fc7f..a6214174 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java @@ -19,6 +19,7 @@ package com.stoutner.privacybrowser.fragments; +import android.content.Context; import android.database.Cursor; import android.os.Bundle; // We have to use `android.support.v4.app.Fragment` until minimum API >= 23. Otherwise we cannot call `getContext()`. @@ -26,7 +27,9 @@ import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ArrayAdapter; import android.widget.EditText; +import android.widget.Spinner; import com.stoutner.privacybrowser.R; import com.stoutner.privacybrowser.helpers.DomainsDatabaseHelper; @@ -51,6 +54,14 @@ public class DomainSettingsFragment extends Fragment { // Inflate `domain_settings`. `false` does not attach it to the root `container`. View domainSettingsView = inflater.inflate(R.layout.domain_settings, container, false); + // Get a handle for the `Context`. + Context context = getContext(); + + // Get handles for the views in the fragment. + EditText domainNameEditText = (EditText) domainSettingsView.findViewById(R.id.domain_settings_name_edittext); + Spinner userAgentSpinner = (Spinner) domainSettingsView.findViewById(R.id.domain_settings_user_agent_spinner); + Spinner fontSizeSpinner = (Spinner) domainSettingsView.findViewById(R.id.domain_settings_font_size_spinner); + // Initialize the database handler. `this` specifies the context. The two `nulls` do not specify the database name or a `CursorFactory`. // The `0` specifies the database version, but that is ignored and set instead using a constant in `DomainsDatabaseHelper`. DomainsDatabaseHelper domainsDatabaseHelper = new DomainsDatabaseHelper(getContext(), null, null, 0); @@ -59,11 +70,34 @@ public class DomainSettingsFragment extends Fragment { Cursor domainCursor = domainsDatabaseHelper.getCursorForId(databaseId); domainCursor.moveToFirst(); - // Get handles for the `EditTexts`. - EditText domainNameEditText = (EditText) domainSettingsView.findViewById(R.id.domain_settings_name_edittext); + // Save the `Cursor` entries as variables. + String domainNameString = domainCursor.getString(domainCursor.getColumnIndex(DomainsDatabaseHelper.DOMAIN)); + int fontSizeInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.FONT_SIZE)); + + // Create `ArrayAdapters` for the `Spinners`and their `entry values`. + ArrayAdapter userAgentArrayAdapter = ArrayAdapter.createFromResource(context, R.array.user_agent_entries, android.R.layout.simple_spinner_item); + ArrayAdapter userAgentEntryValuesArrayAdapter = ArrayAdapter.createFromResource(context, R.array.user_agent_entry_values, android.R.layout.simple_spinner_item); + ArrayAdapter fontSizeArrayAdapter = ArrayAdapter.createFromResource(context, R.array.default_font_size_entries, android.R.layout.simple_spinner_item); + ArrayAdapter fontSizeEntryValuesArrayAdapter = ArrayAdapter.createFromResource(context, R.array.default_font_size_entry_values, android.R.layout.simple_spinner_item); + + // Set the drop down style for the `ArrayAdapters`. + userAgentArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + fontSizeArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + + // Set the `ArrayAdapters` for the `Spinners`. + userAgentSpinner.setAdapter(userAgentArrayAdapter); + fontSizeSpinner.setAdapter(fontSizeArrayAdapter); + + // + // int userAgentArrayPosition = + + // Set the selected font size. + int fontSizeArrayPosition = fontSizeEntryValuesArrayAdapter.getPosition(String.valueOf(fontSizeInt)); + fontSizeSpinner.setSelection(fontSizeArrayPosition); + // Set the text from the database cursor. - domainNameEditText.setText(domainCursor.getString(domainCursor.getColumnIndex(DomainsDatabaseHelper.DOMAIN))); + domainNameEditText.setText(domainNameString); return domainSettingsView; } diff --git a/app/src/main/java/com/stoutner/privacybrowser/helpers/DomainsDatabaseHelper.java b/app/src/main/java/com/stoutner/privacybrowser/helpers/DomainsDatabaseHelper.java index 1a5c066b..5e792678 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/DomainsDatabaseHelper.java +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/DomainsDatabaseHelper.java @@ -32,7 +32,16 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper { private static final String _ID = "_id"; public static final String DOMAIN = "domain"; + public static final String FONT_SIZE = "fontsize"; + private static final String ENABLE_JAVASCRIPT = "enablejavascript"; + private static final String ENABLE_FIRST_PARTY_COOKIES = "enablefirstpartycookies"; + private static final String ENABLE_THIRD_PARTY_COOKIES = "enablethirdpartycookies"; + private static final String ENABLE_DOM_STORAGE = "enabledomstorage"; + private static final String ENABLE_FORM_DATA = "enableformdata"; + private static final String USER_AGENT_NAME = "useragentname"; + private static final String USER_AGENT_STRING = "useragentstring"; + private static final String CUSTOM_USER_AGENT_STRING = "customuseragent"; // Initialize the database. The lint warnings for the unused parameters are suppressed. public DomainsDatabaseHelper(Context context, @SuppressWarnings("UnusedParameters") String name, SQLiteDatabase.CursorFactory cursorFactory, @SuppressWarnings("UnusedParameters") int version) { @@ -44,7 +53,16 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper { // Setup the SQL string to create the `domains` table. final String CREATE_DOMAINS_TABLE = "CREATE TABLE " + DOMAINS_TABLE + " (" + _ID + " integer primary key, " + - DOMAIN + " text);"; + DOMAIN + " text, " + + ENABLE_JAVASCRIPT + " boolean, " + + ENABLE_FIRST_PARTY_COOKIES + " boolean, " + + ENABLE_THIRD_PARTY_COOKIES + " boolean, " + + ENABLE_DOM_STORAGE + " boolean, " + + ENABLE_FORM_DATA + " boolean, " + + USER_AGENT_NAME + " text, " + + USER_AGENT_STRING + " text, " + + CUSTOM_USER_AGENT_STRING + " text, " + + FONT_SIZE + " integer);"; // Create the `domains` table if it doesn't exist. domainsDatabase.execSQL(CREATE_DOMAINS_TABLE); @@ -83,8 +101,17 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper { // We need to store the domain data in a `ContentValues`. ContentValues domainContentValues = new ContentValues(); - // ID is created automatically. + // Create entries for each field in the database. The ID is created automatically. domainContentValues.put(DOMAIN, domainName); + domainContentValues.put(ENABLE_JAVASCRIPT, false); + domainContentValues.put(ENABLE_FIRST_PARTY_COOKIES, false); + domainContentValues.put(ENABLE_THIRD_PARTY_COOKIES, false); + domainContentValues.put(ENABLE_DOM_STORAGE, false); + domainContentValues.put(ENABLE_FORM_DATA, false); + domainContentValues.put(USER_AGENT_NAME, "Privacy Browser 1.0"); + domainContentValues.put(USER_AGENT_STRING, "PrivacyBrowser/1.0"); + domainContentValues.put(CUSTOM_USER_AGENT_STRING, "PrivacyBrowser/1.0"); + domainContentValues.put(FONT_SIZE, "100"); // Get a writable database handle. SQLiteDatabase domainsDatabase = this.getWritableDatabase(); diff --git a/app/src/main/res/drawable/about.xml b/app/src/main/res/drawable/about.xml index 20532efd..1057e2c4 100644 --- a/app/src/main/res/drawable/about.xml +++ b/app/src/main/res/drawable/about.xml @@ -1,4 +1,4 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/form_data_disabled.xml b/app/src/main/res/drawable/form_data_disabled.xml index b7226db6..7f44621f 100644 --- a/app/src/main/res/drawable/form_data_disabled.xml +++ b/app/src/main/res/drawable/form_data_disabled.xml @@ -1,5 +1,4 @@ - + + + + + + in 2016 - and are released under the GPLv3+ license. --> + + + + + + + + in 2016. - and are released under the GPLv3+ license. --> + + + + + + + + + + diff --git a/app/src/main/res/drawable/warning.xml b/app/src/main/res/drawable/warning.xml index 463aa30c..863c1262 100644 --- a/app/src/main/res/drawable/warning.xml +++ b/app/src/main/res/drawable/warning.xml @@ -1,6 +1,5 @@ - + - + android:layout_weight="3" /> \ No newline at end of file diff --git a/app/src/main/res/layout/domain_settings.xml b/app/src/main/res/layout/domain_settings.xml index a71cd610..725041ea 100644 --- a/app/src/main/res/layout/domain_settings.xml +++ b/app/src/main/res/layout/domain_settings.xml @@ -18,37 +18,230 @@ You should have received a copy of the GNU General Public License along with Privacy Browser. If not, see . --> - + android:focusable="true" + android:focusableInTouchMode="true" + android:descendantFocusability="beforeDescendants" > - + android:layout_width="match_parent" + android:layout_margin="12dp" + android:orientation="vertical" + android:divider="?android:attr/dividerVertical" + android:showDividers="middle" > - + - + android:layout_width="match_parent" + android:orientation="horizontal" > - - + + + + - - + + + + + + - + android:layout_width="match_parent" + android:orientation="horizontal" > + + + + + + + + + + + + + + + + + + + + + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/url_app_bar.xml b/app/src/main/res/layout/url_app_bar.xml index b2c7fb57..506e9c12 100644 --- a/app/src/main/res/layout/url_app_bar.xml +++ b/app/src/main/res/layout/url_app_bar.xml @@ -23,7 +23,8 @@ xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" - android:layout_width="match_parent" > + android:layout_width="match_parent" + tools:context=".activities.MainWebViewActivity" > Domain Settings Add Domain Add - Domain Name + Domain name Privacy Browser Guide diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4c8acdfd..ef87e8d0 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -24,15 +24,19 @@ @@ -53,4 +57,19 @@ + + + + \ No newline at end of file