| 1 | /* This file is part of Aard Dictionary for Android <http://aarddict.org>. |
| 2 | * |
| 3 | * This program is free software: you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 3 |
| 5 | * as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt> |
| 11 | * for more details. |
| 12 | * |
| 13 | * Copyright (C) 2010 Igor Tkach |
| 14 | */ |
| 15 | |
| 16 | package aarddict.android; |
| 17 | |
| 18 | import aarddict.Metadata; |
| 19 | import aarddict.Volume; |
| 20 | import android.content.Intent; |
| 21 | import android.text.util.Linkify; |
| 22 | import android.view.View; |
| 23 | import android.widget.TabHost; |
| 24 | import android.widget.TextView; |
| 25 | import android.widget.TabHost.TabContentFactory; |
| 26 | |
| 27 | public final class DictionaryInfoActivity extends BaseDictionaryActivity implements TabContentFactory { |
| 28 | |
| 29 | private TabHost tabs; |
| 30 | |
| 31 | @Override |
| 32 | void initUI() { |
| 33 | setContentView(R.layout.dict_info); |
| 34 | tabs = (TabHost)findViewById(android.R.id.tabhost); |
| 35 | tabs.setup(); |
| 36 | setTitle(R.string.titleDictionaryInfoActivity); |
| 37 | } |
| 38 | |
| 39 | @Override |
| 40 | void onDictionaryServiceReady() { |
| 41 | tabs.addTab(tabs.newTabSpec("d").setIndicator(getString(R.string.tabDescription)).setContent(this)); |
| 42 | tabs.addTab(tabs.newTabSpec("c").setIndicator(getString(R.string.tabCopyright)).setContent(this)); |
| 43 | tabs.addTab(tabs.newTabSpec("s").setIndicator(getString(R.string.tabSource)).setContent(this)); |
| 44 | tabs.addTab(tabs.newTabSpec("l").setIndicator(getString(R.string.tabLicense)).setContent(this)); |
| 45 | } |
| 46 | |
| 47 | public View createTabContent(String tag) { |
| 48 | Intent intent = getIntent(); |
| 49 | String volumeId = intent.getStringExtra("volumeId"); |
| 50 | Volume d = dictionaryService.getVolume(volumeId); |
| 51 | setTitle(new StringBuilder(d.getDisplayTitle(false)).append(" ").append(d.metadata.version)); |
| 52 | Metadata m = d.metadata; |
| 53 | TextView textView = new TextView(this); |
| 54 | textView.setAutoLinkMask(Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES); |
| 55 | CharSequence text = ""; |
| 56 | if (tag.equals("d")) { |
| 57 | text = m.description; |
| 58 | } |
| 59 | else |
| 60 | if (tag.equals("c")) { |
| 61 | text = m.copyright; |
| 62 | } |
| 63 | else |
| 64 | if (tag.equals("s")) { |
| 65 | text = m.source; |
| 66 | } |
| 67 | else |
| 68 | if (tag.equals("l")) { |
| 69 | text = m.license; |
| 70 | textView.setHorizontallyScrolling(true); |
| 71 | } |
| 72 | textView.setText(text); |
| 73 | return textView; |
| 74 | } |
| 75 | } |