Page MenuHomeGitPull.it

D17.1729266668.diff
No OneTemporary

Size
17 KB
Referenced Files
None
Subscribers
None

D17.1729266668.diff

diff --git a/build.gradle b/build.gradle
--- a/build.gradle
+++ b/build.gradle
@@ -34,6 +34,7 @@
targetSdkVersion 25
versionCode 27
versionName "1.11"
+ vectorDrawables.useSupportLibrary = true
}
compileOptions {
diff --git a/gradlew.bat b/gradlew.bat
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,84 +1,84 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/res/drawable-xxxhdpi/qrcode_button_custom.xml b/res/drawable-xxxhdpi/qrcode_button_custom.xml
--- a/res/drawable-xxxhdpi/qrcode_button_custom.xml
+++ b/res/drawable-xxxhdpi/qrcode_button_custom.xml
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="utf-8"?>
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
- <item android:drawable="@drawable/qrcode_button_pressed" android:state_pressed="true"/>
- <item android:drawable="@drawable/qrcode_button_pressed" android:state_focused="true"/>
- <item android:drawable="@drawable/qrcode_button_default"/>
-
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:drawable="@drawable/qrcode_button_pressed" android:state_pressed="true"/>
+ <item android:drawable="@drawable/qrcode_button_pressed" android:state_focused="true"/>
+ <item android:drawable="@drawable/qrcode_button_default"/>
+
</selector>
\ No newline at end of file
diff --git a/res/drawable/ic_star_filled.xml b/res/drawable/ic_star_filled.xml
new file mode 100644
--- /dev/null
+++ b/res/drawable/ic_star_filled.xml
@@ -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:fillColor="@color/orange_500"
+ android:pathData="M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z"/>
+</vector>
diff --git a/res/drawable/ic_star_outline.xml b/res/drawable/ic_star_outline.xml
new file mode 100644
--- /dev/null
+++ b/res/drawable/ic_star_outline.xml
@@ -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:fillColor="@color/orange_500"
+ android:pathData="M12,15.39L8.24,17.66L9.23,13.38L5.91,10.5L10.29,10.13L12,6.09L13.71,10.13L18.09,10.5L14.77,13.38L15.76,17.66M22,9.24L14.81,8.63L12,2L9.19,8.63L2,9.24L7.45,13.97L5.82,21L12,17.27L18.18,21L16.54,13.97L22,9.24Z"/>
+</vector>
diff --git a/res/layout/fragment_list_view.xml b/res/layout/fragment_list_view.xml
--- a/res/layout/fragment_list_view.xml
+++ b/res/layout/fragment_list_view.xml
@@ -1,28 +1,46 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:fab="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginEnd="16dp"
- android:layout_marginLeft="16dp"
- android:layout_marginRight="16dp"
- android:layout_marginStart="16dp"
- android:layout_marginTop="10dp"
- android:id="@+id/messageTextView" android:gravity="center_vertical"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:minHeight="48dp"
- android:layout_marginBottom="10dp" />
- <ListView
- android:layout_below="@id/messageTextView"
- android:id="@+id/resultsListView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clickable="true"
- android:descendantFocusability="blocksDescendants"
- android:visibility="visible"
- />
- </RelativeLayout>
\ No newline at end of file
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android
+ xmlns:fab="http://schemas.android.com/apk/res-auto
+ xmlns:tools="http://schemas.android.com/tools
+ android:layout_width="match_parent
+ android:layout_height="match_parent
+
+
+ <TextVie
+ android:id="@+id/messageTextView
+ android:layout_width="match_parent
+ android:layout_height="wrap_content
+ android:layout_marginStart="16dp
+ android:layout_marginLeft="16dp
+ android:layout_marginTop="10dp
+ android:layout_marginEnd="307dp
+ android:layout_marginRight="10dp
+ android:layout_marginBottom="10dp
+ android:layout_toStartOf="@+id/addToFavorites
+ android:layout_toLeftOf="@+id/addToFavorites
+ android:gravity="center_vertical
+ android:minHeight="48dp
+ android:textAppearance="?android:attr/textAppearanceMedium" /
+
+ <ImageButto
+ android:id="@+id/addToFavorites
+ android:layout_width="wrap_content
+ android:layout_height="wrap_content
+ android:layout_above="@+id/resultsListView
+ android:layout_alignParentRight="true
+ android:layout_marginLeft="16dp
+ android:layout_marginTop="10dp
+ android:layout_marginRight="16dp
+ android:layout_marginBottom="16dp
+ android:background="@android:color/transparent
+ fab:srcCompat="@drawable/ic_star_outline" /
+
+ <ListVie
+ android:layout_below="@id/messageTextView
+ android:id="@+id/resultsListView
+ android:layout_width="match_parent
+ android:layout_height="match_parent
+ android:clickable="true
+ android:descendantFocusability="blocksDescendants
+ android:visibility="visible
+ /
+ </RelativeLayout
\ No newline at end of file
diff --git a/res/layout/rename_dialog.xml b/res/layout/rename_dialog.xml
--- a/res/layout/rename_dialog.xml
+++ b/res/layout/rename_dialog.xml
@@ -1,15 +1,15 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <EditText
- android:id="@+id/rename_dialog_bus_stop_name"
- android:inputType="text"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginLeft="20dp"
- android:layout_marginRight="20dp"
- android:selectAllOnFocus="true"/>
-
-</LinearLayout>
\ No newline at end of file
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android
+ android:orientation="vertical
+ android:layout_width="match_parent
+ android:layout_height="match_parent"
+
+ <EditTex
+ android:id="@+id/rename_dialog_bus_stop_name
+ android:inputType="text
+ android:layout_width="match_parent
+ android:layout_height="match_parent
+ android:layout_marginLeft="20dp
+ android:layout_marginRight="20dp
+ android:selectAllOnFocus="true"/
+
+</LinearLayout
\ No newline at end of file
diff --git a/src/it/reyboz/bustorino/ActivityMain.java b/src/it/reyboz/bustorino/ActivityMain.java
--- a/src/it/reyboz/bustorino/ActivityMain.java
+++ b/src/it/reyboz/bustorino/ActivityMain.java
@@ -76,6 +76,7 @@
private static final int SEARCH_BY_ID = 1;
private static final int SEARCH_BY_ROUTE = 2; // TODO: implement this -- https://gitpull.it/T12
private int searchMode;
+ private ImageButton addToFavorites;
/*
* Options
@@ -638,19 +639,27 @@
*/
@Override
public void updateStarIconFromLastBusStop() {
+
+ // no favorites no party!
+ addToFavorites = (ImageButton) findViewById(R.id.addToFavorites);
+ if (addToFavorites == null) {
+ Log.d("MainActivity", "Why the fuck the star is not here?!");
+ return;
+ }
+
// check if there is a last Stop
String stopID = getLastSuccessfullySearchedBusStopID();
if(stopID == null) {
- // TODO: hide the star
+ addToFavorites.setVisibility(View.INVISIBLE);
} else {
// filled or outline?
if(isStopInFavorites(stopID)) {
- // TODO: fill star
+ addToFavorites.setImageResource(R.drawable.ic_star_filled);
} else {
- // TODO: outline star
+ addToFavorites.setImageResource(R.drawable.ic_star_outline);
}
- // TODO: show the star
+ addToFavorites.setVisibility(View.VISIBLE);
}
}
@@ -690,6 +699,7 @@
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
+
// update the star icon
updateStarIconFromLastBusStop();
}
@@ -872,6 +882,21 @@
return busStopID;
}
+ public void changeStarType(String stopID) {
+ if(isStopInFavorites(stopID)) {
+ changeStarFilled();
+ } else {
+ changeStarOutline();
+ }
+ }
+
+ public void changeStarFilled() {
+ addToFavorites.setImageResource(R.drawable.ic_star_filled);
+ }
+
+ public void changeStarOutline() {
+ addToFavorites.setImageResource(R.drawable.ic_star_outline);
+ }
+
-}
\ No newline at end of file
diff --git a/src/it/reyboz/bustorino/fragments/ArrivalsFragment.java b/src/it/reyboz/bustorino/fragments/ArrivalsFragment.java
--- a/src/it/reyboz/bustorino/fragments/ArrivalsFragment.java
+++ b/src/it/reyboz/bustorino/fragments/ArrivalsFragment.java
@@ -26,6 +26,7 @@
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.util.Log;
+import android.widget.ImageButton;
import android.widget.TextView;
import it.reyboz.bustorino.R;
@@ -46,6 +47,8 @@
private DBStatusManager prefs;
private DBStatusManager.OnDBUpdateStatusChangeListener listener;
private boolean justCreated = false;
+ private ImageButton addToFavorites;
+
public static ArrivalsFragment newInstance(String stopID){
Bundle args = new Bundle();
diff --git a/src/it/reyboz/bustorino/fragments/ResultListFragment.java b/src/it/reyboz/bustorino/fragments/ResultListFragment.java
--- a/src/it/reyboz/bustorino/fragments/ResultListFragment.java
+++ b/src/it/reyboz/bustorino/fragments/ResultListFragment.java
@@ -20,6 +20,7 @@
package it.reyboz.bustorino.fragments;
import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.Nullable;
@@ -38,6 +39,7 @@
import it.reyboz.bustorino.backend.Palina;
import it.reyboz.bustorino.backend.Route;
import it.reyboz.bustorino.backend.Stop;
+import it.reyboz.bustorino.middleware.UserDB;
/**
* This is a generalized fragment that can be used both for
@@ -57,6 +59,7 @@
private boolean adapterSet = false;
protected FragmentListener mListener;
private TextView messageTextView;
+ private ImageButton addToFavorites;
private FloatingActionButton fabutton;
private ListView resultsListView;
@@ -102,12 +105,28 @@
}
}
+ /**
+ * Check if the last Bus Stop is in the favorites
+ * @return
+ */
+ public boolean isStopInFavorites(String busStopId) {
+ boolean found = false;
+
+ // no stop no party
+ if(busStopId != null) {
+ SQLiteDatabase userDB = new UserDB(getContext()).getReadableDatabase();
+ found = UserDB.isStopInFavorites(userDB, busStopId);
+ }
+
+ return found;
+ }
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_list_view, container, false);
messageTextView = (TextView) root.findViewById(R.id.messageTextView);
-
+ addToFavorites = (ImageButton) root.findViewById(R.id.addToFavorites);
if (adapterKind != null) {
resultsListView = (ListView) root.findViewById(R.id.resultsListView);
switch (adapterKind) {
@@ -275,8 +294,8 @@
messageTextView.setText(message);
switch (adapterKind) {
case ARRIVALS:
- messageTextView.setClickable(true);
- messageTextView.setOnClickListener(new View.OnClickListener() {
+ addToFavorites.setClickable(true);
+ addToFavorites.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// add/remove the stop in the favorites
@@ -285,10 +304,11 @@
});
break;
case STOPS:
- messageTextView.setClickable(false);
+ addToFavorites.setClickable(false);
break;
}
+
messageTextView.setVisibility(View.VISIBLE);
}
-}
+}
\ No newline at end of file

File Metadata

Mime Type
text/plain
Expires
Fri, Oct 18, 17:51 (11 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
635067
Default Alt Text
D17.1729266668.diff (17 KB)

Event Timeline