mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 11:35:07 -05:00
new help activity, removing old code
This commit is contained in:
parent
ff4d0c26b9
commit
4f35355e8a
@ -228,11 +228,6 @@
|
||||
android:name=".ui.ImportFromQRCodeActivity"
|
||||
android:configChanges="keyboardHidden|orientation|keyboard"
|
||||
android:label="@string/title_importFromQRCode" />
|
||||
<activity
|
||||
android:name=".ui.AboutActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:label="@string/title_about"
|
||||
android:theme="@style/Theme.Sherlock.Light.Dialog" />
|
||||
<activity
|
||||
android:name=".ui.HelpActivity"
|
||||
android:label="@string/title_help" />
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
android:layout_height="match_parent">
|
||||
</android.support.v4.view.ViewPager>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/help_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:textColor="#000" >
|
||||
</TextView>
|
||||
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
@ -8,7 +8,9 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:isScrollContainer="true"
|
||||
android:orientation="vertical"
|
||||
android:padding="15dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:scrollbars="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
@ -38,10 +40,11 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_version"
|
||||
android:id="@+id/help_about_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@android:style/TextAppearance.Small" />
|
||||
@ -49,48 +52,11 @@
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/help_about_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:autoLink="web"
|
||||
android:text="@string/about_url"
|
||||
android:textAppearance="@android:style/TextAppearance.Small" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/about_description"
|
||||
android:textAppearance="@android:style/TextAppearance.Small" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/about_license"
|
||||
android:textAppearance="@android:style/TextAppearance.Small" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/about_developer"
|
||||
android:textAppearance="@android:style/TextAppearance.Small" />
|
||||
|
||||
<!-- <TextView -->
|
||||
<!-- android:layout_width="wrap_content" -->
|
||||
<!-- android:layout_height="wrap_content" -->
|
||||
<!-- android:layout_marginTop="8dp" -->
|
||||
<!-- android:text="@string/about_icons" -->
|
||||
<!-- android:textAppearance="@android:style/TextAppearance.Small" /> -->
|
||||
|
||||
|
||||
<!-- <TextView -->
|
||||
<!-- android:layout_width="wrap_content" -->
|
||||
<!-- android:layout_height="wrap_content" -->
|
||||
<!-- android:layout_marginTop="8dp" -->
|
||||
<!-- android:text="@string/about_libs" -->
|
||||
<!-- android:textAppearance="@android:style/TextAppearance.Small" /> -->
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 Thialfihar <thi@thialfihar.org>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fillViewport="true"
|
||||
android:padding="5dip">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:textColor="#ffffffff"
|
||||
android:autoLink="all"/>
|
||||
</ScrollView>
|
@ -1,16 +0,0 @@
|
||||
<!-- Maintain structure with headings with h2 tags and content with p tags.
|
||||
This makes it easy to translate the values with transifex!
|
||||
And don't add newlines before or after p tags because of transifex -->
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Beta software</h2>
|
||||
<p>This is beta software. It contains many remaining bugs!</p>
|
||||
<h2>APG+</h2>
|
||||
<p>Android Privacy Guard (APG) is a OpenPGP implementation for Android.
|
||||
<br />APG+ is a fork based on the original APG to introduce more features and a new user interface.</p>
|
||||
<h2>I found a bug in APG+!</h2>
|
||||
<p>Please report it in the <a href="https://github.com/dschuermann/apg/issues">issue tracker of APG+</a>.</p>
|
||||
</body>
|
||||
</html>
|
21
org_apg/res/raw/help_about.html
Normal file
21
org_apg/res/raw/help_about.html
Normal file
@ -0,0 +1,21 @@
|
||||
<!-- Maintain structure with headings with h2 tags and content with p tags.
|
||||
This makes it easy to translate the values with transifex!
|
||||
And don't add newlines before or after p tags because of transifex -->
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<p><a href="https://github.com/dschuermann/apg">https://github.com/dschuermann/apg</a></p>
|
||||
<p>Android Privacy Guard (APG) is a OpenPGP implementation for Android.</p>
|
||||
<p>License: Apache License v2</p>
|
||||
<p>Developer: Thialfihar (Main developer), Senecaso (QRCode, sign key, upload key), Markus Doits (AIDL), Oliver Runge, Dominik Schürmann (Version 2 and up)</p>
|
||||
|
||||
<h2>Libraries</h2>
|
||||
<p>• <a href="http://actionbarsherlock.com/">ActionBarSherlock</a> (Apache License v2)
|
||||
<br/>• <a href="http://code.google.com/p/zxing/">ZXing QRCode Integration</a> (Apache License v2)
|
||||
<br/>• <a href="https://github.com/rtyley/spongycastle">SpongyCastle</a> (MIT X11 License)
|
||||
<br/>• <a href="http://www.tcpdump.org/">Tcpdump/Libpcap</a> (BSD 3-Clause License)
|
||||
<br/>• Icons from <a href="http://rrze-icon-set.berlios.de/">RRZE Icon Set</a> (Creative Commons Attribution Share-Alike licence 3.0)
|
||||
<br/>• Icons from <a href="http://tango.freedesktop.org/">Tango Icon Set</a> (Public Domain)</p>
|
||||
</body>
|
||||
</html>
|
23
org_apg/res/raw/help_changelog.html
Normal file
23
org_apg/res/raw/help_changelog.html
Normal file
@ -0,0 +1,23 @@
|
||||
<!-- Maintain structure with headings with h2 tags and content with p tags.
|
||||
This makes it easy to translate the values with transifex!
|
||||
And don't add newlines before or after p tags because of transifex -->
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<h2>2.0</h2>
|
||||
<p>* Complete redesign
|
||||
<br/>* Integration of different branches:
|
||||
<br/>* Share public keys via qr codes
|
||||
<br/>* Sign keys
|
||||
<br/>* Upload keys to server</p>
|
||||
|
||||
<h2>1.08</h2>
|
||||
<p>* basic key server support
|
||||
<br/>* app2sd (untested, let me know if there are problems)
|
||||
<br/>* more choices for pass phrase cache: 1, 2, 4, 8, hours
|
||||
<br/>* translations: Norwegian (thanks, Sander Danielsen), Chinese (thanks, Zhang Fredrick)
|
||||
<br/>* bugfixes
|
||||
<br/>* optimizations</p>
|
||||
</body>
|
||||
</html>
|
27
org_apg/res/raw/help_start.html
Normal file
27
org_apg/res/raw/help_start.html
Normal file
@ -0,0 +1,27 @@
|
||||
<!-- Maintain structure with headings with h2 tags and content with p tags.
|
||||
This makes it easy to translate the values with transifex!
|
||||
And don't add newlines before or after p tags because of transifex -->
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Beta software</h2>
|
||||
<p>This is beta software. It contains many remaining bugs!</p>
|
||||
|
||||
<h2>APG</h2>
|
||||
<p>Android Privacy Guard (APG) is a OpenPGP implementation for Android.
|
||||
<br />This is a fork based on the original APG to introduce more features and a new user interface.</p>
|
||||
|
||||
<h2>WARNING</h2>
|
||||
<p>Be careful editing your existing keys, as they WILL be stripped of certificates right now.
|
||||
<br/><br/>Also: key cross-certification is NOT supported, so signing with those keys will get a warning when the signature is checked.</p>
|
||||
|
||||
<h2>Getting started</h2>
|
||||
<p>Install K-9 Mail for the best integration, it supports APG for PGP/INLINE and lets you directly encrypt/decrypt emails.
|
||||
<br/>It is recommended that you install OI File Manager to be able to use the browse button for file selection in APG.
|
||||
<br/>First you need some keys. Either import them via the option menus in "Manage Keys" and "My Keys" or create them in "My Keys".<p>
|
||||
|
||||
<h2>I found a bug in APG!</h2>
|
||||
<p>Please report it in the <a href="https://github.com/dschuermann/apg/issues">issue tracker of APG</a>.</p>
|
||||
</body>
|
||||
</html>
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
Copyright (C) 2010 Thialfihar <thi@thialfihar.org>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -315,22 +316,8 @@
|
||||
<string name="slow">slow</string>
|
||||
<string name="very_slow">very slow</string>
|
||||
|
||||
<!-- texts -->
|
||||
<!-- "OI File Manager", "ASTRO", and "K-9 Mail" must not be translated in order for the links to the market to work. -->
|
||||
<string name="text_help">Install K-9 Mail for the best integration, it supports APG for PGP/INLINE and lets you directly encrypt/decrypt emails.
|
||||
\n\nIt is recommended that you install OI File Manager or ASTRO to be able to use the browse button for file selection in APG.
|
||||
\n\nFirst you need some keys. Either import them via the option menus in \"Manage Public Keys\" and \"Manage Secret Keys\" or create them in \"Manage Secret Keys\".
|
||||
\n\nYou can also add a GMail account in the main activity via \"Add Account\", which simplifies decrypting emails received there.
|
||||
\n\nCheck out the option menus in the various activities to find more functions.</string>
|
||||
<!-- APG Fork -->
|
||||
|
||||
<!-- APG Plus -->
|
||||
|
||||
|
||||
<!-- about -->
|
||||
<string name="about_description">Android Privacy Guard (APG) is a OpenPGP implementation for Android.</string>
|
||||
<string name="about_license">License: Apache License 2.0</string>
|
||||
<string name="about_version">Version:</string>
|
||||
<string name="about_developer">Developer: Thialfihar (Main developer), Senecaso (QRCode, sign key, upload key), Markus Doits (AIDL), Oliver Runge, Dominik Schürmann (New user interface)</string>
|
||||
|
||||
<!-- Dashboard -->
|
||||
<string name="dashboard_manage_keys">Manage Keys</string>
|
||||
@ -340,4 +327,10 @@
|
||||
<string name="dashboard_help">Help</string>
|
||||
<string name="dashboard_scan_qrcode">Scan QRCode</string>
|
||||
|
||||
<!-- Help -->
|
||||
<string name="help_tab_start">Start</string>
|
||||
<string name="help_tab_changelog">Changelog</string>
|
||||
<string name="help_tab_about">About</string>
|
||||
<string name="help_about_version">Version:</string>
|
||||
|
||||
</resources>
|
@ -24,7 +24,7 @@ import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Singelton Implementation of a Preference Helper
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class Preferences {
|
||||
private static Preferences mPreferences;
|
||||
@ -135,26 +135,6 @@ public class Preferences {
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public boolean hasSeenChangeLog(String version) {
|
||||
return mSharedPreferences.getBoolean(Constants.pref.HAS_SEEN_CHANGE_LOG + version, false);
|
||||
}
|
||||
|
||||
public void setHasSeenChangeLog(String version, boolean value) {
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(Constants.pref.HAS_SEEN_CHANGE_LOG + version, value);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public boolean hasSeenHelp() {
|
||||
return mSharedPreferences.getBoolean(Constants.pref.HAS_SEEN_HELP, false);
|
||||
}
|
||||
|
||||
public void setHasSeenHelp(boolean value) {
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(Constants.pref.HAS_SEEN_HELP, value);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public String[] getKeyServers() {
|
||||
String rawData = mSharedPreferences.getString(Constants.pref.KEY_SERVERS,
|
||||
Constants.defaults.KEY_SERVERS);
|
||||
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.thialfihar.android.apg.ui;
|
||||
|
||||
import org.thialfihar.android.apg.R;
|
||||
import org.thialfihar.android.apg.Constants;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AboutActivity extends Activity {
|
||||
Activity mActivity;
|
||||
|
||||
/**
|
||||
* Instantiate View for this Activity
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.about_activity);
|
||||
|
||||
mActivity = this;
|
||||
|
||||
TextView versionText = (TextView) findViewById(R.id.about_version);
|
||||
versionText.setText(getString(R.string.about_version) + " " + getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current package version.
|
||||
*
|
||||
* @return The current version.
|
||||
*/
|
||||
private String getVersion() {
|
||||
String result = "";
|
||||
try {
|
||||
PackageManager manager = mActivity.getPackageManager();
|
||||
PackageInfo info = manager.getPackageInfo(mActivity.getPackageName(), 0);
|
||||
|
||||
result = String.format("%s (%s)", info.versionName, info.versionCode);
|
||||
} catch (NameNotFoundException e) {
|
||||
Log.w(Constants.TAG, "Unable to get application version: " + e.getMessage());
|
||||
result = "Unable to get application version.";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -17,63 +17,146 @@
|
||||
package org.thialfihar.android.apg.ui;
|
||||
|
||||
import org.thialfihar.android.apg.R;
|
||||
import org.thialfihar.android.apg.util.Utils;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.SherlockActivity;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class HelpActivity extends SherlockActivity {
|
||||
Activity mActivity;
|
||||
TextView mHelpText;
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.ActionBar.Tab;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
|
||||
public class HelpActivity extends SherlockFragmentActivity {
|
||||
ViewPager mViewPager;
|
||||
TabsAdapter mTabsAdapter;
|
||||
TextView tabCenter;
|
||||
TextView tabText;
|
||||
|
||||
/**
|
||||
* Menu Items
|
||||
*/
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
||||
case android.R.id.home:
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
// app icon in Action Bar clicked; go home
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate View for this Activity
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.help_activity);
|
||||
mViewPager = new ViewPager(this);
|
||||
mViewPager.setId(R.id.pager);
|
||||
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(mViewPager);
|
||||
ActionBar bar = getSupportActionBar();
|
||||
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
||||
bar.setDisplayShowTitleEnabled(true);
|
||||
bar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
mActivity = this;
|
||||
mTabsAdapter = new TabsAdapter(this, mViewPager);
|
||||
|
||||
mHelpText = (TextView) findViewById(R.id.help_text);
|
||||
Bundle startBundle = new Bundle();
|
||||
startBundle.putInt(HelpFragmentHtml.ARG_HTML_FILE, R.raw.help_start);
|
||||
mTabsAdapter.addTab(bar.newTab().setText(getString(R.string.help_tab_start)),
|
||||
HelpFragmentHtml.class, startBundle);
|
||||
|
||||
// load html from html file from /res/raw
|
||||
String helpText = Utils.readContentFromResource(mActivity, R.raw.help);
|
||||
|
||||
// set text from resources with html markup
|
||||
mHelpText.setText(Html.fromHtml(helpText));
|
||||
// make links work
|
||||
mHelpText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
Bundle changelogBundle = new Bundle();
|
||||
changelogBundle.putInt(HelpFragmentHtml.ARG_HTML_FILE, R.raw.help_changelog);
|
||||
mTabsAdapter.addTab(bar.newTab().setText(getString(R.string.help_tab_changelog)),
|
||||
HelpFragmentHtml.class, changelogBundle);
|
||||
|
||||
mTabsAdapter.addTab(bar.newTab().setText(getString(R.string.help_tab_about)),
|
||||
HelpFragmentAbout.class, null);
|
||||
}
|
||||
|
||||
}
|
||||
public static class TabsAdapter extends FragmentPagerAdapter implements ActionBar.TabListener,
|
||||
ViewPager.OnPageChangeListener {
|
||||
private final Context mContext;
|
||||
private final ActionBar mActionBar;
|
||||
private final ViewPager mViewPager;
|
||||
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
||||
|
||||
static final class TabInfo {
|
||||
private final Class<?> clss;
|
||||
private final Bundle args;
|
||||
|
||||
TabInfo(Class<?> _class, Bundle _args) {
|
||||
clss = _class;
|
||||
args = _args;
|
||||
}
|
||||
}
|
||||
|
||||
public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) {
|
||||
super(activity.getSupportFragmentManager());
|
||||
mContext = activity;
|
||||
mActionBar = activity.getSupportActionBar();
|
||||
mViewPager = pager;
|
||||
mViewPager.setAdapter(this);
|
||||
mViewPager.setOnPageChangeListener(this);
|
||||
}
|
||||
|
||||
public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
|
||||
TabInfo info = new TabInfo(clss, args);
|
||||
tab.setTag(info);
|
||||
tab.setTabListener(this);
|
||||
mTabs.add(info);
|
||||
mActionBar.addTab(tab);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mTabs.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
TabInfo info = mTabs.get(position);
|
||||
return Fragment.instantiate(mContext, info.clss.getName(), info.args);
|
||||
}
|
||||
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
}
|
||||
|
||||
public void onPageSelected(int position) {
|
||||
mActionBar.setSelectedNavigationItem(position);
|
||||
}
|
||||
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
}
|
||||
|
||||
public void onTabSelected(Tab tab, FragmentTransaction ft) {
|
||||
Object tag = tab.getTag();
|
||||
for (int i = 0; i < mTabs.size(); i++) {
|
||||
if (mTabs.get(i) == tag) {
|
||||
mViewPager.setCurrentItem(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
|
||||
}
|
||||
|
||||
public void onTabReselected(Tab tab, FragmentTransaction ft) {
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.thialfihar.android.apg.ui;
|
||||
|
||||
import org.thialfihar.android.apg.Constants;
|
||||
import org.thialfihar.android.apg.R;
|
||||
import org.thialfihar.android.apg.util.Utils;
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragment;
|
||||
|
||||
public class HelpFragmentAbout extends SherlockFragment {
|
||||
|
||||
/**
|
||||
* Workaround for Android Bug. See
|
||||
* http://stackoverflow.com/questions/8748064/starting-activity-from
|
||||
* -fragment-causes-nullpointerexception
|
||||
*/
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
setUserVisibleHint(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.help_fragment_about, container, false);
|
||||
|
||||
// load html from html file from /res/raw
|
||||
String aboutText = Utils.readContentFromResource(this.getActivity(), R.raw.help_about);
|
||||
|
||||
TextView versionText = (TextView) view.findViewById(R.id.help_about_version);
|
||||
versionText.setText(getString(R.string.help_about_version) + " " + getVersion());
|
||||
|
||||
TextView aboutTextView = (TextView) view.findViewById(R.id.help_about_text);
|
||||
|
||||
// load html into textview
|
||||
aboutTextView.setText(Html.fromHtml(aboutText));
|
||||
|
||||
// make links work
|
||||
aboutTextView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
// no flickering when clicking textview for Android < 4
|
||||
aboutTextView.setTextColor(getResources().getColor(android.R.color.black));
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current package version.
|
||||
*
|
||||
* @return The current version.
|
||||
*/
|
||||
private String getVersion() {
|
||||
String result = "";
|
||||
try {
|
||||
PackageManager manager = getActivity().getPackageManager();
|
||||
PackageInfo info = manager.getPackageInfo(getActivity().getPackageName(), 0);
|
||||
|
||||
result = String.format("%s (%s)", info.versionName, info.versionCode);
|
||||
} catch (NameNotFoundException e) {
|
||||
Log.w(Constants.TAG, "Unable to get application version: " + e.getMessage());
|
||||
result = "Unable to get application version.";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.thialfihar.android.apg.ui;
|
||||
|
||||
import org.thialfihar.android.apg.util.Utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragment;
|
||||
|
||||
public class HelpFragmentHtml extends SherlockFragment {
|
||||
private Activity mActivity;
|
||||
|
||||
private int htmlFile;
|
||||
|
||||
public static final String ARG_HTML_FILE = "htmlFile";
|
||||
|
||||
/**
|
||||
* Create a new instance of HelpFragmentHtml, providing "htmlFile" as an argument.
|
||||
*/
|
||||
static HelpFragmentHtml newInstance(int htmlFile) {
|
||||
HelpFragmentHtml f = new HelpFragmentHtml();
|
||||
|
||||
// Supply html raw file input as an argument.
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_HTML_FILE, htmlFile);
|
||||
f.setArguments(args);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Workaround for Android Bug. See
|
||||
* http://stackoverflow.com/questions/8748064/starting-activity-from
|
||||
* -fragment-causes-nullpointerexception
|
||||
*/
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
setUserVisibleHint(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
htmlFile = getArguments().getInt(ARG_HTML_FILE);
|
||||
|
||||
// load html from html file from /res/raw
|
||||
String helpText = Utils.readContentFromResource(this.getActivity(), htmlFile);
|
||||
|
||||
mActivity = getActivity();
|
||||
|
||||
ScrollView scroller = new ScrollView(mActivity);
|
||||
TextView text = new TextView(mActivity);
|
||||
|
||||
// padding
|
||||
int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, mActivity
|
||||
.getResources().getDisplayMetrics());
|
||||
text.setPadding(padding, padding, padding, 0);
|
||||
|
||||
scroller.addView(text);
|
||||
|
||||
// load html into textview
|
||||
text.setText(Html.fromHtml(helpText));
|
||||
|
||||
// make links work
|
||||
text.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
// no flickering when clicking textview for Android < 4
|
||||
text.setTextColor(getResources().getColor(android.R.color.black));
|
||||
|
||||
return scroller;
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
* Copyright (C) 2010 Thialfihar <thi@thialfihar.org>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -28,13 +29,9 @@ import com.actionbarsherlock.app.SherlockActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class MainActivity extends SherlockActivity {
|
||||
static {
|
||||
@ -80,94 +77,6 @@ public class MainActivity extends SherlockActivity {
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
||||
actionBar.setHomeButtonEnabled(false);
|
||||
|
||||
// if (!mPreferences.hasSeenHelp()) {
|
||||
// showDialog(Id.dialog.help);
|
||||
// }
|
||||
//
|
||||
// if (Apg.isReleaseVersion(this) && !mPreferences.hasSeenChangeLog(Apg.getVersion(this))) {
|
||||
// showDialog(Id.dialog.change_log);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
switch (id) {
|
||||
|
||||
// case Id.dialog.change_log: {
|
||||
// AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
//
|
||||
// alert.setTitle("Changes " + Apg.getFullVersion(this));
|
||||
// LayoutInflater inflater = (LayoutInflater) this
|
||||
// .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
// View layout = inflater.inflate(R.layout.info, null);
|
||||
// TextView message = (TextView) layout.findViewById(R.id.message);
|
||||
//
|
||||
// message.setText("Changes:\n" + "* \n" + "\n"
|
||||
// + "WARNING: be careful editing your existing keys, as they "
|
||||
// + "WILL be stripped of certificates right now.\n" + "\n"
|
||||
// + "Also: key cross-certification is NOT supported, so signing "
|
||||
// + "with those keys will get a warning when the signature is " + "checked.\n"
|
||||
// + "\n" + "I hope APG continues to be useful to you, please send "
|
||||
// + "bug reports, feature wishes, feedback.");
|
||||
// alert.setView(layout);
|
||||
//
|
||||
// alert.setCancelable(false);
|
||||
// alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
// public void onClick(DialogInterface dialog, int id) {
|
||||
// MainActivity.this.removeDialog(Id.dialog.change_log);
|
||||
// mPreferences.setHasSeenChangeLog(Apg.getVersion(MainActivity.this), true);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// return alert.create();
|
||||
// }
|
||||
|
||||
// case Id.dialog.help: {
|
||||
// AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
//
|
||||
// alert.setTitle(R.string.title_help);
|
||||
//
|
||||
// LayoutInflater inflater = (LayoutInflater) this
|
||||
// .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
// View layout = inflater.inflate(R.layout.info, null);
|
||||
// TextView message = (TextView) layout.findViewById(R.id.message);
|
||||
// message.setText(R.string.text_help);
|
||||
//
|
||||
// TransformFilter packageNames = new TransformFilter() {
|
||||
// public final String transformUrl(final Matcher match, String url) {
|
||||
// String name = match.group(1).toLowerCase();
|
||||
// if (name.equals("astro")) {
|
||||
// return "com.metago.astro";
|
||||
// } else if (name.equals("k-9 mail")) {
|
||||
// return "com.fsck.k9";
|
||||
// } else {
|
||||
// return "org.openintents.filemanager";
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// Pattern pattern = Pattern.compile("(OI File Manager|ASTRO|K-9 Mail)");
|
||||
// String scheme = "market://search?q=pname:";
|
||||
// message.setAutoLinkMask(0);
|
||||
// Linkify.addLinks(message, pattern, scheme, null, packageNames);
|
||||
//
|
||||
// alert.setView(layout);
|
||||
//
|
||||
// alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
// public void onClick(DialogInterface dialog, int id) {
|
||||
// MainActivity.this.removeDialog(Id.dialog.help);
|
||||
// mPreferences.setHasSeenHelp(true);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// return alert.create();
|
||||
// }
|
||||
|
||||
default: {
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -175,40 +84,22 @@ public class MainActivity extends SherlockActivity {
|
||||
menu.add(0, Id.menu.option.preferences, 0, R.string.menu_preferences)
|
||||
.setIcon(R.drawable.ic_menu_settings)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
menu.add(0, Id.menu.option.about, 1, R.string.menu_about).setIcon(R.drawable.ic_menu_about)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case Id.menu.option.about: {
|
||||
startActivity(new Intent(this, AboutActivity.class));
|
||||
return true;
|
||||
}
|
||||
|
||||
case Id.menu.option.preferences: {
|
||||
case Id.menu.option.preferences:
|
||||
startActivity(new Intent(this, PreferencesActivity.class));
|
||||
return true;
|
||||
}
|
||||
|
||||
default: {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
|
||||
TextView nameTextView = (TextView) v.findViewById(R.id.accountName);
|
||||
if (nameTextView != null) {
|
||||
menu.setHeaderTitle(nameTextView.getText());
|
||||
menu.add(0, Id.menu.delete, 0, R.string.menu_deleteAccount);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user