Skip to content

Commit

Permalink
Added a dialog which informs about disabling SMS feature
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Feb 19, 2019
1 parent d47e331 commit 371b968
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@
import org.odk.collect.android.R;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.dao.InstancesDao;
import org.odk.collect.android.fragments.dialogs.SimpleDialog;
import org.odk.collect.android.preferences.AdminKeys;
import org.odk.collect.android.preferences.AdminPreferencesActivity;
import org.odk.collect.android.preferences.AdminSharedPreferences;
import org.odk.collect.android.preferences.AutoSendPreferenceMigrator;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.GeneralKeys;
import org.odk.collect.android.preferences.PreferencesActivity;
import org.odk.collect.android.preferences.Transport;
import org.odk.collect.android.provider.InstanceProviderAPI.InstanceColumns;
import org.odk.collect.android.utilities.ApplicationConstants;
import org.odk.collect.android.utilities.PlayServicesUtil;
Expand All @@ -68,6 +70,8 @@

import timber.log.Timber;

import static org.odk.collect.android.preferences.GeneralKeys.KEY_SUBMISSION_TRANSPORT_TYPE;

/**
* Responsible for displaying buttons to launch the major activities. Launches
* some activities based on returns of others.
Expand Down Expand Up @@ -113,6 +117,8 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.main_menu);
initToolbar();

showSMSFeatureDisabledDialogIfNeeded();

// enter data button. expects a result.
Button enterDataButton = findViewById(R.id.enter_data);
enterDataButton.setText(getString(R.string.enter_data_button));
Expand Down Expand Up @@ -648,4 +654,13 @@ public void onChange(boolean selfChange) {
}
}

private void showSMSFeatureDisabledDialogIfNeeded() {
if (Transport.Internet != Transport.fromPreference(GeneralSharedPreferences.getInstance().get(KEY_SUBMISSION_TRANSPORT_TYPE))) {
GeneralSharedPreferences.getInstance().save(KEY_SUBMISSION_TRANSPORT_TYPE, getString(R.string.transport_type_value_internet));

SimpleDialog
.newInstance(getString(R.string.sms_feature_disabled_dialog_title), 0, getString(R.string.sms_feature_disabled_dialog_message), getString(R.string.ok), false)
.show(getSupportFragmentManager(), SimpleDialog.COLLECT_DIALOG_TAG);
}
}
}
2 changes: 2 additions & 0 deletions collect_app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -664,4 +664,6 @@
<string name="background_location_disabled">This form wants to track your location but tracking is disabled. Please enable in the \u0020\u0020⋮\u0020\u0020 menu above.</string>
<string name="background_location_enabled">This form tracks your location. You can disable tracking in the \u0020\u0020⋮\u0020\u0020 menu above.</string>
<string name="open_file">Open file</string>
<string name="sms_feature_disabled_dialog_title">SMS feature disabled</string>
<string name="sms_feature_disabled_dialog_message">Sending forms via SMS has been disabled in v1.20.0 due to the new Google\'s permission policy. We will try to bring the feature back soon.</string>
</resources>

0 comments on commit 371b968

Please sign in to comment.