mirror of https://github.com/M66B/NetGuard.git
Make filtering a pro feature
This commit is contained in:
parent
58cfe19c9c
commit
d01297aa21
|
@ -46,6 +46,7 @@ public class ActivityPro extends AppCompatActivity {
|
||||||
// adb shell pm clear com.android.vending
|
// adb shell pm clear com.android.vending
|
||||||
// android.test.purchased
|
// android.test.purchased
|
||||||
public static final String SKU_LOG = "log";
|
public static final String SKU_LOG = "log";
|
||||||
|
public static final String SKU_FILTER = "filter";
|
||||||
public static final String SKU_NOTIFY = "notify";
|
public static final String SKU_NOTIFY = "notify";
|
||||||
public static final String SKU_SPEED = "speed";
|
public static final String SKU_SPEED = "speed";
|
||||||
public static final String SKU_THEME = "theme";
|
public static final String SKU_THEME = "theme";
|
||||||
|
@ -68,6 +69,7 @@ public class ActivityPro extends AppCompatActivity {
|
||||||
updateState();
|
updateState();
|
||||||
|
|
||||||
TextView tvLogTitle = (TextView) findViewById(R.id.tvLogTitle);
|
TextView tvLogTitle = (TextView) findViewById(R.id.tvLogTitle);
|
||||||
|
TextView tvFilterTitle = (TextView) findViewById(R.id.tvFilterTitle);
|
||||||
TextView tvNotifyTitle = (TextView) findViewById(R.id.tvNotifyTitle);
|
TextView tvNotifyTitle = (TextView) findViewById(R.id.tvNotifyTitle);
|
||||||
TextView tvSpeedTitle = (TextView) findViewById(R.id.tvSpeedTitle);
|
TextView tvSpeedTitle = (TextView) findViewById(R.id.tvSpeedTitle);
|
||||||
TextView tvThemeTitle = (TextView) findViewById(R.id.tvThemeTitle);
|
TextView tvThemeTitle = (TextView) findViewById(R.id.tvThemeTitle);
|
||||||
|
@ -81,6 +83,7 @@ public class ActivityPro extends AppCompatActivity {
|
||||||
};
|
};
|
||||||
|
|
||||||
Linkify.addLinks(tvLogTitle, Pattern.compile(".*"), "http://www.netguard.me/#log", null, filter);
|
Linkify.addLinks(tvLogTitle, Pattern.compile(".*"), "http://www.netguard.me/#log", null, filter);
|
||||||
|
Linkify.addLinks(tvFilterTitle, Pattern.compile(".*"), "http://www.netguard.me/#filter", null, filter);
|
||||||
Linkify.addLinks(tvNotifyTitle, Pattern.compile(".*"), "http://www.netguard.me/#notify", null, filter);
|
Linkify.addLinks(tvNotifyTitle, Pattern.compile(".*"), "http://www.netguard.me/#notify", null, filter);
|
||||||
Linkify.addLinks(tvSpeedTitle, Pattern.compile(".*"), "http://www.netguard.me/#speed", null, filter);
|
Linkify.addLinks(tvSpeedTitle, Pattern.compile(".*"), "http://www.netguard.me/#speed", null, filter);
|
||||||
Linkify.addLinks(tvThemeTitle, Pattern.compile(".*"), "http://www.netguard.me/#theme", null, filter);
|
Linkify.addLinks(tvThemeTitle, Pattern.compile(".*"), "http://www.netguard.me/#theme", null, filter);
|
||||||
|
@ -127,6 +130,7 @@ public class ActivityPro extends AppCompatActivity {
|
||||||
updateState();
|
updateState();
|
||||||
|
|
||||||
final Button btnLog = (Button) findViewById(R.id.btnLog);
|
final Button btnLog = (Button) findViewById(R.id.btnLog);
|
||||||
|
final Button btnFilter = (Button) findViewById(R.id.btnFilter);
|
||||||
final Button btnNotify = (Button) findViewById(R.id.btnNotify);
|
final Button btnNotify = (Button) findViewById(R.id.btnNotify);
|
||||||
final Button btnSpeed = (Button) findViewById(R.id.btnSpeed);
|
final Button btnSpeed = (Button) findViewById(R.id.btnSpeed);
|
||||||
final Button btnTheme = (Button) findViewById(R.id.btnTheme);
|
final Button btnTheme = (Button) findViewById(R.id.btnTheme);
|
||||||
|
@ -138,6 +142,8 @@ public class ActivityPro extends AppCompatActivity {
|
||||||
try {
|
try {
|
||||||
if (view == btnLog)
|
if (view == btnLog)
|
||||||
startIntentSenderForResult(iab.getBuyIntent(SKU_LOG).getIntentSender(), view.getId(), new Intent(), 0, 0, 0);
|
startIntentSenderForResult(iab.getBuyIntent(SKU_LOG).getIntentSender(), view.getId(), new Intent(), 0, 0, 0);
|
||||||
|
else if (view == btnFilter)
|
||||||
|
startIntentSenderForResult(iab.getBuyIntent(SKU_FILTER).getIntentSender(), view.getId(), new Intent(), 0, 0, 0);
|
||||||
else if (view == btnNotify)
|
else if (view == btnNotify)
|
||||||
startIntentSenderForResult(iab.getBuyIntent(SKU_NOTIFY).getIntentSender(), view.getId(), new Intent(), 0, 0, 0);
|
startIntentSenderForResult(iab.getBuyIntent(SKU_NOTIFY).getIntentSender(), view.getId(), new Intent(), 0, 0, 0);
|
||||||
else if (view == btnSpeed)
|
else if (view == btnSpeed)
|
||||||
|
@ -154,12 +160,14 @@ public class ActivityPro extends AppCompatActivity {
|
||||||
};
|
};
|
||||||
|
|
||||||
btnLog.setOnClickListener(listener);
|
btnLog.setOnClickListener(listener);
|
||||||
|
btnFilter.setOnClickListener(listener);
|
||||||
btnNotify.setOnClickListener(listener);
|
btnNotify.setOnClickListener(listener);
|
||||||
btnSpeed.setOnClickListener(listener);
|
btnSpeed.setOnClickListener(listener);
|
||||||
btnTheme.setOnClickListener(listener);
|
btnTheme.setOnClickListener(listener);
|
||||||
btnMulti.setOnClickListener(listener);
|
btnMulti.setOnClickListener(listener);
|
||||||
|
|
||||||
btnLog.setEnabled(true);
|
btnLog.setEnabled(true);
|
||||||
|
btnFilter.setEnabled(true);
|
||||||
btnNotify.setEnabled(true);
|
btnNotify.setEnabled(true);
|
||||||
btnSpeed.setEnabled(true);
|
btnSpeed.setEnabled(true);
|
||||||
btnTheme.setEnabled(true);
|
btnTheme.setEnabled(true);
|
||||||
|
@ -200,6 +208,10 @@ public class ActivityPro extends AppCompatActivity {
|
||||||
IAB.setBought(SKU_LOG, this);
|
IAB.setBought(SKU_LOG, this);
|
||||||
updateState();
|
updateState();
|
||||||
break;
|
break;
|
||||||
|
case R.id.btnFilter:
|
||||||
|
IAB.setBought(SKU_FILTER, this);
|
||||||
|
updateState();
|
||||||
|
break;
|
||||||
case R.id.btnNotify:
|
case R.id.btnNotify:
|
||||||
IAB.setBought(SKU_NOTIFY, this);
|
IAB.setBought(SKU_NOTIFY, this);
|
||||||
updateState();
|
updateState();
|
||||||
|
@ -222,11 +234,13 @@ public class ActivityPro extends AppCompatActivity {
|
||||||
|
|
||||||
private void updateState() {
|
private void updateState() {
|
||||||
Button btnLog = (Button) findViewById(R.id.btnLog);
|
Button btnLog = (Button) findViewById(R.id.btnLog);
|
||||||
|
Button btnFilter = (Button) findViewById(R.id.btnFilter);
|
||||||
Button btnNotify = (Button) findViewById(R.id.btnNotify);
|
Button btnNotify = (Button) findViewById(R.id.btnNotify);
|
||||||
Button btnSpeed = (Button) findViewById(R.id.btnSpeed);
|
Button btnSpeed = (Button) findViewById(R.id.btnSpeed);
|
||||||
Button btnTheme = (Button) findViewById(R.id.btnTheme);
|
Button btnTheme = (Button) findViewById(R.id.btnTheme);
|
||||||
Button btnMulti = (Button) findViewById(R.id.btnMulti);
|
Button btnMulti = (Button) findViewById(R.id.btnMulti);
|
||||||
TextView tvLog = (TextView) findViewById(R.id.tvLog);
|
TextView tvLog = (TextView) findViewById(R.id.tvLog);
|
||||||
|
TextView tvFilter = (TextView) findViewById(R.id.tvFilter);
|
||||||
TextView tvNotify = (TextView) findViewById(R.id.tvNotify);
|
TextView tvNotify = (TextView) findViewById(R.id.tvNotify);
|
||||||
TextView tvSpeed = (TextView) findViewById(R.id.tvSpeed);
|
TextView tvSpeed = (TextView) findViewById(R.id.tvSpeed);
|
||||||
TextView tvTheme = (TextView) findViewById(R.id.tvTheme);
|
TextView tvTheme = (TextView) findViewById(R.id.tvTheme);
|
||||||
|
@ -234,12 +248,14 @@ public class ActivityPro extends AppCompatActivity {
|
||||||
LinearLayout llChallenge = (LinearLayout) findViewById(R.id.llChallenge);
|
LinearLayout llChallenge = (LinearLayout) findViewById(R.id.llChallenge);
|
||||||
|
|
||||||
btnLog.setVisibility(IAB.isPurchased(SKU_LOG, this) ? View.GONE : View.VISIBLE);
|
btnLog.setVisibility(IAB.isPurchased(SKU_LOG, this) ? View.GONE : View.VISIBLE);
|
||||||
|
btnFilter.setVisibility(IAB.isPurchased(SKU_FILTER, this) ? View.GONE : View.VISIBLE);
|
||||||
btnNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, this) ? View.GONE : View.VISIBLE);
|
btnNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, this) ? View.GONE : View.VISIBLE);
|
||||||
btnSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.GONE : View.VISIBLE);
|
btnSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.GONE : View.VISIBLE);
|
||||||
btnTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.GONE : View.VISIBLE);
|
btnTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.GONE : View.VISIBLE);
|
||||||
btnMulti.setVisibility(IAB.isPurchased(SKU_MULTI, this) ? View.GONE : View.VISIBLE);
|
btnMulti.setVisibility(IAB.isPurchased(SKU_MULTI, this) ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
tvLog.setVisibility(IAB.isPurchased(SKU_LOG, this) ? View.VISIBLE : View.GONE);
|
tvLog.setVisibility(IAB.isPurchased(SKU_LOG, this) ? View.VISIBLE : View.GONE);
|
||||||
|
tvFilter.setVisibility(IAB.isPurchased(SKU_FILTER, this) ? View.VISIBLE : View.GONE);
|
||||||
tvNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, this) ? View.VISIBLE : View.GONE);
|
tvNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, this) ? View.VISIBLE : View.GONE);
|
||||||
tvSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.VISIBLE : View.GONE);
|
tvSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.VISIBLE : View.GONE);
|
||||||
tvTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.VISIBLE : View.GONE);
|
tvTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.VISIBLE : View.GONE);
|
||||||
|
|
|
@ -475,6 +475,7 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
||||||
holder.lvAccess.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
holder.lvAccess.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, final int bposition, long bid) {
|
public void onItemClick(AdapterView<?> parent, View view, final int bposition, long bid) {
|
||||||
|
if (IAB.isPurchased(ActivityPro.SKU_FILTER, context)) {
|
||||||
Cursor cursor = (Cursor) badapter.getItem(bposition);
|
Cursor cursor = (Cursor) badapter.getItem(bposition);
|
||||||
final long id = cursor.getLong(cursor.getColumnIndex("ID"));
|
final long id = cursor.getLong(cursor.getColumnIndex("ID"));
|
||||||
String daddr = cursor.getString(cursor.getColumnIndex("daddr"));
|
String daddr = cursor.getString(cursor.getColumnIndex("daddr"));
|
||||||
|
@ -512,6 +513,8 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
||||||
popup.getMenu().removeItem(R.id.menu_block);
|
popup.getMenu().removeItem(R.id.menu_block);
|
||||||
|
|
||||||
popup.show();
|
popup.show();
|
||||||
|
} else
|
||||||
|
context.startActivity(new Intent(context, ActivityPro.class));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,43 @@
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?android:attr/listPreferredItemHeightSmall"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvFilterTitle"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:text="@string/title_pro_filter"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Small" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnFilter"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical|center_horizontal"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:enabled="false"
|
||||||
|
android:text="@string/title_pro_buy"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvFilter"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text="@string/title_pro_bought"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Medium"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:visibility="gone" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?android:attr/listPreferredItemHeightSmall"
|
android:layout_height="?android:attr/listPreferredItemHeightSmall"
|
||||||
|
|
|
@ -139,6 +139,7 @@ Since NetGuard has no internet permission, you know your internet traffic is not
|
||||||
<string name="title_pro_trial_ended">Pro features trial period ended</string>
|
<string name="title_pro_trial_ended">Pro features trial period ended</string>
|
||||||
<string name="title_pro_description">The following convenience features are available:</string>
|
<string name="title_pro_description">The following convenience features are available:</string>
|
||||||
<string name="title_pro_log">View blocked traffic log</string>
|
<string name="title_pro_log">View blocked traffic log</string>
|
||||||
|
<string name="title_pro_filter">Filter network traffic</string>
|
||||||
<string name="title_pro_notify">New application notifications</string>
|
<string name="title_pro_notify">New application notifications</string>
|
||||||
<string name="title_pro_speed">Network speed graph notification</string>
|
<string name="title_pro_speed">Network speed graph notification</string>
|
||||||
<string name="title_pro_theme">Appearance (theme, colors)</string>
|
<string name="title_pro_theme">Appearance (theme, colors)</string>
|
||||||
|
|
Loading…
Reference in New Issue