Page Menu
Home
GitPull.it
Search
Configure Global Search
Log In
Files
F6999270
D17.1765105087.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D17.1765105087.diff
View Options
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
old mode 100755
new mode 100644
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
@@ -2,20 +2,38 @@
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"
- >
+ 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" />
+ 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" />
+
+ <ImageButton
+ 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" />
+
<ListView
android:layout_below="@id/messageTextView"
android:id="@+id/resultsListView"
diff --git a/res/layout/stop_card.xml b/res/layout/stop_card.xml
old mode 100755
new mode 100644
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 11:58 (1 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1427240
Default Alt Text
D17.1765105087.diff (10 KB)
Attached To
Mode
D17: Added favorites button
Attached
Detach File
Event Timeline
Log In to Comment