Skip to content

Commit

Permalink
Merge pull request #121 from hyperrail/development
Browse files Browse the repository at this point in the history
v1.3.3 (beta) with support for Android 13
  • Loading branch information
Bertware authored Sep 24, 2022
2 parents aedf893 + b708c5a commit 12cbad6
Show file tree
Hide file tree
Showing 29 changed files with 799 additions and 748 deletions.
49 changes: 28 additions & 21 deletions Hyperrail/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

def VERSION_CODE = 56
def VERSION_NAME = '1.3.2'
def VERSION_CODE = 57
def VERSION_NAME = '1.3.3'

android {
compileSdkVersion 31
buildToolsVersion '30.0.3'
compileSdk 33
buildToolsVersion '33.0.0'
defaultConfig {
applicationId "be.hyperrail.android"
minSdkVersion 21
targetSdkVersion 31
targetSdkVersion 33
versionCode VERSION_CODE
versionName VERSION_NAME
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
resConfigs 'en', 'nl', 'fr'
}
buildTypes {
release {
Expand All @@ -35,43 +36,49 @@ android {
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
targetCompatibility 11
sourceCompatibility 11
}
lintOptions {
lint {
abortOnError false
}
}

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


implementation 'com.android.volley:volley:1.2.1@aar'
implementation 'joda-time:joda-time:2.10.3'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'joda-time:joda-time:2.11.0'
implementation 'com.squareup.picasso:picasso:2.71828'

def lifecycle_version = "2.5.1"
// Force the same lifecycle-viewmodel for kotlin and java.
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"

implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.firebase:firebase-crashlytics:18.2.5'
implementation 'androidx.preference:preference:1.2.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.gms:play-services-location:20.0.0'
implementation 'com.google.firebase:firebase-crashlytics:18.2.13'

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.json:json:20200518'
testImplementation "org.mockito:mockito-core:2.18.3"
testImplementation 'org.json:json:20220320'
testImplementation 'org.mockito:mockito-core:4.7.0'
// org.json is included with Android, but Android.jar can not be used from unit tests
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0', {
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'recyclerview-v7'
}

androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0', {
androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})

Expand Down
12 changes: 9 additions & 3 deletions Hyperrail/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@
android:fullBackupContent="@xml/backup_descriptor"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:localeConfig="@xml/locales_config"
android:supportsRtl="false"
android:theme="@style/Hyperrail"
tools:ignore="GoogleAppIndexingWarning">


<uses-library
android:name="org.apache.http.legacy"
android:required="false" />

<activity
android:exported="true"
android:name=".activities.MainActivity"
android:exported="true"
android:hardwareAccelerated="true"
android:windowSoftInputMode="stateUnchanged">
<intent-filter>
Expand Down Expand Up @@ -75,7 +77,9 @@
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />

<receiver android:name=".widget.NextDeparturesWidgetProvider" android:exported="true">
<receiver
android:name=".widget.NextDeparturesWidgetProvider"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
Expand All @@ -85,7 +89,9 @@
android:resource="@xml/appwidget_provider" />
</receiver>

<activity android:name=".activities.NextDeparturesWidgetConfiguration" android:exported="true">
<activity
android:name=".activities.NextDeparturesWidgetConfiguration"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,11 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,

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

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

return rootView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;

import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
Expand All @@ -50,6 +50,7 @@
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceManager;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,15 @@
package be.hyperrail.android.activities;

import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;

import androidx.annotation.Nullable;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.preference.PreferenceFragmentCompat;

import be.hyperrail.android.R;

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

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

// Display the fragment as the main content.
getFragmentManager().beginTransaction()
getSupportFragmentManager().beginTransaction()
.replace(R.id.preferences_content, new SettingsFragment())
.commit();

}

