fixed google play purchase redeem
This commit is contained in:
parent
7e20e20781
commit
521f947420
|
@ -71,11 +71,14 @@ class GooglePlayInAppPurchaseActivity : BaseActivity(), BillingProcessor.IBillin
|
|||
}
|
||||
|
||||
private fun handleError(billingResponse: Int) {
|
||||
if (billingResponse == BILLING_ERROR_OTHER_ERROR) {
|
||||
getProductDetailsAndFinish()
|
||||
} else {
|
||||
setResult(getResultCode(billingResponse))
|
||||
finish()
|
||||
when (billingResponse) {
|
||||
BILLING_ERROR_OTHER_ERROR, BILLING_ERROR_INVALID_DEVELOPER_PAYLOAD -> {
|
||||
getProductDetailsAndFinish()
|
||||
}
|
||||
else -> {
|
||||
setResult(getResultCode(billingResponse))
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package org.mariotaku.twidere.model.sync
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import org.mariotaku.twidere.service.DropboxDataSyncService
|
||||
import org.mariotaku.twidere.util.sync.DropboxSyncController
|
||||
import org.mariotaku.twidere.util.sync.SyncController
|
||||
|
||||
/**
|
||||
|
@ -29,15 +28,4 @@ class DropboxSyncProviderInfo(val authToken: String) : SyncProviderInfo(DropboxS
|
|||
}
|
||||
}
|
||||
|
||||
class DropboxSyncController(val context: Context) : SyncController() {
|
||||
override fun cleanupSyncCache() {
|
||||
|
||||
}
|
||||
|
||||
override fun performSync() {
|
||||
context.startService(Intent(context, DropboxDataSyncService::class.java))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package org.mariotaku.twidere.util.sync
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import org.mariotaku.twidere.service.DropboxDataSyncService
|
||||
|
||||
class DropboxSyncController(val context: Context) : SyncController() {
|
||||
override fun cleanupSyncCache() {
|
||||
context.syncDataDir.listFiles { file, name -> file.isFile }.forEach { file ->
|
||||
file.delete()
|
||||
}
|
||||
}
|
||||
|
||||
override fun performSync() {
|
||||
context.startService(Intent(context, DropboxDataSyncService::class.java))
|
||||
}
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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 android.util.Log;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.mariotaku.twidere.TwidereConstants.LOGTAG;
|
||||
|
||||
public class ClearCachePreference extends AsyncTaskPreference {
|
||||
|
||||
public ClearCachePreference(final Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ClearCachePreference(final Context context, final AttributeSet attrs) {
|
||||
this(context, attrs, R.attr.preferenceStyle);
|
||||
}
|
||||
|
||||
public ClearCachePreference(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInBackground() {
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
final File externalCacheDir = context.getExternalCacheDir();
|
||||
if (externalCacheDir != null) {
|
||||
final File[] files = externalCacheDir.listFiles();
|
||||
if (files != null) {
|
||||
for (final File file : files) {
|
||||
deleteRecursive(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
final File internalCacheDir = context.getCacheDir();
|
||||
if (internalCacheDir != null) {
|
||||
final File[] files = internalCacheDir.listFiles();
|
||||
if (files != null) {
|
||||
for (final File file : files) {
|
||||
deleteRecursive(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteRecursive(final File f) {
|
||||
if (f.isDirectory()) {
|
||||
final File[] files = f.listFiles();
|
||||
if (files == null) return;
|
||||
for (final File c : files) {
|
||||
deleteRecursive(c);
|
||||
}
|
||||
}
|
||||
if (!f.delete()) {
|
||||
Log.w(LOGTAG, String.format("Unable to delete %s", f));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -53,9 +53,10 @@ class ExtraFeaturesIntroductionCardFragment : BaseSupportFragment() {
|
|||
activity?.recreate()
|
||||
}
|
||||
REQUEST_RESTORE_PURCHASE -> {
|
||||
if (requestCode == Activity.RESULT_OK) {
|
||||
activity?.recreate()
|
||||
} else when (resultCode) {
|
||||
when (resultCode) {
|
||||
Activity.RESULT_OK -> {
|
||||
activity?.recreate()
|
||||
}
|
||||
RESULT_NOT_PURCHASED -> {
|
||||
Toast.makeText(context, R.string.message_extra_features_not_purchased, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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
|
||||
|
||||
class ClearCachePreference @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = R.attr.preferenceStyle
|
||||
) : AsyncTaskPreference(context, attrs, defStyle) {
|
||||
|
||||
override fun doInBackground() {
|
||||
val context = context ?: return
|
||||
val externalCacheDir = context.externalCacheDir
|
||||
if (externalCacheDir != null) {
|
||||
externalCacheDir.listFiles()?.forEach { file ->
|
||||
file.deleteRecursively()
|
||||
}
|
||||
}
|
||||
val internalCacheDir = context.cacheDir
|
||||
if (internalCacheDir != null) {
|
||||
internalCacheDir.listFiles()?.forEach { file ->
|
||||
file.deleteRecursively()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue