From: Gustavo Martin Morcuende Date: Wed, 31 Aug 2016 22:52:11 +0000 (+0200) Subject: Using ActionBar with AppCompat X-Git-Tag: weatherinformation-1.3~7 X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=437261c4ea5025f08e18b8bcd4ab621ff38280c6;p=AndroidWeatherInformation Using ActionBar with AppCompat --- 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();