Skip to content

Commit

Permalink
Merge pull request #45 from samoryka/master
Browse files Browse the repository at this point in the history
GUI modifications - part 2
  • Loading branch information
jklmnn committed Aug 24, 2017
2 parents 896e4d5 + 1393887 commit e10ea7f
Show file tree
Hide file tree
Showing 68 changed files with 536 additions and 421 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
ParkenDD
========

Android App for parking spots in Dresden.
If you want to contribute a translation be free to do so on [poeditor.com](https://poeditor.com/join/project/eu2wqvnR4z).
An android application to find free parking sports in Dresden and other cities.

<a href="https://f-droid.org/repository/browse/?fdid=de.jkliemann.parkendd" target="_blank">
<img src="https://f-droid.org/badge/get-it-on.png" alt="Get it on F-Droid" height="80"/></a>
<a href="https://play.google.com/store/apps/details?id=de.jkliemann.parkendd" target="_blank">
<img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png" alt="Get it on Google Play" height="80"/></a>
<a href="https://f-droid.org/repository/browse/?fdid=de.jkliemann.parkendd" target="_blank"><img src="https://f-droid.org/badge/get-it-on.png" alt="Get it on F-Droid" height="80"/></a>
<a href="https://play.google.com/store/apps/details?id=de.jkliemann.parkendd" target="_blank"><img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png" alt="Get it on Google Play" height="80"/></a>

This app shows the free parking lots in Dresden with the possibility to view them with a maps application.
## Features
![Different screenshots of ParkenDD: the main list of parking spots, a forecast showing how many places are available at a certain date and a map of Dresden and its free parking spots.](resources/readmeScreenshots/assortment.png)
* See how many free places are available in the parking spots near you
* Find out how busy parking spots will be at a certain date and time
* Display a map showing all your city's parking spots

## Translation
ParkenDD is available in several languages including English, German and French.
If you want to contribute a translation be free to do so on [poeditor.com](https://poeditor.com/join/project/eu2wqvnR4z)!

## Licenses
Licenses can be viewed in the files LICENSE and LICENSE-EXTRA.

![screen](http://jkliemann.de/parkendd/media/parkendd4.png "screenshot")
18 changes: 9 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 22
compileSdkVersion 25
buildToolsVersion '25.0.0'

defaultConfig {
applicationId "de.jkliemann.parkendd"
minSdkVersion 14
targetSdkVersion 22
versionCode 28
versionName "1.2.3"
targetSdkVersion 25
versionCode 27
versionName "1.2.2"
}
buildTypes {
release {
Expand All @@ -24,12 +24,12 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.android.support:design:25.4.0'
compile 'org.piwik.sdk:piwik-sdk:0.0.3'
compile 'org.osmdroid:osmdroid-android:5.0.1@aar'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:25.4.0'
compile 'com.android.support:cardview-v7:25.4.0'
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<application
android:name=".ParkenDD"
android:allowBackup="true"
android:icon="@drawable/ic_app_icon"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package de.jkliemann.parkendd.Utilities;

import android.animation.ArgbEvaluator;
import android.content.res.ColorStateList;
import android.graphics.Color;

/**
* Created by kasam on 18/08/2017.
*/

public class ColorUtilities {

public static int mixBetweenColors(float percentage, Object firstColor, Object secondColor) {
ArgbEvaluator colorEvaluator = new ArgbEvaluator();

return (int)colorEvaluator.evaluate(percentage, firstColor, secondColor);
}

public static int darkenColor(int color, float percentage) {
float factor = (100-percentage)/100;

int alpha = Color.alpha(color);

int red = Math.round(Color.red(color) * factor);
int green = Math.round(Color.green(color) * factor);
int blue = Math.round(Color.blue(color) * factor);

return Color.argb(alpha, red, green, blue);
}
}
185 changes: 115 additions & 70 deletions app/src/main/java/de/jkliemann/parkendd/Views/Main/ForecastFragment.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package de.jkliemann.parkendd.Views.Main;

import android.app.Activity;
import android.content.Context;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.ExpandableListView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.TimePicker;

import org.json.JSONException;
Expand Down Expand Up @@ -52,17 +51,18 @@
* Use the {@link ForecastFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class ForecastFragment extends Fragment implements LoaderInterface, View.OnClickListener {
public class ForecastFragment extends Fragment implements LoaderInterface, DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener {

private OnFragmentInteractionListener mListener;
private static final int DATE_OFFSET = 1900;

private RelativeLayout relativeLayout;
private RelativeLayout datePickerLayout;
private TimePicker timePicker;
private OnFragmentInteractionListener mListener;
private View mView;
private static final int dateOffset = 1900;
private TextView displayedDate;
private TextView displayedTime;
private Map<ParkingSpot, Map<Date, Integer>> spotmap;
private Date date;
private int previousGroup = -1;

ProgressBar pg;
ParkingSpot[] spotList;
Loader forecastLoader;
Expand All @@ -89,15 +89,10 @@ public void onCreate(Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_forecast, container, false);
relativeLayout = (RelativeLayout) view.findViewById(R.id.RelativeLayout);
datePickerLayout = (RelativeLayout) view.findViewById(R.id.datePickerLayout);
datePickerLayout.setVisibility(View.INVISIBLE);

mView = view;

setupDateText();
setupHourText();
setupProgressBar();
setupOkButton();
setupCancelButton();
setupTimePicker();
((ParkenDD) getActivity().getApplication()).getTracker().trackScreenView("/forecast/" + city.id(), "Vorhersage-" + city.name());
return view;
Expand Down Expand Up @@ -147,7 +142,7 @@ public void onLoaderFinished(String[] data, Loader instance) {
spotmap.put(spotList[i], dateMap);
}

updateList(timePicker.getCurrentHour());
updateTimeGUIElements(date);
onProgressUpdated();
}

Expand All @@ -163,33 +158,37 @@ private void setupProgressBar() {
pg.setIndeterminate(true);
}

private void setupOkButton() {
Button okButton = (Button)mView.findViewById(R.id.okbutton);
okButton.setOnClickListener(this);
}

private void setupCancelButton() {
Button cancelButton = (Button)mView.findViewById(R.id.cancelbutton);
cancelButton.setOnClickListener(this);
}

private void setupTimePicker() {

Calendar cal = Calendar.getInstance();
date = new Date(cal.get(Calendar.YEAR) - dateOffset, cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
date = new Date(cal.get(Calendar.YEAR) - DATE_OFFSET, cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH),
cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE));
TimeZone tz = Calendar.getInstance().getTimeZone();
dateFormat = android.text.format.DateFormat.getDateFormat(getActivity());
dateFormat.setTimeZone(tz);
String locDate = dateFormat.format(date);
city = ((ParkenDD) getActivity().getApplication()).currentCity();
getActivity().setTitle(city.name() + " - " + locDate);
loadDate();
timePicker = (TimePicker)mView.findViewById(R.id.timePicker);
timePicker.setIs24HourView(true);
timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {

updateDateGUIElements(date);
updateTimeGUIElements(date);
}

private void setupDateText() {
displayedDate = (TextView) mView.findViewById(R.id.dateText);

displayedDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openDatePicker();
}
});
}

private void setupHourText() {
displayedTime = (TextView) mView.findViewById(R.id.hourText);

displayedTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
updateList(hourOfDay);
public void onClick(View view) {
openTimePicker();
}
});
}
Expand Down Expand Up @@ -249,7 +248,15 @@ private void updateList(int hour){
}

private void setList(ArrayList<ParkingSpot> spots){
ExpandableListView spotView = (ExpandableListView)mView.findViewById(R.id.listView);
final ExpandableListView spotView = (ExpandableListView)getView().findViewById(R.id.listView);
spotView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
if(groupPosition != previousGroup)
spotView.collapseGroup(previousGroup);
previousGroup = groupPosition;
}
});
String sortOptions[] = getResources().getStringArray(R.array.setting_sort_options);
String sortPreference = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("sorting", sortOptions[0]);
Boolean hide_closed = PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("hide_closed", true);
Expand Down Expand Up @@ -316,45 +323,83 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
{
menu.clear();
}
inflater.inflate(R.menu.menu_forecast, menu);
super.onCreateOptionsMenu(menu,inflater);
}

