compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services-maps:+'
compile 'com.google.android.gms:play-services-analytics:+'
+ compile 'com.android.support:design:+'
compile 'com.fasterxml.jackson.core:jackson-core:2.3.3'
compile 'com.jakewharton.timber:timber:2.5.0'
}
*/
package name.gumartinm.weather.information.activity;
-import android.app.ActionBar;
-import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
import android.view.View;
import name.gumartinm.weather.information.R;
-public class AboutActivity extends Activity {
+public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
public void onResume() {
super.onResume();
- final ActionBar actionBar = this.getActionBar();
+ final ActionBar actionBar = this.getSupportActionBar();
actionBar.setTitle(this.getString(R.string.weather_about_action));
}
*/
package name.gumartinm.weather.information.activity;
-import android.app.ActionBar;
-import android.app.Activity;
import android.os.Bundle;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
import android.webkit.WebView;
import com.google.android.gms.common.GooglePlayServicesUtil;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
-public class LicensesActivity extends Activity {
+public class LicensesActivity extends AppCompatActivity {
private WebView mWebView;
public void onResume() {
super.onResume();
- final ActionBar actionBar = this.getActionBar();
+ final ActionBar actionBar = this.getSupportActionBar();
actionBar.setTitle(this.getString(R.string.weather_licenses_title));
final String googlePlayServices = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(this.getApplicationContext());
*/
package name.gumartinm.weather.information.activity;
-import android.app.ActionBar;
-import android.app.ActionBar.Tab;
-import android.app.FragmentTransaction;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import android.support.design.widget.TabLayout;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
+import java.text.MessageFormat;
+import java.util.Locale;
+
import name.gumartinm.weather.information.R;
import name.gumartinm.weather.information.fragment.APIKeyNoticeDialogFragment;
import name.gumartinm.weather.information.fragment.current.CurrentFragment;
import name.gumartinm.weather.information.model.DatabaseQueries;
import name.gumartinm.weather.information.model.WeatherLocation;
-import java.text.MessageFormat;
-import java.util.Locale;
-
-public class MainTabsActivity extends FragmentActivity {
+public class MainTabsActivity extends AppCompatActivity {
private static final int NUM_ITEMS = 2;
private ViewPager mPager;
this.setContentView(R.layout.weather_main_tabs);
this.mPager = (ViewPager)this.findViewById(R.id.pager);
- this.mPager.setAdapter(new TabsAdapter(this.getSupportFragmentManager()));
-
+ this.mPager.setAdapter(new TabsAdapter(this.getSupportFragmentManager(), this.getApplicationContext()));
- this.mPager.setOnPageChangeListener(
- new ViewPager.SimpleOnPageChangeListener() {
- @Override
- public void onPageSelected(final int position) {
- MainTabsActivity.this.getActionBar().setSelectedNavigationItem(position);
- }
- });
+ // Give the TabLayout the ViewPager
+ TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
+ tabLayout.setupWithViewPager(mPager);
-
- final ActionBar actionBar = this.getActionBar();
+ final ActionBar actionBar = this.getSupportActionBar();
PreferenceManager.setDefaultValues(this, R.xml.weather_preferences, false);
// Specify that tabs should be displayed in the action bar.
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setDisplayHomeAsUpEnabled(true);
-
- // Create a tab listener that is called when the user changes tabs.
- final ActionBar.TabListener tabListener = new ActionBar.TabListener() {
-
- @Override
- public void onTabSelected(final Tab tab, final FragmentTransaction ft) {
- MainTabsActivity.this.mPager.setCurrentItem(tab.getPosition());
-
- }
-
- @Override
- public void onTabUnselected(final Tab tab, final FragmentTransaction ft) {
-
- }
-
- @Override
- public void onTabReselected(final Tab tab, final FragmentTransaction ft) {
-
- }
-
- };
-
- actionBar.addTab(actionBar.newTab().setText(this.getString(R.string.text_tab_currently)).setTabListener(tabListener));
- actionBar.addTab(actionBar.newTab().setText(this.getString(R.string.text_tab_five_days_forecast)).setTabListener(tabListener));
}
@Override
}
}
- final ActionBar actionBar = this.getActionBar();
+ final ActionBar actionBar = this.getSupportActionBar();
// 1. Update title.
final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext());
actionBar.setTitle(this.getString(R.string.text_field_no_chosen_location));
}
- // 2. Update forecast tab text.
- final String keyPreference = this.getString(R.string.weather_preferences_day_forecast_key);
- final String value = sharedPreferences.getString(keyPreference, "");
- String humanValue = "";
- if (value.equals(this.getString(R.string.weather_preferences_day_forecast_five_day))) {
- humanValue = this.getString(R.string.text_tab_five_days_forecast);
- } else if (value.equals(this.getString(R.string.weather_preferences_day_forecast_ten_day))) {
- humanValue = this.getString(R.string.text_tab_ten_days_forecast);
- } else if (value.equals(this.getString(R.string.weather_preferences_day_forecast_fourteen_day))) {
- humanValue = this.getString(R.string.text_tab_fourteen_days_forecast);
- }
- actionBar.getTabAt(1).setText(humanValue);
+
}
@Override
}
private class TabsAdapter extends FragmentPagerAdapter {
- public TabsAdapter(final FragmentManager fm) {
+ private final String tabTitles[] = new String[NUM_ITEMS];
+ private final Context context;
+
+ public TabsAdapter(final FragmentManager fm, Context context) {
super(fm);
+ this.context = context;
}
@Override
}
}
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ final SharedPreferences sharedPreferences = PreferenceManager
+ .getDefaultSharedPreferences(context);
+
+ // 1. Set currently tab text.
+ final String currently = context.getString(R.string.text_tab_currently);
+ tabTitles[0] = currently;
+
+ // 2. Update forecast tab text.
+ final String keyPreference = context.getString(R.string.weather_preferences_day_forecast_key);
+ final String value = sharedPreferences.getString(keyPreference, "");
+ String forecast = "";
+ if (value.equals(context.getString(R.string.weather_preferences_day_forecast_five_day))) {
+ forecast = context.getString(R.string.text_tab_five_days_forecast);
+ } else if (value.equals(context.getString(R.string.weather_preferences_day_forecast_ten_day))) {
+ forecast = context.getString(R.string.text_tab_ten_days_forecast);
+ } else if (value.equals(context.getString(R.string.weather_preferences_day_forecast_fourteen_day))) {
+ forecast = context.getString(R.string.text_tab_fourteen_days_forecast);
+ }
+ tabTitles[1] = forecast;
+
+ return tabTitles[position];
+ }
}
}
*/
package name.gumartinm.weather.information.activity;
-import android.app.ActionBar;
import android.content.Context;
import android.location.Criteria;
import android.location.Geocoder;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import name.gumartinm.weather.information.model.WeatherLocation;
-public class MapActivity extends FragmentActivity implements
+public class MapActivity extends AppCompatActivity implements
LocationListener,
MapProgressFragment.TaskCallbacks {
private static final String PROGRESS_FRAGMENT_TAG = "PROGRESS_FRAGMENT";
public void onResume() {
super.onResume();
- final ActionBar actionBar = this.getActionBar();
+ final ActionBar actionBar = this.getSupportActionBar();
actionBar.setTitle(this.getString(R.string.weather_map_mark_location));
WeatherLocation weatherLocation;
*/
package name.gumartinm.weather.information.activity;
-import android.app.ActionBar;
-import android.app.Activity;
import android.os.Bundle;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
import name.gumartinm.weather.information.R;
import name.gumartinm.weather.information.fragment.preferences.PreferencesFragment;
-public class PreferencesActivity extends Activity {
+public class PreferencesActivity extends AppCompatActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
public void onResume() {
super.onResume();
- final ActionBar actionBar = this.getActionBar();
+ final ActionBar actionBar = this.getSupportActionBar();
actionBar.setTitle(this.getString(R.string.weather_preferences_action_settings));
}
}
*/
package name.gumartinm.weather.information.activity;
-import android.app.ActionBar;
import android.os.Bundle;
-import android.support.v4.app.FragmentActivity;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+
+import java.text.MessageFormat;
+import java.util.Locale;
import name.gumartinm.weather.information.R;
import name.gumartinm.weather.information.model.DatabaseQueries;
import name.gumartinm.weather.information.model.WeatherLocation;
-import java.text.MessageFormat;
-import java.util.Locale;
-
-public class SpecificActivity extends FragmentActivity {
+public class SpecificActivity extends AppCompatActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.weather_specific);
- final ActionBar actionBar = this.getActionBar();
+ final ActionBar actionBar = this.getSupportActionBar();
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setDisplayHomeAsUpEnabled(true);
final DatabaseQueries query = new DatabaseQueries(this);
final WeatherLocation weatherLocation = query.queryDataBase();
if (weatherLocation != null) {
- final ActionBar actionBar = this.getActionBar();
+ final ActionBar actionBar = this.getSupportActionBar();
final String[] array = new String[2];
array[0] = weatherLocation.getCity();
array[1] = weatherLocation.getCountry();
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:padding="4dip"
- android:gravity="center_horizontal"
- android:layout_width="match_parent" android:layout_height="match_parent">
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:orientation="vertical"
+ android:padding="4dip"
+ android:gravity="center_horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <android.support.design.widget.TabLayout
+ android:id="@+id/sliding_tabs"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:tabMode="scrollable"
+ android:fillViewport="false" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
- <style name="AppBaseTheme" parent="android:Theme.Holo">
+ <style name="AppBaseTheme" parent="Theme.AppCompat">
<!-- API 11 theme customizations can go here. -->
</style>
- <!-- Application theme. -->
- <style name="AppTheme" parent="android:Theme.Holo">
- <!-- All customizations that are NOT specific to a particular API-level can go here. -->
- </style>
-
<style name="Divider">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
- <style name="AppBaseTheme" parent="android:Theme.Holo">
+ <style name="AppBaseTheme" parent="Theme.AppCompat">
<!-- API 14 theme customizations can go here. -->
</style>
- <!-- Application theme. -->
- <style name="AppTheme" parent="android:Theme.Holo">
- <!-- All customizations that are NOT specific to a particular API-level can go here. -->
- </style>
-
<style name="Divider">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
- <style name="AppBaseTheme" parent="android:Theme.Holo">
+ <style name="AppBaseTheme" parent="Theme.AppCompat">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
</style>
<!-- Application theme. -->
- <style name="AppTheme" parent="android:Theme.Holo">
+ <style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>