trying to fix travis error

hides unavailable settings for F-droid
This commit is contained in:
Mariotaku Lee 2017-03-01 10:43:17 +08:00
parent 15ee2043ce
commit 2db855e2f3
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
6 changed files with 112 additions and 3 deletions

View File

@ -62,7 +62,7 @@ before_install:
install:
# Extracts build configs into source tree
- tar zxf travis/configs/twidere_private_config.tar.gz
- GIT_SSH_COMMAND='ssh -i priv_components_ssh_key' git clone $COMPONENT_GOOGLE_REPO > /dev/null 2>&1
- GIT_SSH_COMMAND='ssh -i priv_components_ssh_key' git clone $COMPONENT_GOOGLE_REPO twidere/src/google > /dev/null 2>&1
before_script:
# Validate if patches work

View File

@ -0,0 +1,41 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.extension
import android.support.v7.preference.Preference
import android.support.v7.preference.PreferenceGroup
import android.support.v7.preference.PreferenceScreen
import java.util.*
fun Preference.findParent(screen: PreferenceScreen): PreferenceGroup? {
val curParents = Stack<PreferenceGroup>()
curParents.add(screen)
while (!curParents.isEmpty()) {
val parent = curParents.pop()
for (i in 0 until parent.preferenceCount) {
val child = parent.getPreference(i)
if (child == this) return parent
if (child is PreferenceGroup) {
curParents.push(child)
}
}
}
return null
}

View File

@ -7,6 +7,7 @@ import android.util.AttributeSet
import org.mariotaku.chameleon.ChameleonUtils
import org.mariotaku.twidere.R
import org.mariotaku.twidere.TwidereConstants.REQUEST_PURCHASE_EXTRA_FEATURES
import org.mariotaku.twidere.extension.findParent
import org.mariotaku.twidere.fragment.ExtraFeaturesIntroductionDialogFragment
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
@ -40,4 +41,13 @@ class PremiumEntryPreference(context: Context, attrs: AttributeSet) : Preference
return@setOnPreferenceClickListener false
}
}
override fun onAttached() {
super.onAttached()
if (!extraFeaturesService.isSupported()) {
preferenceManager.preferenceScreen?.let { screen ->
findParent(screen)?.removePreference(this)
}
}
}
}

View File

@ -0,0 +1,55 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.preference
import android.content.Context
import android.util.AttributeSet
import org.mariotaku.twidere.R
import org.mariotaku.twidere.extension.findParent
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
import javax.inject.Inject
/**
* Created by mariotaku on 2017/1/12.
*/
class PremiumEntryPreferenceCategory(context: Context, attrs: AttributeSet) : TintedPreferenceCategory(context, attrs) {
@Inject
internal lateinit var extraFeaturesService: ExtraFeaturesService
init {
GeneralComponentHelper.build(context).inject(this)
val a = context.obtainStyledAttributes(attrs, R.styleable.PremiumEntryPreference)
a.recycle()
isEnabled = extraFeaturesService.isSupported()
}
override fun onAttached() {
super.onAttached()
if (!extraFeaturesService.isSupported()) {
preferenceManager.preferenceScreen?.let { screen ->
findParent(screen)?.removePreference(this)
}
}
}
}

View File

@ -33,6 +33,7 @@ import org.mariotaku.twidere.loader.*
import org.mariotaku.twidere.preference.AccountsListPreference
import org.mariotaku.twidere.preference.KeyboardShortcutPreference
import org.mariotaku.twidere.preference.PremiumEntryPreference
import org.mariotaku.twidere.preference.PremiumEntryPreferenceCategory
import org.mariotaku.twidere.preference.sync.SyncItemPreference
import org.mariotaku.twidere.provider.CacheProvider
import org.mariotaku.twidere.provider.TwidereDataProvider
@ -130,6 +131,8 @@ interface GeneralComponent {
fun inject(preference: PremiumEntryPreference)
fun inject(preference: PremiumEntryPreferenceCategory)
fun inject(loader: CacheUserSearchLoader)
fun inject(loader: BaseUserListsLoader)

View File

@ -10,7 +10,7 @@
android:defaultValue="false"
android:key="filter_possibility_sensitive_statuses"
android:title="@string/preference_filter_possibility_sensitive_statuses"/>
<org.mariotaku.twidere.preference.TintedPreferenceCategory android:title="@string/preference_title_filter_subscriptions">
<org.mariotaku.twidere.preference.PremiumEntryPreferenceCategory android:title="@string/preference_title_filter_subscriptions">
<org.mariotaku.twidere.preference.PremiumEntryPreference
android:key="manage_filter_subscriptions"
android:title="@string/preference_title_filter_manage_subscriptions"
@ -20,5 +20,5 @@
android:targetClass="org.mariotaku.twidere.activity.LinkHandlerActivity"
android:targetPackage="org.mariotaku.twidere"/>
</org.mariotaku.twidere.preference.PremiumEntryPreference>
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
</org.mariotaku.twidere.preference.PremiumEntryPreferenceCategory>
</PreferenceScreen>