Skip to content

Commit 12cbad6

Browse files
authored
Merge pull request #121 from hyperrail/development
v1.3.3 (beta) with support for Android 13
2 parents aedf893 + b708c5a commit 12cbad6

File tree

29 files changed

+799
-748
lines changed

29 files changed

+799
-748
lines changed

Hyperrail/build.gradle

+28-21
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@ apply plugin: 'com.android.application'
88
apply plugin: 'com.google.gms.google-services'
99
apply plugin: 'com.google.firebase.crashlytics'
1010

11-
def VERSION_CODE = 56
12-
def VERSION_NAME = '1.3.2'
11+
def VERSION_CODE = 57
12+
def VERSION_NAME = '1.3.3'
1313

1414
android {
15-
compileSdkVersion 31
16-
buildToolsVersion '30.0.3'
15+
compileSdk 33
16+
buildToolsVersion '33.0.0'
1717
defaultConfig {
1818
applicationId "be.hyperrail.android"
1919
minSdkVersion 21
20-
targetSdkVersion 31
20+
targetSdkVersion 33
2121
versionCode VERSION_CODE
2222
versionName VERSION_NAME
2323
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2424
multiDexEnabled true
25+
resConfigs 'en', 'nl', 'fr'
2526
}
2627
buildTypes {
2728
release {
@@ -35,43 +36,49 @@ android {
3536
}
3637
}
3738
compileOptions {
38-
targetCompatibility 1.8
39-
sourceCompatibility 1.8
39+
targetCompatibility 11
40+
sourceCompatibility 11
4041
}
41-
lintOptions {
42+
lint {
4243
abortOnError false
4344
}
4445
}
4546

4647
dependencies {
47-
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
48-
implementation 'com.google.android.gms:play-services-maps:18.0.0'
48+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
49+
implementation 'com.google.android.gms:play-services-maps:18.1.0'
4950
implementation fileTree(include: ['*.jar'], dir: 'libs')
5051

51-
5252
implementation 'com.android.volley:volley:1.2.1@aar'
53-
implementation 'joda-time:joda-time:2.10.3'
54-
implementation 'androidx.appcompat:appcompat:1.4.0'
53+
implementation 'joda-time:joda-time:2.11.0'
54+
implementation 'com.squareup.picasso:picasso:2.71828'
55+
56+
def lifecycle_version = "2.5.1"
57+
// Force the same lifecycle-viewmodel for kotlin and java.
58+
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
59+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
60+
61+
implementation 'androidx.appcompat:appcompat:1.5.1'
5562
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
5663
implementation 'androidx.cardview:cardview:1.0.0'
5764
implementation 'androidx.recyclerview:recyclerview:1.2.1'
58-
implementation 'com.google.android.material:material:1.4.0'
59-
implementation 'com.google.android.gms:play-services-location:18.0.0'
60-
implementation 'com.squareup.picasso:picasso:2.71828'
61-
implementation 'com.google.firebase:firebase-crashlytics:18.2.5'
65+
implementation 'androidx.preference:preference:1.2.0'
66+
implementation 'com.google.android.material:material:1.6.1'
67+
implementation 'com.google.android.gms:play-services-location:20.0.0'
68+
implementation 'com.google.firebase:firebase-crashlytics:18.2.13'
6269

6370
testImplementation 'junit:junit:4.13.2'
64-
testImplementation 'org.json:json:20200518'
65-
testImplementation "org.mockito:mockito-core:2.18.3"
71+
testImplementation 'org.json:json:20220320'
72+
testImplementation 'org.mockito:mockito-core:4.7.0'
6673
// org.json is included with Android, but Android.jar can not be used from unit tests
67-
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0', {
74+
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0', {
6875
exclude group: 'com.android.support', module: 'support-annotations'
6976
exclude group: 'com.android.support', module: 'support-v4'
7077
exclude group: 'com.android.support', module: 'design'
7178
exclude group: 'com.android.support', module: 'recyclerview-v7'
7279
}
7380

74-
androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0', {
81+
androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0', {
7582
exclude group: 'com.android.support', module: 'support-annotations'
7683
})
7784

Hyperrail/src/main/AndroidManifest.xml

