diff --git a/app/build.gradle b/app/build.gradle
index 4a18004..81373f6 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -18,8 +18,8 @@ android {
applicationId "eu.zderadicka.audioserve"
minSdkVersion 21
targetSdkVersion 27
- versionCode 14
- versionName "0.6.7"
+ versionCode 15
+ versionName "0.6.8"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
diff --git a/app/src/main/java/eu/zderadicka/audioserve/DetailsActivity.kt b/app/src/main/java/eu/zderadicka/audioserve/DetailsActivity.kt
index 5180dda..198c6f3 100644
--- a/app/src/main/java/eu/zderadicka/audioserve/DetailsActivity.kt
+++ b/app/src/main/java/eu/zderadicka/audioserve/DetailsActivity.kt
@@ -1,23 +1,37 @@
package eu.zderadicka.audioserve
+import android.content.Intent
+import android.net.Uri
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
+import android.preference.PreferenceManager
+import android.view.Menu
+import android.view.MenuItem
import eu.zderadicka.audioserve.data.pathFromFolderId
import eu.zderadicka.audioserve.fragments.ARG_FOLDER_DETAILS
import eu.zderadicka.audioserve.fragments.ARG_FOLDER_NAME
import eu.zderadicka.audioserve.fragments.ARG_FOLDER_PATH
import eu.zderadicka.audioserve.fragments.DetailsFragment
+private val searchUri = Uri.parse("https://www.google.com/search")
+private val toReplace = Regex("""[_\-/,]""")
+private val bracketed = Regex("""[(\[{].*[)\]}]""")
+
+
+
class DetailsActivity : AppCompatActivity() {
+ lateinit var folderName: String
+ lateinit var folderPath:String
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_details)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
- val folderName = intent.getStringExtra(ARG_FOLDER_NAME)?:""
+ folderName = intent.getStringExtra(ARG_FOLDER_NAME)?:""
val folderId = intent.getStringExtra(ARG_FOLDER_PATH)!!
- val folderPath = pathFromFolderId(folderId)
+ folderPath = pathFromFolderId(folderId)
val details = intent.getBundleExtra(ARG_FOLDER_DETAILS)
val t = supportFragmentManager.beginTransaction()
t.add(R.id.detailsFragment, DetailsFragment.newInstance(folderPath,folderName,details))
@@ -25,4 +39,34 @@ class DetailsActivity : AppCompatActivity() {
}
+
+ override fun onCreateOptionsMenu(menu: Menu?): Boolean {
+ menuInflater.inflate(R.menu.info_menu, menu)
+ return true
+ }
+
+ private val searchString:String
+ get() {
+ val searchPrefix = PreferenceManager.getDefaultSharedPreferences(this)
+ .getString("pref_web_search_prefix", "")
+ var query = searchPrefix+ " "+folderName + " " + folderPath
+ query = toReplace.replace(query, " ")
+ query = bracketed.replace(query, "")
+ query = Regex("""\s{2,}""").replace(query, " ")
+ query = query.trim()
+ return query
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
+ when (item.itemId) {
+ R.id.action_web_search -> {
+ val uri = searchUri.buildUpon().appendQueryParameter("q", searchString).build()
+ val intent = Intent(Intent.ACTION_VIEW)
+ intent.data = uri
+ startActivity(intent)
+ }
+ }
+
+ return super.onOptionsItemSelected(item)
+ }
}
diff --git a/app/src/main/java/eu/zderadicka/audioserve/SettingsActivity.kt b/app/src/main/java/eu/zderadicka/audioserve/SettingsActivity.kt
index 37c9945..d320c90 100644
--- a/app/src/main/java/eu/zderadicka/audioserve/SettingsActivity.kt
+++ b/app/src/main/java/eu/zderadicka/audioserve/SettingsActivity.kt
@@ -225,6 +225,16 @@ class SettingsFragment: PreferenceFragment(), SharedPreferences.OnSharedPreferen
}
+ "pref_web_search_prefix" -> {
+ if (pref !is EditTextPreference) return
+ val prefix = sps.getString("pref_web_search_prefix", null)
+ if (prefix.isNullOrBlank()) {
+ pref.summary = getString(R.string.pref_web_search_prefix_summary_empty)
+ } else {
+ pref.summary = getString(R.string.pref_web_search_prefix_summary, prefix)
+ }
+ }
+
}
}
diff --git a/app/src/main/res/drawable/ic_web.xml b/app/src/main/res/drawable/ic_web.xml
new file mode 100644
index 0000000..74bc279
--- /dev/null
+++ b/app/src/main/res/drawable/ic_web.xml
@@ -0,0 +1,5 @@
+