mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-08 15:58:40 +01:00
implemented some ads for promotion reward
This commit is contained in:
parent
daf965173e
commit
d520483ee3
@ -6,7 +6,7 @@ buildscript {
|
||||
maven { url 'https://maven.google.com' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.0-beta5'
|
||||
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
|
@ -148,6 +148,7 @@ dependencies {
|
||||
// START Non-FOSS component
|
||||
googleImplementation "com.google.android.gms:play-services-maps:${libVersions['PlayServices']}"
|
||||
googleImplementation "com.google.android.gms:play-services-auth:${libVersions['PlayServices']}"
|
||||
googleImplementation "com.google.android.gms:play-services-ads:${libVersions['PlayServices']}"
|
||||
googleImplementation "com.google.maps.android:android-maps-utils:${libVersions['MapsUtils']}"
|
||||
googleImplementation "com.anjlab.android.iab.v3:library:${libVersions['IABv3']}"
|
||||
googleImplementation "com.dropbox.core:dropbox-core-sdk:${libVersions['DropboxCoreSdk']}"
|
||||
|
1
twidere/proguard-rules.pro
vendored
1
twidere/proguard-rules.pro
vendored
@ -69,6 +69,7 @@
|
||||
|
||||
# Extra feature service
|
||||
-keep class * extends org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
||||
-keep class * extends org.mariotaku.twidere.util.promotion.PromotionService
|
||||
|
||||
# Extra feature component factories
|
||||
-keep class * extends org.mariotaku.twidere.util.gifshare.GifShareProvider.Factory
|
||||
|
@ -75,6 +75,7 @@ import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallb
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
import org.mariotaku.twidere.util.gifshare.GifShareProvider
|
||||
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
||||
import org.mariotaku.twidere.util.promotion.PromotionService
|
||||
import org.mariotaku.twidere.util.schedule.StatusScheduleProvider
|
||||
import org.mariotaku.twidere.util.support.ActivitySupport
|
||||
import org.mariotaku.twidere.util.support.ActivitySupport.TaskDescriptionCompat
|
||||
@ -125,6 +126,8 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity<BaseActivity>, IThe
|
||||
lateinit var mastodonApplicationRegistry: MastodonApplicationRegistry
|
||||
@Inject
|
||||
lateinit var taskServiceRunner: TaskServiceRunner
|
||||
@Inject
|
||||
lateinit var promotionService: PromotionService
|
||||
|
||||
lateinit var requestManager: RequestManager
|
||||
private set
|
||||
|
@ -15,7 +15,7 @@ import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import com.bumptech.glide.RequestManager
|
||||
import kotlinx.android.synthetic.main.activity_premium_dashboard.*
|
||||
import kotlinx.android.synthetic.main.card_item_extra_feature.view.*
|
||||
import kotlinx.android.synthetic.main.adapter_item_extra_feature_normal.view.*
|
||||
import nl.komponents.kovenant.combine.and
|
||||
import nl.komponents.kovenant.task
|
||||
import nl.komponents.kovenant.ui.alwaysUi
|
||||
@ -34,6 +34,7 @@ import org.mariotaku.twidere.model.analyzer.PurchaseFinished
|
||||
import org.mariotaku.twidere.util.Analyzer
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
||||
import org.mariotaku.twidere.util.promotion.PromotionService
|
||||
import org.mariotaku.twidere.util.schedule.StatusScheduleProvider
|
||||
import org.mariotaku.twidere.view.ContainerView
|
||||
import java.lang.ref.WeakReference
|
||||
@ -47,6 +48,7 @@ class PremiumDashboardActivity : BaseActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_premium_dashboard)
|
||||
|
||||
adapter = ControllersAdapter(this, requestManager)
|
||||
recyclerView.adapter = adapter
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
@ -62,7 +64,7 @@ class PremiumDashboardActivity : BaseActivity() {
|
||||
val lm = recyclerView.layoutManager as LinearLayoutManager
|
||||
for (pos in lm.findFirstVisibleItemPosition()..lm.findLastVisibleItemPosition()) {
|
||||
val holder = recyclerView.findViewHolderForLayoutPosition(pos) as? ControllerViewHolder ?: return
|
||||
val controller = holder.controller as? ExtraFeatureViewController ?: return
|
||||
val controller = holder.controller as? BaseItemViewController ?: return
|
||||
controller.onPause()
|
||||
}
|
||||
}
|
||||
@ -72,7 +74,7 @@ class PremiumDashboardActivity : BaseActivity() {
|
||||
val lm = recyclerView.layoutManager as LinearLayoutManager
|
||||
for (pos in lm.findFirstVisibleItemPosition()..lm.findLastVisibleItemPosition()) {
|
||||
val holder = recyclerView.findViewHolderForLayoutPosition(pos) as? ControllerViewHolder ?: return
|
||||
val controller = holder.controller as? ExtraFeatureViewController ?: return
|
||||
val controller = holder.controller as? BaseItemViewController ?: return
|
||||
controller.onResume()
|
||||
}
|
||||
}
|
||||
@ -97,7 +99,7 @@ class PremiumDashboardActivity : BaseActivity() {
|
||||
val position = ((requestCode and 0xFF00) shr 8) - 1
|
||||
if (position >= 0) {
|
||||
val holder = recyclerView.findViewHolderForLayoutPosition(position) as? ControllerViewHolder ?: return
|
||||
val controller = holder.controller as? ExtraFeatureViewController ?: return
|
||||
val controller = holder.controller as? BaseItemViewController ?: return
|
||||
controller.onActivityResult(requestCode and 0xFF, resultCode, data)
|
||||
}
|
||||
}
|
||||
@ -150,6 +152,10 @@ class PremiumDashboardActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
R.id.enable_promotions -> {
|
||||
preferences[promotionsEnabledKey] = true
|
||||
recreate()
|
||||
}
|
||||
R.id.disable_promotions -> {
|
||||
preferences[promotionsEnabledKey] = false
|
||||
recreate()
|
||||
@ -173,11 +179,7 @@ class PremiumDashboardActivity : BaseActivity() {
|
||||
|
||||
}
|
||||
|
||||
open class ExtraFeatureViewController : ContainerView.ViewController() {
|
||||
protected val titleView: TextView by lazy { view.findViewById<TextView>(R.id.title) }
|
||||
protected val messageView: TextView by lazy { view.findViewById<TextView>(R.id.message) }
|
||||
protected val button1: Button by lazy { view.findViewById<Button>(R.id.button1) }
|
||||
protected val button2: Button by lazy { view.findViewById<Button>(R.id.button2) }
|
||||
abstract class BaseItemViewController : ContainerView.ViewController() {
|
||||
|
||||
@Inject
|
||||
protected lateinit var extraFeaturesService: ExtraFeaturesService
|
||||
@ -186,11 +188,16 @@ class PremiumDashboardActivity : BaseActivity() {
|
||||
protected lateinit var preferences: SharedPreferences
|
||||
|
||||
@Inject
|
||||
protected lateinit var mScheduleProviderFactory: StatusScheduleProvider.Factory
|
||||
protected lateinit var scheduleProviderFactory: StatusScheduleProvider.Factory
|
||||
|
||||
@Inject
|
||||
protected lateinit var promotionService: PromotionService
|
||||
|
||||
var position: Int = RecyclerView.NO_POSITION
|
||||
internal set
|
||||
|
||||
open val useCardBackground: Boolean = true
|
||||
|
||||
protected val activity: PremiumDashboardActivity get() = context as PremiumDashboardActivity
|
||||
|
||||
override fun onCreate() {
|
||||
@ -198,16 +205,26 @@ class PremiumDashboardActivity : BaseActivity() {
|
||||
GeneralComponent.get(context).inject(this)
|
||||
}
|
||||
|
||||
open fun onPause() {}
|
||||
|
||||
open fun onResume() {}
|
||||
|
||||
open fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {}
|
||||
|
||||
}
|
||||
|
||||
open class ExtraFeatureViewController : BaseItemViewController() {
|
||||
protected val titleView: TextView by lazy { view.findViewById<TextView>(R.id.title) }
|
||||
protected val messageView: TextView by lazy { view.findViewById<TextView>(R.id.message) }
|
||||
protected val button1: Button by lazy { view.findViewById<Button>(R.id.button1) }
|
||||
protected val button2: Button by lazy { view.findViewById<Button>(R.id.button2) }
|
||||
|
||||
|
||||
override fun onCreateView(parent: ContainerView): View {
|
||||
return LayoutInflater.from(parent.context).inflate(R.layout.layout_controller_extra_feature,
|
||||
parent, false)
|
||||
}
|
||||
|
||||
open fun onPause() {}
|
||||
open fun onResume() {}
|
||||
|
||||
open fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {}
|
||||
|
||||
}
|
||||
|
||||
class ControllersAdapter(
|
||||
@ -215,6 +232,10 @@ class PremiumDashboardActivity : BaseActivity() {
|
||||
requestManager: RequestManager
|
||||
) : BaseRecyclerViewAdapter<ControllerViewHolder>(context, requestManager) {
|
||||
|
||||
init {
|
||||
setHasStableIds(true)
|
||||
}
|
||||
|
||||
var controllers: List<Class<out ContainerView.ViewController>>? = null
|
||||
set(value) {
|
||||
field = value
|
||||
@ -227,16 +248,36 @@ class PremiumDashboardActivity : BaseActivity() {
|
||||
|
||||
override fun onBindViewHolder(holder: ControllerViewHolder, position: Int) {
|
||||
val controller = controllers!![position].newInstance()
|
||||
if (controller is ExtraFeatureViewController) {
|
||||
if (controller is BaseItemViewController) {
|
||||
controller.position = holder.layoutPosition
|
||||
}
|
||||
holder.controller = controller
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ControllerViewHolder {
|
||||
return ControllerViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.card_item_extra_feature,
|
||||
parent, false))
|
||||
return ControllerViewHolder(LayoutInflater.from(parent.context).inflate(when (viewType) {
|
||||
VIEW_TYPE_NO_CARD -> R.layout.adapter_item_extra_feature_nocard
|
||||
else -> R.layout.adapter_item_extra_feature_normal
|
||||
}, parent, false))
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
val controller = controllers!![position].newInstance()
|
||||
if (controller is BaseItemViewController) {
|
||||
if (!controller.useCardBackground) {
|
||||
return VIEW_TYPE_NO_CARD
|
||||
}
|
||||
}
|
||||
return VIEW_TYPE_NORMAL
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return System.identityHashCode(controllers!![position]).toLong()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val VIEW_TYPE_NORMAL = 1
|
||||
private const val VIEW_TYPE_NO_CARD = 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.*
|
||||
import android.widget.AdapterView.OnItemClickListener
|
||||
import android.widget.AdapterView.OnItemSelectedListener
|
||||
import com.bumptech.glide.Glide
|
||||
import jopt.csp.util.SortableIntList
|
||||
import kotlinx.android.synthetic.main.activity_quick_search_bar.*
|
||||
import org.mariotaku.kpreferences.get
|
||||
@ -71,6 +70,7 @@ import org.mariotaku.twidere.provider.TwidereDataStore.Suggestions
|
||||
import org.mariotaku.twidere.util.*
|
||||
import org.mariotaku.twidere.util.EditTextEnterHandler.EnterListener
|
||||
import org.mariotaku.twidere.util.content.ContentResolverUtils
|
||||
import org.mariotaku.twidere.util.promotion.PromotionService
|
||||
import org.mariotaku.twidere.view.ProfileImageView
|
||||
|
||||
/**
|
||||
@ -91,6 +91,11 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_quick_search_bar)
|
||||
|
||||
promotionService.setupBanner(adContainer, PromotionService.BannerType.QUICK_SEARCH,
|
||||
FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM))
|
||||
|
||||
val am = AccountManager.get(this)
|
||||
val accounts = AccountUtils.getAllAccountDetails(am, AccountUtils.getAccounts(am), true).toList()
|
||||
val accountsSpinnerAdapter = AccountsSpinnerAdapter(this, R.layout.spinner_item_account_icon,
|
||||
@ -111,6 +116,9 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
||||
}
|
||||
}
|
||||
ViewCompat.setOnApplyWindowInsetsListener(mainContent, this)
|
||||
mainContent.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
suggestionsList.adapter = SuggestionsAdapter(this)
|
||||
suggestionsList.onItemClickListener = this
|
||||
|
||||
@ -153,6 +161,7 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
||||
supportLoaderManager.initLoader(0, null, this)
|
||||
|
||||
updateSubmitButton()
|
||||
promotionService.loadBanner(adContainer)
|
||||
}
|
||||
|
||||
override fun canDismiss(position: Int): Boolean {
|
||||
|
@ -73,6 +73,7 @@ import org.mariotaku.twidere.util.net.TwidereDns
|
||||
import org.mariotaku.twidere.util.notification.ContentNotificationManager
|
||||
import org.mariotaku.twidere.util.notification.NotificationChannelsManager
|
||||
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
||||
import org.mariotaku.twidere.util.promotion.PromotionService
|
||||
import org.mariotaku.twidere.util.refresh.AutoRefreshController
|
||||
import org.mariotaku.twidere.util.sync.DataSyncProvider
|
||||
import org.mariotaku.twidere.util.sync.SyncController
|
||||
@ -106,6 +107,8 @@ class TwidereApplication : Application(), OnSharedPreferenceChangeListener {
|
||||
@Inject
|
||||
lateinit internal var extraFeaturesService: ExtraFeaturesService
|
||||
@Inject
|
||||
lateinit internal var promotionService: PromotionService
|
||||
@Inject
|
||||
lateinit internal var mediaPreloader: MediaPreloader
|
||||
@Inject
|
||||
lateinit internal var contentNotificationManager: ContentNotificationManager
|
||||
@ -157,6 +160,7 @@ class TwidereApplication : Application(), OnSharedPreferenceChangeListener {
|
||||
autoRefreshController.appStarted()
|
||||
syncController.appStarted()
|
||||
extraFeaturesService.appStarted()
|
||||
promotionService.appStarted()
|
||||
|
||||
registerActivityLifecycleCallbacks(activityTracker)
|
||||
registerReceiver(ConnectivityStateReceiver(), IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION))
|
||||
@ -173,7 +177,6 @@ class TwidereApplication : Application(), OnSharedPreferenceChangeListener {
|
||||
}, updateImmediately = true)
|
||||
}
|
||||
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||
applyLanguageSettings()
|
||||
super.onConfigurationChanged(newConfig)
|
||||
|
@ -115,9 +115,7 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
val o = pagerAdapter.instantiateItem(viewPager, viewPager.currentItem)
|
||||
if (o is Fragment) {
|
||||
o.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
o.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
|
||||
override fun scrollToStart(): Boolean {
|
||||
@ -142,6 +140,7 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte
|
||||
}
|
||||
|
||||
override fun onApplySystemWindowInsets(insets: Rect) {
|
||||
|
||||
}
|
||||
|
||||
override fun getSystemWindowInsets(caller: Fragment, insets: Rect): Boolean {
|
||||
|
@ -99,11 +99,11 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
||||
|
||||
private lateinit var accountsAdapter: AccountSelectorAdapter
|
||||
|
||||
private val navigationView by lazy { view as NavigationView }
|
||||
private val accountsHeader by lazy { navigationView.getHeaderView(0) }
|
||||
private val hasNextAccountIndicator by lazy { accountsHeader.hasNextAccountIndicator }
|
||||
private val hasPrevAccountIndicator by lazy { accountsHeader.hasPrevAccountIndicator }
|
||||
private val accountsSelector by lazy { accountsHeader.otherAccountsList }
|
||||
private val navigationView by lazy { view as NavigationView }
|
||||
private val accountsHeader by lazy { navigationView.getHeaderView(0) }
|
||||
private val accountProfileBanner by lazy { accountsHeader.accountProfileBanner }
|
||||
private val floatingProfileImageSnapshot by lazy { accountsHeader.floatingProfileImageSnapshot }
|
||||
private val accountProfileImageView by lazy { accountsHeader.profileImage }
|
||||
@ -206,7 +206,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
return inflater.inflate(R.layout.fragment_accounts_dashboard, container, false)
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ import org.mariotaku.twidere.util.*
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
import org.mariotaku.twidere.util.gifshare.GifShareProvider
|
||||
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
||||
import org.mariotaku.twidere.util.promotion.PromotionService
|
||||
import org.mariotaku.twidere.util.schedule.StatusScheduleProvider
|
||||
import org.mariotaku.twidere.util.sync.SyncPreferences
|
||||
import org.mariotaku.twidere.util.sync.TimelineSyncManager
|
||||
@ -85,6 +86,8 @@ open class BaseFragment : Fragment(), IBaseFragment<BaseFragment> {
|
||||
lateinit var syncPreferences: SyncPreferences
|
||||
@Inject
|
||||
lateinit var externalThemeManager: ExternalThemeManager
|
||||
@Inject
|
||||
lateinit var promotionService: PromotionService
|
||||
|
||||
lateinit var requestManager: RequestManager
|
||||
private set
|
||||
|
@ -57,6 +57,7 @@ import org.mariotaku.twidere.annotation.CacheFileType
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_POSITION
|
||||
import org.mariotaku.twidere.extension.model.authorizationHeader
|
||||
import org.mariotaku.twidere.extension.model.getBestVideoUrlAndType
|
||||
import org.mariotaku.twidere.extension.setVisible
|
||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment
|
||||
import org.mariotaku.twidere.fragment.media.VideoPageFragment.Companion.EXTRA_PAUSED_BY_USER
|
||||
import org.mariotaku.twidere.fragment.media.VideoPageFragment.Companion.EXTRA_PLAY_AUDIO
|
||||
@ -73,6 +74,7 @@ import org.mariotaku.twidere.provider.CacheProvider
|
||||
import org.mariotaku.twidere.task.SaveFileTask
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||
import org.mariotaku.twidere.util.media.TwidereMediaDownloader
|
||||
import org.mariotaku.twidere.util.promotion.PromotionService
|
||||
import java.io.InputStream
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -93,6 +95,9 @@ class ExoPlayerPageFragment : MediaViewerFragment(), IBaseFragment<ExoPlayerPage
|
||||
@Inject
|
||||
internal lateinit var okHttpClient: OkHttpClient
|
||||
|
||||
@Inject
|
||||
internal lateinit var promotionService: PromotionService
|
||||
|
||||
private lateinit var mainHandler: Handler
|
||||
|
||||
private var playAudio: Boolean = false
|
||||
@ -135,16 +140,22 @@ class ExoPlayerPageFragment : MediaViewerFragment(), IBaseFragment<ExoPlayerPage
|
||||
hideProgress()
|
||||
val activity = activity as? MediaViewerActivity
|
||||
activity?.setBarVisibility(true)
|
||||
|
||||
adContainer.setVisible(true)
|
||||
}
|
||||
ExoPlayer.STATE_READY -> {
|
||||
playbackCompleted = playWhenReady
|
||||
playerHasError = false
|
||||
playerView.keepScreenOn = playWhenReady
|
||||
hideProgress()
|
||||
|
||||
adContainer.setVisible(!playWhenReady)
|
||||
}
|
||||
ExoPlayer.STATE_IDLE -> {
|
||||
playerView.keepScreenOn = false
|
||||
hideProgress()
|
||||
|
||||
adContainer.setVisible(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -204,6 +215,8 @@ class ExoPlayerPageFragment : MediaViewerFragment(), IBaseFragment<ExoPlayerPage
|
||||
return@setOnTouchListener true
|
||||
}
|
||||
updateVolume()
|
||||
|
||||
promotionService.loadBanner(adContainer)
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
@ -254,6 +267,11 @@ class ExoPlayerPageFragment : MediaViewerFragment(), IBaseFragment<ExoPlayerPage
|
||||
return inflater.inflate(R.layout.layout_media_viewer_exo_player_view, parent, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
promotionService.setupBanner(adContainer, PromotionService.BannerType.MEDIA_PAUSE)
|
||||
}
|
||||
|
||||
override fun onApplySystemWindowInsets(insets: Rect) {
|
||||
val lp = videoControl.layoutParams
|
||||
if (lp is ViewGroup.MarginLayoutParams) {
|
||||
|
@ -61,6 +61,7 @@ import org.mariotaku.twidere.util.media.TwidereMediaDownloader
|
||||
import org.mariotaku.twidere.util.net.TwidereDns
|
||||
import org.mariotaku.twidere.util.notification.ContentNotificationManager
|
||||
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
||||
import org.mariotaku.twidere.util.promotion.PromotionService
|
||||
import org.mariotaku.twidere.util.refresh.AutoRefreshController
|
||||
import org.mariotaku.twidere.util.refresh.JobSchedulerAutoRefreshController
|
||||
import org.mariotaku.twidere.util.refresh.LegacyAutoRefreshController
|
||||
@ -360,6 +361,12 @@ class ApplicationModule(private val context: Context) {
|
||||
return MastodonApplicationRegistry(context)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun promotionService(preferences: SharedPreferences): PromotionService {
|
||||
return PromotionService.newInstance(context, preferences)
|
||||
}
|
||||
|
||||
private fun getCacheDir(dirName: String, sizeInBytes: Long): File {
|
||||
return Utils.getExternalCacheDir(context, dirName, sizeInBytes) ?:
|
||||
Utils.getInternalCacheDir(context, dirName)
|
||||
|
@ -139,7 +139,7 @@ interface GeneralComponent {
|
||||
|
||||
fun inject(loader: BaseUserListsLoader)
|
||||
|
||||
fun inject(controller: PremiumDashboardActivity.ExtraFeatureViewController)
|
||||
fun inject(controller: PremiumDashboardActivity.BaseItemViewController)
|
||||
|
||||
fun inject(fragment: ExoPlayerPageFragment)
|
||||
|
||||
|
@ -7,10 +7,6 @@ import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.view.ContainerView
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2016/12/25.
|
||||
*/
|
||||
|
||||
abstract class ExtraFeaturesService {
|
||||
protected lateinit var context: Context
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.util.promotion
|
||||
|
||||
import android.view.ViewGroup
|
||||
|
||||
class DummyPromotionService : PromotionService() {
|
||||
override fun appStarted() {
|
||||
// No-op
|
||||
}
|
||||
|
||||
override fun setupBanner(container: ViewGroup, type: BannerType, params: ViewGroup.LayoutParams?) {
|
||||
// No-op
|
||||
}
|
||||
|
||||
override fun loadBanner(container: ViewGroup, extras: BannerExtras?) {
|
||||
// No-op
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.util.promotion
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.view.ViewGroup
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2017/9/17.
|
||||
*/
|
||||
abstract class PromotionService {
|
||||
|
||||
protected lateinit var context: Context
|
||||
private set
|
||||
protected lateinit var preferences: SharedPreferences
|
||||
private set
|
||||
|
||||
abstract fun appStarted()
|
||||
|
||||
abstract fun setupBanner(container: ViewGroup, type: BannerType, params: ViewGroup.LayoutParams? = null)
|
||||
|
||||
abstract fun loadBanner(container: ViewGroup, extras: BannerExtras? = null)
|
||||
|
||||
protected open fun init(context: Context) {
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun newInstance(context: Context, preferences: SharedPreferences): PromotionService {
|
||||
val instance = ServiceLoader.load(PromotionService::class.java).firstOrNull() ?: run {
|
||||
return@run DummyPromotionService()
|
||||
}
|
||||
instance.context = context
|
||||
instance.preferences = preferences
|
||||
instance.init(context)
|
||||
return instance
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum class BannerType {
|
||||
PREMIUM_DASHBOARD, QUICK_SEARCH, MEDIA_PAUSE
|
||||
}
|
||||
|
||||
data class BannerExtras(val contentUrl: String?)
|
||||
}
|
@ -27,10 +27,7 @@ import org.mariotaku.twidere.activity.PremiumDashboardActivity
|
||||
import org.mariotaku.twidere.constant.promotionsEnabledKey
|
||||
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2017/8/24.
|
||||
*/
|
||||
class LaunchPromotionOfferViewController : PremiumDashboardActivity.ExtraFeatureViewController() {
|
||||
class PromotionOfferViewController : PremiumDashboardActivity.ExtraFeatureViewController() {
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
@ -8,7 +8,5 @@
|
||||
android:clipToPadding="false"
|
||||
android:fitsSystemWindows="true"
|
||||
android:paddingBottom="@dimen/element_spacing_normal"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/element_spacing_normal"
|
||||
tools:context="org.mariotaku.twidere.activity.PremiumDashboardActivity"/>
|
@ -26,7 +26,9 @@
|
||||
android:layout_height="match_parent"
|
||||
android:padding="@dimen/element_spacing_normal">
|
||||
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:id="@+id/searchContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
@ -99,4 +101,12 @@
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<!-- Make sure ad won't overlap search box -->
|
||||
<FrameLayout
|
||||
android:id="@+id/adContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_below="@+id/searchContainer"/>
|
||||
|
||||
</org.mariotaku.twidere.view.ExtendedRelativeLayout>
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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/>.
|
||||
-->
|
||||
|
||||
<org.mariotaku.twidere.view.ContainerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/containerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/element_spacing_small"/>
|
@ -5,6 +5,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/element_spacing_small"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="@dimen/element_spacing_small"
|
||||
app:cardBackgroundColor="?cardItemBackgroundColor">
|
||||
|
@ -18,13 +18,25 @@
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/playerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
app:controller_layout_id="@layout/layout_media_viewer_video_controller_exo"
|
||||
app:resize_mode="fit"
|
||||
app:surface_type="texture_view"/>
|
||||
android:layout_centerInParent="true">
|
||||
|
||||
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
|
||||
android:id="@+id/playerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:controller_layout_id="@layout/layout_media_viewer_video_controller_exo"
|
||||
app:resize_mode="fit"
|
||||
app:surface_type="texture_view"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/adContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
</FrameLayout>
|
@ -7,6 +7,11 @@
|
||||
android:title="@string/action_consume_purchase"
|
||||
android:visible="@bool/debug"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/enable_promotions"
|
||||
android:enabled="@bool/debug"
|
||||
android:title="@string/action_enable_promotions"
|
||||
android:visible="@bool/debug"/>
|
||||
<item
|
||||
android:id="@+id/disable_promotions"
|
||||
android:title="@string/action_disable_promotions"/>
|
||||
|
@ -58,6 +58,7 @@
|
||||
<string name="action_edit_filter_rule">Edit rule</string>
|
||||
<string name="action_enable">Enable</string>
|
||||
<string name="action_enable_notifications">Enable notifications</string>
|
||||
<string name="action_enable_promotions">Enable promotions</string>
|
||||
<string name="action_enable_retweets">Enable retweets</string>
|
||||
<string name="action_export_to_muted_users">Export to muted users</string>
|
||||
<string name="action_favorite">Favorite</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user