Page Menu
Home
GitPull.it
Search
Configure Global Search
Log In
Files
F13611847
D251.1785320578.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Authored By
Unknown
Size
21 KB
Referenced Files
None
Subscribers
None
D251.1785320578.diff
View Options
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -56,7 +56,7 @@
<activity
android:name=".ActivityIntro"
android:exported="false"
- android:theme="@style/AppThemeDayNight.NoActionBar"
+ android:theme="@style/AppThemeIntro"
/>
<activity
android:name=".ActivityExperiments"
@@ -76,36 +76,12 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
-
- <category android:name="android.intent.category.DEFAULT"/>
- <category android:name="android.intent.category.BROWSABLE"/>
-
- <data
- android:host="www.gtt.to.it"
- android:pathPrefix="/cms/percorari/arrivi"
- android:scheme="http"/>
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.VIEW"/>
-
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
-
- <data
- android:host="gtt.to.it"
- android:pathPrefix="/cms/percorari/arrivi"
- android:scheme="http"/>
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.VIEW"/>
-
- <category android:name="android.intent.category.DEFAULT"/>
- <category android:name="android.intent.category.BROWSABLE"/>
-
- <data
- android:host="m.gtt.to.it"
- android:pathPrefix="/m/it/arrivi.jsp"
- android:scheme="http"/>
+ <data android:scheme="http" />
+ <data android:scheme="https" />
+ <data android:host="www.gtt.to.it" />
+ <data android:pathPrefix="/cms/percorari/arrivi" />
</intent-filter>
</activity>
<activity
diff --git a/app/src/main/java/it/reyboz/bustorino/ActivityPrincipal.java b/app/src/main/java/it/reyboz/bustorino/ActivityPrincipal.java
--- a/app/src/main/java/it/reyboz/bustorino/ActivityPrincipal.java
+++ b/app/src/main/java/it/reyboz/bustorino/ActivityPrincipal.java
@@ -73,9 +73,30 @@
private final static String TAG_FAVORITES="favorites_frag";
private Snackbar snackbar;
-
+ private boolean startedFromIntent = false;
private ServiceAlertsViewModel serviceAlertsViewModel;
+
+ private final DrawerLayout.DrawerListener drawerListener = new DrawerLayout.DrawerListener() {
+ @Override
+ public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
+
+ }
+
+ @Override
+ public void onDrawerOpened(@NonNull View drawerView) {
+ hideKeyboard();
+ }
+
+ @Override
+ public void onDrawerClosed(@NonNull View drawerView) {
+
+ }
+
+ @Override
+ public void onDrawerStateChanged(int newState) {
+ }
+ };
//private FragmentKind showingFragmentKind;
private final Map<Integer, Runnable> menuActions = Map.of(
@@ -108,13 +129,17 @@
boolean isResolved = activityCustomBackPressed();
Log.d(DEBUG_TAG, "backpress resolved: " + isResolved);
if(!isResolved){
- long currentTime = System.currentTimeMillis();
- if(currentTime - lastClosingAttempt < 2000){
- finish();
- } else{
- lastClosingAttempt = currentTime;
- Toast.makeText(getApplicationContext(),R.string.back_again_to_close,Toast.LENGTH_SHORT).show();
- }
+ //if(startedFromIntent){
+ // finish();
+ //} else{
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastClosingAttempt < 2000)
+ finish();
+ else {
+ lastClosingAttempt = currentTime;
+ Toast.makeText(getApplicationContext(), R.string.back_again_to_close, Toast.LENGTH_SHORT).show();
+ }
+ //}
}
}
};
@@ -132,7 +157,6 @@
//onBackPressed solution required from Android 16
backPressedCallback.setEnabled(true);
this.getOnBackPressedDispatcher().addCallback(backPressedCallback);
- boolean showingArrivalsFromIntent = false;
final Toolbar mToolbar = findViewById(R.id.default_toolbar);
setSupportActionBar(mToolbar);
@@ -150,27 +174,7 @@
drawerToggle.syncState();
mDrawer.addDrawerListener(drawerToggle);
- mDrawer.addDrawerListener(new DrawerLayout.DrawerListener() {
- @Override
- public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
-
- }
-
- @Override
- public void onDrawerOpened(@NonNull View drawerView) {
- hideKeyboard();
- }
-
- @Override
- public void onDrawerClosed(@NonNull View drawerView) {
-
- }
-
- @Override
- public void onDrawerStateChanged(int newState) {
- }
- });
-
+ mDrawer.addDrawerListener(drawerListener);
mNavView = findViewById(R.id.nvView);
@@ -186,32 +190,38 @@
// Intercept calls from URL intent
boolean tryedFromIntent = false;
- String busStopID = null;
- Uri data = getIntent().getData();
- if (data != null) {
+ String initialBusStopID = null;
+ var intent = getIntent();
+ if(intent != null){
+ var data = intent.getData();
+ if(data != null){
+ //var rest = data.getSchemeSpecificPart();
+ //Log.d(DEBUG_TAG, "the rest is: "+rest);
- busStopID = getBusStopIDFromUri(data);
- Log.d(DEBUG_TAG, "Opening Intent: busStopID: "+busStopID);
- tryedFromIntent = true;
- }
+ initialBusStopID = getBusStopIDFromUri(data);
+ tryedFromIntent = true;
+ Log.d(DEBUG_TAG, "Opening Intent: initialBusStopID: "+initialBusStopID);
- // Intercept calls from other activities
- if (!tryedFromIntent) {
- Bundle b = getIntent().getExtras();
- if (b != null) {
- busStopID = b.getString("bus-stop-ID");
-
- /*
- * I'm not very sure if you are coming from an Intent.
- * Some launchers work in strange ways.
- */
- tryedFromIntent = busStopID != null;
+ }
+ // Intercept calls from other activities
+ if(!tryedFromIntent){
+ Bundle b =intent.getExtras();
+ if (b != null) {
+ initialBusStopID = b.getString("bus-stop-ID");
+
+ /*
+ * I'm not very sure if you are coming from an Intent.
+ * Some launchers work in strange ways.
+ */
+ tryedFromIntent = initialBusStopID != null;
+ }
}
}
+
//---------------------------- END INTENT CHECK QUEUE --------------------------------------
- if (busStopID == null) {
+ if (initialBusStopID == null) {
// Show keyboard if can't start from intent
// JUST DON'T
// showKeyboard();
@@ -223,20 +233,14 @@
Toast.makeText(getApplicationContext(),
R.string.insert_bus_stop_number_error, Toast.LENGTH_SHORT).show();
}
- } else {
- // If you are here an intent has worked successfully
- //setBusStopSearchByIDEditText(busStopID);
- //Log.d(DEBUG_TAG, "Requesting arrivals for stop "+busStopID+" from intent");
- requestArrivalsForStopID(busStopID); //this shows the fragment, too
- showingArrivalsFromIntent = true;
}
- //database check
+ //save whether we started from intent
+ startedFromIntent = tryedFromIntent;
- // DatabaseUpdate.requestDBUpdateWithWork(this, false, false);
+ //period database check
DBUpdateCheckWorker.Companion.schedulePeriodicCheck(this,false);
- /*
- Watch for database update
- */
+
+ //Watch for database update
DBUpdateWorker.getWorkInfoLiveData(this)
.observe(this, workInfoList -> {
// If there are no matching work info, do nothing
@@ -268,10 +272,12 @@
String vl = PreferenceManager.getDefaultSharedPreferences(this).getString(SettingsFragment.PREF_KEY_STARTUP_SCREEN, "");
Log.d(DEBUG_TAG, "The default screen to open is: "+vl);
- if (showingArrivalsFromIntent){
- //do nothing but exclude a case
+ var framan = getSupportFragmentManager();
+
+ if (initialBusStopID!=null) {
+ Log.d(DEBUG_TAG, "Opening Main Fragment on arrivals, bus Stop: "+initialBusStopID);
+ createShowMainFragment(framan, MainScreenFragment.makeArgsArrivals(initialBusStopID), false);
}else if (savedInstanceState==null) {
- var framan = getSupportFragmentManager();
//we are not restarting the activity from nothing
switch (vl){
case "map" -> {requestMapFragment(false);}
diff --git a/app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java b/app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java
--- a/app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java
+++ b/app/src/main/java/it/reyboz/bustorino/fragments/MainScreenFragment.java
@@ -259,8 +259,10 @@
internalScreen = (parsed != null) ? parsed : InternalScreen.HOME_BUTTONS;
}
String stopId = args.getString(ARG_STOP_ID);
- if (stopId != null) pendingStopID = stopId;
- pendingSearchQuery = args.getString(ARG_SEARCH_QUERY);
+ if (stopId != null)
+ pendingSearchQuery = stopId;
+ else
+ pendingSearchQuery = args.getString(ARG_SEARCH_QUERY);
}
fragmentHelper = new FragmentHelper(this, getChildFragmentManager(), getContext(), R.id.resultFrame);
@@ -413,6 +415,13 @@
break;
case ARRIVALS:
// pendingStopID is consumed in onResume → requestArrivalsForStopID
+ if(pendingSearchQuery != null && isResumed()) {
+ swipeRefreshLayout.setVisibility(View.VISIBLE);
+ Log.d(DEBUG_TAG, "Searching arrivals for initial stop: "+pendingSearchQuery);
+ requestsArrivalsInternal(pendingSearchQuery, false);
+ pendingSearchQuery = null;
+ }
+
break;
case STOP_SEARCH:
if (pendingSearchQuery != null && pendingSearchQuery.length() >= 2) {
@@ -591,22 +600,6 @@
//this is the second time we are attaching this fragment ->
Log.d(DEBUG_TAG, "Waiting for new stop request: "+ suppressArrivalsReload);
- if(!suppressArrivalsReload && pendingStopID==null){
- //none of the following cases are true
- // check if we are showing any fragment
- /*
- //TODO: check if this is needed
- final Fragment fragment = getChildFragmentManager().findFragmentById(R.id.resultFrame);
-
- if(fragment==null || swipeRefreshLayout.getVisibility() != View.VISIBLE){
- //we are not showing anything
- if(Permissions.anyLocationPermissionsGranted(getContext())){
- showNearbyFragmentIfPossible();
- }
- }
-
- */
- }
if (suppressArrivalsReload){
// we have to suppress the reloading of the (possible) ArrivalsFragment
Fragment fragment = getChildFragmentManager().findFragmentById(R.id.resultFrame);
@@ -617,8 +610,12 @@
//deactivate
suppressArrivalsReload = false;
}
-
- if(pendingStopID!=null){
+ // check if the fragment start query is null
+ if(pendingSearchQuery!=null) {
+ requestsArrivalsInternal(pendingSearchQuery, false);
+ pendingSearchQuery = null;
+ }
+ else if(pendingStopID!=null){
Log.d(DEBUG_TAG, "Pending request for arrivals at stop ID: "+pendingStopID);
requestArrivalsForStopID(pendingStopID);
@@ -872,17 +869,11 @@
if(mListener!=null) mListener.showMapCenteredOnStop(stop);
}
-
- /**
- * Main method for stops requests
- * @param ID the Stop ID
- */
- @Override
- public void requestArrivalsForStopID(String ID) {
+ private void requestsArrivalsInternal(String stopID, boolean addToBackStack) {
if (!isResumed()){
- //defer request
- pendingStopID = ID;
- Log.d(DEBUG_TAG, "Deferring update for stop "+ID+ " saved: "+pendingStopID);
+ //defer request to onResume - it will be added to the backstack
+ pendingStopID = stopID;
+ Log.d(DEBUG_TAG, "Deferring update for stop "+stopID+ " saved: "+pendingStopID);
return;
}
final boolean delayedRequest = !(pendingStopID==null);
@@ -891,12 +882,15 @@
Log.e(DEBUG_TAG, "Asked for arrivals with null context");
return;
}
- if (ID == null || ID.isEmpty()) {
+ if (stopID == null || stopID.isEmpty()) {
// we're still in UI thread, no need to mess with Progress
showToastMessage(R.string.insert_bus_stop_number_error, true);
toggleSpinner(false);
} else{
- var palinaTrial = new Palina(ID);
+ // ensure that the new sub-fragment is gonna be visible
+ swipeRefreshLayout.setVisibility(View.VISIBLE);
+
+ var palinaTrial = new Palina(stopID);
if (framan.findFragmentById(R.id.resultFrame) instanceof ArrivalsFragment fragment) {
if (fragment.isFragmentForTheSameStop(palinaTrial)){
// Run with previous fetchers
@@ -904,18 +898,27 @@
fragment.requestArrivalsForTheFragment();
} else{
// The rest of the case is handled by the fragment Helper
- fragmentHelper.showArrivalsFragmentForStop(palinaTrial, true);
+ fragmentHelper.showArrivalsFragmentForStop(palinaTrial, addToBackStack);
}
}
else {
// this is not needed any more
//prepareGUIForArrivals();
- fragmentHelper.showArrivalsFragmentForStop(palinaTrial, true);
+ fragmentHelper.showArrivalsFragmentForStop(palinaTrial, addToBackStack);
}
}
}
+ /**
+ * Main method for stops requests
+ * @param ID the Stop ID
+ */
+ @Override
+ public void requestArrivalsForStopID(String ID) {
+ requestsArrivalsInternal(ID, true);
+ }
+
private boolean checkLocationPermission(){
final Context context = getContext();
if(context==null) return false;
diff --git a/app/src/main/java/it/reyboz/bustorino/fragments/NearbyStopsFragment.kt b/app/src/main/java/it/reyboz/bustorino/fragments/NearbyStopsFragment.kt
--- a/app/src/main/java/it/reyboz/bustorino/fragments/NearbyStopsFragment.kt
+++ b/app/src/main/java/it/reyboz/bustorino/fragments/NearbyStopsFragment.kt
@@ -338,6 +338,9 @@
}
FragType.ARRIVALS -> {
+ lastPosition?.let{
+ Collections.sort(stops, StopSorterByDistance(loc))
+ }
viewModel.requestArrivalsForStops(stops)
}
}
diff --git a/app/src/main/res/layout/activity_principal.xml b/app/src/main/res/layout/activity_principal.xml
--- a/app/src/main/res/layout/activity_principal.xml
+++ b/app/src/main/res/layout/activity_principal.xml
@@ -41,7 +41,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
- android:theme="@style/ThemeOverlay.AppCompat.DayNight"
+ android:theme="@style/AppThemeDayNight"
app:headerLayout="@layout/nav_header"
app:itemIconTint="@color/teal_500"
app:itemTextAppearance="?android:attr/textAppearanceMedium"
diff --git a/app/src/main/res/values-night-v27/themes.xml b/app/src/main/res/values-night-v27/themes.xml
new file mode 100644
--- /dev/null
+++ b/app/src/main/res/values-night-v27/themes.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <!-- copy all relevant values from the night/themes.xml file -->
+
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml
--- a/app/src/main/res/values-night/themes.xml
+++ b/app/src/main/res/values-night/themes.xml
@@ -1,11 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
+ <!-- REMEMBER TO COPY COLORS in values-v27-night -->
+
<style name="AppThemeDayNight" parent="Theme.MaterialComponents.DayNight">
<item name="android:textColorSecondary">@color/text_secondary_night</item>
<item name="colorPrimary">@color/orange_500_night</item>
<item name="colorPrimaryDark">@color/orange_700_night</item>
<item name="colorAccent">@color/teal_500_night</item>
+ <item name="android:navigationBarColor">?android:colorBackground</item>
+ </style>
-
+ <style name="AppThemeIntro" parent="AppThemeDayNight.NoActionBar">
+ <item name="android:windowLightStatusBar">false</item>
</style>
</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values-v19/styles.xml b/app/src/main/res/values-v19/styles.xml
deleted file mode 100644
--- a/app/src/main/res/values-v19/styles.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <style name="AppTheme.NoActionBar" parent="AppTheme">
-
- <item name="android:windowTranslucentStatus">false</item>
-
- <item name="windowActionBar">false</item>
- <item name="windowNoTitle">true</item>
- </style>
-</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values-v27/styles.xml b/app/src/main/res/values-v27/styles.xml
new file mode 100644
--- /dev/null
+++ b/app/src/main/res/values-v27/styles.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <style name="AppThemeDayNight" parent="Theme.MaterialComponents.DayNight">
+
+ <item name="colorPrimary">@color/orange_500</item>
+ <item name="colorPrimaryDark">@color/orange_700</item>
+ <item name="colorAccent">@color/teal_500</item>
+ <item name="colorOnPrimary">@color/white</item>
+
+ <item name="android:textColor">@color/black_800</item>
+
+ <item name="android:windowLightNavigationBar">true</item>
+ <item name="android:windowLightStatusBar">false</item>
+
+ </style>
+ <style name="AppThemeIntro" parent="AppThemeDayNight.NoActionBar">
+ <item name="android:windowLightStatusBar">true</item>
+
+ <item name="android:windowLightNavigationBar">true</item>
+
+ </style>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values-v35/styles.xml b/app/src/main/res/values-v35/styles.xml
deleted file mode 100644
--- a/app/src/main/res/values-v35/styles.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<resources>
-
-
-</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -8,6 +8,7 @@
<color name="orange_750_l45">#e66b00</color>
<color name="orange_700_40light">#cc6600</color>
<color name="orange_700_30light">#994d00</color>
+ <color name="orange_700_L35">#b35900</color>
<color name="blue_500">#2196F3</color>
<color name="blue_500_night">#0b6fc1</color>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -79,15 +79,13 @@
<item name="colorPrimaryDark">@color/orange_700</item>
<item name="colorAccent">@color/teal_500</item>
<item name="colorOnPrimary">@color/white</item>
+ <!-- REMEMBER TO COPY THEM in values-v27 -->
<!-- For the preferences Fragment -->
<!--<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>-->
<item name="android:textColor">@color/black_800</item>
- <!-- keep default for day, change for night-->
- <!--
- <item name="android:textColorPrimary">@color/grey_700</item>
- <item name="android:textColorSecondary">@color/text_secondary</item>
- -->
+ <item name="android:windowLightStatusBar">false</item>
+
</style>
<style name="AppThemeDayNight.NoActionBar" parent="AppThemeDayNight">
@@ -102,5 +100,10 @@
<item name="android:fontFamily">@font/lato_regular</item>
</style>
+ <style name="AppThemeIntro" parent="AppThemeDayNight.NoActionBar">
+ <item name="android:windowLightStatusBar">true</item>
+
+ </style>
+
</resources>
\ No newline at end of file
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 29, 12:22 (28 m, 37 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2026197
Default Alt Text
D251.1785320578.diff (21 KB)
Attached To
Mode
D251: Fix status and navigation bar colors, fix open by intent
Attached
Detach File
Event Timeline