Skip to content

Commit 703384c

Browse files
author
Gaukler Faun
committed
added password protection
1 parent b8dc24f commit 703384c

20 files changed

+726
-9
lines changed

LICENSE.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
This program is free software: you can redistribute it and/or modify
2+
it under the terms of the GNU General Public License as published by
3+
the Free Software Foundation, either version 3 of the License, or
4+
(at your option) any later version.
5+
6+
This program is distributed in the hope that it will be useful,
7+
but WITHOUT ANY WARRANTY; without even the implied warranty of
8+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9+
GNU General Public License for more details.
10+
11+
You should have received a copy of the GNU General Public License
12+
along with this program. If not, see <http://www.gnu.org/licenses/>.
13+
14+
**Used open source libraries:**
15+
16+
_android-file-chooser_
17+
https://github.com/hedzr/android-file-chooser
18+
19+
_Android-ObservableScrollView_
20+
https://github.com/ksoichiro/Android-ObservableScrollView
21+
22+
_browser_
23+
https://github.com/yoshihiroando/browser
24+
25+
_encrypted-userprefs_
26+
https://github.com/sveinungkb/encrypted-userprefs

app/src/main/AndroidManifest.xml

+7
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@
120120
android:launchMode="singleTask"
121121
android:theme="@style/AppTheme.NoActionBar" />
122122

123+
<activity
124+
android:name="de.baumann.browser.helper.Activity_password"
125+
android:launchMode="singleTask"
126+
android:label="@string/app_name"
127+
android:screenOrientation="portrait"
128+
android:theme="@style/AppTheme.NoActionBar" />
129+
123130
<provider
124131
android:name="android.support.v4.content.FileProvider"
125132
android:authorities="de.baumann.browser.provider"

app/src/main/java/de/baumann/browser/Bookmarks.java

+21-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848
import java.util.HashMap;
4949

5050
import de.baumann.browser.databases.Database_Bookmarks;
51+
import de.baumann.browser.helper.Activity_password;
5152
import de.baumann.browser.helper.Activity_settings;
53+
import de.baumann.browser.helper.class_SecurePreferences;
5254
import de.baumann.browser.helper.helper_editText;
5355
import de.baumann.browser.helper.helper_main;
5456
import de.baumann.browser.popups.Popup_history;
@@ -68,11 +70,22 @@ protected void onCreate(Bundle savedInstanceState) {
6870
super.onCreate(savedInstanceState);
6971

7072
PreferenceManager.setDefaultValues(this, R.xml.user_settings, false);
73+
PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false);
7174
sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
7275

76+
class_SecurePreferences sharedPrefSec = new class_SecurePreferences(Bookmarks.this, "sharedPrefSec", "Ywn-YM.XK$b:/:&CsL8;=L,y4", true);
77+
String pw = sharedPrefSec.getString("protect_PW");
78+
79+
if (pw != null && pw.length() > 0) {
80+
if (sharedPref.getBoolean("isOpened", true)) {
81+
helper_main.switchToActivity(Bookmarks.this, Activity_password.class, "", false);
82+
}
83+
}
84+
7385
if (sharedPref.getBoolean ("hideStatus", false)){
7486
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
7587
}
88+
7689
setContentView(R.layout.activity_bookmarks);
7790

7891
sharedPref.edit()
@@ -88,7 +101,7 @@ protected void onCreate(Bundle savedInstanceState) {
88101
setSupportActionBar(toolbar);
89102

90103
editText = (EditText) findViewById(R.id.editText);
91-
helper_editText.editText_Touch(editText, Bookmarks.this);
104+
helper_editText.editText_Touch_Bookmark(editText, Bookmarks.this);
92105
helper_editText.editText_FocusChange(editText, Bookmarks.this);
93106

94107
searchEngine = sharedPref.getString("searchEngine", "https://startpage.com/do/search?query=");
@@ -290,6 +303,12 @@ public void onClick(DialogInterface dialog, int which) {
290303
}
291304
}
292305

306+
@Override
307+
public void onBackPressed() {
308+
helper_main.isClosed(Bookmarks.this);
309+
finishAffinity();
310+
}
311+
293312
private void setBookmarkList() {
294313

295314
ArrayList<HashMap<String,String>> mapList = new ArrayList<>();
@@ -509,7 +528,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
509528
editText.setHint(getString(R.string.app_search_hint_bookmark));
510529
editText.setText("");
511530
editText.setHint(R.string.app_search_hint);
512-
helper_editText.editText_Touch(editText, Bookmarks.this);
531+
helper_editText.editText_Touch_Bookmark(editText, Bookmarks.this);
513532
helper_editText.editText_FocusChange(editText, Bookmarks.this);
514533
helper_main.hideKeyboard(Bookmarks.this, editText);
515534
}

app/src/main/java/de/baumann/browser/Browser.java

+34-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@
8282
import java.util.Locale;
8383

8484
import de.baumann.browser.databases.Database_ReadLater;
85+
import de.baumann.browser.helper.Activity_password;
8586
import de.baumann.browser.helper.Activity_settings;
87+
import de.baumann.browser.helper.class_SecurePreferences;
8688
import de.baumann.browser.helper.helper_editText;
8789
import de.baumann.browser.helper.helper_webView;
8890
import de.baumann.browser.helper.helper_main;
@@ -140,6 +142,15 @@ protected void onCreate(Bundle savedInstanceState) {
140142
PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false);
141143
sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
142144

145+
class_SecurePreferences sharedPrefSec = new class_SecurePreferences(Browser.this, "sharedPrefSec", "Ywn-YM.XK$b:/:&CsL8;=L,y4", true);
146+
String pw = sharedPrefSec.getString("protect_PW");
147+
148+
if (pw != null && pw.length() > 0) {
149+
if (sharedPref.getBoolean("isOpened", true)) {
150+
helper_main.switchToActivity(Browser.this, Activity_password.class, "", false);
151+
}
152+
}
153+
143154
if (sharedPref.getBoolean ("hideStatus", false)){
144155
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
145156
}
@@ -253,7 +264,7 @@ public void onClick(View view) {
253264
}
254265
});
255266

256-
helper_editText.editText_Touch(editText, Browser.this);
267+
helper_editText.editText_Touch(editText, Browser.this, mWebView);
257268
helper_editText.editText_EditorAction(editText, Browser.this, mWebView);
258269
helper_editText.editText_FocusChange(editText, Browser.this);
259270

@@ -646,7 +657,7 @@ public void run() {
646657
.apply();
647658
invalidateOptionsMenu();
648659
editText.setHint(R.string.app_search_hint);
649-
helper_editText.editText_Touch(editText, Browser.this);
660+
helper_editText.editText_Touch(editText, Browser.this, mWebView);
650661
helper_editText.editText_EditorAction(editText, Browser.this, mWebView);
651662
helper_editText.editText_FocusChange(editText, Browser.this);
652663
helper_main.hideKeyboard(Browser.this, editText);
@@ -914,7 +925,7 @@ public void onClick(DialogInterface dialog, int item) {
914925
invalidateOptionsMenu();
915926
editText.setText(mWebView.getTitle());
916927
editText.setHint(R.string.app_search_hint);
917-
helper_editText.editText_Touch(editText, Browser.this);
928+
helper_editText.editText_Touch(editText, Browser.this, mWebView);
918929
helper_editText.editText_EditorAction(editText, Browser.this, mWebView);
919930
helper_editText.editText_FocusChange(editText, Browser.this);
920931
helper_main.hideKeyboard(Browser.this, editText);
@@ -1186,6 +1197,26 @@ public void onHideCustomView() {
11861197
}
11871198
}
11881199

1200+
@Override
1201+
protected void onPause() {
1202+
super.onPause(); //To change body of overridden methods use File | Settings | File Templates.
1203+
mWebView.onPause();
1204+
}
1205+
1206+
@Override
1207+
protected void onResume() {
1208+
super.onResume(); //To change body of overridden methods use File | Settings | File Templates.
1209+
mWebView.onResume();
1210+
}
1211+
1212+
@Override
1213+
protected void onStop() {
1214+
super.onStop(); //To change body of overridden methods use File | Settings | File Templates.
1215+
if (inCustomView()) {
1216+
hideCustomView();
1217+
}
1218+
}
1219+
11891220
private boolean inCustomView() {
11901221
return (mCustomView != null);
11911222
}

0 commit comments

Comments
 (0)