Skip to content

Commit 2343984

Browse files
committed
Fix post-Christmas regression fixes
1 parent 58566fe commit 2343984

6 files changed

Lines changed: 31 additions & 2 deletions

File tree

app/src/main/java/eu/faircode/netguard/ActivityMain.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,10 @@ public void onReceive(Context context, Intent intent) {
790790
adapter.setDisconnected();
791791
ivMetered.setVisibility(View.INVISIBLE);
792792
}
793+
if (intent.getBooleanExtra(EXTRA_REFRESH, false)) {
794+
updateApplicationList(null);
795+
loadInsightsData();
796+
}
793797
} else
794798
updateApplicationList(null);
795799
}

app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,10 @@ public void onCallStateChanged(int state, String incomingNumber) {
488488
if (cmd == Command.start || cmd == Command.reload || cmd == Command.stop) {
489489
// Update main view
490490
Intent ruleset = new Intent(ActivityMain.ACTION_RULES_CHANGED);
491+
boolean refreshRules = "changed blocking_mode".equals(reason)
492+
|| "blocklist changed".equals(reason)
493+
|| "hosts file download".equals(reason);
494+
ruleset.putExtra(ActivityMain.EXTRA_REFRESH, refreshRules);
491495
ruleset.putExtra(ActivityMain.EXTRA_CONNECTED, cmd == Command.stop ? false : last_connected);
492496
ruleset.putExtra(ActivityMain.EXTRA_METERED, cmd == Command.stop ? false : last_metered);
493497
LocalBroadcastManager.getInstance(ServiceSinkhole.this).sendBroadcast(ruleset);

app/src/main/java/net/kollnig/missioncontrol/ActivityBlocklists.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.Date;
3131
import java.util.List;
3232

33+
import eu.faircode.netguard.ServiceSinkhole;
3334
import eu.faircode.netguard.Util;
3435

3536
public class ActivityBlocklists extends AppCompatActivity {
@@ -86,9 +87,16 @@ private void showAddDialog(Blocklist item) {
8687
Blocklist newItem = new Blocklist(url, true);
8788
manager.addBlocklist(newItem);
8889
} else {
90+
if (!url.equals(item.url)) {
91+
item.lastModified = 0;
92+
item.lastDownloadSuccess = true;
93+
item.lastErrorMessage = null;
94+
manager.getBlocklistFile(item.uuid).delete();
95+
}
8996
item.url = url;
9097
manager.updateBlocklist(item);
9198
}
99+
applyBlocklists();
92100
adapter.refresh();
93101
} catch (MalformedURLException e) {
94102
Toast.makeText(ActivityBlocklists.this, R.string.msg_invalid_url, Toast.LENGTH_SHORT).show();
@@ -147,6 +155,7 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
147155
holder.switchEnabled.setOnCheckedChangeListener((buttonView, isChecked) -> {
148156
item.enabled = isChecked;
149157
manager.updateBlocklist(item);
158+
applyBlocklists();
150159
});
151160

152161
// Edit on click
@@ -158,6 +167,7 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
158167
.setMessage(R.string.msg_delete_blocklist_confirm)
159168
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
160169
manager.removeBlocklist(item.uuid);
170+
applyBlocklists();
161171
refresh();
162172
})
163173
.setNegativeButton(android.R.string.no, null)
@@ -187,4 +197,13 @@ public ViewHolder(View itemView) {
187197
}
188198
}
189199
}
200+
201+
private void applyBlocklists() {
202+
if (!manager.mergeBlocklists()) {
203+
Toast.makeText(this, R.string.msg_apply_blocklists_failed, Toast.LENGTH_SHORT).show();
204+
return;
205+
}
206+
207+
ServiceSinkhole.reload("blocklist changed", this, false);
208+
}
190209
}

app/src/main/java/net/kollnig/missioncontrol/ActivityOnboarding.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ private void finishOnboarding() {
434434
.putBoolean("enabled", vpnPrepared)
435435
.apply();
436436

437-
ServiceSinkhole.start("onboarding", this);
437+
if (vpnPrepared)
438+
ServiceSinkhole.start("onboarding", this);
438439

439440
startActivity(new Intent(this, ActivityMain.class));
440441
finish();

app/src/main/java/net/kollnig/missioncontrol/data/InsightsDataProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class InsightsDataProvider(context: Context) {
106106
uniqueCompanies.add(companyName)
107107
appsWithTrackers.add(uid)
108108

109-
// Count total trackers contacted (each row = 1 unique host)
109+
// Count tracker hosts seen over the last 7 days.
110110
data.totalTrackingAttempts += 1
111111

112112
// Check if this tracker is currently blocked

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,5 +630,6 @@ Sincerely,\n\n]]></string>
630630
<string name="title_delete_blocklist">Delete host file</string>
631631
<string name="msg_delete_blocklist_confirm">Are you sure you want to delete this host file?</string>
632632
<string name="msg_invalid_url">Invalid URL</string>
633+
<string name="msg_apply_blocklists_failed">Failed to apply host files</string>
633634
<string name="msg_last_update">Last update: %s</string>
634635
</resources>

0 commit comments

Comments
 (0)