mirror of https://github.com/M66B/NetGuard.git
parent
7e1b909be5
commit
487e8edd13
|
@ -122,14 +122,6 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
prefs.edit().putBoolean("enabled", isChecked).apply();
|
||||
|
||||
if (isChecked) {
|
||||
// Check if secondary user
|
||||
if (!IAB.isPurchased(ActivityPro.SKU_MULTI, ActivityMain.this))
|
||||
if (android.os.Process.myUid() / 100000 != 0) {
|
||||
prefs.edit().putBoolean("enabled", false).apply();
|
||||
startActivity(new Intent(ActivityMain.this, ActivityPro.class));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final Intent prepare = VpnService.prepare(ActivityMain.this);
|
||||
if (prepare == null) {
|
||||
|
@ -274,10 +266,6 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
}
|
||||
if (!IAB.isPurchased(ActivityPro.SKU_SPEED, ActivityMain.this))
|
||||
prefs.edit().putBoolean("show_stats", false).apply();
|
||||
if (!IAB.isPurchased(ActivityPro.SKU_MULTI, ActivityMain.this)) {
|
||||
if (android.os.Process.myUid() / 100000 != 0)
|
||||
prefs.edit().putBoolean("enabled", false).apply();
|
||||
}
|
||||
|
||||
iab.unbind();
|
||||
} catch (Throwable ex) {
|
||||
|
|
|
@ -50,7 +50,6 @@ public class ActivityPro extends AppCompatActivity {
|
|||
public static final String SKU_NOTIFY = "notify";
|
||||
public static final String SKU_SPEED = "speed";
|
||||
public static final String SKU_THEME = "theme";
|
||||
public static final String SKU_MULTI = "multi";
|
||||
public static final String SKU_DONATION = "donation";
|
||||
|
||||
@Override
|
||||
|
@ -73,7 +72,6 @@ public class ActivityPro extends AppCompatActivity {
|
|||
TextView tvNotifyTitle = (TextView) findViewById(R.id.tvNotifyTitle);
|
||||
TextView tvSpeedTitle = (TextView) findViewById(R.id.tvSpeedTitle);
|
||||
TextView tvThemeTitle = (TextView) findViewById(R.id.tvThemeTitle);
|
||||
TextView tvMultiTitle = (TextView) findViewById(R.id.tvMultiTitle);
|
||||
|
||||
Linkify.TransformFilter filter = new Linkify.TransformFilter() {
|
||||
@Override
|
||||
|
@ -87,7 +85,6 @@ public class ActivityPro extends AppCompatActivity {
|
|||
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(tvThemeTitle, Pattern.compile(".*"), "http://www.netguard.me/#theme", null, filter);
|
||||
Linkify.addLinks(tvMultiTitle, Pattern.compile(".*"), "http://www.netguard.me/#multi", null, filter);
|
||||
|
||||
// Challenge
|
||||
TextView tvChallenge = (TextView) findViewById(R.id.tvChallenge);
|
||||
|
@ -134,7 +131,6 @@ public class ActivityPro extends AppCompatActivity {
|
|||
final Button btnNotify = (Button) findViewById(R.id.btnNotify);
|
||||
final Button btnSpeed = (Button) findViewById(R.id.btnSpeed);
|
||||
final Button btnTheme = (Button) findViewById(R.id.btnTheme);
|
||||
final Button btnMulti = (Button) findViewById(R.id.btnMulti);
|
||||
|
||||
View.OnClickListener listener = new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -150,8 +146,6 @@ public class ActivityPro extends AppCompatActivity {
|
|||
startIntentSenderForResult(iab.getBuyIntent(SKU_SPEED).getIntentSender(), view.getId(), new Intent(), 0, 0, 0);
|
||||
else if (view == btnTheme)
|
||||
startIntentSenderForResult(iab.getBuyIntent(SKU_THEME).getIntentSender(), view.getId(), new Intent(), 0, 0, 0);
|
||||
else if (view == btnMulti)
|
||||
startIntentSenderForResult(iab.getBuyIntent(SKU_MULTI).getIntentSender(), view.getId(), new Intent(), 0, 0, 0);
|
||||
} catch (Throwable ex) {
|
||||
Log.i(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
Util.sendCrashReport(ex, ActivityPro.this);
|
||||
|
@ -164,14 +158,12 @@ public class ActivityPro extends AppCompatActivity {
|
|||
btnNotify.setOnClickListener(listener);
|
||||
btnSpeed.setOnClickListener(listener);
|
||||
btnTheme.setOnClickListener(listener);
|
||||
btnMulti.setOnClickListener(listener);
|
||||
|
||||
btnLog.setEnabled(true);
|
||||
btnFilter.setEnabled(true);
|
||||
btnNotify.setEnabled(true);
|
||||
btnSpeed.setEnabled(true);
|
||||
btnTheme.setEnabled(true);
|
||||
btnMulti.setEnabled(true);
|
||||
|
||||
} catch (Throwable ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
|
@ -224,10 +216,6 @@ public class ActivityPro extends AppCompatActivity {
|
|||
IAB.setBought(SKU_THEME, this);
|
||||
updateState();
|
||||
break;
|
||||
case R.id.btnMulti:
|
||||
IAB.setBought(SKU_MULTI, this);
|
||||
updateState();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,13 +226,11 @@ public class ActivityPro extends AppCompatActivity {
|
|||
Button btnNotify = (Button) findViewById(R.id.btnNotify);
|
||||
Button btnSpeed = (Button) findViewById(R.id.btnSpeed);
|
||||
Button btnTheme = (Button) findViewById(R.id.btnTheme);
|
||||
Button btnMulti = (Button) findViewById(R.id.btnMulti);
|
||||
TextView tvLog = (TextView) findViewById(R.id.tvLog);
|
||||
TextView tvFilter = (TextView) findViewById(R.id.tvFilter);
|
||||
TextView tvNotify = (TextView) findViewById(R.id.tvNotify);
|
||||
TextView tvSpeed = (TextView) findViewById(R.id.tvSpeed);
|
||||
TextView tvTheme = (TextView) findViewById(R.id.tvTheme);
|
||||
TextView tvMulti = (TextView) findViewById(R.id.tvMulti);
|
||||
LinearLayout llChallenge = (LinearLayout) findViewById(R.id.llChallenge);
|
||||
|
||||
btnLog.setVisibility(IAB.isPurchased(SKU_LOG, this) ? View.GONE : View.VISIBLE);
|
||||
|
@ -252,14 +238,12 @@ public class ActivityPro extends AppCompatActivity {
|
|||
btnNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, 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);
|
||||
btnMulti.setVisibility(IAB.isPurchased(SKU_MULTI, this) ? View.GONE : View.VISIBLE);
|
||||
|
||||
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);
|
||||
tvSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.VISIBLE : View.GONE);
|
||||
tvTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.VISIBLE : View.GONE);
|
||||
tvMulti.setVisibility(IAB.isPurchased(SKU_MULTI, this) ? View.VISIBLE : View.GONE);
|
||||
|
||||
llChallenge.setVisibility(IAB.isPurchased(SKU_DONATION, this) ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
|
|
@ -1123,6 +1123,7 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
|||
|
||||
private BroadcastReceiver userReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.i(TAG, "Received " + intent);
|
||||
Util.logExtras(intent);
|
||||
|
@ -1258,10 +1259,12 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
|||
registerReceiver(interactiveStateReceiver, ifInteractive);
|
||||
|
||||
// Listen for user switches
|
||||
IntentFilter ifUser = new IntentFilter();
|
||||
ifUser.addAction(Intent.ACTION_USER_BACKGROUND);
|
||||
ifUser.addAction(Intent.ACTION_USER_FOREGROUND);
|
||||
registerReceiver(userReceiver, ifUser);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
IntentFilter ifUser = new IntentFilter();
|
||||
ifUser.addAction(Intent.ACTION_USER_BACKGROUND);
|
||||
ifUser.addAction(Intent.ACTION_USER_FOREGROUND);
|
||||
registerReceiver(userReceiver, ifUser);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// Listen for idle mode state changes
|
||||
|
@ -1354,7 +1357,8 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
|||
mServiceLooper.quit();
|
||||
|
||||
unregisterReceiver(interactiveStateReceiver);
|
||||
unregisterReceiver(userReceiver);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
unregisterReceiver(userReceiver);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
unregisterReceiver(idleStateReceiver);
|
||||
unregisterReceiver(connectivityChangedReceiver);
|
||||
|
|
|
@ -208,43 +208,6 @@
|
|||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/listPreferredItemHeightSmall"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvMultiTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="2"
|
||||
android:text="@string/title_pro_multi"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnMulti"
|
||||
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/tvMulti"
|
||||
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
|
||||
android:id="@+id/llChallenge"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -143,7 +143,6 @@ Since NetGuard has no internet permission, you know your internet traffic is not
|
|||
<string name="title_pro_notify">New application notifications</string>
|
||||
<string name="title_pro_speed">Network speed graph notification</string>
|
||||
<string name="title_pro_theme">Appearance (theme, colors)</string>
|
||||
<string name="title_pro_multi">Multi user support</string>
|
||||
<string name="title_pro_buy">Details</string>
|
||||
<string name="title_pro_bought">Enabled</string>
|
||||
<string name="title_pro_challenge">Challenge</string>
|
||||
|
|
Loading…
Reference in New Issue