feat: 优化代码

pull/172/head
kunfei 5 years ago
parent f6d010923b
commit c2bdea7026
  1. 12
      app/build.gradle
  2. 29
      app/google-services.json
  3. 4
      app/src/main/AndroidManifest.xml
  4. 15
      app/src/main/java/io/legado/app/help/AppConfig.kt
  5. 6
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt
  6. 4
      app/src/main/res/xml/pref_main.xml

@ -37,6 +37,7 @@ android {
targetSdkVersion 29
versionCode gitCommits
versionName version
flavorDimensions "versionCode"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
project.ext.set("archivesBaseName", name + "_" + version)
multiDexEnabled true
@ -73,7 +74,15 @@ android {
}
}
}
productFlavors{
app{
manifestPlaceholders = [APP_CHANNEL_VALUE:"app"]
}
google{
applicationId "io.legado.play"
manifestPlaceholders = [APP_CHANNEL_VALUE:"google"]
}
}
compileOptions {
// Flag to enable support for the new language APIs
//coreLibraryDesugaringEnabled true
@ -130,6 +139,7 @@ dependencies {
def room_version = '2.2.4'
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
kapt "android.arch.persistence.room:compiler:$room_version"
//paging
implementation 'androidx.paging:paging-runtime:2.1.1'

@ -92,6 +92,35 @@
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:453392274790:android:b891abd2331577dff624a7",
"android_client_info": {
"package_name": "io.legado.play.release"
}
},
"oauth_client": [
{
"client_id": "453392274790-hnbpatpce9hbjiggj76hgo7queu86atq.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyD90mfNLhA7cAzzI9SonpSz5mrF5BnmyJA"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "453392274790-hnbpatpce9hbjiggj76hgo7queu86atq.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"

@ -252,6 +252,10 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<meta-data
android:name="channel"
android:value="${APP_CHANNEL_VALUE}" />
</application>
</manifest>

@ -1,6 +1,7 @@
package io.legado.app.help
import android.content.Context
import android.content.pm.PackageManager
import io.legado.app.App
import io.legado.app.R
import io.legado.app.constant.PreferKey
@ -119,4 +120,18 @@ object AppConfig {
set(value) {
App.INSTANCE.putPrefInt("elevation", value)
}
}
val Context.channel: String
get() {
try {
val pm = packageManager
val appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
return appInfo.metaData.getString("channel") ?: ""
} catch (e: Exception) {
e.printStackTrace();
}
return ""
}

@ -13,6 +13,7 @@ import io.legado.app.R
import io.legado.app.base.BaseFragment
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.help.channel
import io.legado.app.lib.theme.ATH
import io.legado.app.service.WebService
import io.legado.app.ui.about.AboutActivity
@ -24,6 +25,7 @@ import io.legado.app.ui.config.ConfigViewModel
import io.legado.app.ui.filechooser.FileChooserDialog
import io.legado.app.ui.replacerule.ReplaceRuleActivity
import io.legado.app.ui.widget.prefs.NameListPreference
import io.legado.app.ui.widget.prefs.PreferenceCategory
import io.legado.app.ui.widget.prefs.SwitchPreference
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.view_title_bar.*
@ -81,6 +83,10 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog.
true
}
}
if (requireContext().channel == "google") {
findPreference<PreferenceCategory>("aboutCategory")
?.removePreference(findPreference("donate"))
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

@ -56,7 +56,9 @@
</io.legado.app.ui.widget.prefs.PreferenceCategory>
<io.legado.app.ui.widget.prefs.PreferenceCategory app:iconSpaceReserved="false">
<io.legado.app.ui.widget.prefs.PreferenceCategory
android:key="aboutCategory"
app:iconSpaceReserved="false">
<androidx.preference.Preference
android:key="donate"

Loading…
Cancel
Save