Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create 3 Sliding Tabs for maps, past trips and indego stations #9

Merged
merged 4 commits into from Sep 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 31 additions & 2 deletions CyclePhillyAndroid/build.gradle
@@ -1,3 +1,5 @@
apply plugin: 'com.android.application'

task wrapper(type: Wrapper) {
gradleVersion = '1.10'
}
Expand All @@ -11,28 +13,55 @@ buildscript {
}
}

apply plugin: 'android'

repositories {
mavenCentral()
}

android {
compileSdkVersion 21
buildToolsVersion '21.1.2'

defaultConfig {
minSdkVersion 10
targetSdkVersion 21
}

productFlavors {
mainActivity {
manifestPlaceholders = [mainCategory: "android.intent.category.LAUNCHER"]
}
mainInput {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lets you still run the original Launcher Activity: Main Input as long as you go into Run > Edit Configurations and change the launcher activity to MainInput.

image

image

You can switch between MainInput and MainActivity product flavors in the build variants:
image

manifestPlaceholders = [mainCategory: "android.intent.category.LAUNCHER"]
}
}

packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}

buildTypes {
release {
minifyEnabled false
debuggable false
jniDebuggable false
}
debug {
debuggable true
}
}

sourceSets {
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}

}




dependencies {
compile 'com.android.support:support-v4:22.1.1'
compile 'com.android.support:recyclerview-v7:21.0.0'
Expand Down
37 changes: 25 additions & 12 deletions CyclePhillyAndroid/src/main/AndroidManifest.xml
Expand Up @@ -28,20 +28,33 @@
android:normalScreens="true" />

<application
android:icon="@drawable/icon72"
android:icon="@drawable/icon72"
android:label="@string/app_name"
android:allowBackup="true" >
<activity
android:name="org.phillyopen.mytracks.cyclephilly.activity.MainActivity"
android:label="@string/app_name"
android:allowBackup="true" >
<activity
android:name="org.phillyopen.mytracks.cyclephilly.MainInput"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
android:theme="@style/AppTheme"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<category android:name="${mainCategory}" />
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mainCategory is used in build.gradle to switch between launcher activities

</intent-filter>
</activity>

<activity
android:name="org.phillyopen.mytracks.cyclephilly.MainInput"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="${mainCategory}" />
</intent-filter>
</activity>
<activity
android:name="RecordingActivity"
android:finishOnTaskLaunch="true"
Expand Down
Expand Up @@ -30,7 +30,6 @@

package org.phillyopen.mytracks.cyclephilly;

import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
Expand All @@ -50,7 +49,6 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
Expand All @@ -70,21 +68,21 @@
import android.widget.TextView;
import android.widget.Toast;

import com.firebase.client.*;
import com.firebase.client.DataSnapshot;
import com.firebase.client.Firebase;
import com.firebase.client.FirebaseError;
import com.firebase.client.ValueEventListener;
import com.firebase.geofire.GeoFire;
import com.firebase.geofire.GeoLocation;
import com.firebase.geofire.GeoQuery;
import com.firebase.geofire.GeoQueryEventListener;
import com.firebase.geofire.LocationCallback;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.model.LatLng;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down
@@ -0,0 +1,26 @@
package org.phillyopen.mytracks.cyclephilly.activity;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;

import org.phillyopen.mytracks.cyclephilly.R;
import org.phillyopen.mytracks.cyclephilly.tab.SlidingTabsColorsFragment;


public class MainActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

if (savedInstanceState == null) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
SlidingTabsColorsFragment fragment = new SlidingTabsColorsFragment();
transaction.replace(R.id.sample_content_fragment, fragment);
transaction.commit();
}
}
}

@@ -0,0 +1,82 @@
/*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.phillyopen.mytracks.cyclephilly.tab;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import org.phillyopen.mytracks.cyclephilly.R;

/**
* Simple Fragment used to display some meaningful content for each page in the sample's
* {@link android.support.v4.view.ViewPager}.
*/
public class ContentFragment extends Fragment {

private static final String KEY_TITLE = "title";
private static final String KEY_INDICATOR_COLOR = "indicator_color";
private static final String KEY_DIVIDER_COLOR = "divider_color";

/**
* @return a new instance of {@link ContentFragment}, adding the parameters into a bundle and
* setting them as arguments.
*/
public static ContentFragment newInstance(CharSequence title, int indicatorColor,
int dividerColor) {
Bundle bundle = new Bundle();
bundle.putCharSequence(KEY_TITLE, title);
bundle.putInt(KEY_INDICATOR_COLOR, indicatorColor);
bundle.putInt(KEY_DIVIDER_COLOR, dividerColor);

ContentFragment fragment = new ContentFragment();
fragment.setArguments(bundle);

return fragment;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.pager_item, container, false);
}

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

Bundle args = getArguments();

if (args != null) {
TextView title = (TextView) view.findViewById(R.id.item_title);
title.setText("Title: " + args.getCharSequence(KEY_TITLE));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to put all UI text in strings.xml, for future translation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do


int indicatorColor = args.getInt(KEY_INDICATOR_COLOR);
TextView indicatorColorView = (TextView) view.findViewById(R.id.item_indicator_color);
indicatorColorView.setText("Indicator: #" + Integer.toHexString(indicatorColor));
indicatorColorView.setTextColor(indicatorColor);

int dividerColor = args.getInt(KEY_DIVIDER_COLOR);
TextView dividerColorView = (TextView) view.findViewById(R.id.item_divider_color);
dividerColorView.setText("Divider: #" + Integer.toHexString(dividerColor));
dividerColorView.setTextColor(dividerColor);
}
}
}