1
0
mirror of https://github.com/akaessens/NoFbEventScraper synced 2025-06-05 23:29:13 +02:00

add maps intent

not gmaps exclusive
closes #9
This commit is contained in:
akaessens
2020-08-26 17:56:20 +02:00
parent 9fd1a975ec
commit 57b00e2e57
3 changed files with 41 additions and 3 deletions

View File

@ -41,7 +41,7 @@ public class MainActivity extends AppCompatActivity {
private ImageView toolbar_image_view; private ImageView toolbar_image_view;
private CollapsingToolbarLayout toolbar_layout; private CollapsingToolbarLayout toolbar_layout;
private TextInputLayout input_layout; private TextInputLayout input_layout;
private TextInputLayout location_layout;
private FbScraper scraper; private FbScraper scraper;
@Override @Override
@ -56,6 +56,7 @@ public class MainActivity extends AppCompatActivity {
field_uri_input = (TextInputEditText) findViewById(R.id.field_uri_input); field_uri_input = (TextInputEditText) findViewById(R.id.field_uri_input);
input_layout = (TextInputLayout) findViewById(R.id.textInputLayout); input_layout = (TextInputLayout) findViewById(R.id.textInputLayout);
location_layout = (TextInputLayout) findViewById(R.id.location_layout);
field_event_name = (TextInputEditText) findViewById(R.id.field_event_name); field_event_name = (TextInputEditText) findViewById(R.id.field_event_name);
field_event_start = (TextInputEditText) findViewById(R.id.field_event_start); field_event_start = (TextInputEditText) findViewById(R.id.field_event_start);
field_event_end = (TextInputEditText) findViewById(R.id.field_event_end); field_event_end = (TextInputEditText) findViewById(R.id.field_event_end);
@ -66,6 +67,7 @@ public class MainActivity extends AppCompatActivity {
ok_button.setEnabled(false); ok_button.setEnabled(false);
location_layout.setEndIconVisible(false);
toolbar_image_view.setImageResource(R.drawable.ic_banner_foreground); toolbar_image_view.setImageResource(R.drawable.ic_banner_foreground);
@ -122,6 +124,23 @@ public class MainActivity extends AppCompatActivity {
} }
}); });
location_layout.setEndIconOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String map_search = "geo:0,0?q=" + field_event_location.getText();
Uri gmmIntentUri = Uri.parse(map_search);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
//mapIntent.setPackage("com.google.android.apps.maps");
if (mapIntent.resolveActivity(getPackageManager()) != null) {
startActivity(mapIntent);
}
}
});
ok_button.setOnClickListener(new View.OnClickListener() { ok_button.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -276,6 +295,7 @@ public class MainActivity extends AppCompatActivity {
scraper = null; scraper = null;
} }
ok_button.setEnabled(false); ok_button.setEnabled(false);
location_layout.setEndIconVisible(false);
toolbar_image_view.setImageResource(R.drawable.ic_banner_foreground); toolbar_image_view.setImageResource(R.drawable.ic_banner_foreground);
} }
@ -306,6 +326,11 @@ public class MainActivity extends AppCompatActivity {
{ {
field_event_location.setError("no event location detected"); field_event_location.setError("no event location detected");
} }
else
{
location_layout.setEndIconVisible(true);
field_event_location.setError(null);
}
field_event_description.setText(event.description); field_event_description.setText(event.description);
if (event.description.equals("")) if (event.description.equals(""))

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,2C8.14,2 5,5.14 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.86 -3.14,-7 -7,-7zM16,10h-3v3h-2v-3L8,10L8,8h3L11,5h2v3h3v2z"
android:fillColor="#000000"/>
</vector>

View File

@ -130,10 +130,14 @@
android:singleLine="true" /> android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:id="@+id/location_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
app:endIconDrawable="@drawable/ic_add_location"
app:endIconMode="custom">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/field_event_location" android:id="@+id/field_event_location"
@ -142,8 +146,8 @@
android:autoLink="map" android:autoLink="map"
android:clickable="true" android:clickable="true"
android:cursorVisible="true" android:cursorVisible="true"
android:inputType="textNoSuggestions"
android:hint="Event location" android:hint="Event location"
android:inputType="textNoSuggestions"
android:singleLine="true" /> android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>