pull/37/head
kunfei 5 years ago
parent 32e65f609b
commit 43e1bcdc83
  1. 29
      app/src/main/AndroidManifest.xml
  2. 27
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt

@ -57,7 +57,20 @@
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity android:name=".ui.config.ConfigActivity" />
<activity android:name=".ui.replacerule.ReplaceRuleActivity" />
<activity android:name="io.legado.app.ui.book.search.SearchActivity" />
<activity
android:name="io.legado.app.ui.book.search.SearchActivity"
android:label="@string/receiving_shared_label">
<intent-filter>
<action android:name="android.intent.action.PROCESS_TEXT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity android:name=".ui.about.AboutActivity" />
<activity android:name=".ui.qrcode.QrCodeActivity" />
<activity android:name=".ui.about.DonateActivity" />
@ -66,11 +79,14 @@
<activity android:name=".ui.book.source.debug.BookSourceDebugActivity" />
<activity android:name=".ui.book.source.manage.BookSourceActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="yuedu" android:host="booksource"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="booksource"
android:scheme="yuedu" />
</intent-filter>
</activity>
<activity android:name=".ui.chapterlist.ChapterListActivity" />
@ -79,7 +95,8 @@
<activity android:name=".ui.explore.ExploreShowActivity" />
<activity android:name=".ui.rss.source.manage.RssSourceActivity" />
<activity android:name=".ui.rss.source.debug.RssSourceDebugActivity" />
<activity android:name=".ui.rss.article.RssArticlesActivity"/>
<activity android:name=".ui.rss.article.RssArticlesActivity" />
<service android:name=".service.CheckSourceService" />
<service android:name=".service.DownloadService" />
<service android:name=".service.UpdateService" />

@ -1,5 +1,7 @@
package io.legado.app.ui.book.search
import android.content.Intent
import android.os.Build
import android.os.Bundle
import androidx.appcompat.widget.SearchView
import androidx.lifecycle.LiveData
@ -49,9 +51,8 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
initSearchView()
initOtherView()
initData()
intent.getStringExtra("key")?.let {
search_view.setQuery(it, true)
}
initIntent()
upHistory()
}
private fun initSearchView() {
@ -125,7 +126,25 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
), 30
).build()
searchBookData?.observe(this, Observer { adapter.submitList(it) })
upHistory()
}
private fun initIntent() {
if (Intent.ACTION_SEND == intent.action && intent.type == "text/plain") {
intent.getStringExtra(Intent.EXTRA_TEXT)?.let {
search_view.setQuery(it, true)
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& Intent.ACTION_PROCESS_TEXT == intent.action
&& intent.type == "text/plain"
) {
intent.getStringExtra(Intent.EXTRA_PROCESS_TEXT)?.let {
search_view.setQuery(it, true)
}
} else {
intent.getStringExtra("key")?.let {
search_view.setQuery(it, true)
}
}
}
private fun upHistory(key: String? = null) {

Loading…
Cancel
Save