Skip to content
This repository has been archived by the owner on Mar 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request #204 from PanicInitiative/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
niccs committed Feb 2, 2016
2 parents e111af6 + 5eeab08 commit 86a9198
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
4 changes: 3 additions & 1 deletion app/src/main/java/org/iilab/pb/alert/PanicMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.location.Location;
import android.util.Log;

import org.iilab.pb.R;
import org.iilab.pb.common.ApplicationSettings;
Expand All @@ -13,7 +14,7 @@
import static android.telephony.SmsMessage.MAX_USER_DATA_SEPTETS;

public class PanicMessage {
// public static final int TWITTER_MAX_LENGTH = 140;
private static final String TAG= PanicMessage.class.getName();
private Context context;
private Location location;

Expand All @@ -34,6 +35,7 @@ public void sendAlertMessage(Location location) {

public void sendStopAlertMessage() {
String message = SMSSettings.retrieveStopAlertMessage(context);
Log.d(TAG, "Stop Alert message is " + message);
sendMessage(message, getPhoneNumbers());
}

Expand Down
42 changes: 24 additions & 18 deletions app/src/main/java/org/iilab/pb/fragment/SetupMessageFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,28 @@
import org.iilab.pb.R;
import org.iilab.pb.WizardActivity;
import org.iilab.pb.adapter.PageItemAdapter;
import org.iilab.pb.common.AppConstants;
import org.iilab.pb.common.AppUtil;
import org.iilab.pb.common.ApplicationSettings;
import org.iilab.pb.common.MyTagHandler;
import org.iilab.pb.data.PBDatabase;
import org.iilab.pb.model.Page;
import org.iilab.pb.model.PageItem;
import org.iilab.pb.model.SMSSettings;

import static org.iilab.pb.common.AppConstants.DEFAULT_CONFIRMATION_MESSAGE;
import static org.iilab.pb.common.AppConstants.FROM_MAIN_ACTIVITY;
import static org.iilab.pb.common.AppConstants.FROM_WIZARD_ACTIVITY;
import static org.iilab.pb.common.AppConstants.IMAGE_INLINE;
import static org.iilab.pb.common.AppConstants.PAGE_ID;
import static org.iilab.pb.common.AppConstants.PARENT_ACTIVITY;
import static org.iilab.pb.common.AppUtil.updateImages;
import static org.iilab.pb.common.ApplicationSettings.getSelectedLanguage;


/**
* Created by aoe on 12/12/13.
*/
public class SetupMessageFragment extends Fragment {

private static final String PAGE_ID = "page_id";
private static final String PARENT_ACTIVITY = "parent_activity";
private static final String TAG = SetupMessageFragment.class.getName();
private Activity activity;
DisplayMetrics metrics;
int parentActivity;
Expand Down Expand Up @@ -73,7 +78,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
if (childFragment == null) {
childFragment = new MessageTextFragment();
Bundle args = new Bundle();
args.putInt(AppConstants.PARENT_ACTIVITY, parentActivity);
args.putInt(PARENT_ACTIVITY, parentActivity);
childFragment.setArguments(args);
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.replace(R.id.sms_message, childFragment);
Expand All @@ -84,28 +89,29 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
bAction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e(">>>>", "action button pressed");
Log.d(TAG, "action button pressed");

MessageTextFragment childFragment = (MessageTextFragment) getChildFragmentManager().findFragmentById(R.id.sms_message);
String emergencyMessage = childFragment.getEmergencyMsgFromView();
SMSSettings.saveMessage(activity, emergencyMessage);
childFragment.displayEmergencyMsg(emergencyMessage);
if (parentActivity == AppConstants.FROM_MAIN_ACTIVITY) {
String stopAlertMessage=childFragment.getStopAlertMsgFromView();
SMSSettings.saveStopAlertMessage(activity, stopAlertMessage);
String stopAlertMessage=getString(R.string.stop_alert_message);
if (parentActivity == FROM_MAIN_ACTIVITY) {
stopAlertMessage=childFragment.getStopAlertMsgFromView();
Log.d(TAG, "stop alert message is " + stopAlertMessage);
childFragment.displayStopAlertMsg(stopAlertMessage);
}

SMSSettings.saveStopAlertMessage(activity, stopAlertMessage);
String pageId = currentPage.getAction().get(0).getLink();
// parentActivity = getArguments().getInt(PARENT_ACTIVITY);
Intent i;

if (parentActivity == AppConstants.FROM_WIZARD_ACTIVITY) {
if (parentActivity == FROM_WIZARD_ACTIVITY) {
i = new Intent(activity, WizardActivity.class);
} else {
// AppUtil.showToast("Message saved.", 1000, activity);
// showToast("Message saved.", 1000, activity);
String confirmation = (currentPage.getAction().get(0).getConfirmation() == null)
? AppConstants.DEFAULT_CONFIRMATION_MESSAGE
? DEFAULT_CONFIRMATION_MESSAGE
: currentPage.getAction().get(0).getConfirmation();
Toast.makeText(activity, confirmation, Toast.LENGTH_SHORT).show();

Expand All @@ -114,7 +120,7 @@ public void onClick(View v) {
i.putExtra(PAGE_ID, pageId);
startActivity(i);

if (parentActivity == AppConstants.FROM_MAIN_ACTIVITY) {
if (parentActivity == FROM_MAIN_ACTIVITY) {
activity.finish();
}
}
Expand All @@ -134,7 +140,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
int parentActivity = getArguments().getInt(PARENT_ACTIVITY);
Intent i;

if (parentActivity == AppConstants.FROM_WIZARD_ACTIVITY) {
if (parentActivity == FROM_WIZARD_ACTIVITY) {
i = new Intent(activity, WizardActivity.class);
} else {
i = new Intent(activity, MainActivity.class);
Expand All @@ -159,7 +165,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

String pageId = getArguments().getString(PAGE_ID);
String selectedLang = ApplicationSettings.getSelectedLanguage(activity);
String selectedLang = getSelectedLanguage(activity);

PBDatabase dbInstance = new PBDatabase(activity);
dbInstance.open();
Expand Down Expand Up @@ -189,7 +195,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
lvItems.setAdapter(pageItemAdapter);
pageItemAdapter.setData(currentPage.getItems());

AppUtil.updateImages(true, currentPage.getContent(), activity, metrics, tvContent, AppConstants.IMAGE_INLINE);
updateImages(true, currentPage.getContent(), activity, metrics, tvContent, IMAGE_INLINE);

}
}
Expand Down

0 comments on commit 86a9198

Please sign in to comment.