From 499d1ecd79ca5bbfa70405d561d01e7fe4c9068a Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 4 Sep 2016 06:59:05 +0200 Subject: [PATCH] Using ToolBar --- .../weather/information/activity/AboutActivity.java | 1 - .../weather/information/activity/LicensesActivity.java | 7 ++++--- .../weather/information/activity/MapActivity.java | 3 +-- .../weather/information/activity/PreferencesActivity.java | 1 - .../weather/information/activity/SpecificActivity.java | 1 - .../information/fragment/specific/SpecificFragment.java | 8 -------- app/src/main/res/layout/weather_general_toolbar.xml | 15 +++++++++++++++ app/src/main/res/layout/weather_licenses.xml | 6 +++++- 8 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/name/gumartinm/weather/information/activity/AboutActivity.java b/app/src/main/java/name/gumartinm/weather/information/activity/AboutActivity.java index 452473f..15b886d 100644 --- a/app/src/main/java/name/gumartinm/weather/information/activity/AboutActivity.java +++ b/app/src/main/java/name/gumartinm/weather/information/activity/AboutActivity.java @@ -38,7 +38,6 @@ public class AboutActivity extends AppCompatActivity { final ActionBar actionBar = this.getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); - actionBar.setIcon(R.drawable.ic_launcher); } @Override diff --git a/app/src/main/java/name/gumartinm/weather/information/activity/LicensesActivity.java b/app/src/main/java/name/gumartinm/weather/information/activity/LicensesActivity.java index 411723c..4e1c767 100644 --- a/app/src/main/java/name/gumartinm/weather/information/activity/LicensesActivity.java +++ b/app/src/main/java/name/gumartinm/weather/information/activity/LicensesActivity.java @@ -18,10 +18,10 @@ package name.gumartinm.weather.information.activity; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.webkit.WebView; import com.google.android.gms.common.GoogleApiAvailability; -import com.google.android.gms.common.GooglePlayServicesUtil; import name.gumartinm.weather.information.R; import timber.log.Timber; @@ -41,11 +41,12 @@ public class LicensesActivity extends AppCompatActivity { super.onCreate(savedInstanceState); this.setContentView(R.layout.weather_licenses); + final Toolbar toolbar = (Toolbar) findViewById(R.id.weather_main_toolbar); + this.setSupportActionBar(toolbar); + final ActionBar actionBar = this.getSupportActionBar(); - actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); - actionBar.setIcon(R.drawable.ic_launcher); mWebView = (WebView) this.findViewById(R.id.weather_licenses); } diff --git a/app/src/main/java/name/gumartinm/weather/information/activity/MapActivity.java b/app/src/main/java/name/gumartinm/weather/information/activity/MapActivity.java index 63ac19a..bc9ed8d 100644 --- a/app/src/main/java/name/gumartinm/weather/information/activity/MapActivity.java +++ b/app/src/main/java/name/gumartinm/weather/information/activity/MapActivity.java @@ -80,8 +80,7 @@ public class MapActivity extends AppCompatActivity implements final ActionBar actionBar = this.getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); - actionBar.setIcon(R.drawable.ic_launcher); - + // Acquire a reference to the system Location Manager this.mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); diff --git a/app/src/main/java/name/gumartinm/weather/information/activity/PreferencesActivity.java b/app/src/main/java/name/gumartinm/weather/information/activity/PreferencesActivity.java index 6754a68..0207556 100644 --- a/app/src/main/java/name/gumartinm/weather/information/activity/PreferencesActivity.java +++ b/app/src/main/java/name/gumartinm/weather/information/activity/PreferencesActivity.java @@ -35,7 +35,6 @@ public class PreferencesActivity extends AppCompatActivity { final ActionBar actionBar = this.getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); - actionBar.setIcon(R.drawable.ic_launcher); } @Override diff --git a/app/src/main/java/name/gumartinm/weather/information/activity/SpecificActivity.java b/app/src/main/java/name/gumartinm/weather/information/activity/SpecificActivity.java index b6dc05d..d2f5e0b 100644 --- a/app/src/main/java/name/gumartinm/weather/information/activity/SpecificActivity.java +++ b/app/src/main/java/name/gumartinm/weather/information/activity/SpecificActivity.java @@ -40,7 +40,6 @@ public class SpecificActivity extends AppCompatActivity { final ActionBar actionBar = this.getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); - actionBar.setIcon(R.drawable.ic_launcher); } @Override diff --git a/app/src/main/java/name/gumartinm/weather/information/fragment/specific/SpecificFragment.java b/app/src/main/java/name/gumartinm/weather/information/fragment/specific/SpecificFragment.java index cb68e4d..c450827 100644 --- a/app/src/main/java/name/gumartinm/weather/information/fragment/specific/SpecificFragment.java +++ b/app/src/main/java/name/gumartinm/weather/information/fragment/specific/SpecificFragment.java @@ -26,7 +26,6 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.support.v4.app.Fragment; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.view.LayoutInflater; import android.view.View; @@ -51,13 +50,6 @@ public class SpecificFragment extends Fragment { public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - final AppCompatActivity appCompatActivity = (AppCompatActivity)this.getActivity(); - final ActionBar actionBar = appCompatActivity.getSupportActionBar(); - actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - actionBar.setIcon(R.drawable.ic_launcher); - final Bundle extras = this.getActivity().getIntent().getExtras(); if (extras != null) { diff --git a/app/src/main/res/layout/weather_general_toolbar.xml b/app/src/main/res/layout/weather_general_toolbar.xml index 08ac0de..bed8195 100644 --- a/app/src/main/res/layout/weather_general_toolbar.xml +++ b/app/src/main/res/layout/weather_general_toolbar.xml @@ -1,4 +1,19 @@ + + android:layout_height="fill_parent" + tools:context="name.gumartinm.weather.information.activity.LicensesActivity"> + +