+9-3
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@
1919
android:fullBackupContent="@xml/backup_descriptor"
2020
android:icon="@mipmap/ic_launcher"
2121
android:label="@string/app_name"
22+
android:localeConfig="@xml/locales_config"
2223
android:supportsRtl="false"
2324
android:theme="@style/Hyperrail"
2425
tools:ignore="GoogleAppIndexingWarning">
2526

27+
2628
<uses-library
2729
android:name="org.apache.http.legacy"
2830
android:required="false" />
2931

3032
<activity
31-
android:exported="true"
3233
android:name=".activities.MainActivity"
34+
android:exported="true"
3335
android:hardwareAccelerated="true"
3436
android:windowSoftInputMode="stateUnchanged">
3537
<intent-filter>
@@ -75,7 +77,9 @@
7577
android:name="com.google.android.geo.API_KEY"
7678
android:value="@string/google_maps_key" />
7779

78-
<receiver android:name=".widget.NextDeparturesWidgetProvider" android:exported="true">
80+
<receiver
81+
android:name=".widget.NextDeparturesWidgetProvider"
82+
android:exported="true">
7983
<intent-filter>
8084
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
8185
</intent-filter>
@@ -85,7 +89,9 @@
8589
android:resource="@xml/appwidget_provider" />
8690
</receiver>
8791

88-
<activity android:name=".activities.NextDeparturesWidgetConfiguration" android:exported="true">
92+
<activity
93+
android:name=".activities.NextDeparturesWidgetConfiguration"
94+
android:exported="true">
8995
<intent-filter>
9096
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
9197
</intent-filter>

Hyperrail/src/main/java/be/hyperrail/android/activities/FirstLaunchGuide.java

+2
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,11 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
174174

175175
TextView titleView = rootView.findViewById(R.id.text_title);
176176
titleView.setText(getArguments().getString(ARG_TITLE));
177+
titleView.setTextColor(getResources().getColor(R.color.colorTextAlwaysLight)); // TODO: this hard-coded light color should be cleaned up
177178

178179
TextView descriptionView = rootView.findViewById(R.id.text_description);
179180
descriptionView.setText(getArguments().getString(ARG_DESCRIPTION));
181+
descriptionView.setTextColor(getResources().getColor(R.color.colorTextAlwaysLight)); // TODO: this hard-coded light color should be cleaned up
180182

181183
return rootView;
182184
}

Hyperrail/src/main/java/be/hyperrail/android/activities/MainActivity.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import android.net.Uri;
3434
import android.os.Build;
3535
import android.os.Bundle;
36-
import android.preference.PreferenceManager;
36+
3737
import android.view.Menu;
3838
import android.view.MenuInflater;
3939
import android.view.MenuItem;
@@ -50,6 +50,7 @@
5050
import androidx.core.view.GravityCompat;
5151
import androidx.drawerlayout.widget.DrawerLayout;
5252
import androidx.fragment.app.Fragment;
53+
import androidx.preference.PreferenceManager;
5354

5455
import com.google.android.material.navigation.NavigationView;
5556

Hyperrail/src/main/java/be/hyperrail/android/activities/SettingsActivity.java

+7-21
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,15 @@
1919
package be.hyperrail.android.activities;
2020

2121
import android.os.Bundle;
22-
import android.preference.PreferenceActivity;
23-
import android.preference.PreferenceFragment;
22+
23+
import androidx.annotation.Nullable;
2424

2525
import androidx.appcompat.app.AppCompatActivity;
2626
import androidx.appcompat.widget.Toolbar;
27+
import androidx.preference.PreferenceFragmentCompat;
2728

2829
import be.hyperrail.android.R;
2930

