2 * Copyright (C) 2013 by Raphael Michel under the MIT license:
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the Software
9 * is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
22 package de.geeksfactory.opacclient.frontend;
24 import org.holoeverywhere.preference.Preference;
25 import org.holoeverywhere.preference.Preference.OnPreferenceClickListener;
26 import org.holoeverywhere.preference.PreferenceCategory;
28 import android.content.Intent;
29 import android.os.Build;
30 import android.os.Bundle;
31 import android.view.MenuItem;
32 import de.geeksfactory.opacclient.OpacClient;
33 import jp.sourceforge.worldopac.R;
34 import de.geeksfactory.opacclient.reminder.ReminderCheckService;
35 import de.geeksfactory.opacclient.storage.AccountDataSource;
36 import de.geeksfactory.opacclient.storage.MetaDataSource;
37 import de.geeksfactory.opacclient.storage.SQLMetaDataSource;
39 public class MainPreferenceActivity extends OpacPreferenceActivity {
41 protected boolean ebooksSupported() {
46 @SuppressWarnings("deprecation")
47 public void onCreate(Bundle savedInstanceState) {
48 super.onCreate(savedInstanceState);
50 getSupportActionBar().setDisplayHomeAsUpEnabled(true);
52 addPreferencesFromResource(R.xml.settings);
54 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH
55 || !getPackageManager()
56 .hasSystemFeature("android.hardware.nfc")) {
57 findPreference("nfc_search").setEnabled(false);
60 Preference assistant = findPreference("accounts");
61 assistant.setOnPreferenceClickListener(new OnPreferenceClickListener() {
63 public boolean onPreferenceClick(Preference arg0) {
64 ((OpacClient) getApplication())
65 .openAccountList(MainPreferenceActivity.this);
70 if (!ebooksSupported()) {
71 ((PreferenceCategory) findPreference("cat_web_opac"))
72 .removePreference(findPreference("email"));
75 Preference meta = findPreference("meta_clear");
76 meta.setOnPreferenceClickListener(new OnPreferenceClickListener() {
78 public boolean onPreferenceClick(Preference arg0) {
79 MetaDataSource data = new SQLMetaDataSource(
80 MainPreferenceActivity.this);
83 } catch (Exception e) {
84 throw new RuntimeException(e);
88 AccountDataSource adata = new AccountDataSource(
89 MainPreferenceActivity.this);
91 adata.invalidateCachedData();
92 adata.notificationClearCache(true);
94 Intent i = new Intent(MainPreferenceActivity.this,
95 ReminderCheckService.class);
103 public boolean onOptionsItemSelected(MenuItem item) {
104 switch (item.getItemId()) {
106 return super.onOptionsItemSelected(item);