private void updateDateGUIElements(Date aDate) {
loadDate();

String locDate = dateFormat.format(aDate);
city = ((ParkenDD) getActivity().getApplication()).currentCity();
getActivity().setTitle(city.name() + " - " + locDate);
displayedDate.setText(locDate);
}

private void updateTimeGUIElements(Date aDate) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, aDate.getHours());
cal.set(Calendar.MINUTE, aDate.getMinutes());
displayedTime.setText(formatTime(cal));

updateList(cal.get(Calendar.HOUR_OF_DAY));
}

private void openDatePicker() {
Calendar c = Calendar.getInstance();
c.setTime(date);
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);

DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), this, year, month, day);
datePickerDialog.show();
}

private void openTimePicker() {
Calendar c = Calendar.getInstance();
c.setTime(date);
int hourOfDay = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);

TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(),this,hourOfDay, minute, true);
timePickerDialog.show();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_datePicker) {
relativeLayout.setVisibility(View.INVISIBLE);
datePickerLayout.setVisibility(View.VISIBLE);
return true;
}
public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
date = new Date(datePicker.getYear() - DATE_OFFSET, datePicker.getMonth(), datePicker.getDayOfMonth());

return super.onOptionsItemSelected(item);
updateDateGUIElements(date);
}

@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.okbutton :
relativeLayout.setVisibility(View.VISIBLE);
datePickerLayout.setVisibility(View.INVISIBLE);
DatePicker datePicker = (DatePicker) datePickerLayout.findViewById(R.id.datePicker);
date = new Date(datePicker.getYear() - dateOffset, datePicker.getMonth(), datePicker.getDayOfMonth());
loadDate();
String locDate = dateFormat.format(date);
getActivity().setTitle(city.name() + " - " + locDate);
break;

case R.id.cancelbutton:
relativeLayout.setVisibility(View.VISIBLE);
datePickerLayout.setVisibility(View.INVISIBLE);
break;
}
public void onTimeSet(TimePicker timePicker, int i, int i1) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour());
cal.set(Calendar.MINUTE, timePicker.getCurrentMinute());
date = new Date(cal.get(Calendar.YEAR) - DATE_OFFSET, cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH),
cal.get(Calendar.HOUR_OF_DAY),cal.get(Calendar.MINUTE));

updateTimeGUIElements(date);
}

private String formatTime(Calendar cal) {
int hours = cal.get(Calendar.HOUR_OF_DAY);
String hoursText;
if(hours < 10)
hoursText = "0" + hours;
else
hoursText = hours + "";

int minutes = cal.get(Calendar.MINUTE);
String minutesText;
if(minutes < 10)
minutesText = "0" + minutes;
else
minutesText = minutes + "";

return hoursText + ":" + minutesText;
}

/**
Expand Down
Loading

0 comments on commit e10ea7f

Please sign in to comment.