diff options
21 files changed, 675 insertions, 51 deletions
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser Binary files differindex d0a563d..0f5c9d1 100644 --- a/.idea/caches/build_file_checksums.ser +++ b/.idea/caches/build_file_checksums.ser diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml deleted file mode 100644 index 5806fb3..0000000 --- a/.idea/kotlinc.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="Kotlin2JsCompilerArguments"> - <option name="sourceMapEmbedSources" /> - <option name="sourceMapPrefix" /> - </component> -</project>
\ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index d1817bf..99202cc 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,11 +5,12 @@ <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> <option name="myNullables"> <value> - <list size="4"> + <list size="5"> <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> - <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> - <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> + <item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" /> + <item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> + <item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> </list> </value> </option> @@ -24,5 +25,10 @@ </value> </option> </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK" /> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/build/classes" /> + </component> + <component name="ProjectType"> + <option name="id" value="Android" /> + </component> </project>
\ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index f6f9cee..33f5b4a 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ <project version="4"> <component name="ProjectModuleManager"> <modules> - <module fileurl="file://$PROJECT_DIR$/.idea/Liberavem.iml" filepath="$PROJECT_DIR$/.idea/Liberavem.iml" /> + <module fileurl="file://$PROJECT_DIR$/Liberavem.iml" filepath="$PROJECT_DIR$/Liberavem.iml" /> <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> </modules> </component> diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 8306744..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="VcsDirectoryMappings"> - <mapping directory="" vcs="Git" /> - <mapping directory="$PROJECT_DIR$" vcs="Git" /> - </component> -</project>
\ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 21419c7..fe925d9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,11 +26,14 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" - implementation 'com.android.support:appcompat-v7:27.1.0' - implementation 'com.android.support:support-v4:27.1.0' - implementation 'com.android.support:design:27.1.0' - implementation 'com.android.support.constraint:constraint-layout:1.0.2' - implementation 'com.android.support:support-vector-drawable:27.1.0' + implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:support-v4:27.1.1' + implementation 'com.android.support:design:27.1.1' + implementation 'com.android.support.constraint:constraint-layout:1.1.0' + implementation 'com.android.support:support-vector-drawable:27.1.1' + implementation 'com.android.volley:volley:1.1.0' + implementation 'com.google.code.gson:gson:2.8.2' + implementation 'com.squareup.retrofit2:retrofit:2.4.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c5206f3..edc0b5d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,6 +3,8 @@ xmlns:tools="http://schemas.android.com/tools" package="org.marcinzelent.liberavem"> + <uses-permission android:name="android.permission.INTERNET" /> + <application android:allowBackup="false" android:icon="@mipmap/ic_launcher" @@ -23,7 +25,8 @@ </activity> <activity android:name=".SettingsActivity" - android:label="@string/title_activity_settings"></activity> + android:label="@string/title_activity_settings" /> + <activity android:name=".ObservationDetailsActivity"></activity> </application> </manifest>
\ No newline at end of file diff --git a/app/src/main/java/org/marcinzelent/liberavem/AllObservationsFragment.java b/app/src/main/java/org/marcinzelent/liberavem/AllObservationsFragment.java index ee07682..3f3ad7b 100644 --- a/app/src/main/java/org/marcinzelent/liberavem/AllObservationsFragment.java +++ b/app/src/main/java/org/marcinzelent/liberavem/AllObservationsFragment.java @@ -1,18 +1,40 @@ package org.marcinzelent.liberavem; +import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.ListView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.Response; +import com.android.volley.VolleyError; +import com.android.volley.toolbox.StringRequest; +import com.android.volley.toolbox.Volley; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import org.jetbrains.annotations.Nullable; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; /** * A simple {@link Fragment} subclass. */ public class AllObservationsFragment extends Fragment { - + Observation[] observations; + Bird[] birds; public AllObservationsFragment() { // Required empty public constructor @@ -26,4 +48,51 @@ public class AllObservationsFragment extends Fragment { return rootView; } + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + final ListView observationsListView = view.findViewById(R.id.observations_list_view); + + observationsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { + Intent detailsIntent = new Intent(getActivity(), ObservationDetailsActivity.class); + detailsIntent.putExtra("Observation", observations[position]); + + //String photoUrl = ""; + //for (Bird bird : birds) + // if (bird.getId() == observations[position].getBirdId()) + // photoUrl = bird.getPhotoUrl(); + //detailsIntent.putExtra("Photo", photoUrl); + startActivity(detailsIntent); + } + }); + + //final ObservationsListAdapter adapter = new ObservationsListAdapter(getActivity(), observations, birds); + //observationsListView.setAdapter(adapter); + + String observationsUrl = "http://birdobservationservice.azurewebsites.net/Service1.svc/observations"; + final StringRequest observationRequest = new StringRequest(Request.Method.GET, observationsUrl, new Response.Listener<String>() { + @Override + public void onResponse(String response) { + Gson gson = new GsonBuilder().create(); + observations = gson.fromJson(response, Observation[].class); + for (Observation o : observations) { + int p = o.getCreated().indexOf('+'); + long epoch = Long.parseLong(o.getCreated().substring(6, p)); + Date date = new Date(epoch); + String formatted = new SimpleDateFormat("dd.MM.yyyy HH:mm", Locale.ENGLISH).format(date); + o.setCreated(formatted); + } + final ObservationsListAdapter adapter = new ObservationsListAdapter(getActivity(), observations, birds); + observationsListView.setAdapter(adapter); + } + }, new com.android.volley.Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + Toast.makeText(getActivity(), "Database connection error :( ", Toast.LENGTH_LONG).show(); + } + }); + + Volley.newRequestQueue(getActivity()).add(observationRequest); + } } diff --git a/app/src/main/java/org/marcinzelent/liberavem/Bird.java b/app/src/main/java/org/marcinzelent/liberavem/Bird.java index 668059c..a94faf3 100644 --- a/app/src/main/java/org/marcinzelent/liberavem/Bird.java +++ b/app/src/main/java/org/marcinzelent/liberavem/Bird.java @@ -1,37 +1,51 @@ package org.marcinzelent.liberavem; -public class Bird { - private int Id; - private long Created; - private String NameEnglish; - private String NameDanish; - private String PhotoUrl; - - public Bird(int id, long created, String nameEnglish, String nameDanish, String photoUrl) { - Id = id; - Created = created; - NameEnglish = nameEnglish; - NameDanish = nameDanish; - PhotoUrl = photoUrl; +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class Bird implements Serializable { + @SerializedName("Id") + private int id; + @SerializedName("Created") + private String created; + @SerializedName("NameEnglish") + private String nameEnglish; + @SerializedName("NameDanish") + private String nameDanish; + @SerializedName("PhotoUrl") + private String photoUrl; + + public Bird(int id, String created, String nameEnglish, String nameDanish, String photoUrl) { + this.id = id; + this.created = created; + this.nameEnglish = nameEnglish; + this.nameDanish = nameDanish; + this.photoUrl = photoUrl; } public int getId() { - return Id; + return id; } - public long getCreated() { - return Created; + public String getCreated() { + return created; } public String getNameEnglish() { - return NameEnglish; + return nameEnglish; } public String getNameDanish() { - return NameDanish; + return nameDanish; } public String getPhotoUrl() { - return PhotoUrl; + return photoUrl; + } + + @Override + public String toString() { + return getNameEnglish(); } } diff --git a/app/src/main/java/org/marcinzelent/liberavem/MainActivity.java b/app/src/main/java/org/marcinzelent/liberavem/MainActivity.java index dc261c5..b1c73b4 100644 --- a/app/src/main/java/org/marcinzelent/liberavem/MainActivity.java +++ b/app/src/main/java/org/marcinzelent/liberavem/MainActivity.java @@ -17,6 +17,14 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.Response; +import com.android.volley.VolleyError; +import com.android.volley.toolbox.StringRequest; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, @@ -51,6 +59,7 @@ public class MainActivity extends AppCompatActivity toggle.syncState(); NavigationView navigationView = findViewById(R.id.nav_view); + navigationView.getMenu().getItem(0).setChecked(true); navigationView.setNavigationItemSelectedListener(this); } diff --git a/app/src/main/java/org/marcinzelent/liberavem/MyObservationsFragment.java b/app/src/main/java/org/marcinzelent/liberavem/MyObservationsFragment.java index bcc9067..1d27e99 100644 --- a/app/src/main/java/org/marcinzelent/liberavem/MyObservationsFragment.java +++ b/app/src/main/java/org/marcinzelent/liberavem/MyObservationsFragment.java @@ -1,11 +1,13 @@ package org.marcinzelent.liberavem; +import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @@ -18,7 +20,8 @@ import java.util.ArrayList; * A simple {@link Fragment} subclass. */ public class MyObservationsFragment extends Fragment { - + Observation[] observations; + Bird[] birds; public MyObservationsFragment() { // Required empty public constructor @@ -40,6 +43,22 @@ public class MyObservationsFragment extends Fragment { "String 3" }; ListView observationsListView = view.findViewById(R.id.observations_list_view); + + observationsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { + Intent detailsIntent = new Intent(getActivity(), ObservationDetailsActivity.class); + detailsIntent.putExtra("Observation", observations[position]); + + String photoUrl = ""; + for (Bird bird : birds) + if (bird.getId() == observations[position].getBirdId()) + photoUrl = bird.getPhotoUrl(); + detailsIntent.putExtra("Photo", photoUrl); + startActivity(detailsIntent); + } + }); + ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, list); observationsListView.setAdapter(adapter); } diff --git a/app/src/main/java/org/marcinzelent/liberavem/Observation.java b/app/src/main/java/org/marcinzelent/liberavem/Observation.java new file mode 100644 index 0000000..be02812 --- /dev/null +++ b/app/src/main/java/org/marcinzelent/liberavem/Observation.java @@ -0,0 +1,93 @@ +package org.marcinzelent.liberavem; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class Observation implements Serializable { + @SerializedName("Id") + private int id; + @SerializedName("Created") + private String created; + @SerializedName("Latitude") + private double latitude; + @SerializedName("Longitude") + private double longitude; + @SerializedName("Placename") + private String placeName; + @SerializedName("Comment") + private String comment; + @SerializedName("UserId") + private String userId; + @SerializedName("BirdId") + private int birdId; + @SerializedName("NameEnglish") + private String nameEnglish; + @SerializedName("NameDanish") + private String nameDanish; + @SerializedName("Population") + private int population; + + public Observation(int id, String created, double latitude, double longitude, String placeName, + String comment, String userId, int birdId, String nameEnglish, + String nameDanish, int population) { + this.id = id; + this.created = created; + this.latitude = latitude; + this.longitude = longitude; + this.placeName = placeName; + this.comment = comment; + this.userId = userId; + this.birdId = birdId; + this.nameEnglish = nameEnglish; + this.nameDanish = nameDanish; + this.population = population; + } + + public int getId() { + return id; + } + + public String getCreated() { + return created; + } + public void setCreated(String created) { + this.created = created; + } + + public double getLatitude() { + return latitude; + } + + public double getLongitude() { + return longitude; + } + + public String getPlaceName() { + return placeName; + } + + public String getComment() { + return comment; + } + + public String getUserId() { + return userId; + } + + public int getBirdId() { + return birdId; + } + + public String getNameEnglish() { + return nameEnglish; + } + + public String getNameDanish() { + return nameDanish; + } + + public int getPopulation() { + return population; + } +} diff --git a/app/src/main/java/org/marcinzelent/liberavem/ObservationDetailsActivity.java b/app/src/main/java/org/marcinzelent/liberavem/ObservationDetailsActivity.java new file mode 100644 index 0000000..8373145 --- /dev/null +++ b/app/src/main/java/org/marcinzelent/liberavem/ObservationDetailsActivity.java @@ -0,0 +1,36 @@ +package org.marcinzelent.liberavem; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.widget.TextView; + +public class ObservationDetailsActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_observation_details); + + Intent intent = getIntent(); + Observation observation = (Observation) intent.getSerializableExtra("Observation"); + //String photoUrl = (String) intent.getSerializableExtra("Photo"); + + TextView detailsName = findViewById(R.id.details_name); + detailsName.setText(observation.getNameEnglish()); + TextView detailsCreated = findViewById(R.id.details_created); + detailsCreated.setText(observation.getCreated()); + TextView detailsUser = findViewById(R.id.details_user); + detailsUser.setText(observation.getUserId()); + TextView detailsPopulation = findViewById(R.id.details_population); + detailsPopulation.setText(String.valueOf(observation.getPopulation())); + TextView detailsPlacename = findViewById(R.id.details_placename); + detailsPlacename.setText(observation.getPlaceName()); + TextView detailsLongitude = findViewById(R.id.details_longitude); + detailsLongitude.setText(String.valueOf(observation.getLongitude())); + TextView detailsLatitude = findViewById(R.id.details_latitude); + detailsLatitude.setText(String.valueOf(observation.getLatitude())); + TextView detailsComment = findViewById(R.id.details_comment); + if(observation.getComment() != null) detailsComment.setText(observation.getComment()); + } +} diff --git a/app/src/main/java/org/marcinzelent/liberavem/ObservationsFragment.java b/app/src/main/java/org/marcinzelent/liberavem/ObservationsFragment.java index aefaaf4..b093461 100644 --- a/app/src/main/java/org/marcinzelent/liberavem/ObservationsFragment.java +++ b/app/src/main/java/org/marcinzelent/liberavem/ObservationsFragment.java @@ -8,12 +8,10 @@ import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ListView; /** diff --git a/app/src/main/java/org/marcinzelent/liberavem/ObservationsListAdapter.java b/app/src/main/java/org/marcinzelent/liberavem/ObservationsListAdapter.java new file mode 100644 index 0000000..b73f103 --- /dev/null +++ b/app/src/main/java/org/marcinzelent/liberavem/ObservationsListAdapter.java @@ -0,0 +1,88 @@ +package org.marcinzelent.liberavem; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.TextView; + + +public class ObservationsListAdapter extends BaseAdapter { + + private Context context; + private final Observation[] observations; + private final Bird[] birds; + + public ObservationsListAdapter(Context context, Observation[] observations, Bird[] birds){ + //super(context, R.layout.single_list_app_item, utilsArrayList); + this.context = context; + this.observations = observations; + this.birds = birds; + } + + @Override + public int getCount() { + return observations.length; + } + + @Override + public Object getItem(int i) { + return i; + } + + @Override + public long getItemId(int i) { + return i; + } + + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + ViewHolder viewHolder; + final View result; + + if (convertView == null) { + + viewHolder = new ViewHolder(); + LayoutInflater inflater = LayoutInflater.from(context); + convertView = inflater.inflate(R.layout.observations_list_item, parent, false); + viewHolder.name = convertView.findViewById(R.id.oli_name); + viewHolder.date = convertView.findViewById(R.id.oli_date); + viewHolder.photo = convertView.findViewById(R.id.oli_photo); + + result = convertView; + + convertView.setTag(viewHolder); + } else { + viewHolder = (ViewHolder) convertView.getTag(); + result = convertView; + } + + viewHolder.name.setText(observations[position].getNameEnglish()); + viewHolder.date.setText(observations[position].getCreated()); + + String photoUrl = ""; + //for (Bird bird : birds) + // if (bird.getId() == observations[position].getBirdId()) + // photoUrl = bird.getPhotoUrl(); + + //viewHolder.photo.setImageResource(photoUrl); + + return convertView; + } + + public void add(int position, Observation observation, Bird bird) { + + } + + private static class ViewHolder { + TextView name; + TextView date; + ImageView photo; + } + +}
\ No newline at end of file diff --git a/app/src/main/java/org/marcinzelent/liberavem/SquareImageView.java b/app/src/main/java/org/marcinzelent/liberavem/SquareImageView.java new file mode 100644 index 0000000..ed5dbb7 --- /dev/null +++ b/app/src/main/java/org/marcinzelent/liberavem/SquareImageView.java @@ -0,0 +1,28 @@ +package org.marcinzelent.liberavem; + +import android.content.Context; +import android.util.AttributeSet; + +public class SquareImageView extends android.support.v7.widget.AppCompatImageView { + + public SquareImageView(Context context) { + super(context); + } + + public SquareImageView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public SquareImageView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + int width = getMeasuredWidth(); + setMeasuredDimension(width, width); + } + +} diff --git a/app/src/main/res/layout/activity_observation_details.xml b/app/src/main/res/layout/activity_observation_details.xml new file mode 100644 index 0000000..938fe91 --- /dev/null +++ b/app/src/main/res/layout/activity_observation_details.xml @@ -0,0 +1,216 @@ +<?xml version="1.0" encoding="utf-8"?> +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".ObservationDetailsActivity"> + + <ScrollView + android:id="@+id/scrollView2" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.0"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <org.marcinzelent.liberavem.SquareImageView + android:id="@+id/details_photo" + android:layout_width="match_parent" + android:layout_height="fill_parent" + app:srcCompat="@drawable/ic_launcher_background" /> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="8dp" + android:layout_marginLeft="16dp" + android:layout_marginStart="16dp" + android:layout_marginTop="16dp" + android:orientation="horizontal"> + + <TextView + android:id="@+id/details_name" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:minLines="1" + android:textAppearance="@style/TextAppearance.AppCompat.Large" + android:textStyle="bold" /> + + </LinearLayout> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="16dp" + android:layout_marginStart="16dp" + android:orientation="horizontal"> + + <TextView + android:id="@+id/details_created_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:minLines="1" + android:text="@string/created" + android:textStyle="bold" /> + + <TextView + android:id="@+id/details_created" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:layout_weight="1" + android:minLines="1" /> + </LinearLayout> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_marginLeft="16dp" + android:layout_marginStart="16dp" + android:orientation="horizontal"> + + <TextView + android:id="@+id/details_user_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="@string/author" + android:textStyle="bold" /> + + <TextView + android:id="@+id/details_user" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:layout_weight="1" /> + </LinearLayout> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_marginLeft="16dp" + android:layout_marginStart="16dp" + android:orientation="horizontal"> + + <TextView + android:id="@+id/details_population_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="@string/population" + android:textStyle="bold" /> + + <TextView + android:id="@+id/details_population" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:layout_weight="1" /> + </LinearLayout> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_marginLeft="16dp" + android:layout_marginStart="16dp" + android:orientation="horizontal"> + + <TextView + android:id="@+id/details_placename_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="@string/place" + android:textStyle="bold" /> + + <TextView + android:id="@+id/details_placename" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:layout_weight="1" /> + </LinearLayout> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_marginLeft="16dp" + android:layout_marginStart="16dp" + android:orientation="horizontal"> + + <TextView + android:id="@+id/details_longitude_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="@string/longitude" + android:textStyle="bold" /> + + <TextView + android:id="@+id/details_longitude" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:layout_weight="1" /> + </LinearLayout> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_marginLeft="16dp" + android:layout_marginStart="16dp" + android:orientation="horizontal"> + + <TextView + android:id="@+id/details_latitude_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="@string/latitude" + android:textStyle="bold" /> + + <TextView + android:id="@+id/details_latitude" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:layout_weight="1" /> + </LinearLayout> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_marginLeft="16dp" + android:layout_marginStart="16dp" + android:orientation="horizontal"> + + <TextView + android:id="@+id/details_comment_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="@string/comment" + android:textStyle="bold" /> + + <TextView + android:id="@+id/details_comment" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:layout_weight="1" /> + </LinearLayout> + </LinearLayout> + </ScrollView> + +</android.support.constraint.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/observations_list_item.xml b/app/src/main/res/layout/observations_list_item.xml new file mode 100644 index 0000000..3aea796 --- /dev/null +++ b/app/src/main/res/layout/observations_list_item.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:padding="8dp"> + + <ImageView + android:id="@+id/oli_photo" + app:srcCompat="@drawable/ic_launcher_background" + android:layout_width="60dp" + android:layout_height="60dp" /> + + <TextView + android:id="@+id/oli_name" + android:text="Bird name" + android:textSize="20sp" + android:layout_marginTop="8dp" + android:maxLines="1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_toRightOf="@+id/oli_photo" + android:layout_toEndOf="@+id/oli_photo" + android:layout_marginLeft="12dp" + android:layout_marginStart="12dp" /> + + <TextView + android:id="@+id/oli_date" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignLeft="@+id/oli_name" + android:layout_alignStart="@+id/oli_name" + android:layout_below="@+id/oli_name" + android:maxLines="1" + android:text="Date" + android:textSize="14sp" /> + + + +</RelativeLayout>
\ No newline at end of file diff --git a/app/src/main/res/values/attrs_square_image_view.xml b/app/src/main/res/values/attrs_square_image_view.xml new file mode 100644 index 0000000..13e655a --- /dev/null +++ b/app/src/main/res/values/attrs_square_image_view.xml @@ -0,0 +1,8 @@ +<resources> + <declare-styleable name="SquareImageView"> + <attr name="exampleString" format="string" /> + <attr name="exampleDimension" format="dimension" /> + <attr name="exampleColor" format="color" /> + <attr name="exampleDrawable" format="color|reference" /> + </declare-styleable> +</resources> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1f045bd..1561e86 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -88,4 +88,11 @@ <string name="hello_blank_fragment">Hello blank fragment</string> <string name="my_observations">My observations</string> <string name="all_observations">All observations</string> + <string name="created">Created:</string> + <string name="author">Author:</string> + <string name="population">Population:</string> + <string name="place">Place:</string> + <string name="latitude">Latitude:</string> + <string name="longitude">Longitude:</string> + <string name="comment">Comment:</string> </resources> diff --git a/build.gradle b/build.gradle index 683db77..eb8c588 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.1.51' + ext.kotlin_version = '1.2.30' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.0' + classpath 'com.android.tools.build:gradle:3.1.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong |