Skip to content

Commit

Permalink
Fix #340 - Add About Activity
Browse files Browse the repository at this point in the history
Also update the Contributors.md file
  • Loading branch information
barbeau committed Oct 27, 2015
1 parent 2711e44 commit ba2d2a1
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 2 deletions.
6 changes: 4 additions & 2 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ We'd like to thank the following developers who have contributed to OneBusAway A
* Daniel Welsh
* Arno Hart (ahart@skuzme.com)
* Sean Barbeau (sjbarbeau@gmail.com)

The bus stop marker was adapted from the Map Marker designed by Venkatesh Aiyulu from the thenounproject.com
* Ari Rusakko
* Ben Du
* Cagri Cetin
* Mike Karabushin
10 changes: 10 additions & 0 deletions onebusaway-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/apiv2_key"/>

<activity
android:name="org.onebusaway.android.ui.AboutActivity"
android:label="@string/title_activity_about"
android:parentActivityName="org.onebusaway.android.ui.PreferencesActivity"
android:theme="@style/Theme.OneBusAway.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.PreferencesActivity"/>
</activity>
</application>

<uses-feature
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.onebusaway.android.ui;

import com.google.android.gms.common.GoogleApiAvailability;

import org.onebusaway.android.R;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.TextView;

/**
* An Activity that displays version, license, and contributor information
*/
public class AboutActivity extends AppCompatActivity {

public static void start(Context context) {
Intent intent = new Intent(context, AboutActivity.class);
context.startActivity(intent);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
CollapsingToolbarLayout toolBarLayout = (CollapsingToolbarLayout) findViewById(
R.id.toolbar_layout);
toolBarLayout.setTitle(getTitle());

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

TextView tv = (TextView) findViewById(R.id.about_text);
String versionString = "";
int versionCode = 0;
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
versionString = info.versionName;
versionCode = info.versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}

StringBuilder builder = new StringBuilder();
// Version info
builder.append("v")
.append(versionString)
.append(" (")
.append(versionCode)
.append(")\n\n");

// Majority of content from string resource
builder.append(getString(R.string.about_text));
String googleOssLicense = null;

// License info for Google Play Services, if available
try {
GoogleApiAvailability gaa = GoogleApiAvailability.getInstance();
googleOssLicense = gaa.getOpenSourceSoftwareLicenseInfo(this);
} catch (Exception e) {
e.printStackTrace();
}
if (googleOssLicense != null) {
builder.append(googleOssLicense);
}

builder.append("\n\n");

tv.setText(builder.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public class PreferencesActivity extends PreferenceActivity

Preference poweredByObaPref;

Preference aboutPref;

boolean autoSelectInitialValue;
//Save initial value so we can compare to current value in onDestroy()

Expand Down Expand Up @@ -96,6 +98,9 @@ public void onCreate(Bundle savedInstanceState) {
poweredByObaPref = findPreference(getString(R.string.preferences_key_powered_by_oba));
poweredByObaPref.setOnPreferenceClickListener(this);

aboutPref = findPreference(getString(R.string.preferences_key_about));
aboutPref.setOnPreferenceClickListener(this);

SharedPreferences settings = Application.getPrefs();
autoSelectInitialValue = settings
.getBoolean(getString(R.string.preference_key_auto_select_region), true);
Expand Down Expand Up @@ -235,6 +240,11 @@ public boolean onPreferenceClick(Preference pref) {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(getString(R.string.powered_by_oba_url)));
startActivity(intent);
} else if (pref.equals(aboutPref)) {
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
getString(R.string.analytics_action_button_press),
getString(R.string.analytics_label_button_press_about));
AboutActivity.start(this);
}
return true;
}
Expand Down
38 changes: 38 additions & 0 deletions onebusaway-android/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="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:fitsSystemWindows="true"
tools:context="org.onebusaway.android.ui.AboutActivity">

<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:fitsSystemWindows="true"
android:layout_height="@dimen/app_bar_height"
android:layout_width="match_parent"
android:theme="@style/Theme.OneBusAway.AppBarOverlay">

<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"
app:popupTheme="@style/Theme.OneBusAway.PopupOverlay"/>

</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_about"/>

</android.support.design.widget.CoordinatorLayout>
19 changes: 19 additions & 0 deletions onebusaway-android/src/main/res/layout/content_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_about"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.onebusaway.android.ui.AboutActivity">

<TextView
android:id="@+id/about_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:autoLink="web"/>