30-
/**
31-
* A {@link PreferenceActivity} that presents a set of application settings. On
32-
* handset devices, settings are presented as a single list. On tablets,
33-
* settings are split by category, with category headers shown to the left of
34-
* the list of settings.
35-
* <p>
36-
* See <a href="http://developer.android.com/design/patterns/settings.html">
37-
* Android Design: Settings</a> for design guidelines and the <a
38-
* href="http://developer.android.com/guide/topics/ui/settings.html">Settings
39-
* API Guide</a> for more information on developing a Settings UI.
40-
*/
4131
public class SettingsActivity extends AppCompatActivity {
4232

4333
@Override
@@ -54,23 +44,19 @@ protected void onCreate(Bundle savedInstanceState) {
5444
setTitle(R.string.title_activity_settings);
5545

5646
// Display the fragment as the main content.
57-
getFragmentManager().beginTransaction()
47+
getSupportFragmentManager().beginTransaction()
5848
.replace(R.id.preferences_content, new SettingsFragment())
5949
.commit();
6050

6151
}
6252

63-
public static class SettingsFragment extends PreferenceFragment {
53+
public static class SettingsFragment extends PreferenceFragmentCompat {
6454

6555
@Override
66-
public void onCreate(Bundle savedInstanceState) {
67-
super.onCreate(savedInstanceState);
68-
56+
public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) {
6957
// Load the preferences from an XML resource
70-
71-
addPreferencesFromResource(R.xml.pref_general);
58+
setPreferencesFromResource(R.xml.pref_general, rootKey);
7259
}
73-
7460
}
7561

7662
}

Hyperrail/src/main/java/be/hyperrail/android/fragments/LiveboardSearchFragment.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,9 @@ public void onChanged() {
144144

145145
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
146146

147-
//noinspection ConstantConditions
148-
mNumberOfNearbyStations = Integer.valueOf(preferences.getString(PREF_STATIONS_NEARBY_COUNT, "3"));
147+
mNumberOfNearbyStations = Integer.parseInt(preferences.getString(PREF_STATIONS_NEARBY_COUNT, "3"));
149148

150-
//noinspection ConstantConditions
151-
int order = Integer.valueOf(preferences.getString(PREF_STATIONS_ORDER, "0"));
149+
int order = Integer.parseInt(preferences.getString(PREF_STATIONS_ORDER, "0"));
152150
// 0 || 1: suggestions before nearby
153151
// 2 || 3: nearby before suggestions
154152
mNearbyOnTop = (order == 2 || order == 3);

Hyperrail/src/main/java/be/hyperrail/android/fragments/RouteSearchFragment.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ public void onDateTimePicked(DateTime d) {
386386

387387
DateTime now = new DateTime();
388388

389-
DateTimeFormatter df = DateTimeFormat.forPattern("dd MMMM yyyy");
389+
DateTimeFormatter df = DateTimeFormat.forPattern("dd MMMM");
390390
DateTimeFormatter tf = DateTimeFormat.forPattern("HH:mm");
391391

392392
String day = df.print(searchDateTime);
@@ -396,10 +396,11 @@ public void onDateTimePicked(DateTime d) {
396396
if (now.get(DateTimeFieldType.year()) == searchDateTime.get(DateTimeFieldType.year())) {
397397
if (now.get(DateTimeFieldType.dayOfYear()) == searchDateTime.get(DateTimeFieldType.dayOfYear())) {
398398
day = getActivity().getResources().getString(R.string.time_today);
399-
} else //noinspection RedundantCast
400-
if (now.get(DateTimeFieldType.dayOfYear()) + 1 == (int) searchDateTime.get(DateTimeFieldType.dayOfYear())) {
401-
day = getActivity().getResources().getString(R.string.time_tomorrow);
402-
}
399+
} else if (now.get(DateTimeFieldType.dayOfYear()) + 1 == (int) searchDateTime.get(DateTimeFieldType.dayOfYear())) {
400+
day = getActivity().getResources().getString(R.string.time_tomorrow);
401+
} else if (now.get(DateTimeFieldType.dayOfYear()) - 1 == (int) searchDateTime.get(DateTimeFieldType.dayOfYear())) {
402+
day = getActivity().getResources().getString(R.string.time_yesterday);
403+
}
403404
}
404405
vDatetime.setText(day + " " + at + " " + time);
405406
}
@@ -444,7 +445,8 @@ private static class LoadAutoCompleteTask extends AsyncTask<TransportStopsDataSo
444445
@Override
445446
protected String[] doInBackground(TransportStopsDataSource... provider) {
446447
Thread.currentThread().setName("LoadAutoCompleteTask");
447-
return provider[0].getStoplocationsNames(provider[0].getStoplocationsOrderedBySize());
448+
// TODO: "make use of translations" a setting
449+
return provider[0].getStoplocationsNames(provider[0].getStoplocationsOrderedBySize(), false);
448450

449451
}
450452

Hyperrail/src/main/java/be/hyperrail/android/persistence/PersistentQueryProvider.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ public static PersistentQueryProvider getInstance(Context context) {
105105
*/
106106
public List<Suggestion<RoutePlanningRequest>> getAllRoutes() {
107107

108-
//noinspection ConstantConditions
109108
int recentLimit = Integer.valueOf(sharedPreferences.getString(PREF_ROUTES_HISTORY_COUNT, "3"));
110-
//noinspection ConstantConditions
111109
int order = Integer.valueOf(sharedPreferences.getString(PREF_ROUTES_ORDER, "0"));
112110
// 0: recents before favorites
113111
// 1: favorites before recents
@@ -143,11 +141,9 @@ public List<Suggestion<RoutePlanningRequest>> getAllRoutes() {
143141
* @return Sorted array with favorite and recent liveboard requests
144142
*/
145143
public List<Suggestion<LiveboardRequest>> getAllStations() {
146-
//noinspection ConstantConditions
147-
int recentLimit = Integer.valueOf(
144+
int recentLimit = Integer.parseInt(
148145
sharedPreferences.getString(PREF_STOPLOCATIONS_HISTORY_COUNT, "3"));
149-
//noinspection ConstantConditions
150-
int order = Integer.valueOf(sharedPreferences.getString(PREF_STATIONS_ORDER, "0"));
146+
int order = Integer.parseInt(sharedPreferences.getString(PREF_STATIONS_ORDER, "0"));
151147
// 0 || 2: recents before favorites
152148
// 1 || 3: favorites before recents
153149

@@ -182,9 +178,7 @@ public List<Suggestion<LiveboardRequest>> getAllStations() {
182178
* @return Sorted array with favorite and recent vehicle requests
183179
*/
184180
public List<Suggestion<VehicleRequest>> getAllTrains() {
185-
//noinspection ConstantConditions
186181
int recentLimit = Integer.valueOf(sharedPreferences.getString("trains_history_count", "3"));
187-
//noinspection ConstantConditions
188182
int order = Integer.valueOf(sharedPreferences.getString("trains_order", "0"));
189183
// 0: recents before favorites
190184
// 1: favorites before recents

Hyperrail/src/main/res/drawable/dottab_indicator_default.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
android:shape="ring"
77
android:thickness="2dp"
88
android:useLevel="false">
9-
<solid android:color="@android:color/darker_gray"/>
9+
<solid android:color="@color/colorPrimaryLight"/>
1010
</shape>
1111
</item>
1212
</layer-list>

Hyperrail/src/main/res/layout/activity_first_launch_guide.xml

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
xmlns:app="http://schemas.android.com/apk/res-auto"
88
android:layout_width="match_parent"
99
android:layout_height="match_parent"
10-
android:background="@color/colorPrimary">
10+
android:background="@color/colorPrimaryDark">
1111

12-
<androidx.viewpager.widget.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
13-
xmlns:app="http://schemas.android.com/apk/res-auto"
12+
<androidx.viewpager.widget.ViewPager
1413
xmlns:tools="http://schemas.android.com/tools"
1514
android:id="@+id/container"
1615
android:layout_width="match_parent"
@@ -39,7 +38,7 @@
3938
android:gravity="center_vertical|left"
4039
android:padding="16dp"
4140
android:text="@string/skip"
42-
android:textColor="@color/colorTextLight" />
41+
android:textColor="@color/colorTextAlwaysLight" />
4342

4443
<Button
4544
android:id="@+id/button_next"
@@ -52,5 +51,5 @@
5251
android:gravity="center_vertical|right"
5352
android:padding="16dp"
5453
android:text="@string/next"
55-
android:textColor="@color/colorTextLight" />
54+
android:textColor="@color/colorTextAlwaysLight" />
5655
</RelativeLayout>

0 commit comments

Comments
 (0)