Skip to content

Commit

Permalink
Adds support for choosing location for message
Browse files Browse the repository at this point in the history
Refers to #34
  • Loading branch information
Gisson committed May 6, 2017
1 parent 6bf50d0 commit 6de12af
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class LocMessManager {
public interface CompleteCallback{
void OnComplete(boolean result, String message);
}

public static final int PICK_LOCATION_REQUEST=1;
private static LocMessManager _manager=null;
private String _currentToken = "undefined";
private String _username = "undefined";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class LocationsMenuActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {

private LocationsListAdapter messagesAdapter;
private static final String TAG = "LocationsMeny";
private static final String TAG = "LocationsMenu";
private ListLocationsCommand command;

@Override
Expand Down Expand Up @@ -162,4 +162,5 @@ public void addLocation(View v){
Intent i = new Intent(this, AddLocationActivity.class);
startActivity(i);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatSpinner;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -24,6 +25,7 @@
public class NewMessageActivity extends AppCompatActivity {

private AbstractCommand command;
private String TAG="NewMesageActivity";

private String modes[] = new String[]{
"Centralized",
Expand Down Expand Up @@ -101,7 +103,9 @@ public void selectPolicy(View v){

public void selectLocation(View v){
Intent i = new Intent(this, LocationsMenuActivity.class);
startActivity(i);
i.putExtra("chooseLocation","true");
startActivityForResult(i, LocMessManager.PICK_LOCATION_REQUEST);
//startActivity(i);
}

public void postMesage(View v){
Expand Down Expand Up @@ -141,4 +145,16 @@ public void OnComplete(boolean result, String message) {
}
});
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
Log.d(TAG,"Activity Result inc! The code is "+requestCode);
if(requestCode == LocMessManager.PICK_LOCATION_REQUEST){
Log.d(TAG,"okokok");
if( resultCode == RESULT_OK){
Log.d(TAG,"AND IT WAS SUCESSFUL!!!");
((TextView) findViewById(R.id.location_name)).setText(data.getStringExtra("locationChoice"));
}
}
}
}
19 changes: 19 additions & 0 deletions android-project/app/src/main/res/layout/dialog_location_info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.64"
android:text="Text in message"
android:textAlignment="center"
android:textSize="@dimen/read_message_text"
android:layout_marginBottom="@dimen/read_message_text"
android:layout_marginTop="@dimen/read_message_text"
android:gravity="start"/>

</LinearLayout>

0 comments on commit 6de12af

Please sign in to comment.