public static class SettingsFragment extends PreferenceFragment {
public static class SettingsFragment extends PreferenceFragmentCompat {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) {
// Load the preferences from an XML resource

addPreferencesFromResource(R.xml.pref_general);
setPreferencesFromResource(R.xml.pref_general, rootKey);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,9 @@ public void onChanged() {

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

//noinspection ConstantConditions
mNumberOfNearbyStations = Integer.valueOf(preferences.getString(PREF_STATIONS_NEARBY_COUNT, "3"));
mNumberOfNearbyStations = Integer.parseInt(preferences.getString(PREF_STATIONS_NEARBY_COUNT, "3"));

//noinspection ConstantConditions
int order = Integer.valueOf(preferences.getString(PREF_STATIONS_ORDER, "0"));
int order = Integer.parseInt(preferences.getString(PREF_STATIONS_ORDER, "0"));
// 0 || 1: suggestions before nearby
// 2 || 3: nearby before suggestions
mNearbyOnTop = (order == 2 || order == 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public void onDateTimePicked(DateTime d) {

DateTime now = new DateTime();

DateTimeFormatter df = DateTimeFormat.forPattern("dd MMMM yyyy");
DateTimeFormatter df = DateTimeFormat.forPattern("dd MMMM");
DateTimeFormatter tf = DateTimeFormat.forPattern("HH:mm");

String day = df.print(searchDateTime);
Expand All @@ -396,10 +396,11 @@ public void onDateTimePicked(DateTime d) {
if (now.get(DateTimeFieldType.year()) == searchDateTime.get(DateTimeFieldType.year())) {
if (now.get(DateTimeFieldType.dayOfYear()) == searchDateTime.get(DateTimeFieldType.dayOfYear())) {
day = getActivity().getResources().getString(R.string.time_today);
} else //noinspection RedundantCast
if (now.get(DateTimeFieldType.dayOfYear()) + 1 == (int) searchDateTime.get(DateTimeFieldType.dayOfYear())) {
day = getActivity().getResources().getString(R.string.time_tomorrow);
}
} else if (now.get(DateTimeFieldType.dayOfYear()) + 1 == (int) searchDateTime.get(DateTimeFieldType.dayOfYear())) {
day = getActivity().getResources().getString(R.string.time_tomorrow);
} else if (now.get(DateTimeFieldType.dayOfYear()) - 1 == (int) searchDateTime.get(DateTimeFieldType.dayOfYear())) {
day = getActivity().getResources().getString(R.string.time_yesterday);
}
}
vDatetime.setText(day + " " + at + " " + time);
}
Expand Down Expand Up @@ -444,7 +445,8 @@ private static class LoadAutoCompleteTask extends AsyncTask<TransportStopsDataSo
@Override
protected String[] doInBackground(TransportStopsDataSource... provider) {
Thread.currentThread().setName("LoadAutoCompleteTask");
return provider[0].getStoplocationsNames(provider[0].getStoplocationsOrderedBySize());
// TODO: "make use of translations" a setting
return provider[0].getStoplocationsNames(provider[0].getStoplocationsOrderedBySize(), false);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ public static PersistentQueryProvider getInstance(Context context) {
*/
public List<Suggestion<RoutePlanningRequest>> getAllRoutes() {

//noinspection ConstantConditions
int recentLimit = Integer.valueOf(sharedPreferences.getString(PREF_ROUTES_HISTORY_COUNT, "3"));
//noinspection ConstantConditions
int order = Integer.valueOf(sharedPreferences.getString(PREF_ROUTES_ORDER, "0"));
// 0: recents before favorites
// 1: favorites before recents
Expand Down Expand Up @@ -143,11 +141,9 @@ public List<Suggestion<RoutePlanningRequest>> getAllRoutes() {
* @return Sorted array with favorite and recent liveboard requests
*/
public List<Suggestion<LiveboardRequest>> getAllStations() {
//noinspection ConstantConditions
int recentLimit = Integer.valueOf(
int recentLimit = Integer.parseInt(
sharedPreferences.getString(PREF_STOPLOCATIONS_HISTORY_COUNT, "3"));
//noinspection ConstantConditions
int order = Integer.valueOf(sharedPreferences.getString(PREF_STATIONS_ORDER, "0"));
int order = Integer.parseInt(sharedPreferences.getString(PREF_STATIONS_ORDER, "0"));
// 0 || 2: recents before favorites
// 1 || 3: favorites before recents

Expand Down Expand Up @@ -182,9 +178,7 @@ public List<Suggestion<LiveboardRequest>> getAllStations() {
* @return Sorted array with favorite and recent vehicle requests
*/
public List<Suggestion<VehicleRequest>> getAllTrains() {
//noinspection ConstantConditions
int recentLimit = Integer.valueOf(sharedPreferences.getString("trains_history_count", "3"));
//noinspection ConstantConditions
int order = Integer.valueOf(sharedPreferences.getString("trains_order", "0"));
// 0: recents before favorites
// 1: favorites before recents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:shape="ring"
android:thickness="2dp"
android:useLevel="false">
<solid android:color="@android:color/darker_gray"/>
<solid android:color="@color/colorPrimaryLight"/>
</shape>
</item>
</layer-list>
9 changes: 4 additions & 5 deletions Hyperrail/src/main/res/layout/activity_first_launch_guide.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary">
android:background="@color/colorPrimaryDark">

<androidx.viewpager.widget.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<androidx.viewpager.widget.ViewPager
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
Expand Down Expand Up @@ -39,7 +38,7 @@
android:gravity="center_vertical|left"
android:padding="16dp"
android:text="@string/skip"
android:textColor="@color/colorTextLight" />
android:textColor="@color/colorTextAlwaysLight" />

<Button
android:id="@+id/button_next"
Expand All @@ -52,5 +51,5 @@
android:gravity="center_vertical|right"
android:padding="16dp"
android:text="@string/next"
android:textColor="@color/colorTextLight" />
android:textColor="@color/colorTextAlwaysLight" />
</RelativeLayout>
Loading

0 comments on commit 12cbad6

Please sign in to comment.