mirror of https://github.com/M66B/NetGuard.git
Multi user support is a pro feature
This commit is contained in:
parent
17a590c795
commit
09b841f63e
|
@ -117,10 +117,18 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
swEnabled.setChecked(enabled);
|
||||
swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
Log.i(TAG, "Switch=" + isChecked);
|
||||
prefs.edit().putBoolean("enabled", isChecked).apply();
|
||||
|
||||
if (isChecked) {
|
||||
Log.i(TAG, "Switch on");
|
||||
// Check if secondary user
|
||||
if (android.os.Process.myUid() / 100000 != 0 &&
|
||||
!IAB.isPurchased(ActivityPro.SKU_MULTI, ActivityMain.this)) {
|
||||
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) {
|
||||
|
@ -165,11 +173,8 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
prefs.edit().putBoolean("enabled", false).apply();
|
||||
}
|
||||
|
||||
} else {
|
||||
Log.i(TAG, "Switch off");
|
||||
prefs.edit().putBoolean("enabled", false).apply();
|
||||
} else
|
||||
SinkholeService.stop("switch off", ActivityMain.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ public class ActivityPro extends AppCompatActivity {
|
|||
public static final String SKU_THEME = "theme";
|
||||
public static final String SKU_SPEED = "speed";
|
||||
public static final String SKU_LOG = "log";
|
||||
public static final String SKU_MULTI = "multi";
|
||||
public static final String SKU_DONATION = "donation";
|
||||
|
||||
@Override
|
||||
|
@ -106,6 +107,7 @@ public class ActivityPro extends AppCompatActivity {
|
|||
final Button btnTheme = (Button) findViewById(R.id.btnTheme);
|
||||
final Button btnSpeed = (Button) findViewById(R.id.btnSpeed);
|
||||
final Button btnLog = (Button) findViewById(R.id.btnLog);
|
||||
final Button btnMulti = (Button) findViewById(R.id.btnMulti);
|
||||
|
||||
View.OnClickListener listener = new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -119,6 +121,8 @@ public class ActivityPro extends AppCompatActivity {
|
|||
startIntentSenderForResult(iab.getBuyIntent(SKU_SPEED).getIntentSender(), view.getId(), new Intent(), 0, 0, 0);
|
||||
else if (view == btnLog)
|
||||
startIntentSenderForResult(iab.getBuyIntent(SKU_LOG).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);
|
||||
|
@ -130,11 +134,13 @@ public class ActivityPro extends AppCompatActivity {
|
|||
btnTheme.setOnClickListener(listener);
|
||||
btnSpeed.setOnClickListener(listener);
|
||||
btnLog.setOnClickListener(listener);
|
||||
btnMulti.setOnClickListener(listener);
|
||||
|
||||
btnNotify.setEnabled(true);
|
||||
btnTheme.setEnabled(true);
|
||||
btnSpeed.setEnabled(true);
|
||||
btnLog.setEnabled(true);
|
||||
btnMulti.setEnabled(true);
|
||||
|
||||
} catch (Throwable ex) {
|
||||
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
|
||||
|
@ -183,6 +189,10 @@ public class ActivityPro extends AppCompatActivity {
|
|||
IAB.setBought(SKU_LOG, this);
|
||||
updateState();
|
||||
break;
|
||||
case R.id.btnMulti:
|
||||
IAB.setBought(SKU_MULTI, this);
|
||||
updateState();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -192,21 +202,25 @@ public class ActivityPro extends AppCompatActivity {
|
|||
Button btnTheme = (Button) findViewById(R.id.btnTheme);
|
||||
Button btnSpeed = (Button) findViewById(R.id.btnSpeed);
|
||||
Button btnLog = (Button) findViewById(R.id.btnLog);
|
||||
Button btnMulti = (Button) findViewById(R.id.btnMulti);
|
||||
TextView tvNotify = (TextView) findViewById(R.id.tvNotify);
|
||||
TextView tvTheme = (TextView) findViewById(R.id.tvTheme);
|
||||
TextView tvSpeed = (TextView) findViewById(R.id.tvSpeed);
|
||||
TextView tvLog = (TextView) findViewById(R.id.tvLog);
|
||||
TextView tvMulti = (TextView) findViewById(R.id.tvMulti);
|
||||
LinearLayout llChallenge = (LinearLayout) findViewById(R.id.llChallenge);
|
||||
|
||||
btnNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, this) ? View.GONE : View.VISIBLE);
|
||||
btnTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.GONE : View.VISIBLE);
|
||||
btnSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.GONE : View.VISIBLE);
|
||||
btnLog.setVisibility(IAB.isPurchased(SKU_LOG, this) ? View.GONE : View.VISIBLE);
|
||||
btnMulti.setVisibility(IAB.isPurchased(SKU_MULTI, this) ? View.GONE : View.VISIBLE);
|
||||
|
||||
tvNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, this) ? View.VISIBLE : View.GONE);
|
||||
tvTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.VISIBLE : View.GONE);
|
||||
tvSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.VISIBLE : View.GONE);
|
||||
tvLog.setVisibility(IAB.isPurchased(SKU_LOG, 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);
|
||||
}
|
||||
|
|
|
@ -167,6 +167,42 @@
|
|||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/listPreferredItemHeightSmall"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
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"
|
||||
|
|
|
@ -116,6 +116,7 @@ Since NetGuard has no internet permission, you know your internet traffic is not
|
|||
<string name="title_pro_theme">Appearance (theme, colors)</string>
|
||||
<string name="title_pro_speed">Network speed graph notification</string>
|
||||
<string name="title_pro_log">View blocked traffic log</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