package com.frozendevs.cache.cleaner.activity;

import android.app.AlertDialog;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.view.MenuItem;
import android.webkit.WebView;

import com.frozendevs.cache.cleaner.R;

public class SettingsActivity extends PreferenceActivity {

    private final static String ACTION_SETTINGS_ABOUT = "com.frozendevs.cache.cleaner.activity.SETTINGS_ABOUT";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        String action = getIntent().getAction();
        if (action != null && action.equals(ACTION_SETTINGS_ABOUT)) {
            addPreferencesFromResource(R.xml.settings_about);

            String versionName;
            try {
                versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
            } catch (Exception e) {
                versionName = getString(R.string.version_number_unknown);
            }
            findPreference("version").setSummary(versionName);

            findPreference("licences").setOnPreferenceClickListener(
                    new Preference.OnPreferenceClickListener() {
                        @Override
                        public boolean onPreferenceClick(Preference preference) {
                            WebView webView = new WebView(getApplicationContext());
                            webView.loadUrl("file:///android_asset/html/licenses.html");

                            AlertDialog dialog = new AlertDialog.Builder(SettingsActivity.this).create();
                            dialog.setTitle(R.string.open_source_licences);
                            dialog.setView(webView);
                            dialog.show();

                            return true;
                        }
                    });
        } else {
            addPreferencesFromResource(R.xml.settings);
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

@@ -73,16 +73,55 @@
 Dialog;%0A
+import android.content.res.TypedArray;%0A
 import a
@@ -241,52 +241,193 @@
 oid.
-view.MenuItem;%0Aimport android.webkit.WebView
+support.v7.widget.Toolbar;%0Aimport android.view.LayoutInflater;%0Aimport android.view.View;%0Aimport android.view.ViewGroup;%0Aimport android.webkit.WebView;%0Aimport android.widget.LinearLayout
 ;%0A%0Ai
@@ -638,16 +638,49 @@
 BOUT%22;%0A%0A
+    private Toolbar mActionBar;%0A%0A
     @Ove
@@ -832,24 +832,25 @@
 etAction();%0A
+%0A
         if (
@@ -2188,158 +2188,852 @@
   %7D%0A
-    %7D%0A%0A    @Override%0A    public boolean onOptionsItemSelected(MenuItem item) %7B%0A        switch (item.getItemId()) %7B%0A            case android.R.id.home:
+%0A        mActionBar.setTitle(getTitle());%0A    %7D%0A%0A    @Override%0A    public void setContentView(int layoutResID) %7B%0A        ViewGroup contentView = (ViewGroup) LayoutInflater.from(this).inflate(layoutResID,%0A                new LinearLayout(this), false);%0A%0A        TypedArray typedArray = getTheme().obtainStyledAttributes(R.style.Theme_Application,%0A                new int%5B%5D%7BR.attr.colorPrimary, R.attr.homeAsUpIndicator%7D);%0A%0A        mActionBar = new Toolbar(this);%0A        mActionBar.setBackgroundResource(typedArray.getResourceId(0,%0A                R.color.primary_material_dark));%0A        mActionBar.setNavigationIcon(typedArray.getResourceId(1,%0A                R.drawable.abc_ic_ab_back_mtrl_am_alpha));%0A        mActionBar.setNavigationOnClickListener(new View.OnClickListener() %7B%0A            @Override%0A            public void onClick(View v) %7B
 %0A   
@@ -3071,33 +3071,62 @@
     
+%7D%0A
     
-return true
+    %7D);%0A%0A        typedArray.recycle()
 ;%0A
+%0A
         
 %7D%0A%0A 
@@ -3113,33 +3113,67 @@
 cle();%0A%0A        
-%7D
+contentView.addView(mActionBar, 0);
 %0A%0A        return
@@ -3170,47 +3170,46 @@
     
-return super.onOptionsItemSelected(item
+getWindow().setContentView(contentView
 );%0A 

Add action bar using android.support.v7.widget.Toolbar