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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to put all UI text in There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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.
You can switch between MainInput and MainActivity product flavors in the build variants: