Skip to content

Commit

Permalink
added sms intent with MSI commands, removed sms permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
codephillip committed Sep 24, 2020
1 parent 85d7afd commit d976611
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion collect_app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":3875,"versionName":"1.24-10-g056ef9242","enabled":true,"outputFile":"collect-release.apk","fullName":"release","baseName":"release"},"path":"collect-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":3892,"versionName":"1.24-11-g85d7afd7f","enabled":true,"outputFile":"collect-release.apk","fullName":"release","baseName":"release"},"path":"collect-release.apk","properties":{}}]
4 changes: 0 additions & 4 deletions collect_app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<!-- <uses-permission android:name="android.permission.READ_SMS" />-->
<!-- <uses-permission android:name="android.permission.WRITE_SMS" />-->
<!-- <uses-permission android:name="android.permission.RECEIVE_SMS" />-->
<!-- Normal permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
public class MainMenuActivity extends CollectAbstractActivity {
private static final boolean EXIT = true;
private static final String TASK_ID = "NotificationWorker";
private static final int REQUEST_SEND_SMS = 35;
// buttons
private Button callMidwifeOrChewButton;
private Button callAmbulanceButton;
Expand Down Expand Up @@ -360,7 +359,6 @@ public void onClick(View v) {
}
viewSentCount = viewSentCursor != null ? viewSentCursor.getCount() : 0;
setupGoogleAnalytics();
requestSmsPermissions();
stopNotificationSoundAndVibration();
}

Expand Down Expand Up @@ -685,18 +683,6 @@ private void callGetInHelpUser() {
}
}

public void requestSmsPermissions() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS)
!= PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.SEND_SMS)) {
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.SEND_SMS}, REQUEST_SEND_SMS);
}
}
}

public void logoutDialog() {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainMenuActivity.this);
alertDialog.setTitle("Confirm Logout");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.KeyEvent;
Expand Down Expand Up @@ -179,26 +180,31 @@ public void cancelLongPress() {
@Override
public void onButtonClick(int buttonId) {
SmsManager smsManager = SmsManager.getDefault();
String message = "";

if (questionMediaLayout.getView_Text().getText().toString().contains("validate")) {
smsManager.sendTextMessage(BuildConfig.MSI_PHONE_NUMBER, null,
String.format(getResources().getString(R.string.validate_voucher_sms_format),
Prefs.getString(GIRL_VOUCHER_NUMBER, "123-ABC"),
BuildConfig.MSI_HEALTH_FACILITY_ID), null, null);
message = String.format(getResources().getString(R.string.validate_voucher_sms_format),
Prefs.getString(GIRL_VOUCHER_NUMBER, "123-ABC"),
BuildConfig.MSI_HEALTH_FACILITY_ID);

} else {
String redeemServiceSelected = Prefs.getString(GIRL_REDEEM_SERVICE_SELECTED, "AN1");
if (redeemServiceSelected.contains(getContext().getString(R.string.select_one))){
if (redeemServiceSelected.contains(getContext().getString(R.string.select_one))) {
ToastUtils.showShortToast("Please select a service to redeem!");
} else {
smsManager.sendTextMessage(BuildConfig.MSI_PHONE_NUMBER, null,
String.format(getResources().getString(R.string.redeem_voucher_sms_format),
Prefs.getString(GIRL_VOUCHER_NUMBER, "123-ABC"), redeemServiceSelected,
BuildConfig.MSI_HEALTH_FACILITY_ID), null, null);
message = String.format(getResources().getString(R.string.redeem_voucher_sms_format),
Prefs.getString(GIRL_VOUCHER_NUMBER, "123-ABC"), redeemServiceSelected,
BuildConfig.MSI_HEALTH_FACILITY_ID);
}
}

TextView questionText = questionMediaLayout.getView_Text();
String previousString = questionText.getText().toString();
questionText.setText(String.format("%s\n\nResult:\n%s", previousString, "Please check your sms inbox for the response and then return to the GetIN app"));

Uri uri = Uri.parse("smsto:" + BuildConfig.MSI_PHONE_NUMBER);
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
intent.putExtra("sms_body", message);
this.getContext().startActivity(intent);
}
}

0 comments on commit d976611

Please sign in to comment.