2015-12-30 08:58:21 +00:00
|
|
|
package eu.faircode.netguard;
|
|
|
|
|
|
|
|
/*
|
|
|
|
This file is part of NetGuard.
|
|
|
|
|
|
|
|
NetGuard 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.
|
|
|
|
|
|
|
|
NetGuard 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 NetGuard. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-12-31 16:12:49 +00:00
|
|
|
Copyright 2015-2019 by Marcel Bokhorst (M66B)
|
2015-12-30 08:58:21 +00:00
|
|
|
*/
|
|
|
|
|
2016-02-18 08:16:18 +00:00
|
|
|
import android.app.PendingIntent;
|
2019-08-10 09:08:13 +00:00
|
|
|
import android.content.ClipData;
|
|
|
|
import android.content.ClipboardManager;
|
|
|
|
import android.content.Context;
|
2015-12-30 08:58:21 +00:00
|
|
|
import android.content.Intent;
|
2018-02-07 14:34:17 +00:00
|
|
|
import android.graphics.Paint;
|
|
|
|
import android.net.Uri;
|
2015-12-31 09:03:32 +00:00
|
|
|
import android.os.Build;
|
2015-12-30 08:58:21 +00:00
|
|
|
import android.os.Bundle;
|
2017-08-05 08:27:27 +00:00
|
|
|
import android.provider.Settings;
|
2015-12-31 09:03:32 +00:00
|
|
|
import android.text.Editable;
|
|
|
|
import android.text.TextWatcher;
|
2015-12-30 08:58:21 +00:00
|
|
|
import android.util.Log;
|
2018-02-06 17:41:50 +00:00
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuInflater;
|
2015-12-30 08:58:21 +00:00
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
2015-12-31 09:03:32 +00:00
|
|
|
import android.view.WindowManager;
|
2015-12-30 08:58:21 +00:00
|
|
|
import android.widget.Button;
|
2015-12-31 09:03:32 +00:00
|
|
|
import android.widget.EditText;
|
2019-08-10 09:08:13 +00:00
|
|
|
import android.widget.ImageButton;
|
2015-12-30 08:58:21 +00:00
|
|
|
import android.widget.TextView;
|
2019-08-10 09:08:13 +00:00
|
|
|
import android.widget.Toast;
|
2015-12-30 08:58:21 +00:00
|
|
|
|
2018-11-17 16:32:36 +00:00
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
import androidx.core.app.NavUtils;
|
|
|
|
|
2019-08-10 09:08:13 +00:00
|
|
|
import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN;
|
|
|
|
|
2015-12-30 08:58:21 +00:00
|
|
|
public class ActivityPro extends AppCompatActivity {
|
|
|
|
private static final String TAG = "NetGuard.Pro";
|
|
|
|
|
|
|
|
private IAB iab;
|
|
|
|
|
|
|
|
// adb shell pm clear com.android.vending
|
2016-01-03 08:51:36 +00:00
|
|
|
// android.test.purchased
|
2016-07-17 16:49:07 +00:00
|
|
|
|
|
|
|
private static final int SKU_LOG_ID = 1;
|
|
|
|
private static final int SKU_FILTER_ID = 2;
|
|
|
|
private static final int SKU_NOTIFY_ID = 3;
|
|
|
|
private static final int SKU_SPEED_ID = 4;
|
|
|
|
private static final int SKU_THEME_ID = 5;
|
|
|
|
private static final int SKU_PRO1_ID = 6;
|
2016-07-23 08:07:39 +00:00
|
|
|
private static final int SKU_SUPPORT1_ID = 7;
|
2016-07-23 15:27:20 +00:00
|
|
|
private static final int SKU_SUPPORT2_ID = 8;
|
2016-07-17 16:49:07 +00:00
|
|
|
|
2016-01-21 16:57:55 +00:00
|
|
|
public static final String SKU_LOG = "log";
|
2016-01-31 08:30:06 +00:00
|
|
|
public static final String SKU_FILTER = "filter";
|
2016-01-03 08:51:36 +00:00
|
|
|
public static final String SKU_NOTIFY = "notify";
|
2015-12-30 08:58:21 +00:00
|
|
|
public static final String SKU_SPEED = "speed";
|
2016-01-21 16:57:55 +00:00
|
|
|
public static final String SKU_THEME = "theme";
|
2016-02-07 09:30:50 +00:00
|
|
|
public static final String SKU_PRO1 = "pro1";
|
2016-07-23 08:07:39 +00:00
|
|
|
public static final String SKU_SUPPORT1 = "support1";
|
2016-07-23 15:27:20 +00:00
|
|
|
public static final String SKU_SUPPORT2 = "support2";
|
2015-12-30 08:58:21 +00:00
|
|
|
public static final String SKU_DONATION = "donation";
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
2015-12-31 09:18:00 +00:00
|
|
|
Log.i(TAG, "Create");
|
2016-01-02 15:38:24 +00:00
|
|
|
Util.setTheme(this);
|
2015-12-30 08:58:21 +00:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.pro);
|
|
|
|
|
|
|
|
getSupportActionBar().setTitle(R.string.title_pro);
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
2015-12-31 09:03:32 +00:00
|
|
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
|
|
|
|
2015-12-31 15:55:39 +00:00
|
|
|
// Initial state
|
2015-12-30 08:58:21 +00:00
|
|
|
updateState();
|
|
|
|
|
2017-08-05 08:27:27 +00:00
|
|
|
TextView tvLogTitle = findViewById(R.id.tvLogTitle);
|
|
|
|
TextView tvFilterTitle = findViewById(R.id.tvFilterTitle);
|
|
|
|
TextView tvNotifyTitle = findViewById(R.id.tvNotifyTitle);
|
|
|
|
TextView tvSpeedTitle = findViewById(R.id.tvSpeedTitle);
|
|
|
|
TextView tvThemeTitle = findViewById(R.id.tvThemeTitle);
|
|
|
|
TextView tvAllTitle = findViewById(R.id.tvAllTitle);
|
|
|
|
TextView tvDev1Title = findViewById(R.id.tvDev1Title);
|
|
|
|
TextView tvDev2Title = findViewById(R.id.tvDev2Title);
|
2016-01-21 13:33:19 +00:00
|
|
|
|
2018-02-07 14:34:17 +00:00
|
|
|
tvLogTitle.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
tvFilterTitle.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
tvNotifyTitle.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
tvSpeedTitle.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
tvThemeTitle.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
tvAllTitle.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
tvDev1Title.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
tvDev2Title.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
|
|
|
|
View.OnClickListener listener = new View.OnClickListener() {
|
2016-01-21 13:33:19 +00:00
|
|
|
@Override
|
2018-02-07 14:34:17 +00:00
|
|
|
public void onClick(View view) {
|
|
|
|
String sku;
|
|
|
|
switch (view.getId()) {
|
|
|
|
case R.id.tvLogTitle:
|
|
|
|
sku = SKU_LOG;
|
|
|
|
break;
|
|
|
|
case R.id.tvFilterTitle:
|
|
|
|
sku = SKU_FILTER;
|
|
|
|
break;
|
|
|
|
case R.id.tvNotifyTitle:
|
|
|
|
sku = SKU_NOTIFY;
|
|
|
|
break;
|
|
|
|
case R.id.tvSpeedTitle:
|
|
|
|
sku = SKU_SPEED;
|
|
|
|
break;
|
|
|
|
case R.id.tvThemeTitle:
|
|
|
|
sku = SKU_THEME;
|
|
|
|
break;
|
|
|
|
case R.id.tvAllTitle:
|
|
|
|
sku = SKU_PRO1;
|
|
|
|
break;
|
|
|
|
case R.id.tvDev1Title:
|
|
|
|
sku = SKU_SUPPORT1;
|
|
|
|
break;
|
|
|
|
case R.id.tvDev2Title:
|
|
|
|
sku = SKU_SUPPORT2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sku = SKU_PRO1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
|
|
intent.setData(Uri.parse("http://www.netguard.me/#" + sku));
|
|
|
|
if (intent.resolveActivity(getPackageManager()) != null)
|
|
|
|
startActivity(intent);
|
2016-01-21 13:33:19 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-07 14:34:17 +00:00
|
|
|
tvLogTitle.setOnClickListener(listener);
|
|
|
|
tvFilterTitle.setOnClickListener(listener);
|
|
|
|
tvNotifyTitle.setOnClickListener(listener);
|
|
|
|
tvSpeedTitle.setOnClickListener(listener);
|
|
|
|
tvThemeTitle.setOnClickListener(listener);
|
|
|
|
tvAllTitle.setOnClickListener(listener);
|
|
|
|
tvDev1Title.setOnClickListener(listener);
|
|
|
|
tvDev2Title.setOnClickListener(listener);
|
2016-01-21 13:33:19 +00:00
|
|
|
|
2015-12-30 08:58:21 +00:00
|
|
|
try {
|
|
|
|
iab = new IAB(new IAB.Delegate() {
|
|
|
|
@Override
|
2016-02-18 08:16:18 +00:00
|
|
|
public void onReady(final IAB iab) {
|
2015-12-30 08:58:21 +00:00
|
|
|
Log.i(TAG, "IAB ready");
|
|
|
|
try {
|
2015-12-31 15:55:39 +00:00
|
|
|
iab.updatePurchases();
|
|
|
|
updateState();
|
2015-12-30 08:58:21 +00:00
|
|
|
|
2017-08-05 08:27:27 +00:00
|
|
|
final Button btnLog = findViewById(R.id.btnLog);
|
|
|
|
final Button btnFilter = findViewById(R.id.btnFilter);
|
|
|
|
final Button btnNotify = findViewById(R.id.btnNotify);
|
|
|
|
final Button btnSpeed = findViewById(R.id.btnSpeed);
|
|
|
|
final Button btnTheme = findViewById(R.id.btnTheme);
|
|
|
|
final Button btnAll = findViewById(R.id.btnAll);
|
|
|
|
final Button btnDev1 = findViewById(R.id.btnDev1);
|
|
|
|
final Button btnDev2 = findViewById(R.id.btnDev2);
|
2015-12-30 08:58:21 +00:00
|
|
|
|
|
|
|
View.OnClickListener listener = new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
try {
|
2016-07-17 16:49:07 +00:00
|
|
|
int id = 0;
|
2016-02-18 08:16:18 +00:00
|
|
|
PendingIntent pi = null;
|
2016-07-17 16:49:07 +00:00
|
|
|
if (view == btnLog) {
|
|
|
|
id = SKU_LOG_ID;
|
2016-07-23 08:09:09 +00:00
|
|
|
pi = iab.getBuyIntent(SKU_LOG, false);
|
2016-07-17 16:49:07 +00:00
|
|
|
} else if (view == btnFilter) {
|
|
|
|
id = SKU_FILTER_ID;
|
2016-07-23 08:09:09 +00:00
|
|
|
pi = iab.getBuyIntent(SKU_FILTER, false);
|
2016-07-17 16:49:07 +00:00
|
|
|
} else if (view == btnNotify) {
|
|
|
|
id = SKU_NOTIFY_ID;
|
2016-07-23 08:09:09 +00:00
|
|
|
pi = iab.getBuyIntent(SKU_NOTIFY, false);
|
2016-07-17 16:49:07 +00:00
|
|
|
} else if (view == btnSpeed) {
|
|
|
|
id = SKU_SPEED_ID;
|
2016-07-23 08:09:09 +00:00
|
|
|
pi = iab.getBuyIntent(SKU_SPEED, false);
|
2016-07-17 16:49:07 +00:00
|
|
|
} else if (view == btnTheme) {
|
|
|
|
id = SKU_THEME_ID;
|
2016-07-23 08:09:09 +00:00
|
|
|
pi = iab.getBuyIntent(SKU_THEME, false);
|
2016-07-17 16:49:07 +00:00
|
|
|
} else if (view == btnAll) {
|
|
|
|
id = SKU_PRO1_ID;
|
2016-07-23 08:09:09 +00:00
|
|
|
pi = iab.getBuyIntent(SKU_PRO1, false);
|
2016-07-23 15:27:20 +00:00
|
|
|
} else if (view == btnDev1) {
|
2016-07-23 08:07:39 +00:00
|
|
|
id = SKU_SUPPORT1_ID;
|
2016-07-23 08:09:09 +00:00
|
|
|
pi = iab.getBuyIntent(SKU_SUPPORT1, true);
|
2016-07-23 15:27:20 +00:00
|
|
|
} else if (view == btnDev2) {
|
|
|
|
id = SKU_SUPPORT2_ID;
|
|
|
|
pi = iab.getBuyIntent(SKU_SUPPORT2, true);
|
2016-07-17 16:49:07 +00:00
|
|
|
}
|
2016-02-18 08:16:18 +00:00
|
|
|
|
2016-07-17 16:49:07 +00:00
|
|
|
if (id > 0 && pi != null)
|
|
|
|
startIntentSenderForResult(pi.getIntentSender(), id, new Intent(), 0, 0, 0);
|
2015-12-30 08:58:21 +00:00
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.i(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-01-21 16:57:55 +00:00
|
|
|
btnLog.setOnClickListener(listener);
|
2016-01-31 08:30:06 +00:00
|
|
|
btnFilter.setOnClickListener(listener);
|
2015-12-31 09:03:32 +00:00
|
|
|
btnNotify.setOnClickListener(listener);
|
2015-12-30 08:58:21 +00:00
|
|
|
btnSpeed.setOnClickListener(listener);
|
2016-01-21 16:57:55 +00:00
|
|
|
btnTheme.setOnClickListener(listener);
|
2016-02-07 09:30:50 +00:00
|
|
|
btnAll.setOnClickListener(listener);
|
2016-07-23 15:27:20 +00:00
|
|
|
btnDev1.setOnClickListener(listener);
|
|
|
|
btnDev2.setOnClickListener(listener);
|
2015-12-30 08:58:21 +00:00
|
|
|
|
2016-01-21 16:57:55 +00:00
|
|
|
btnLog.setEnabled(true);
|
2016-01-31 08:30:06 +00:00
|
|
|
btnFilter.setEnabled(true);
|
2015-12-31 09:03:32 +00:00
|
|
|
btnNotify.setEnabled(true);
|
2015-12-30 08:58:21 +00:00
|
|
|
btnSpeed.setEnabled(true);
|
2016-01-21 16:57:55 +00:00
|
|
|
btnTheme.setEnabled(true);
|
2016-02-07 09:30:50 +00:00
|
|
|
btnAll.setEnabled(true);
|
2016-07-23 15:27:20 +00:00
|
|
|
btnDev1.setEnabled(true);
|
|
|
|
btnDev2.setEnabled(true);
|
2015-12-30 08:58:21 +00:00
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
iab.bind();
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDestroy() {
|
2015-12-31 09:18:00 +00:00
|
|
|
Log.i(TAG, "Destroy");
|
2015-12-30 08:58:21 +00:00
|
|
|
iab.unbind();
|
2016-11-10 07:54:32 +00:00
|
|
|
iab = null;
|
2015-12-30 08:58:21 +00:00
|
|
|
super.onDestroy();
|
|
|
|
}
|
|
|
|
|
2018-02-06 17:41:50 +00:00
|
|
|
@Override
|
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
MenuInflater inflater = getMenuInflater();
|
|
|
|
inflater.inflate(R.menu.pro, menu);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-02 08:01:04 +00:00
|
|
|
@Override
|
2015-12-30 08:58:21 +00:00
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case android.R.id.home:
|
2016-02-02 08:01:04 +00:00
|
|
|
Log.i(TAG, "Up");
|
|
|
|
NavUtils.navigateUpFromSameTask(this);
|
2015-12-30 08:58:21 +00:00
|
|
|
return true;
|
2018-02-06 17:41:50 +00:00
|
|
|
case R.id.menu_challenge:
|
|
|
|
menu_challenge();
|
|
|
|
return true;
|
2016-02-02 08:01:04 +00:00
|
|
|
default:
|
|
|
|
return super.onOptionsItemSelected(item);
|
2015-12-30 08:58:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-06 17:41:50 +00:00
|
|
|
@Override
|
|
|
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
|
|
|
if (IAB.isPurchased(SKU_DONATION, this) || Util.isPlayStoreInstall(this))
|
|
|
|
menu.removeItem(R.id.menu_challenge);
|
|
|
|
|
|
|
|
return super.onPrepareOptionsMenu(menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void menu_challenge() {
|
|
|
|
LayoutInflater inflater = LayoutInflater.from(this);
|
|
|
|
View view = inflater.inflate(R.layout.challenge, null, false);
|
|
|
|
|
|
|
|
final AlertDialog dialog = new AlertDialog.Builder(this)
|
|
|
|
.setView(view)
|
|
|
|
.setCancelable(true)
|
|
|
|
.create();
|
|
|
|
|
|
|
|
String android_id = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
|
2019-08-10 09:08:13 +00:00
|
|
|
final String challenge = (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? Build.SERIAL : "O3" + android_id);
|
2018-02-06 17:41:50 +00:00
|
|
|
String seed = (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? "NetGuard2" : "NetGuard3");
|
|
|
|
|
|
|
|
// Challenge
|
|
|
|
TextView tvChallenge = view.findViewById(R.id.tvChallenge);
|
|
|
|
tvChallenge.setText(challenge);
|
|
|
|
|
2019-08-10 09:08:13 +00:00
|
|
|
ImageButton ibCopy = view.findViewById(R.id.ibCopy);
|
|
|
|
ibCopy.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
|
|
|
ClipData clip = ClipData.newPlainText(getString(R.string.title_pro_challenge), challenge);
|
|
|
|
clipboard.setPrimaryClip(clip);
|
|
|
|
Toast.makeText(ActivityPro.this, android.R.string.copy, Toast.LENGTH_LONG).show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-02-06 17:41:50 +00:00
|
|
|
// Response
|
2019-08-10 09:08:13 +00:00
|
|
|
final EditText etResponse = view.findViewById(R.id.etResponse);
|
2018-02-06 17:41:50 +00:00
|
|
|
try {
|
|
|
|
final String response = Util.md5(challenge, seed);
|
|
|
|
etResponse.addTextChangedListener(new TextWatcher() {
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
// Do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
// Do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable editable) {
|
|
|
|
if (response.equals(editable.toString().toUpperCase())) {
|
|
|
|
IAB.setBought(SKU_DONATION, ActivityPro.this);
|
|
|
|
dialog.dismiss();
|
|
|
|
invalidateOptionsMenu();
|
|
|
|
updateState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
|
|
|
}
|
|
|
|
|
2019-08-10 09:08:13 +00:00
|
|
|
ImageButton ibPaste = view.findViewById(R.id.ibPaste);
|
|
|
|
ibPaste.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
|
|
|
if (clipboard != null &&
|
|
|
|
clipboard.hasPrimaryClip() &&
|
|
|
|
clipboard.getPrimaryClipDescription().hasMimeType(MIMETYPE_TEXT_PLAIN)) {
|
|
|
|
ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
|
|
|
|
etResponse.setText(item.getText().toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-02-06 17:41:50 +00:00
|
|
|
dialog.show();
|
|
|
|
}
|
|
|
|
|
2015-12-30 08:58:21 +00:00
|
|
|
@Override
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
switch (requestCode) {
|
2016-07-17 16:49:07 +00:00
|
|
|
case SKU_LOG_ID:
|
2016-01-21 16:57:55 +00:00
|
|
|
IAB.setBought(SKU_LOG, this);
|
2015-12-30 08:58:21 +00:00
|
|
|
updateState();
|
|
|
|
break;
|
2016-07-17 16:49:07 +00:00
|
|
|
case SKU_FILTER_ID:
|
2016-01-31 08:30:06 +00:00
|
|
|
IAB.setBought(SKU_FILTER, this);
|
|
|
|
updateState();
|
|
|
|
break;
|
2016-07-17 16:49:07 +00:00
|
|
|
case SKU_NOTIFY_ID:
|
2016-01-21 16:57:55 +00:00
|
|
|
IAB.setBought(SKU_NOTIFY, this);
|
2015-12-30 08:58:21 +00:00
|
|
|
updateState();
|
|
|
|
break;
|
2016-07-17 16:49:07 +00:00
|
|
|
case SKU_SPEED_ID:
|
2015-12-30 08:58:21 +00:00
|
|
|
IAB.setBought(SKU_SPEED, this);
|
|
|
|
updateState();
|
|
|
|
break;
|
2016-07-17 16:49:07 +00:00
|
|
|
case SKU_THEME_ID:
|
2016-01-21 16:57:55 +00:00
|
|
|
IAB.setBought(SKU_THEME, this);
|
2016-01-05 12:40:02 +00:00
|
|
|
updateState();
|
|
|
|
break;
|
2016-07-17 16:49:07 +00:00
|
|
|
case SKU_PRO1_ID:
|
2016-02-07 09:30:50 +00:00
|
|
|
IAB.setBought(SKU_PRO1, this);
|
|
|
|
updateState();
|
|
|
|
break;
|
2016-07-23 08:07:39 +00:00
|
|
|
case SKU_SUPPORT1_ID:
|
|
|
|
IAB.setBought(SKU_SUPPORT1, this);
|
|
|
|
updateState();
|
|
|
|
break;
|
2016-07-23 15:27:20 +00:00
|
|
|
case SKU_SUPPORT2_ID:
|
|
|
|
IAB.setBought(SKU_SUPPORT2, this);
|
|
|
|
updateState();
|
|
|
|
break;
|
2015-12-30 08:58:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateState() {
|
2017-08-05 08:27:27 +00:00
|
|
|
Button btnLog = findViewById(R.id.btnLog);
|
|
|
|
Button btnFilter = findViewById(R.id.btnFilter);
|
|
|
|
Button btnNotify = findViewById(R.id.btnNotify);
|
|
|
|
Button btnSpeed = findViewById(R.id.btnSpeed);
|
|
|
|
Button btnTheme = findViewById(R.id.btnTheme);
|
|
|
|
Button btnAll = findViewById(R.id.btnAll);
|
|
|
|
Button btnDev1 = findViewById(R.id.btnDev1);
|
|
|
|
Button btnDev2 = findViewById(R.id.btnDev2);
|
|
|
|
TextView tvLog = findViewById(R.id.tvLog);
|
|
|
|
TextView tvFilter = findViewById(R.id.tvFilter);
|
|
|
|
TextView tvNotify = findViewById(R.id.tvNotify);
|
|
|
|
TextView tvSpeed = findViewById(R.id.tvSpeed);
|
|
|
|
TextView tvTheme = findViewById(R.id.tvTheme);
|
|
|
|
TextView tvAll = findViewById(R.id.tvAll);
|
|
|
|
TextView tvDev1 = findViewById(R.id.tvDev1);
|
|
|
|
TextView tvDev2 = findViewById(R.id.tvDev2);
|
|
|
|
|
|
|
|
TextView tvLogUnavailable = findViewById(R.id.tvLogUnavailable);
|
|
|
|
TextView tvFilterUnavailable = findViewById(R.id.tvFilterUnavailable);
|
2017-04-11 05:49:28 +00:00
|
|
|
|
2017-04-08 06:30:42 +00:00
|
|
|
boolean can = Util.canFilter(this);
|
|
|
|
|
2017-04-11 05:49:28 +00:00
|
|
|
btnLog.setVisibility(IAB.isPurchased(SKU_LOG, this) || !can ? View.GONE : View.VISIBLE);
|
|
|
|
btnFilter.setVisibility(IAB.isPurchased(SKU_FILTER, this) || !can ? View.GONE : View.VISIBLE);
|
2016-01-01 18:03:41 +00:00
|
|
|
btnNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, this) ? View.GONE : View.VISIBLE);
|
|
|
|
btnSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.GONE : View.VISIBLE);
|
2016-01-21 16:57:55 +00:00
|
|
|
btnTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.GONE : View.VISIBLE);
|
2017-04-11 05:49:28 +00:00
|
|
|
btnAll.setVisibility(IAB.isPurchased(SKU_PRO1, this) ? View.GONE : View.VISIBLE);
|
2016-07-23 15:27:20 +00:00
|
|
|
btnDev1.setVisibility(IAB.isPurchased(SKU_SUPPORT1, this) ? View.GONE : View.VISIBLE);
|
|
|
|
btnDev2.setVisibility(IAB.isPurchased(SKU_SUPPORT2, this) ? View.GONE : View.VISIBLE);
|
2015-12-30 17:57:00 +00:00
|
|
|
|
2017-04-11 05:49:28 +00:00
|
|
|
tvLog.setVisibility(IAB.isPurchased(SKU_LOG, this) && can ? View.VISIBLE : View.GONE);
|
|
|
|
tvFilter.setVisibility(IAB.isPurchased(SKU_FILTER, this) && can ? View.VISIBLE : View.GONE);
|
2016-01-01 18:03:41 +00:00
|
|
|
tvNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, this) ? View.VISIBLE : View.GONE);
|
|
|
|
tvSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.VISIBLE : View.GONE);
|
2016-01-21 16:57:55 +00:00
|
|
|
tvTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.VISIBLE : View.GONE);
|
2016-02-07 09:30:50 +00:00
|
|
|
tvAll.setVisibility(IAB.isPurchased(SKU_PRO1, this) ? View.VISIBLE : View.GONE);
|
2016-07-23 15:27:20 +00:00
|
|
|
tvDev1.setVisibility(IAB.isPurchased(SKU_SUPPORT1, this) ? View.VISIBLE : View.GONE);
|
|
|
|
tvDev2.setVisibility(IAB.isPurchased(SKU_SUPPORT2, this) ? View.VISIBLE : View.GONE);
|
2015-12-31 09:03:32 +00:00
|
|
|
|
2017-04-11 05:49:28 +00:00
|
|
|
tvLogUnavailable.setVisibility(can ? View.GONE : View.VISIBLE);
|
|
|
|
tvFilterUnavailable.setVisibility(can ? View.GONE : View.VISIBLE);
|
2015-12-30 08:58:21 +00:00
|
|
|
}
|
|
|
|
}
|