10 | Midori
11 | a lightweight, fast and free web browser for Android
12 |
13 |
14 | 
15 |
16 | Midori is a lightweight yet powerful web browser which runs just as well on little embedded computers named for delicious pastries as it does on beefy machines with a core temperature exceeding that of planet earth. And it looks good doing that, too. Oh, and of course it's free software. And for Android
17 |
18 |
19 | **Privacy out of the box**
20 |
21 | * Adblock filter list support.
22 | * Private browsing.
23 | * Manage cookies and scripts.
24 |
25 | **Productivity features**
26 |
27 | * Opens many Tabs.
28 | * History Manage
29 | * Download Manage.
30 | * Bookmark.
31 | * Dark Theme.
32 | * Share Content.
33 | * and much more.
34 |
35 | 
36 |
--------------------------------------------------------------------------------
/.idea/assetWizardSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
20 |
21 |
29 |
31 |
32 |
33 |
36 |
39 |
40 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_tabs.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
13 |
22 |
23 |
31 |
32 |
33 |
34 |
35 |
39 |
40 |
44 |
45 |
49 |
50 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_browser.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
15 |
16 |
17 |
26 |
27 |
35 |
36 |
37 |
38 |
39 |
43 |
44 |
48 |
49 |
53 |
54 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_midori.xml:
--------------------------------------------------------------------------------
1 |
7 |
13 |
18 |
23 |
27 |
28 |
34 |
35 |
43 |
51 |
59 |
67 |
75 |
76 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/app/src/main/java/org/midori_browser/midori/BrowserActivity.kt:
--------------------------------------------------------------------------------
1 | package org.midori_browser.midori
2 |
3 | import android.app.DownloadManager
4 | import android.content.*
5 | import android.net.Uri
6 | import android.os.Build
7 | import android.os.Bundle
8 | import android.os.Environment
9 | import android.support.annotation.RequiresApi
10 | import android.support.v7.app.AppCompatActivity
11 | import android.text.Editable
12 | import android.text.TextWatcher
13 | import android.util.Log
14 | import android.view.KeyEvent
15 | import android.view.Menu
16 | import android.view.MenuItem
17 | import android.view.inputmethod.EditorInfo
18 | import android.view.inputmethod.InputMethodManager
19 | import android.webkit.*
20 | import android.widget.*
21 | import kotlinx.android.synthetic.main.activity_browser.*
22 | import java.util.ResourceBundle.clearCache
23 |
24 | class BrowserActivity : AppCompatActivity() {
25 |
26 | lateinit var downloadListener: DownloadListener
27 | lateinit var webViews: WebView
28 |
29 | override fun onCreate(savedInstanceState: Bundle?) {
30 | super.onCreate(savedInstanceState)
31 | setContentView(R.layout.activity_browser)
32 | setSupportActionBar(findViewById(R.id.toolbar))
33 |
34 | val webSettings = webView.settings
35 | webSettings.javaScriptEnabled = true
36 | requestDesktopSite(false)
37 | webSettings.databaseEnabled = true
38 | webSettings.setAppCacheEnabled(true)
39 | webView.setPadding(0,0,0,0)
40 | webSettings.domStorageEnabled = true
41 | @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
42 | webSettings.mixedContentMode = WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE
43 | webView.webViewClient = WebViewClient(this)
44 | webView.webChromeClient = WebChromeClient(this)
45 |
46 |
47 | val openTabs = (getSharedPreferences("config", Context.MODE_PRIVATE).getString(
48 | "openTabs", null
49 | ) ?: getString(R.string.appWebsite)).split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
50 | webView.loadUrl(openTabs.first())
51 |
52 | val adapter = ArrayAdapter(
53 | this,
54 | android.R.layout.simple_spinner_dropdown_item, completion
55 | )
56 | urlBar.setAdapter(adapter)
57 | urlBar.onItemClickListener = AdapterView.OnItemClickListener { parent, _, position, _ ->
58 | val im = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
59 | im.hideSoftInputFromWindow(parent.applicationWindowToken, 0)
60 | loadUrlOrSearch(parent.getItemAtPosition(position).toString())
61 | }
62 | urlBar.setOnEditorActionListener() { v, actionId, event ->
63 | if ((event != null && event.keyCode == KeyEvent.KEYCODE_ENTER) || actionId == EditorInfo.IME_ACTION_DONE) {
64 | val im = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
65 | im.hideSoftInputFromWindow(v.applicationWindowToken, 0)
66 | loadUrlOrSearch(urlBar.text.toString())
67 | true
68 | } else {
69 | false
70 | }
71 | }
72 | urlBar.addTextChangedListener(object : TextWatcher {
73 | override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
74 |
75 | override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
76 |
77 | override fun afterTextChanged(s: Editable?) {
78 | }
79 | })
80 |
81 | createDownloaderListener()
82 | onDownloadComplete()
83 | }
84 |
85 | override fun onResume() {
86 | super.onResume()
87 | webViews = findViewById(R.id.webView)
88 | webViews.setDownloadListener(downloadListener)
89 | }
90 |
91 | private fun onDownloadComplete(){
92 |
93 | val onComplete = object: BroadcastReceiver(){
94 | override fun onReceive(context: Context?, intent: Intent?) {
95 | Toast.makeText(context, "File Downloaded", Toast.LENGTH_SHORT).show()
96 | }
97 | }
98 | registerReceiver(onComplete, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
99 | }
100 |
101 | private fun createDownloaderListener(){
102 |
103 | val permissionCheck = PermissionCheck()
104 |
105 | if (permissionCheck.readAndWriteExternalStorage(this)) {
106 | downloadListener = DownloadListener { url,
107 | userAgent,
108 | contentDescription,
109 | mimetype,
110 | contentLength ->
111 | val request = DownloadManager.Request(Uri.parse(url))
112 | val fileName = URLUtil.guessFileName(url, contentDescription, mimetype)
113 | request.allowScanningByMediaScanner()
114 | request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
115 | request.setVisibleInDownloadsUi(true)
116 | .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName)
117 | val dManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
118 | dManager.enqueue(request)
119 | Toast.makeText(this, "Downloading File " , Toast.LENGTH_SHORT).show()
120 | }
121 | }else{
122 | Log.e("Error: ", "Error Downloading")
123 | }
124 | }
125 |
126 | private fun loadUrlOrSearch(text: String) {
127 | webView.loadUrl(magicUri(text) ?: uriForSearch(text))
128 | }
129 |
130 | fun magicUri(text: String): String? {
131 | if (" " in text) {
132 | return null
133 | } else if (text.startsWith("http")) {
134 | return text
135 | } else if (text == "localhost" || "." in text) {
136 | return "http://" + text
137 | }
138 | return null
139 | }
140 |
141 | val locationEntrySearch = "https://duckduckgo.com/?q=%s"
142 | fun uriForSearch(keywords: String? = null, search: String? = null): String {
143 | val uri = search ?: locationEntrySearch
144 | val escaped = Uri.encode(keywords ?: "", ":/")
145 | // Allow DuckDuckGo to distinguish Midori and in turn share revenue
146 | if (uri == "https://duckduckgo.com/?q=%s") {
147 | return "https://duckduckgo.com/?q=$escaped&t=midori"
148 | } else if ("%s" in uri) {
149 | return uri.format(escaped)
150 | }
151 | return uri + escaped
152 | }
153 |
154 | val completion = listOf("www.midori-browser.org", "example.com", "duckduckgo.com")
155 | fun requestDesktopSite(desktopSite: Boolean) {
156 | webView.settings.apply {
157 | userAgentString = null // Reset to default
158 | userAgentString = userAgentString + " " + getString(R.string.userAgentVersion)
159 | if (desktopSite) {
160 | // Websites look for "Android" and "Mobile" keywords to decide what's not desktop
161 | val mobileOS = userAgentString.substring(userAgentString.indexOf("("), userAgentString.indexOf(")") + 1)
162 | userAgentString = userAgentString.replace(mobileOS, "(X11; Linux x86_64)").replace(" Mobile", "")
163 | }
164 | useWideViewPort = desktopSite
165 | loadWithOverviewMode = desktopSite
166 | }
167 | }
168 |
169 | fun showDownload(){
170 | val intent = Intent()
171 | intent.setAction(DownloadManager.ACTION_VIEW_DOWNLOADS)
172 | startActivity(intent)
173 | }
174 |
175 | override fun onCreateOptionsMenu(menu: Menu?): Boolean {
176 | menuInflater.inflate(R.menu.app_menu, menu)
177 | return true
178 | }
179 |
180 | override fun onBackPressed() {
181 | if (webView.canGoBack()){
182 | webView.goBack()
183 | webView.copyBackForwardList()
184 | Toast.makeText(this, webView.url, Toast.LENGTH_SHORT).show()
185 | }else {
186 | webView.goForward()
187 | Toast.makeText(this, webView.url, Toast.LENGTH_SHORT).show()
188 | }
189 | }
190 |
191 | override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
192 | R.id.actionShare -> {
193 | val share = Intent().apply {
194 | action = Intent.ACTION_VIEW
195 | data = Uri.parse(webView.url)
196 | intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
197 | }
198 | startActivity(Intent.createChooser(share, getString(R.string.actionShare)))
199 | true
200 | }
201 | R.id.actionClearPrivateData -> {
202 | @Suppress("DEPRECATION")
203 | CookieManager.getInstance().removeAllCookie()
204 | WebStorage.getInstance().deleteAllData()
205 | webView.clearCache(true)
206 | true
207 | }
208 | R.id.actionRequestDesktopSite -> {
209 | item.isChecked = !item.isChecked
210 | requestDesktopSite(item.isChecked)
211 | webView.reload()
212 | true
213 | }
214 | R.id.actionTabs -> {
215 | val intent = Intent(this, ActivityTabs::class.java)
216 | startActivity(intent)
217 | true
218 | }
219 | R.id.download -> {
220 | showDownload()
221 | true
222 | }
223 | R.id.goBack -> {
224 | onBackPressed()
225 | true
226 | }
227 | R.id.goForward ->{
228 | onBackPressed()
229 | true
230 | }
231 | R.id.history -> {
232 | /**
233 | *
234 | * Code here
235 | *
236 | * */
237 | true
238 | }
239 | else -> {
240 | super.onOptionsItemSelected(item)
241 | }
242 | }
243 | }
244 |
245 |
246 |
247 |
--------------------------------------------------------------------------------
/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |