From 437261c4ea5025f08e18b8bcd4ab621ff38280c6 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Thu, 1 Sep 2016 00:52:11 +0200 Subject: [PATCH] Using ActionBar with AppCompat --- .../gumartinm/weather/information/activity/AboutActivity.java | 7 +++++++ .../gumartinm/weather/information/activity/LicensesActivity.java | 7 +++++++ .../gumartinm/weather/information/activity/MainTabsActivity.java | 8 ++++---- .../name/gumartinm/weather/information/activity/MapActivity.java | 7 +++++++ .../weather/information/activity/PreferencesActivity.java | 6 ++++++ .../gumartinm/weather/information/activity/SpecificActivity.java | 3 ++- .../weather/information/fragment/specific/SpecificFragment.java | 8 ++++++++ .../gumartinm/weather/information/widget/WidgetConfigure.java | 6 ++++++ 8 files changed, 47 insertions(+), 5 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 35fd93e..80d3709 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 @@ -29,6 +29,13 @@ public class AboutActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + 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); + setContentView(R.layout.weather_about); } 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 8aac5d3..d7dd085 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 @@ -38,6 +38,13 @@ public class LicensesActivity extends AppCompatActivity { @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + 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); + setContentView(R.layout.weather_licenses); mWebView = (WebView) this.findViewById(R.id.weather_licenses); diff --git a/app/src/main/java/name/gumartinm/weather/information/activity/MainTabsActivity.java b/app/src/main/java/name/gumartinm/weather/information/activity/MainTabsActivity.java index ccc70a4..5aba1d6 100644 --- a/app/src/main/java/name/gumartinm/weather/information/activity/MainTabsActivity.java +++ b/app/src/main/java/name/gumartinm/weather/information/activity/MainTabsActivity.java @@ -59,12 +59,12 @@ public class MainTabsActivity extends AppCompatActivity { tabLayout.setupWithViewPager(mPager); final ActionBar actionBar = this.getSupportActionBar(); - - PreferenceManager.setDefaultValues(this, R.xml.weather_preferences, false); - - // Specify that tabs should be displayed in the action bar. actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + actionBar.setIcon(R.drawable.ic_launcher); + + PreferenceManager.setDefaultValues(this, R.xml.weather_preferences, false); } @Override 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 69c8eed..77f4306 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 @@ -71,6 +71,13 @@ public class MapActivity extends AppCompatActivity implements @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + 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); + this.setContentView(R.layout.weather_map); // Acquire a reference to the system Location Manager 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 4d31f15..e7a58c3 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 @@ -28,6 +28,12 @@ public class PreferencesActivity extends AppCompatActivity { protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); + 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); + this.getFragmentManager() .beginTransaction() .replace(android.R.id.content, 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 caa0ffe..8189d06 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 @@ -34,9 +34,10 @@ public class SpecificActivity extends AppCompatActivity { this.setContentView(R.layout.weather_specific); 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); } 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 f69e8e2..cb68e4d 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,6 +26,7 @@ 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; @@ -49,6 +50,13 @@ public class SpecificFragment extends Fragment { @Override 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(); diff --git a/app/src/main/java/name/gumartinm/weather/information/widget/WidgetConfigure.java b/app/src/main/java/name/gumartinm/weather/information/widget/WidgetConfigure.java index ec8898e..a16a5b4 100644 --- a/app/src/main/java/name/gumartinm/weather/information/widget/WidgetConfigure.java +++ b/app/src/main/java/name/gumartinm/weather/information/widget/WidgetConfigure.java @@ -37,6 +37,12 @@ public class WidgetConfigure extends AppCompatActivity { public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); + 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); + // Find the widget id from the intent. final Intent intent = getIntent(); final Bundle extras = intent.getExtras(); -- 2.1.4