Added an internal setting for disabling shake to report.

fork-5.53.8
Greyson Parrelli 2021-08-23 15:37:26 -04:00 zatwierdzone przez Alex Hart
rodzic b18c3ec1a9
commit a85b08d9da
6 zmienionych plików z 67 dodań i 36 usunięć

Wyświetl plik

@ -74,8 +74,8 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
)
clickPref(
title = DSLSettingsText.from(R.string.preferences__internal_refresh_remote_values),
summary = DSLSettingsText.from(R.string.preferences__internal_refresh_remote_values_description),
title = DSLSettingsText.from(R.string.preferences__internal_refresh_remote_config),
summary = DSLSettingsText.from(R.string.preferences__internal_refresh_remote_config_description),
onClick = {
refreshRemoteValues()
}
@ -83,7 +83,7 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
dividerPref()
sectionHeaderPref(R.string.preferences__internal_display)
sectionHeaderPref(R.string.preferences__internal_misc)
switchPref(
title = DSLSettingsText.from(R.string.preferences__internal_user_details),
@ -94,6 +94,15 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
}
)
switchPref(
title = DSLSettingsText.from(R.string.preferences__internal_shake_to_report),
summary = DSLSettingsText.from(R.string.preferences__internal_shake_to_report_description),
isChecked = state.shakeToReport,
onClick = {
viewModel.setShakeToReport(!state.shakeToReport)
}
)
dividerPref()
sectionHeaderPref(R.string.preferences__internal_storage_service)

Wyświetl plik

