2016-12-25 17:20:08 +01:00
|
|
|
package org.mariotaku.twidere.fragment
|
|
|
|
|
|
|
|
import android.app.Dialog
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.support.v7.app.AlertDialog
|
2016-12-26 04:25:55 +01:00
|
|
|
import android.view.View
|
2016-12-25 17:20:08 +01:00
|
|
|
import org.mariotaku.twidere.R
|
2016-12-26 04:25:55 +01:00
|
|
|
import org.mariotaku.twidere.util.premium.ExtraFeaturesChecker
|
2016-12-25 17:20:08 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by mariotaku on 2016/12/25.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class ExtraFeaturesIntroductionDialogFragment : BaseDialogFragment() {
|
2016-12-26 04:25:55 +01:00
|
|
|
|
|
|
|
private lateinit var extraFeaturesChecker: ExtraFeaturesChecker
|
|
|
|
|
|
|
|
override fun onDestroy() {
|
|
|
|
extraFeaturesChecker.release()
|
|
|
|
super.onDestroy()
|
|
|
|
}
|
|
|
|
|
2016-12-25 17:20:08 +01:00
|
|
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
2016-12-26 04:25:55 +01:00
|
|
|
extraFeaturesChecker = ExtraFeaturesChecker.newInstance(context)
|
2016-12-25 17:20:08 +01:00
|
|
|
val builder = AlertDialog.Builder(context)
|
|
|
|
builder.setTitle(R.string.title_extra_features)
|
|
|
|
builder.setView(R.layout.dialog_extra_features_introduction)
|
|
|
|
builder.setPositiveButton(R.string.action_purchase) { dialog, which ->
|
2016-12-26 04:25:55 +01:00
|
|
|
startActivity(extraFeaturesChecker.createPurchaseIntent(context))
|
2016-12-25 17:20:08 +01:00
|
|
|
}
|
|
|
|
builder.setNegativeButton(R.string.action_later) { dialog, which ->
|
|
|
|
|
|
|
|
}
|
2016-12-26 04:25:55 +01:00
|
|
|
val restorePurchaseIntent = extraFeaturesChecker.createRestorePurchaseIntent(context)
|
|
|
|
if (restorePurchaseIntent != null) {
|
|
|
|
builder.setNeutralButton(R.string.action_restore_purchase) { dialog, which ->
|
|
|
|
startActivity(restorePurchaseIntent)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val dialog = builder.create()
|
|
|
|
dialog.setOnShowListener {
|
|
|
|
it as Dialog
|
|
|
|
it.findViewById(R.id.restorePurchaseHint).visibility = if (restorePurchaseIntent != null) {
|
|
|
|
View.VISIBLE
|
|
|
|
} else {
|
|
|
|
View.GONE
|
|
|
|
}
|
2016-12-25 17:20:08 +01:00
|
|
|
}
|
2016-12-26 04:25:55 +01:00
|
|
|
return dialog
|
2016-12-25 17:20:08 +01:00
|
|
|
}
|
|
|
|
}
|