List of usage examples for android.app PendingIntent getIntentSender
public IntentSender getIntentSender()
From source file:eu.faircode.netguard.ActivityPro.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "Create"); Util.setTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.pro);/* w ww .j a v a 2 s . c om*/ getSupportActionBar().setTitle(R.string.title_pro); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); // Initial state updateState(); 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); Linkify.TransformFilter filter = new Linkify.TransformFilter() { @Override public String transformUrl(Matcher match, String url) { return ""; } }; Linkify.addLinks(tvLogTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_LOG, null, filter); Linkify.addLinks(tvFilterTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_FILTER, null, filter); Linkify.addLinks(tvNotifyTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_NOTIFY, null, filter); Linkify.addLinks(tvSpeedTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_SPEED, null, filter); Linkify.addLinks(tvThemeTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_THEME, null, filter); Linkify.addLinks(tvAllTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_PRO1, null, filter); Linkify.addLinks(tvDev1Title, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_SUPPORT1, null, filter); Linkify.addLinks(tvDev2Title, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_SUPPORT2, null, filter); String android_id = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); String challenge = (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? Build.SERIAL : "O3" + android_id); String seed = (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? "NetGuard2" : "NetGuard3"); // Challenge TextView tvChallenge = findViewById(R.id.tvChallenge); tvChallenge.setText(challenge); // Response try { final String response = Util.md5(challenge, seed); EditText etResponse = findViewById(R.id.etResponse); 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); updateState(); } } }); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } try { iab = new IAB(new IAB.Delegate() { @Override public void onReady(final IAB iab) { Log.i(TAG, "IAB ready"); try { iab.updatePurchases(); updateState(); 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); View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View view) { try { int id = 0; PendingIntent pi = null; if (view == btnLog) { id = SKU_LOG_ID; pi = iab.getBuyIntent(SKU_LOG, false); } else if (view == btnFilter) { id = SKU_FILTER_ID; pi = iab.getBuyIntent(SKU_FILTER, false); } else if (view == btnNotify) { id = SKU_NOTIFY_ID; pi = iab.getBuyIntent(SKU_NOTIFY, false); } else if (view == btnSpeed) { id = SKU_SPEED_ID; pi = iab.getBuyIntent(SKU_SPEED, false); } else if (view == btnTheme) { id = SKU_THEME_ID; pi = iab.getBuyIntent(SKU_THEME, false); } else if (view == btnAll) { id = SKU_PRO1_ID; pi = iab.getBuyIntent(SKU_PRO1, false); } else if (view == btnDev1) { id = SKU_SUPPORT1_ID; pi = iab.getBuyIntent(SKU_SUPPORT1, true); } else if (view == btnDev2) { id = SKU_SUPPORT2_ID; pi = iab.getBuyIntent(SKU_SUPPORT2, true); } if (id > 0 && pi != null) startIntentSenderForResult(pi.getIntentSender(), id, new Intent(), 0, 0, 0); } catch (Throwable ex) { Log.i(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } } }; btnLog.setOnClickListener(listener); btnFilter.setOnClickListener(listener); btnNotify.setOnClickListener(listener); btnSpeed.setOnClickListener(listener); btnTheme.setOnClickListener(listener); btnAll.setOnClickListener(listener); btnDev1.setOnClickListener(listener); btnDev2.setOnClickListener(listener); btnLog.setEnabled(true); btnFilter.setEnabled(true); btnNotify.setEnabled(true); btnSpeed.setEnabled(true); btnTheme.setEnabled(true); btnAll.setEnabled(true); btnDev1.setEnabled(true); btnDev2.setEnabled(true); } 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)); } }