Skip to content

Commit 00d8292

Browse files
committed
Make sending of statistics into a setting
Counterpart of chatmail/core#6851
1 parent 9caf94d commit 00d8292

File tree

5 files changed

+27
-18
lines changed

5 files changed

+27
-18
lines changed

jni/deltachat-core-rust

Submodule deltachat-core-rust updated 126 files

src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public class DcHelper {
7373
public static final String CONFIG_VERIFIED_ONE_ON_ONE_CHATS = "verified_one_on_one_chats";
7474
public static final String CONFIG_WEBXDC_REALTIME_ENABLED = "webxdc_realtime_enabled";
7575
public static final String CONFIG_PRIVATE_TAG = "private_tag";
76+
public static final String CONFIG_SELF_REPORTING = "self_reporting";
7677

7778
public static DcContext getContext(@NonNull Context context) {
7879
return ApplicationContext.getInstance(context).dcContext;

src/main/java/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_BCC_SELF;
66
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_MVBOX_MOVE;
77
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_ONLY_FETCH_MVBOX;
8+
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_SELF_REPORTING;
89
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_SENTBOX_WATCH;
910
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_SHOW_EMAILS;
1011
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_WEBXDC_REALTIME_ENABLED;
@@ -20,6 +21,7 @@
2021
import android.view.View;
2122
import android.webkit.WebView;
2223
import android.widget.EditText;
24+
import android.widget.TextView;
2325
import android.widget.Toast;
2426

2527
import androidx.annotation.NonNull;
@@ -39,6 +41,7 @@
3941
import org.thoughtcrime.securesms.connect.DcEventCenter;
4042
import org.thoughtcrime.securesms.connect.DcHelper;
4143
import org.thoughtcrime.securesms.proxy.ProxySettingsActivity;
44+
import org.thoughtcrime.securesms.util.IntentUtils;
4245
import org.thoughtcrime.securesms.util.Prefs;
4346
import org.thoughtcrime.securesms.util.ScreenLockUtil;
4447
import org.thoughtcrime.securesms.util.StreamUtil;
@@ -59,6 +62,7 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
5962

6063
private ListPreference showEmails;
6164
CheckBoxPreference sentboxWatchCheckbox;
65+
CheckBoxPreference selfReportingCheckbox;
6266
CheckBoxPreference bccSelfCheckbox;
6367
CheckBoxPreference mvboxMoveCheckbox;
6468
CheckBoxPreference onlyFetchMvboxCheckbox;
@@ -212,22 +216,21 @@ public void onCreate(Bundle paramBundle) {
212216
});
213217
}
214218

215-
Preference selfReporting = this.findPreference("pref_self_reporting");
216-
if (selfReporting != null) {
217-
selfReporting.setOnPreferenceClickListener(((preference) -> {
218-
try {
219-
int chatId = getRpc(requireActivity()).draftSelfReport(dcContext.getAccountId());
220-
221-
Intent intent = new Intent(requireActivity(), ConversationActivity.class);
222-
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, chatId);
223-
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
224-
requireActivity().startActivity(intent);
225-
} catch (RpcException e) {
226-
Log.e(TAG, "Error calling rpc.draftSelfReport()", e);
227-
}
219+
selfReportingCheckbox = this.findPreference("pref_self_reporting");
220+
if (selfReportingCheckbox != null) {
221+
selfReportingCheckbox.setOnPreferenceChangeListener((preference, newValue) -> {
222+
boolean enabled = (Boolean) newValue;
223+
dcContext.setConfigInt(CONFIG_SELF_REPORTING, enabled? 1 : 0);
228224

225+
if (enabled) {
226+
new AlertDialog.Builder(getActivity())
227+
.setMessage(R.string.send_stats_thanks)
228+
.setPositiveButton(android.R.string.ok, null)
229+
.setNegativeButton(R.string.more_info_desktop, (_d, _w) -> IntentUtils.showInBrowser(getContext(), "TODO[blog post]"))
230+
.show();
231+
}
229232
return true;
230-
}));
233+
});
231234
}
232235

233236
Preference proxySettings = this.findPreference("proxy_settings_button");
@@ -274,6 +277,7 @@ public void onResume() {
274277
updateListSummary(showEmails, value);
275278

276279
sentboxWatchCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_SENTBOX_WATCH));
280+
selfReportingCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_SELF_REPORTING));
277281
bccSelfCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_BCC_SELF));
278282
mvboxMoveCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_MVBOX_MOVE));
279283
onlyFetchMvboxCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_ONLY_FETCH_MVBOX));

src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,8 @@
823823
<string name="disable_imap_idle">Disable IMAP IDLE</string>
824824
<string name="disable_imap_idle_explain">Do not use IMAP IDLE extension even if the server supports it. Enabling this option will delay message retrieval, enable it only for testing.</string>
825825
<string name="send_stats_to_devs">Send statistics to Delta Chat\'s developers</string>
826-
826+
<string name="send_stats_to_devs_explanation">Send statistics about how you are using Delta Chat. They help us improve the security of Delta Chat. You can see exactly what data is being sent.</string>
827+
<string name="send_stats_thanks">Thank you for sending statistics about your Delta Chat usage!</string>
827828

828829
<!-- Emoji picker and categories -->
829830
<string name="emoji_search_results">Search Results</string>

src/main/res/xml/preferences_advanced.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
android:summary="@string/enable_realtime_explain"
1212
android:title="@string/enable_realtime"/>
1313

14-
<Preference android:key="pref_self_reporting"
15-
android:title="@string/send_stats_to_devs"/>
14+
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
15+
android:defaultValue="false"
16+
android:key="pref_self_reporting"
17+
android:title="@string/send_stats_to_devs"
18+
android:summary="@string/send_stats_to_devs_explanation"/>
1619

1720
<PreferenceCategory android:title="@string/pref_experimental_features">
1821

0 commit comments

Comments
 (0)