From 070d0a12d12692534cf24f6b84e5910ec8ff0789 Mon Sep 17 00:00:00 2001 From: serso Date: Wed, 28 Jan 2015 21:43:26 +0100 Subject: [PATCH] Action bar is shown in the Settings again --- android-app/src/main/AndroidManifest.xml | 2 +- .../preferences/BasePreferencesActivity.java | 25 +++++++++++++++++++ .../main/res/layout/cpp_activity_settings.xml | 19 ++++++++++++++ android-app/src/main/res/values/theme.xml | 14 +++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 android-app/src/main/res/layout/cpp_activity_settings.xml diff --git a/android-app/src/main/AndroidManifest.xml b/android-app/src/main/AndroidManifest.xml index e5581a6d..886987cb 100644 --- a/android-app/src/main/AndroidManifest.xml +++ b/android-app/src/main/AndroidManifest.xml @@ -46,7 +46,7 @@ - + diff --git a/android-app/src/main/java/org/solovyev/android/calculator/preferences/BasePreferencesActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/preferences/BasePreferencesActivity.java index 10b5e67b..0679bfa3 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/preferences/BasePreferencesActivity.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/preferences/BasePreferencesActivity.java @@ -3,7 +3,11 @@ package org.solovyev.android.calculator.preferences; import android.content.Intent; import android.os.Bundle; import android.preference.PreferenceActivity; +import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; import org.solovyev.android.calculator.ActivityUi; import org.solovyev.android.calculator.AdView; import org.solovyev.android.calculator.App; @@ -20,15 +24,36 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { private final ActivityCheckout checkout = Checkout.forActivity(this, App.getBilling(), App.getProducts()); private Inventory inventory; private AdView adView; + private Toolbar actionBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + actionBar.setTitle(getTitle()); + checkout.start(); inventory = checkout.loadInventory(); } + @Override + public void setContentView(int layout) { + final ViewGroup contentView = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.cpp_activity_settings, new LinearLayout(this), true); + + actionBar = (Toolbar) contentView.findViewById(R.id.action_bar); + actionBar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + + final ViewGroup contentWrapper = (ViewGroup) contentView.findViewById(R.id.content_wrapper); + LayoutInflater.from(this).inflate(layout, contentWrapper, true); + + getWindow().setContentView(contentView); + } + private class InventoryListener implements Inventory.Listener { @Override diff --git a/android-app/src/main/res/layout/cpp_activity_settings.xml b/android-app/src/main/res/layout/cpp_activity_settings.xml new file mode 100644 index 00000000..d92c5661 --- /dev/null +++ b/android-app/src/main/res/layout/cpp_activity_settings.xml @@ -0,0 +1,19 @@ + + + + + + + + \ No newline at end of file diff --git a/android-app/src/main/res/values/theme.xml b/android-app/src/main/res/values/theme.xml index c50fcf30..2f67786e 100644 --- a/android-app/src/main/res/values/theme.xml +++ b/android-app/src/main/res/values/theme.xml @@ -28,4 +28,18 @@ + + + + + \ No newline at end of file