Action bar is shown in the Settings again
This commit is contained in:
parent
3be5a66012
commit
070d0a12d1
@ -46,7 +46,7 @@
|
|||||||
<activity android:clearTaskOnLaunch="true" android:label="@string/c_app_name" android:launchMode="singleTop" android:name=".CalculatorActivityMobile" android:windowSoftInputMode="adjustPan"/>
|
<activity android:clearTaskOnLaunch="true" android:label="@string/c_app_name" android:launchMode="singleTop" android:name=".CalculatorActivityMobile" android:windowSoftInputMode="adjustPan"/>
|
||||||
|
|
||||||
<!-- settings must use action bar icon-->
|
<!-- settings must use action bar icon-->
|
||||||
<activity android:icon="@drawable/ab_icon" android:label="@string/c_app_settings" android:name=".preferences.PreferencesActivity"/>
|
<activity android:icon="@drawable/ab_icon" android:label="@string/c_app_settings" android:name=".preferences.PreferencesActivity" android:theme="@style/Theme.Settings"/>
|
||||||
|
|
||||||
<activity android:label="@string/c_history" android:name=".history.CalculatorHistoryActivity"/>
|
<activity android:label="@string/c_history" android:name=".history.CalculatorHistoryActivity"/>
|
||||||
|
|
||||||
|
@ -3,7 +3,11 @@ package org.solovyev.android.calculator.preferences;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.LayoutInflater;
|
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.ActivityUi;
|
||||||
import org.solovyev.android.calculator.AdView;
|
import org.solovyev.android.calculator.AdView;
|
||||||
import org.solovyev.android.calculator.App;
|
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 final ActivityCheckout checkout = Checkout.forActivity(this, App.getBilling(), App.getProducts());
|
||||||
private Inventory inventory;
|
private Inventory inventory;
|
||||||
private AdView adView;
|
private AdView adView;
|
||||||
|
private Toolbar actionBar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
actionBar.setTitle(getTitle());
|
||||||
|
|
||||||
checkout.start();
|
checkout.start();
|
||||||
inventory = checkout.loadInventory();
|
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 {
|
private class InventoryListener implements Inventory.Listener {
|
||||||
@Override
|
@Override
|
||||||
|
19
android-app/src/main/res/layout/cpp_activity_settings.xml
Normal file
19
android-app/src/main/res/layout/cpp_activity_settings.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/action_bar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?attr/actionBarSize" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/content_wrapper"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -28,4 +28,18 @@
|
|||||||
<style name="Theme.Base" parent="@style/Theme.AppCompat"></style>
|
<style name="Theme.Base" parent="@style/Theme.AppCompat"></style>
|
||||||
<style name="Theme.Base.Dialog" parent="@style/Theme.AppCompat.Dialog"></style>
|
<style name="Theme.Base.Dialog" parent="@style/Theme.AppCompat.Dialog"></style>
|
||||||
|
|
||||||
|
<style name="Theme.Settings" parent="@style/cpp_metro_blue_theme">
|
||||||
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
<item name="android:windowActionBar">false</item>
|
||||||
|
|
||||||
|
<item name="toolbarStyle">@style/Widget.Toolbar</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="Widget.Toolbar" parent="@style/Widget.AppCompat.Toolbar">
|
||||||
|
<item name="android:background">?attr/colorPrimary</item>
|
||||||
|
<item name="android:navigationIcon">?attr/homeAsUpIndicator</item>
|
||||||
|
<item name="navigationIcon">?attr/homeAsUpIndicator</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user