OSDN Git Service

Automatic translation import
[android-x86/packages-apps-Eleven.git] / src / com / andrew / apollo / ui / activities / ThemesActivity.java
1 /*
2  * Copyright (C) 2012 Andrew Neal Licensed under the Apache License, Version 2.0
3  * (the "License"); you may not use this file except in compliance with the
4  * License. You may obtain a copy of the License at
5  * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
6  * or agreed to in writing, software distributed under the License is
7  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8  * KIND, either express or implied. See the License for the specific language
9  * governing permissions and limitations under the License.
10  */
11
12 package com.andrew.apollo.ui.activities;
13
14 import android.app.ActionBar;
15 import android.os.Bundle;
16 import android.view.Menu;
17 import android.view.MenuItem;
18
19 import com.andrew.apollo.R;
20 import com.andrew.apollo.ui.fragments.ThemeFragment;
21
22 /**
23  * A class the displays the {@link ThemeFragment}.
24  * 
25  * @author Andrew Neal (andrewdneal@gmail.com)
26  */
27 public class ThemesActivity extends BaseActivity {
28
29     /**
30      * {@inheritDoc}
31      */
32     @Override
33     protected void onCreate(final Bundle savedInstanceState) {
34         super.onCreate(savedInstanceState);
35
36         // Set up the action bar
37         final ActionBar actionBar = getActionBar();
38         actionBar.setDisplayHomeAsUpEnabled(true);
39         actionBar.setTitle(getString(R.string.settings_theme_chooser_title));
40
41         // Transact the theme fragment
42         if (savedInstanceState == null) {
43             getSupportFragmentManager().beginTransaction()
44                     .replace(R.id.activity_base_content, new ThemeFragment()).commit();
45         }
46     }
47
48     /**
49      * {@inheritDoc}
50      */
51     @Override
52     public boolean onPrepareOptionsMenu(final Menu menu) {
53         mResources.setShopIcon(menu);
54         return super.onPrepareOptionsMenu(menu);
55     }
56
57     /**
58      * {@inheritDoc}
59      */
60     @Override
61     public boolean onCreateOptionsMenu(final Menu menu) {
62         getMenuInflater().inflate(R.menu.theme_shop, menu);
63         return super.onCreateOptionsMenu(menu);
64     }
65
66     /**
67      * {@inheritDoc}
68      */
69     @Override
70     public boolean onOptionsItemSelected(final MenuItem item) {
71         switch (item.getItemId()) {
72             case android.R.id.home:
73                 finish();
74                 return true;
75             case R.id.menu_shop:
76                 mResources.shopFor(this);
77                 return true;
78             default:
79                 break;
80         }
81         return super.onOptionsItemSelected(item);
82     }
83
84     /**
85      * {@inheritDoc}
86      */
87     @Override
88     public int setContentView() {
89         return R.layout.activity_base;
90     }
91 }