@ -4,6 +4,7 @@ import org.thoughtcrime.securesms.emoji.EmojiFiles
data class InternalSettingsState(
val seeMoreUserDetails: Boolean,
val shakeToReport: Boolean,
val gv2doNotCreateGv2Groups: Boolean,
val gv2forceInvites: Boolean,
val gv2ignoreServerChanges: Boolean,

Wyświetl plik

@ -25,6 +25,11 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
refresh()
}
fun setShakeToReport(enabled: Boolean) {
preferenceDataStore.putBoolean(InternalValues.SHAKE_TO_REPORT, enabled)
refresh()
}
fun setGv2DoNotCreateGv2Groups(enabled: Boolean) {
preferenceDataStore.putBoolean(InternalValues.GV2_DO_NOT_CREATE_GV2, enabled)
refresh()
@ -86,6 +91,7 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
private fun getState() = InternalSettingsState(
seeMoreUserDetails = SignalStore.internalValues().recipientDetails(),
shakeToReport = SignalStore.internalValues().shakeToReport(),
gv2doNotCreateGv2Groups = SignalStore.internalValues().gv2DoNotCreateGv2Groups(),
gv2forceInvites = SignalStore.internalValues().gv2ForceInvites(),
gv2ignoreServerChanges = SignalStore.internalValues().gv2IgnoreServerChanges(),

Wyświetl plik

@ -23,6 +23,7 @@ public final class InternalValues extends SignalStoreValues {
public static final String REMOVE_SENDER_KEY_MINIMUM = "internal.remove_sender_key_minimum";
public static final String DELAY_RESENDS = "internal.delay_resends";
public static final String CALLING_SERVER = "internal.calling_server";
public static final String SHAKE_TO_REPORT = "internal.shake_to_report";
InternalValues(KeyValueStore store) {
super(store);
@ -123,6 +124,13 @@ public final class InternalValues extends SignalStoreValues {
return FeatureFlags.internalUser() && getBoolean(GV2_DISABLE_AUTOMIGRATE_NOTIFICATION, false);
}
/**
* Whether or not "shake to report" is enabled.
*/
public synchronized boolean shakeToReport() {
return FeatureFlags.internalUser() && getBoolean(SHAKE_TO_REPORT, true);
}
/**
* The selected group calling server to use.
* <p>

Wyświetl plik

@ -8,12 +8,15 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import org.signal.core.util.ShakeDetector;
import org.signal.core.util.ThreadUtil;
import org.signal.core.util.logging.Log;
import org.signal.core.util.tracing.Tracer;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.logsubmit.SubmitDebugLogRepository;
import org.thoughtcrime.securesms.sharing.ShareIntents;
import org.thoughtcrime.securesms.util.FeatureFlags;
@ -42,25 +45,27 @@ public final class ShakeToReport implements ShakeDetector.Listener {
}
public void enable() {
if (!FeatureFlags.internalUser()) return;
if (!SignalStore.internalValues().shakeToReport()) return;
detector.start(ServiceUtil.getSensorManager(application));
}
public void disable() {
if (!FeatureFlags.internalUser()) return;
if (!SignalStore.internalValues().shakeToReport()) return;
detector.stop();
}
public void registerActivity(@NonNull Activity activity) {
if (!FeatureFlags.internalUser()) return;
if (!SignalStore.internalValues().shakeToReport()) return;
this.weakActivity = new WeakReference<>(activity);
}
@Override
public void onShakeDetected() {
if (!SignalStore.internalValues().shakeToReport()) return;
Activity activity = weakActivity.get();
if (activity == null) {
Log.w(TAG, "No registered activity!");
@ -69,18 +74,18 @@ public final class ShakeToReport implements ShakeDetector.Listener {
disable();
new AlertDialog.Builder(activity)
.setTitle(R.string.ShakeToReport_shake_detected)
.setMessage(R.string.ShakeToReport_submit_debug_log)
.setNegativeButton(android.R.string.cancel, (d, i) -> {
d.dismiss();
enableIfVisible();
})
.setPositiveButton(R.string.ShakeToReport_submit, (d, i) -> {
d.dismiss();
submitLog(activity);
})
.show();
new MaterialAlertDialogBuilder(activity)
.setTitle(R.string.ShakeToReport_shake_detected)
.setMessage(R.string.ShakeToReport_submit_debug_log)
.setNegativeButton(android.R.string.cancel, (d, i) -> {
d.dismiss();
enableIfVisible();
})
.setPositiveButton(R.string.ShakeToReport_submit, (d, i) -> {
d.dismiss();
submitLog(activity);
})
.show();
}
private void submitLog(@NonNull Activity activity) {
@ -106,22 +111,22 @@ public final class ShakeToReport implements ShakeDetector.Listener {
}
private void showPostSubmitDialog(@NonNull Activity activity, @NonNull String url) {
AlertDialog dialog = new AlertDialog.Builder(activity)
.setTitle(R.string.ShakeToReport_success)
.setMessage(url)
.setNegativeButton(android.R.string.cancel, (d, i) -> {
d.dismiss();
enableIfVisible();
})
.setPositiveButton(R.string.ShakeToReport_share, (d, i) -> {
d.dismiss();
enableIfVisible();
AlertDialog dialog = new MaterialAlertDialogBuilder(activity)
.setTitle(R.string.ShakeToReport_success)
.setMessage(url)
.setNegativeButton(android.R.string.cancel, (d, i) -> {
d.dismiss();
enableIfVisible();
})
.setPositiveButton(R.string.ShakeToReport_share, (d, i) -> {
d.dismiss();
enableIfVisible();
activity.startActivity(new ShareIntents.Builder(activity)
.setText(url)
.build());
})
.show();
activity.startActivity(new ShareIntents.Builder(activity)
.setText(url)
.build());
})
.show();
((TextView) dialog.findViewById(android.R.id.message)).setTextIsSelectable(true);
}

Wyświetl plik

@ -2459,11 +2459,13 @@
<string name="preferences__internal_refresh_attributes_description" translatable="false">Forces a write of capabilities on to the server followed by a read.</string>
<string name="preferences__internal_rotate_profile_key" translatable="false">Rotate profile key</string>
<string name="preferences__internal_rotate_profile_key_description" translatable="false">Creates a new versioned profile, and triggers an update of any GV2 group you belong to.</string>
<string name="preferences__internal_refresh_remote_values" translatable="false">Refresh remote values</string>
<string name="preferences__internal_refresh_remote_values_description" translatable="false">Forces a refresh of remote values locally instead of waiting for the elapsed time</string>
<string name="preferences__internal_display" translatable="false">Display</string>
<string name="preferences__internal_refresh_remote_config" translatable="false">Refresh remote config</string>
<string name="preferences__internal_refresh_remote_config_description" translatable="false">Forces a refresh of the remote config locally instead of waiting for the elapsed time.</string>
<string name="preferences__internal_misc" translatable="false">Miscellaneous</string>
<string name="preferences__internal_user_details" translatable="false">User Details</string>
<string name="preferences__internal_user_details_description" translatable="false">See more information about a user when viewing conversation settings.</string>
<string name="preferences__internal_shake_to_report" translatable="false">Shake to Report</string>
<string name="preferences__internal_shake_to_report_description" translatable="false">Shake your phone to easily submit and share a debug log.</string>
<string name="preferences__internal_storage_service" translatable="false">Storage service</string>
<string name="preferences__internal_force_storage_service_sync" translatable="false">Overwrite remote data</string>
<string name="preferences__internal_force_storage_service_sync_description" translatable="false">Forces remote storage to match the local device state.</string>