</android.support.v4.widget.NestedScrollView>
9 changes: 9 additions & 0 deletions onebusaway-android/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- About -->
<resources>
<style name="Theme.OneBusAway.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>
4 changes: 4 additions & 0 deletions onebusaway-android/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@
<!-- Route lines -->
<dimen name="map_route_line_width">5dp</dimen>
<dimen name="map_route_padding">16dp</dimen>

<!-- About -->
<dimen name="app_bar_height">180dp</dimen>
<dimen name="text_margin">16dp</dimen>
</resources>
2 changes: 2 additions & 0 deletions onebusaway-android/src/main/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<string name="preferences_key_analytics">preference_google_analytics</string>
<string name="preferences_key_donate">preference_donate</string>
<string name="preferences_key_powered_by_oba">preference_powered_by_oba</string>
<string name="preferences_key_about">preference_about</string>
<string name="preference_key_preferred_units">preference_preferred_units</string>
<string name="preference_key_arrival_info_style">preference_arrival_info_style</string>
<string name="preference_key_show_negative_arrivals">preference_show_negative_arrivals</string>
Expand Down Expand Up @@ -81,6 +82,7 @@
<string name="analytics_label_button_press_settings">Clicked Settings Link</string>
<string name="analytics_label_button_press_donate">Clicked Donate Link</string>
<string name="analytics_label_button_press_powered_by_oba">Clicked Powered By Oba Link</string>
<string name="analytics_label_button_press_about">Clicked About</string>
<string name="analytics_label_button_press_help">Clicked Help Link</string>
<string name="analytics_label_button_press_feedback">Clicked Email Link</string>
<string name="analytics_label_button_press_stopinfo">Loaded StopInfo from\u0020</string>
Expand Down
38 changes: 38 additions & 0 deletions onebusaway-android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@
<string name="preferences_powered_by_oba_title">Powered by OneBusAway</string>
<string name="preferences_powered_by_oba_summary">Find out more about the open-source project
</string>
<string name="preferences_about_title">About</string>
<string name="preferences_about_summary">Version, contributor, and license information</string>
<!-- Units -->
<string name="feet_abbreviation">ft</string>
<string name="miles_abbreviation">mi</string>
Expand All @@ -498,4 +500,40 @@
<string name="vehicle_last_updated_sec">Data updated %1$d sec ago</string>
<string name="vehicle_last_updated_min_and_sec">Data updated %1$d min %2$d sec ago</string>
<string name="vehicle_last_updated_scheduled">Position calculated from schedule</string>

<!-- About -->
<string name="title_activity_about">About</string>
<string name="about_text">
"Find out more about the OneBusAway open-source project at http://onebusaway.org.\n\n"

"*** Code ***\n\n"

"We'd like to thank the following developers who have contributed to OneBusAway
Android:\n\n"

"* Paul Watts\n"
"* Brian Ferris\n"
"* Daniel Welsh\n"
"* Arno Hart\n"
"* Sean Barbeau\n"
"* Ari Rusakko\n"
"* Ben Du\n"
"* Cagri Cetin\n"
"* Mike Karabushin\n\n"

"Want to contribute to this app? Check it out on Github at
https://github.com/OneBusAway/onebusaway-android.\n\n"

"*** Images ***\n\n"

"Thanks to the designers who created images used in the vehicle icons, which were uploaded "
"to the Noun Project under CC BY 3.0 (http://creativecommons.org/licenses/by/3.0/us/):\n\n"

"* Arrow by Zlatko Najdenovski, MK\n"
"* Map Marker by Housin Aziz, SE\n\n"

"Thanks to Google for the material design icons
(https://github.com/google/material-design-icons), "
"licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/).\n\n"
</string>
</resources>
7 changes: 7 additions & 0 deletions onebusaway-android/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,11 @@
<item name="android:textSize">12sp</item>
<item name="android:textColor">@color/header_text_color</item>
</style>
<!-- About -->
<style name="Theme.OneBusAway.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.OneBusAway.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="Theme.OneBusAway.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
</resources>
4 changes: 4 additions & 0 deletions onebusaway-android/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
android:key="@string/preferences_key_powered_by_oba"
android:title="@string/preferences_powered_by_oba_title"
android:summary="@string/preferences_powered_by_oba_summary"/>
<Preference
android:key="@string/preferences_key_about"
android:title="@string/preferences_about_title"
android:summary="@string/preferences_about_summary"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/preferences_category_advanced"
android:key="@string/preferences_category_advanced">
Expand Down

0 comments on commit ba2d2a1

Please sign in to comment.