Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

White list menu #386

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
case BLACKLIST:
holder.blacklist.setChecked(true);
break;
case PERMITTEDLIST:
holder.permittedList.setChecked(true);
break;
}
holder.showSystemApps.setOnCheckedChangeListener((buttonView, isChecked) -> settingsCallback.shouldShowSystemApps(isChecked));
holder.disabled.setOnCheckedChangeListener((buttonView, isChecked) -> {
Expand All @@ -56,6 +59,13 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
}

});
holder.permittedList.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
settingsCallback.splitTunnelMode(SplitTunnelMode.PERMITTEDLIST);
FileManager.set("splitTunnelMode", SplitTunnelMode.PERMITTEDLIST.toString());
}

});
}

@Override
Expand All @@ -73,12 +83,14 @@ public static class ViewHolder extends RecyclerView.ViewHolder {
SwitchMaterial showSystemApps;
RadioButton disabled;
RadioButton blacklist;
RadioButton permittedList;

public ViewHolder(@NonNull View itemView) {
super(itemView);
showSystemApps = itemView.findViewById(R.id.showSystemApps);
disabled = itemView.findViewById(R.id.disabled);
blacklist = itemView.findViewById(R.id.blacklist);
permittedList = itemView.findViewById(R.id.permittedList);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

public enum SplitTunnelMode {
DISABLED,
BLACKLIST;
BLACKLIST,
PERMITTEDLIST;

public static SplitTunnelMode getSplitTunnelMode() {
SplitTunnelMode splitTunnelMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,15 @@ private void configureVpnBuilder(VpnService.Builder builder) throws Exception {

// Determine split tunnel mode
SplitTunnelMode splitTunnelMode = SplitTunnelMode.getSplitTunnelMode();
if (splitTunnelMode == SplitTunnelMode.BLACKLIST) {
if (splitTunnelMode != SplitTunnelMode.DISABLED) {
Set<String> splitTunnelApps = getSplitTunnelApps();
for (String packageName : splitTunnelApps) {
try {
builder.addDisallowedApplication(packageName);
if (splitTunnelMode == SplitTunnelMode.BLACKLIST)
builder.addDisallowedApplication(packageName);
else if (splitTunnelMode == SplitTunnelMode.PERMITTEDLIST)
builder.addAllowedApplication(packageName);

} catch (PackageManager.NameNotFoundException ignored) {
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
android:layout_height="wrap_content"
android:fontFamily="@font/shabnam"
android:minWidth="100dp"
android:text="@string/blackList"
android:text="@string/blackWhiteList"
android:textAlignment="viewEnd"
android:textColor="@color/text_color"
android:textSize="20sp" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_split_tunnel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
android:fontFamily="@font/shabnamlight"
android:text="@string/blackList"
android:text="@string/blackWhiteList"
android:textColor="@color/text_color"
android:textSize="24sp"
tools:ignore="RelativeOverlap"
Expand Down
38 changes: 37 additions & 1 deletion app/src/main/res/layout/split_tunnel_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
android:textSize="14sp"
android:focusable="true"
android:nextFocusUp="@id/disabled"
android:nextFocusDown="@id/showSystemApps" />
android:nextFocusDown="@id/permittedList" />

<TextView
android:layout_width="match_parent"
Expand All @@ -86,6 +86,42 @@
android:text="@string/enabledRText"
android:textAlignment="textStart"
android:textSize="14sp" />

<RadioButton
android:id="@+id/permittedList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:background="?android:selectableItemBackground"
android:button="@null"
android:textColor="@color/text_color"
android:drawableRight="?android:attr/listChoiceIndicatorSingle"
android:fontFamily="@font/shabnam"
android:layoutDirection="rtl"
android:paddingLeft="20dp"
android:paddingTop="10dp"
android:paddingRight="20dp"
android:paddingBottom="10dp"
android:text="@string/Permitted"
android:textAlignment="textStart"
android:textSize="14sp"
android:focusable="true"
android:nextFocusUp="@id/blacklist"
android:nextFocusDown="@id/showSystemApps" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:fontFamily="@font/shabnam"
android:layoutDirection="rtl"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textColor="@color/subtitle_color"
android:paddingBottom="10dp"
android:text="@string/permittedText"
android:textAlignment="textStart"
android:textSize="14sp" />
</RadioGroup>

<com.google.android.material.switchmaterial.SwitchMaterial
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<string name="segaro">#سگارو</string>
<string name="yousef">#یوسف_قبادی</string>
<string name="slogan">اینترنت برای همه، یا هیچکس</string>
<string name="blackList">لیست سیاه</string>
<string name="blackWhiteList">لیست سیاه/سفید</string>
<string name="disabledR">غیرفعال</string>
<string name="disabledRText">در حالت غیرفعال، ترافیک تمامی برنامه‌ها از VPN عبور می‌کند.</string>
<string name="enabledR">فعال</string>
Expand Down Expand Up @@ -92,4 +92,6 @@
<item>بریتانیا</item>
<item>ایالات متحده</item>
</string-array>
<string name="Permitted">مجاز</string>
<string name="permittedText">در حالت مجاز، فقط ترافیک برنامه های انتخاب شده از VPN عبور می کند.</string>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<string name="segaro">#Segaro</string>
<string name="yousef">#Yousef_Ghobadi</string>
<string name="slogan">Интернет для всех или ни для кого</string>
<string name="blackList">Черный список</string>
<string name="blackWhiteList">Черный/Белый список</string>
<string name="disabledR">Отключено</string>
<string name="disabledRText">В режиме отключения весь трафик приложений проходит через VPN.</string>
<string name="enabledR">Включено</string>
Expand Down Expand Up @@ -92,4 +92,6 @@
<item>Великобритания</item>
<item>Соединенные Штаты</item>
</string-array>
<string name="Permitted">Разрешено</string>
<string name="permittedText">В разрешенном режиме через VPN проходит только трафик выбранных приложений.</string>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<string name="segaro">#Segaro</string>
<string name="yousef">#Yousef_Ghobadi</string>
<string name="slogan">İnternet Herkes İçin, Ya Da Hiç Kimse İçin</string>
<string name="blackList">Kara Liste</string>
<string name="blackWhiteList">Kara/Beyaz Liste</string>
<string name="disabledR">Devre Dışı</string>
<string name="disabledRText">Devre dışı modda, tüm uygulamaların trafiği VPN üzerinden geçer.</string>
<string name="enabledR">Etkin</string>
Expand Down Expand Up @@ -92,4 +92,6 @@
<item>Birleşik Krallık</item>
<item>Birleşik Devletler</item>
</string-array>
<string name="Permitted">İzin verildi</string>
<string name="permittedText">İzin verilen modda yalnızca seçili uygulamaların trafiği VPN üzerinden geçer.</string>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<string name="segaro">#Segaro</string>
<string name="yousef">#Yousef_Ghobadi</string>
<string name="slogan">互联网为所有人,或者无人</string>
<string name="blackList">黑名单</string>
<string name="blackWhiteList">黑/白名单</string>
<string name="disabledR">全局模式</string>
<string name="disabledRText">在全局模式下,所有应用的流量都通过VPN。</string>
<string name="enabledR">绕行模式</string>
Expand Down Expand Up @@ -92,5 +92,7 @@
<item>美国</item>
</string-array>
<string name="select_language">选择语言</string>
<string name="Permitted">允许</string>
<string name="permittedText">在允许模式下,只有选定的应用程序的流量通过 VPN。</string>

</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<string name="segaro">#Segaro</string>
<string name="yousef">#Yousef_Ghobadi</string>
<string name="slogan">Internet for All, or No One</string>
<string name="blackList">Blacklist</string>
<string name="blackWhiteList">Black/White list</string>
<string name="disabledR">Disabled</string>
<string name="disabledRText">In disabled mode, traffic of all apps passes through VPN.</string>
<string name="enabledR">Enabled</string>
Expand Down Expand Up @@ -131,4 +131,6 @@
<item>IPv4</item>
<item>IPv6</item>
</string-array>
<string name="Permitted">Permitted</string>
<string name="permittedText">In permitted mode, just traffic of selected apps pass through VPN.</string>
</resources>