summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/com/jopek/kanakaeiwa/FirstFragment.java132
-rw-r--r--app/src/main/java/com/jopek/kanakaeiwa/MainActivity.java6
-rw-r--r--app/src/main/java/com/jopek/kanakaeiwa/Requests.java2
-rw-r--r--app/src/main/java/com/jopek/kanakaeiwa/SecondFragment.java75
-rw-r--r--app/src/main/res/drawable/ic_baseline_arrow_back_24.xml5
-rw-r--r--app/src/main/res/drawable/ic_baseline_location_city_24.xml5
-rw-r--r--app/src/main/res/drawable/ic_baseline_search_24.xml5
-rw-r--r--app/src/main/res/layout/fragment_first.xml37
-rw-r--r--app/src/main/res/layout/fragment_second.xml116
-rw-r--r--app/src/main/res/menu/menu_main.xml10
10 files changed, 329 insertions, 64 deletions
diff --git a/app/src/main/java/com/jopek/kanakaeiwa/FirstFragment.java b/app/src/main/java/com/jopek/kanakaeiwa/FirstFragment.java
index bef3a9a..b0e7699 100644
--- a/app/src/main/java/com/jopek/kanakaeiwa/FirstFragment.java
+++ b/app/src/main/java/com/jopek/kanakaeiwa/FirstFragment.java
@@ -4,6 +4,8 @@ import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.location.Address;
+import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
@@ -20,26 +22,32 @@ import androidx.navigation.fragment.NavHostFragment;
import com.jopek.kanakaeiwa.databinding.FragmentFirstBinding;
-import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+
public class FirstFragment extends Fragment {
+ private final String[] providers = new String[]{LocationManager.GPS_PROVIDER, LocationManager.NETWORK_PROVIDER};
+ private final long MIN_TIME_LOC = 60_000;
+ private final float MIN_M_LOC = 1000;
+ String chosenProvider = "";
private FragmentFirstBinding binding;
private boolean locationSet = false;
private double lon;
private double lat;
+ private String cityName = null;
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState
) {
-
binding = FragmentFirstBinding.inflate(inflater, container, false);
return binding.getRoot();
-
}
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
@@ -55,16 +63,13 @@ public class FirstFragment extends Fragment {
binding.buttonFirst.setOnClickListener(view1 -> {
NavHostFragment.findNavController(FirstFragment.this)
.navigate(R.id.action_FirstFragment_to_SecondFragment);
- getLocation();
});
}
public void getWeather() {
- Requests requests = new Requests();
String url = "https://api.openweathermap.org/data/2.5/weather?appid=d7eea7960e9b5024b8441fb6f9344ce4&units=metric&lat=" + lat + "&lon=" + lon;
- Log.d(MainActivity.TAG, "getWeather: " + url);
+ Requests requests = new Requests();
requests.get(url, res -> {
- Log.d(MainActivity.TAG, "getWeather: " + res);
try {
JSONObject data = new JSONObject(res);
JSONObject weather = data.getJSONArray("weather").getJSONObject(0);
@@ -72,49 +77,130 @@ public class FirstFragment extends Fragment {
JSONObject wind = data.getJSONObject("wind");
JSONObject sys = data.getJSONObject("sys");
requests.setRemoteSrc(binding.weatherImg, "https://openweathermap.org/img/w/" + weather.getString("icon") + ".png");
- binding.cityName.setText(data.getString("name") + ", " + sys.getString("country"));
- binding.temp.setText(main.getString("temp"));
+ if (cityName != null)
+ binding.cityName.setText(cityName + ", " + sys.getString("country"));
+ else
+ binding.cityName.setText(data.getString("name") + ", " + sys.getString("country"));
+ binding.temp.setText(main.getString("temp") + "°C");
binding.weatherText.setText(weather.getString("description"));
- binding.humidity.setText(main.getString("humidity") + " %");
- binding.maxTemp.setText(main.getString("temp_max") + " °C");
- binding.minTemp.setText(main.getString("temp_min") + " °C");
+ binding.humidity.setText(main.getString("humidity") + "%");
+ binding.maxTemp.setText(main.getString("temp_max") + "°C");
+ binding.minTemp.setText(main.getString("temp_min") + "°C");
binding.pressure.setText(main.getString("pressure") + " hPa");
binding.windSpeed.setText(wind.getString("speed") + " m/s");
} catch (Exception e) {
+ showLocationError();
e.printStackTrace();
}
});
}
+ public void onLocationChanged(@NonNull Location location) {
+ Log.d(MainActivity.TAG, "FirstFragment.LocationChanged");
+ lon = location.getLongitude();
+ lat = location.getLatitude();
+
+ if (cityName == null) {
+ Geocoder gcd = new Geocoder(requireActivity(), Locale.getDefault());
+ List<Address> addresses;
+ try {
+ addresses = gcd.getFromLocation(lat, lon, 1);
+ if (addresses.size() > 0) {
+ cityName = addresses.get(0).getLocality();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ getWeather();
+ }
+
@SuppressLint("MissingPermission")
public void getLocation() {
LocationManager locationManager = (LocationManager) requireActivity().getSystemService(Context.LOCATION_SERVICE);
+ long youngestTime = 0;
+ Location youngest = null;
+
+ for (String provider : providers) {
+ Location loc = locationManager.getLastKnownLocation(provider);
+ if (loc == null) continue;
+ long curTime = loc.getTime();
+ if (curTime > youngestTime)
+ youngest = loc;
+ }
+
+ if (youngest == null) {
+ getBestLocation();
+ } else {
+ onLocationChanged(youngest);
+ getBestLocation();
+ }
+ }
+
+ @SuppressLint("MissingPermission")
+ public void getBestLocation() {
+ LocationManager locationManager = (LocationManager) requireActivity().getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
@Override
public void onLocationChanged(@NonNull Location location) {
- System.out.println("DEBUG 1");
- lon = location.getLongitude();
- lat = location.getLatitude();
- locationSet = true;
- getWeather();
+ Log.d(MainActivity.TAG, "onLocationChanged: " + chosenProvider + ", " + location.getAccuracy());
+ FirstFragment.this.onLocationChanged(location);
}
@Override
public void onProviderEnabled(@NonNull String provider) {
- System.out.println("DEBUG 2");
+ Log.d(MainActivity.TAG, "onProviderEnabled: ");
}
@Override
public void onProviderDisabled(@NonNull String provider) {
- System.out.println("DEBUG 3");
+ Log.d(MainActivity.TAG, "onProviderDisabled: ");
+ if (!locationSet)
+ showLocationError();
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
- System.out.println("DEBUG 4");
+ Log.d(MainActivity.TAG, "onStatusChanged: ");
}
};
- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 50, locationListener);
+
+ boolean providerSet = false;
+ for (String provider : providers) {
+ if (locationManager.isProviderEnabled(provider)) {
+ locationManager.requestLocationUpdates(provider, MIN_TIME_LOC, MIN_M_LOC, locationListener);
+ chosenProvider = provider;
+ providerSet = true;
+ break;
+ }
+ }
+ Log.d(MainActivity.TAG, "getBestLocation: " + chosenProvider);
+ if (!providerSet) {
+ Log.d(MainActivity.TAG, "getBestLocation: getting locationByIp");
+ chosenProvider = "IP";
+ Requests requests = new Requests();
+// requests.get("https://ipapi.co/json", res -> {
+ requests.get("https://ipwho.is/", res -> {
+ Log.d(MainActivity.TAG, "IP Location found: ");
+ try {
+ Log.d(MainActivity.TAG, "getBestLocation: " + res);
+ JSONObject data = new JSONObject(res);
+ lon = data.getDouble("longitude");
+ lat = data.getDouble("latitude");
+ cityName = data.getString("city");
+ locationSet = true;
+ getWeather();
+ } catch (JSONException e) {
+ e.printStackTrace();
+ showLocationError();
+ }
+ });
+ }
+ }
+
+ public void showLocationError() {
+
}
@Override
@@ -126,8 +212,8 @@ public class FirstFragment extends Fragment {
grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Log.d(MainActivity.TAG, "onRequestPermissionsResult: success");
getLocation();
- }
- Log.d(MainActivity.TAG, "onRequestPermissionsResult: fail");
+ } else
+ Log.d(MainActivity.TAG, "onRequestPermissionsResult: fail");
return;
}
// Other 'case' lines to check for other
diff --git a/app/src/main/java/com/jopek/kanakaeiwa/MainActivity.java b/app/src/main/java/com/jopek/kanakaeiwa/MainActivity.java
index 4b0193b..92c84df 100644
--- a/app/src/main/java/com/jopek/kanakaeiwa/MainActivity.java
+++ b/app/src/main/java/com/jopek/kanakaeiwa/MainActivity.java
@@ -49,9 +49,9 @@ public class MainActivity extends AppCompatActivity {
int id = item.getItemId();
//noinspection SimplifiableIfStatement
- if (id == R.id.action_settings) {
- return true;
- }
+// if (id == R.id.action_settings) {
+// return true;
+// }
return super.onOptionsItemSelected(item);
}
diff --git a/app/src/main/java/com/jopek/kanakaeiwa/Requests.java b/app/src/main/java/com/jopek/kanakaeiwa/Requests.java
index 506182b..5a7a6c5 100644
--- a/app/src/main/java/com/jopek/kanakaeiwa/Requests.java
+++ b/app/src/main/java/com/jopek/kanakaeiwa/Requests.java
@@ -59,6 +59,7 @@ public class Requests extends AsyncTask<String, Integer, String> {
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
connection.connect();
+ Log.d(MainActivity.TAG, "doInBackground: " + connection.getResponseCode());
BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String content = "", line;
while ((line = rd.readLine()) != null) {
@@ -66,6 +67,7 @@ public class Requests extends AsyncTask<String, Integer, String> {
}
return content;
} catch (IOException exception) {
+ exception.printStackTrace();
return "ERROR";
}
}
diff --git a/app/src/main/java/com/jopek/kanakaeiwa/SecondFragment.java b/app/src/main/java/com/jopek/kanakaeiwa/SecondFragment.java
index 7164eec..398e828 100644
--- a/app/src/main/java/com/jopek/kanakaeiwa/SecondFragment.java
+++ b/app/src/main/java/com/jopek/kanakaeiwa/SecondFragment.java
@@ -1,19 +1,35 @@
package com.jopek.kanakaeiwa;
+import android.Manifest;
+import android.content.pm.PackageManager;
+import android.location.LocationManager;
import android.os.Bundle;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
+import androidx.core.app.ActivityCompat;
import androidx.fragment.app.Fragment;
import androidx.navigation.fragment.NavHostFragment;
import com.jopek.kanakaeiwa.databinding.FragmentSecondBinding;
+import org.json.JSONObject;
+
public class SecondFragment extends Fragment {
+ private final String[] providers = new String[]{LocationManager.GPS_PROVIDER, LocationManager.NETWORK_PROVIDER};
+ private final long MIN_TIME_LOC = 60_000;
+ private final float MIN_M_LOC = 1000;
+ String chosenProvider = "";
private FragmentSecondBinding binding;
+ private boolean locationSet = false;
+ private double lon;
+ private double lat;
+ private String cityName = null;
+
@Override
public View onCreateView(
@@ -28,6 +44,65 @@ public class SecondFragment extends Fragment {
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
+
+ if (requireActivity().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+ ActivityCompat.requestPermissions(requireActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
+ }
+
+ binding.buttonFirst.setOnClickListener(view1 -> NavHostFragment.findNavController(SecondFragment.this)
+ .navigate(R.id.action_SecondFragment_to_FirstFragment));
+ binding.cityBtn.setOnClickListener(view1 -> {
+ getWeather(String.valueOf(binding.editText.getText()));
+ });
+ }
+
+ public void getWeather(String cityName) {
+ String url = "https://api.openweathermap.org/data/2.5/weather?appid=d7eea7960e9b5024b8441fb6f9344ce4&units=metric&q=" + cityName;
+ Requests requests = new Requests();
+ requests.get(url, res -> {
+ try {
+ JSONObject data = new JSONObject(res);
+ JSONObject weather = data.getJSONArray("weather").getJSONObject(0);
+ JSONObject main = data.getJSONObject("main");
+ JSONObject wind = data.getJSONObject("wind");
+ JSONObject sys = data.getJSONObject("sys");
+ requests.setRemoteSrc(binding.weatherImg, "https://openweathermap.org/img/w/" + weather.getString("icon") + ".png");
+ if (cityName != null)
+ binding.cityName.setText(cityName + ", " + sys.getString("country"));
+ else
+ binding.cityName.setText(data.getString("name") + ", " + sys.getString("country"));
+ binding.temp.setText(main.getString("temp") + "°C");
+ binding.weatherText.setText(weather.getString("description"));
+ binding.humidity.setText(main.getString("humidity") + "%");
+ binding.maxTemp.setText(main.getString("temp_max") + "°C");
+ binding.minTemp.setText(main.getString("temp_min") + "°C");
+ binding.pressure.setText(main.getString("pressure") + " hPa");
+ binding.windSpeed.setText(wind.getString("speed") + " m/s");
+ } catch (Exception e) {
+ showLocationError();
+ e.printStackTrace();
+ }
+ });
+ }
+
+ public void showLocationError() {
+
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String[] permissions,
+ int[] grantResults) {
+ switch (requestCode) {
+ case 1:
+ if (grantResults.length > 0 &&
+ grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ Log.d(MainActivity.TAG, "onRequestPermissionsResult: success");
+ } else
+ Log.d(MainActivity.TAG, "onRequestPermissionsResult: fail");
+ return;
+ }
+ // Other 'case' lines to check for other
+ // permissions this app might request.
}
@Override
diff --git a/app/src/main/res/drawable/ic_baseline_arrow_back_24.xml b/app/src/main/res/drawable/ic_baseline_arrow_back_24.xml
new file mode 100644
index 0000000..8452791
--- /dev/null
+++ b/app/src/main/res/drawable/ic_baseline_arrow_back_24.xml
@@ -0,0 +1,5 @@
+<vector android:autoMirrored="true" android:height="24dp"
+ android:tint="#000000" android:viewportHeight="24"
+ android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_baseline_location_city_24.xml b/app/src/main/res/drawable/ic_baseline_location_city_24.xml
new file mode 100644
index 0000000..7324708
--- /dev/null
+++ b/app/src/main/res/drawable/ic_baseline_location_city_24.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#000000"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M15,11L15,5l-3,-3 -3,3v2L3,7v14h18L21,11h-6zM7,19L5,19v-2h2v2zM7,15L5,15v-2h2v2zM7,11L5,11L5,9h2v2zM13,19h-2v-2h2v2zM13,15h-2v-2h2v2zM13,11h-2L11,9h2v2zM13,7h-2L11,5h2v2zM19,19h-2v-2h2v2zM19,15h-2v-2h2v2z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_baseline_search_24.xml b/app/src/main/res/drawable/ic_baseline_search_24.xml
new file mode 100644
index 0000000..a5687c6
--- /dev/null
+++ b/app/src/main/res/drawable/ic_baseline_search_24.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#000000"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
+</vector>
diff --git a/app/src/main/res/layout/fragment_first.xml b/app/src/main/res/layout/fragment_first.xml
index d876bf5..a1a66d5 100644
--- a/app/src/main/res/layout/fragment_first.xml
+++ b/app/src/main/res/layout/fragment_first.xml
@@ -9,6 +9,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="@color/purple_700"
android:orientation="vertical">
<TextView
@@ -16,9 +17,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
+ android:textColor="@color/white"
android:text="Mountain View, US"
+ android:textFontWeight="600"
android:textAlignment="center"
- android:textSize="25sp" />
+ android:textSize="27sp" />
<LinearLayout
android:layout_width="match_parent"
@@ -45,8 +48,9 @@
android:layout_marginTop="30dp"
android:layout_marginBottom="20dp"
android:textAlignment="center"
+ android:textColor="@color/white"
android:text="14.03 *C"
- android:textFontWeight="700"
+ android:textFontWeight="800"
android:textSize="40sp" />
<TextView
@@ -55,6 +59,8 @@
android:textAlignment="center"
android:id="@+id/weather_text"
android:text="overcast clouds"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:textSize="23sp" />
</LinearLayout>
</LinearLayout>
@@ -64,6 +70,8 @@
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Details:"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:textSize="25sp" />
<GridLayout
@@ -76,52 +84,73 @@
<TextView
android:padding="3dip"
android:text="Humidity: "
+ android:textColor="#808080"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
android:padding="3dip"
android:id="@+id/humidity"
android:text="85%"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
android:padding="3dip"
android:text="Max Temp: "
+ android:textColor="#808080"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
android:padding="3dip"
android:text="15.47 *C"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:id="@+id/max_temp"
android:textSize="23dp" />
<TextView
android:padding="3dip"
android:text="Min Temp: "
+ android:textColor="#808080"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
android:padding="3dip"
android:text="11.29 *C"
android:id="@+id/min_temp"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
android:padding="3dip"
- android:text="Pressure"
+ android:text="Pressure: "
+ android:textColor="#808080"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
android:padding="3dip"
android:text="1013hPa"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:id="@+id/pressure"
android:textSize="23dp" />
<TextView
android:padding="3dip"
- android:text="Wind speed"
+ android:text="Wind speed: "
+ android:textColor="#808080"
+ android:layout_marginRight="10sp"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
android:padding="3dip"
android:text="2.06 km/h"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:id="@+id/wind_speed"
android:textSize="23dp" />
</GridLayout>
diff --git a/app/src/main/res/layout/fragment_second.xml b/app/src/main/res/layout/fragment_second.xml
index 0acfa7f..b3a38aa 100644
--- a/app/src/main/res/layout/fragment_second.xml
+++ b/app/src/main/res/layout/fragment_second.xml
@@ -9,43 +9,71 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="@color/purple_500"
+ android:weightSum="12"
android:orientation="vertical">
- <com.google.android.material.textfield.TextInputLayout
- android:id="@+id/filledTextField"
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginStart="32dp"
- android:layout_marginTop="32dp"
- android:layout_marginEnd="32dp"
- android:hint="Enter something">
+ android:layout_weight="5"
+ android:gravity="center"
+ android:layout_height="match_parent">
+ <com.google.android.material.textfield.TextInputLayout
+ android:id="@+id/filledTextField"
+ android:layout_weight="1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="32dp"
+ android:layout_marginEnd="32dp"
+ app:startIconDrawable="@drawable/ic_baseline_location_city_24"
+ app:boxCornerRadiusTopStart="30dp"
+ app:boxCornerRadiusTopEnd="30dp"
+ app:boxCornerRadiusBottomStart="30dp"
+ app:boxCornerRadiusBottomEnd="30dp"
+ app:boxStrokeWidth="0dp"
+ app:boxStrokeWidthFocused="0dp"
+ android:hint="Enter the city name">
+ <!--this is the actual edit text which takes the input-->
+ <com.google.android.material.textfield.TextInputEditText
+ android:id="@+id/edit_text"
+ android:layout_width="match_parent"
+ android:singleLine="true"
+ android:layout_height="wrap_content" />
+ </com.google.android.material.textfield.TextInputLayout>
- <!--this is the actual edit text which takes the input-->
- <com.google.android.material.textfield.TextInputEditText
- android:id="@+id/edit_text"
+ <com.google.android.material.button.MaterialButton
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_weight="6"
+ app:iconTint="@color/teal_200"
+ app:iconSize="35sp"
+ app:icon="@drawable/ic_baseline_search_24"
+ android:background="#00000000"
+ android:id="@+id/city_btn"
+ android:layout_height="match_parent" />
+ </LinearLayout>
- </com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/city_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
+ android:layout_weight="0"
android:text="Mountain View, US"
android:textAlignment="center"
- android:textSize="25sp" />
+ android:textColor="@color/white"
+ android:textFontWeight="600"
+ android:textSize="27sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_weight="2">
+ android:layout_weight="4">
<ImageView
+ android:id="@+id/weather_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
- android:id="@+id/weather_img"
android:src="@drawable/ic_baseline_wb_sunny_24" />
<LinearLayout
@@ -55,22 +83,25 @@
android:orientation="vertical">
<TextView
+ android:id="@+id/temp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:id="@+id/temp"
android:layout_marginTop="30dp"
android:layout_marginBottom="20dp"
- android:textAlignment="center"
android:text="14.03 *C"
- android:textFontWeight="700"
+ android:textAlignment="center"
+ android:textColor="@color/white"
+ android:textFontWeight="800"
android:textSize="40sp" />
<TextView
+ android:id="@+id/weather_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:textAlignment="center"
- android:id="@+id/weather_text"
android:text="overcast clouds"
+ android:textAlignment="center"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:textSize="23sp" />
</LinearLayout>
</LinearLayout>
@@ -80,65 +111,92 @@
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Details:"
+ android:layout_weight="0"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:textSize="25sp" />
<GridLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
- android:layout_weight="1"
+ android:layout_weight="4"
android:columnCount="2">
<TextView
android:padding="3dip"
android:text="Humidity: "
+ android:textColor="#808080"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
- android:padding="3dip"
android:id="@+id/humidity"
+ android:padding="3dip"
android:text="85%"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
android:padding="3dip"
android:text="Max Temp: "
+ android:textColor="#808080"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
+ android:id="@+id/max_temp"
android:padding="3dip"
android:text="15.47 *C"
- android:id="@+id/max_temp"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:textSize="23dp" />
+
<TextView
android:padding="3dip"
android:text="Min Temp: "
+ android:textColor="#808080"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
+ android:id="@+id/min_temp"
android:padding="3dip"
android:text="11.29 *C"
- android:id="@+id/min_temp"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:textSize="23dp" />
+
<TextView
android:padding="3dip"
- android:text="Pressure"
+ android:text="Pressure: "
+ android:textColor="#808080"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
+ android:id="@+id/pressure"
android:padding="3dip"
android:text="1013hPa"
- android:id="@+id/pressure"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:textSize="23dp" />
+
<TextView
+ android:layout_marginRight="10sp"
android:padding="3dip"
- android:text="Wind speed"
+ android:text="Wind speed: "
+ android:textColor="#808080"
+ android:textFontWeight="600"
android:textSize="23dp" />
<TextView
+ android:id="@+id/wind_speed"
android:padding="3dip"
android:text="2.06 km/h"
- android:id="@+id/wind_speed"
+ android:textColor="@color/white"
+ android:textFontWeight="600"
android:textSize="23dp" />
</GridLayout>
</LinearLayout>
@@ -151,5 +209,5 @@
android:text="@string/next"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
- app:srcCompat="@drawable/ic_baseline_arrow_forward_24" />
+ app:srcCompat="@drawable/ic_baseline_arrow_back_24" />
</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
index 4cb5ffb..752543a 100644
--- a/app/src/main/res/menu/menu_main.xml
+++ b/app/src/main/res/menu/menu_main.xml
@@ -2,9 +2,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.jopek.kanakaeiwa.MainActivity">
- <item
- android:id="@+id/action_settings"
- android:orderInCategory="100"
- android:title="@string/action_settings"
- app:showAsAction="never" />
+<!-- <item-->
+<!-- android:id="@+id/action_settings"-->
+<!-- android:orderInCategory="100"-->
+<!-- android:title="@string/action_settings"-->
+<!-- app:showAsAction="never" />-->
</menu> \ No newline at end of file