small touchups
This commit is contained in:
parent
678571685e
commit
800b82b7bd
3 changed files with 38 additions and 27 deletions
|
|
@ -123,10 +123,10 @@ dependencies {
|
|||
|
||||
implementation "androidx.appcompat:appcompat:$appCompatVer"
|
||||
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
|
||||
implementation 'com.google.android.material:material:1.9.0-alpha02'
|
||||
implementation 'com.google.android.material:material:1.9.0-beta01'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.core:core:1.9.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.3.0'
|
||||
implementation 'androidx.preference:preference:1.2.0'
|
||||
implementation "androidx.navigation:navigation-fragment-ktx:2.5.3"
|
||||
implementation "androidx.navigation:navigation-ui-ktx:2.5.3"
|
||||
|
|
@ -137,7 +137,7 @@ dependencies {
|
|||
androidTestImplementation "junit:junit:$junitVer"
|
||||
androidTestImplementation "androidx.test.ext:junit:$androidJunitVer"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVer"
|
||||
androidTestImplementation "androidx.benchmark:benchmark-macro-junit4:1.2.0-alpha10"
|
||||
androidTestImplementation "androidx.benchmark:benchmark-macro-junit4:1.2.0-alpha11"
|
||||
androidTestImplementation "androidx.test:runner:1.5.2"
|
||||
androidTestImplementation "androidx.test:core:1.5.0"
|
||||
androidTestImplementation "androidx.test:rules:1.5.0"
|
||||
|
|
|
|||
|
|
@ -101,18 +101,22 @@ class CommandTemplateViewModel(private val application: Application) : AndroidVi
|
|||
|
||||
|
||||
fun exportToClipboard() = viewModelScope.launch(Dispatchers.IO) {
|
||||
val allTemplates = repository.getAll()
|
||||
val allShortcuts = repository.getAllShortCuts()
|
||||
val output = jsonFormat.encodeToString(
|
||||
CommandTemplateExport(
|
||||
try{
|
||||
val allTemplates = repository.getAll()
|
||||
val allShortcuts = repository.getAllShortCuts()
|
||||
val output = jsonFormat.encodeToString(
|
||||
CommandTemplateExport(
|
||||
templates = allTemplates,
|
||||
shortcuts = allShortcuts
|
||||
)
|
||||
)
|
||||
|
||||
val clipboard: ClipboardManager =
|
||||
application.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||
clipboard.setText(output)
|
||||
val clipboard: ClipboardManager =
|
||||
application.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||
clipboard.setText(output)
|
||||
}catch (e: Exception){
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -215,24 +215,29 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
|
|||
val linkYouCopied = searchView.findViewById<ConstraintLayout>(R.id.link_you_copied)
|
||||
searchView.addTransitionListener { view, previousState, newState ->
|
||||
if (newState == SearchView.TransitionState.SHOWN) {
|
||||
val clipboard =
|
||||
requireContext().getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val regex =
|
||||
"(https?://(?:www\\.|(?!www))[a-zA-Z\\d][a-zA-Z\\d-]+[a-zA-Z\\d]\\.\\S{2,}|www\\.[a-zA-Z\\d][a-zA-Z\\d-]+[a-zA-Z\\d]\\.\\S{2,}|https?://(?:www\\.|(?!www))[a-zA-Z\\d]+\\.\\S{2,}|www\\.[a-zA-Z\\d]+\\.\\S{2,})".toRegex()
|
||||
val clip = clipboard.primaryClip!!.getItemAt(0).text
|
||||
if (regex.containsMatchIn(clip.toString())) {
|
||||
linkYouCopied.visibility = VISIBLE
|
||||
val textView = linkYouCopied.findViewById<TextView>(R.id.suggestion_text)
|
||||
textView.text = getString(R.string.link_you_copied)
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_language, 0, 0, 0)
|
||||
val mb = linkYouCopied.findViewById<ImageButton>(R.id.set_search_query_button)
|
||||
mb.visibility = INVISIBLE
|
||||
try{
|
||||
val clipboard =
|
||||
requireContext().getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val regex =
|
||||
"(https?://(?:www\\.|(?!www))[a-zA-Z\\d][a-zA-Z\\d-]+[a-zA-Z\\d]\\.\\S{2,}|www\\.[a-zA-Z\\d][a-zA-Z\\d-]+[a-zA-Z\\d]\\.\\S{2,}|https?://(?:www\\.|(?!www))[a-zA-Z\\d]+\\.\\S{2,}|www\\.[a-zA-Z\\d]+\\.\\S{2,})".toRegex()
|
||||
val clip = clipboard.primaryClip!!.getItemAt(0).text
|
||||
if (regex.containsMatchIn(clip.toString())) {
|
||||
linkYouCopied.visibility = VISIBLE
|
||||
val textView = linkYouCopied.findViewById<TextView>(R.id.suggestion_text)
|
||||
textView.text = getString(R.string.link_you_copied)
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_language, 0, 0, 0)
|
||||
val mb = linkYouCopied.findViewById<ImageButton>(R.id.set_search_query_button)
|
||||
mb.visibility = INVISIBLE
|
||||
|
||||
textView.setOnClickListener {
|
||||
searchView.setText(clip.toString())
|
||||
initSearch(searchView)
|
||||
textView.setOnClickListener {
|
||||
searchView.setText(clip.toString())
|
||||
initSearch(searchView)
|
||||
}
|
||||
}else{
|
||||
linkYouCopied.visibility = GONE
|
||||
}
|
||||
}else{
|
||||
}catch (e: Exception){
|
||||
e.printStackTrace()
|
||||
linkYouCopied.visibility = GONE
|
||||
}
|
||||
}
|
||||
|
|
@ -289,7 +294,9 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
|
|||
}
|
||||
}
|
||||
searchHistoryLinearLayout!!.visibility = VISIBLE
|
||||
linkYouCopied!!.visibility = VISIBLE
|
||||
if (linkYouCopied.findViewById<TextView>(R.id.suggestion_text).text.isNotEmpty()){
|
||||
linkYouCopied.visibility = VISIBLE
|
||||
}
|
||||
}else{
|
||||
for (i in suggestions.indices) {
|
||||
val v = LayoutInflater.from(fragmentContext)
|
||||
|
|
|
|||
Loading…
Reference in a new issue