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

Commit

Permalink
added navigation to order detail activity
Browse files Browse the repository at this point in the history
  • Loading branch information
Basler182 committed Apr 28, 2020
1 parent 88d9032 commit 5f8155f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package jetzt.machbarschaft.android.util;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import jetzt.machbarschaft.android.database.entitie.Order;

public class NavigationUtil {

/**
* Start maps app to navigate to order address
*/
public static void navigateToAddress(Order mOrder, Context context) {
if (mOrder == null) {
return;
}

@SuppressLint("DefaultLocale")
Uri locationUri = Uri.parse(String.format("geo:%f,%f?q=%s",
mOrder.getLatitude(), mOrder.getLongitude(), mOrder.getCompleteAddress()));
context.startActivity(new Intent(Intent.ACTION_VIEW, locationUri).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected void onCreate(Bundle savedInstanceState) {
// Button click handlers
btnCall.setOnClickListener(v -> {
startActivity(new Intent(this, OrderCarryOutActivity.class));
ReportProblemUtil.callUser(mOrder);
startActivity(ReportProblemUtil.callUser(mOrder));
finishAfterTransition();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package jetzt.machbarschaft.android.view.order;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

Expand All @@ -24,6 +29,7 @@
import jetzt.machbarschaft.android.database.Storage;
import jetzt.machbarschaft.android.database.entitie.Order;
import jetzt.machbarschaft.android.services.OrderInProgressNotification;
import jetzt.machbarschaft.android.util.NavigationUtil;
import jetzt.machbarschaft.android.view.home.Home;

/**
Expand Down Expand Up @@ -66,6 +72,18 @@ protected void onCreate(Bundle savedInstanceState) {

Button btn_cancel = findViewById(R.id.btn_cancel_button);
btn_cancel.setOnClickListener(v -> goBack());

Button btn_navigate = findViewById(R.id.btn__order_detail_navigate);
btn_navigate.setOnClickListener(v -> {
NavigationUtil.navigateToAddress(mOrder, getApplicationContext());
});

// Set color of icon at "navigation" button
Drawable icon = getResources().getDrawable(android.R.drawable.ic_menu_directions, getTheme());
icon.setColorFilter(

getColor(R.color.order_step_2_icon), PorterDuff.Mode.SRC_IN);
btn_navigate.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_order_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
android:layout_marginBottom="16dp" />

<Button
android:id="@+id/btn_navigate"
android:id="@+id/btn__order_detail_navigate"
style="@style/AppTheme.Button.Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down

0 comments on commit 5f8155f

Please sign in to comment.