android: Switch to AppCompat/Material theme and use custom Toolbar as AppBar
authorTobias Brunner <tobias@strongswan.org>
Wed, 25 Nov 2015 16:05:56 +0000 (17:05 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 27 Apr 2016 12:24:25 +0000 (14:24 +0200)
Also includes some whitespace/formatting changes due to the switch to
Android Studio.

16 files changed:
src/frontends/android/app/src/main/AndroidManifest.xml
src/frontends/android/app/src/main/java/org/strongswan/android/ui/LogActivity.java
src/frontends/android/app/src/main/java/org/strongswan/android/ui/MainActivity.java
src/frontends/android/app/src/main/java/org/strongswan/android/ui/RemediationInstructionsActivity.java
src/frontends/android/app/src/main/java/org/strongswan/android/ui/TrustedCertificateImportActivity.java
src/frontends/android/app/src/main/java/org/strongswan/android/ui/TrustedCertificateListFragment.java
src/frontends/android/app/src/main/java/org/strongswan/android/ui/TrustedCertificatesActivity.java
src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileDetailActivity.java
src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileSelectActivity.java
src/frontends/android/app/src/main/res/menu/certificates.xml
src/frontends/android/app/src/main/res/menu/log.xml
src/frontends/android/app/src/main/res/menu/main.xml
src/frontends/android/app/src/main/res/menu/profile_edit.xml
src/frontends/android/app/src/main/res/menu/profile_list.xml
src/frontends/android/app/src/main/res/menu/profile_list_context.xml
src/frontends/android/app/src/main/res/values/styles.xml

index 2ab833c..41f1037 100644 (file)
@@ -66,7 +66,7 @@
         <activity
             android:name=".ui.TrustedCertificateImportActivity"
             android:label="@string/import_certificate"
-            android:theme="@android:style/Theme.Holo.Dialog.NoActionBar" >
+            android:theme="@style/Theme.AppCompat.Dialog" >
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.DEFAULT" />
index a5efecc..4ad2ebb 100644 (file)
 
 package org.strongswan.android.ui;
 
-import java.io.File;
-
-import org.strongswan.android.R;
-import org.strongswan.android.data.LogContentProvider;
-import org.strongswan.android.logic.CharonVpnService;
-
-import android.app.Activity;
 import android.content.Intent;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.widget.Toast;
 
-public class LogActivity extends Activity
+import org.strongswan.android.R;
+import org.strongswan.android.data.LogContentProvider;
+import org.strongswan.android.logic.CharonVpnService;
+
+import java.io.File;
+
+public class LogActivity extends AppCompatActivity
 {
        @Override
        public void onCreate(Bundle savedInstanceState)
@@ -37,7 +37,7 @@ public class LogActivity extends Activity
                super.onCreate(savedInstanceState);
                setContentView(R.layout.log_activity);
 
-               getActionBar().setDisplayHomeAsUpEnabled(true);
+               getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
 
        @Override
@@ -74,7 +74,7 @@ public class LogActivity extends Activity
                                }
 
                                Intent intent = new Intent(Intent.ACTION_SEND);
-                               intent.putExtra(Intent.EXTRA_EMAIL, new String[] { MainActivity.CONTACT_EMAIL });
+                               intent.putExtra(Intent.EXTRA_EMAIL, new String[]{MainActivity.CONTACT_EMAIL});
                                intent.putExtra(Intent.EXTRA_SUBJECT, String.format(getString(R.string.log_mail_subject), version));
                                intent.setType("text/plain");
                                intent.putExtra(Intent.EXTRA_STREAM, LogContentProvider.createContentUri());
index e1b3e07..31ce5b9 100644 (file)
 
 package org.strongswan.android.ui;
 
-import org.strongswan.android.R;
-import org.strongswan.android.data.VpnProfile;
-import org.strongswan.android.data.VpnProfileDataSource;
-import org.strongswan.android.data.VpnType.VpnTypeFeature;
-import org.strongswan.android.logic.CharonVpnService;
-import org.strongswan.android.logic.TrustedCertificateManager;
-import org.strongswan.android.logic.VpnStateService;
-import org.strongswan.android.logic.VpnStateService.State;
-import org.strongswan.android.ui.VpnProfileListFragment.OnVpnProfileSelectedListener;
-
-import android.app.ActionBar;
 import android.app.Activity;
-import android.app.AlertDialog;
 import android.app.AlertDialog.Builder;
 import android.app.Dialog;
 import android.app.DialogFragment;
@@ -46,6 +34,8 @@ import android.net.VpnService;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuItem;
@@ -54,12 +44,24 @@ import android.view.Window;
 import android.widget.EditText;
 import android.widget.Toast;
 
-public class MainActivity extends Activity implements OnVpnProfileSelectedListener
+import org.strongswan.android.R;
+import org.strongswan.android.data.VpnProfile;
+import org.strongswan.android.data.VpnProfileDataSource;
+import org.strongswan.android.data.VpnType.VpnTypeFeature;
+import org.strongswan.android.logic.CharonVpnService;
+import org.strongswan.android.logic.TrustedCertificateManager;
+import org.strongswan.android.logic.VpnStateService;
+import org.strongswan.android.logic.VpnStateService.State;
+import org.strongswan.android.ui.VpnProfileListFragment.OnVpnProfileSelectedListener;
+
+public class MainActivity extends AppCompatActivity implements OnVpnProfileSelectedListener
 {
        public static final String CONTACT_EMAIL = "android@strongswan.org";
        public static final String START_PROFILE = "org.strongswan.android.action.START_PROFILE";
        public static final String EXTRA_VPN_PROFILE_ID = "org.strongswan.android.VPN_PROFILE_ID";
-       /** Use "bring your own device" (BYOD) features */
+       /**
+        * Use "bring your own device" (BYOD) features
+        */
        public static final boolean USE_BYOD = true;
        private static final int PREPARE_VPN_SERVICE = 0;
        private static final String PROFILE_NAME = "org.strongswan.android.MainActivity.PROFILE_NAME";
@@ -69,7 +71,8 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
 
        private Bundle mProfileInfo;
        private VpnStateService mService;
-       private final ServiceConnection mServiceConnection = new ServiceConnection() {
+       private final ServiceConnection mServiceConnection = new ServiceConnection()
+       {
                @Override
                public void onServiceDisconnected(ComponentName name)
                {
@@ -91,16 +94,18 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
-               super.onCreate(savedInstanceState);
                requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+               super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
 
+               ActionBar bar = getSupportActionBar();
+               bar.setDisplayShowHomeEnabled(true);
+               bar.setDisplayShowTitleEnabled(false);
+               bar.setIcon(R.drawable.ic_launcher);
+
                this.bindService(new Intent(this, VpnStateService.class),
                                                 mServiceConnection, Service.BIND_AUTO_CREATE);
 
-               ActionBar bar = getActionBar();
-               bar.setDisplayShowTitleEnabled(false);
-
                /* load CA certificates in a background task */
                new LoadCertificatesTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
@@ -157,6 +162,7 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
        /**
         * Prepare the VpnService. If this succeeds the current VPN profile is
         * started.
+        *
         * @param profileInfo a bundle containing the information about the profile to be started
         */
        protected void prepareVpnService(Bundle profileInfo)
@@ -239,6 +245,7 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
 
        /**
         * Start the given VPN profile asking the user for a password if required.
+        *
         * @param profileInfo data about the profile
         */
        private void startVpnProfile(Bundle profileInfo)
@@ -257,6 +264,7 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
        /**
         * Start the VPN profile referred to by the given intent. Displays an error
         * if the profile doesn't exist.
+        *
         * @param intent Intent that caused us to start this
         */
        private void startVpnProfile(Intent intent)
@@ -291,11 +299,13 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
                {
                        setProgressBarIndeterminateVisibility(true);
                }
+
                @Override
                protected TrustedCertificateManager doInBackground(Void... params)
                {
                        return TrustedCertificateManager.getInstance().load();
                }
+
                @Override
                protected void onPostExecute(TrustedCertificateManager result)
                {
@@ -341,11 +351,12 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
                                button = R.string.reconnect;
                        }
 
-                       return new AlertDialog.Builder(getActivity())
+                       return new Builder(getActivity())
                                .setIcon(icon)
                                .setTitle(String.format(getString(title), profileInfo.getString(PROFILE_NAME)))
                                .setMessage(message)
-                               .setPositiveButton(button, new DialogInterface.OnClickListener() {
+                               .setPositiveButton(button, new DialogInterface.OnClickListener()
+                               {
                                        @Override
                                        public void onClick(DialogInterface dialog, int whichButton)
                                        {
@@ -353,7 +364,8 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
                                                activity.startVpnProfile(profileInfo);
                                        }
                                })
-                               .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+                               .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener()
+                               {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which)
                                        {
@@ -379,10 +391,11 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
                        username.setText(profileInfo.getString(VpnProfileDataSource.KEY_USERNAME));
                        final EditText password = (EditText)view.findViewById(R.id.password);
 
-                       Builder adb = new AlertDialog.Builder(getActivity());
+                       Builder adb = new Builder(getActivity());
                        adb.setView(view);
                        adb.setTitle(getString(R.string.login_title));
-                       adb.setPositiveButton(R.string.login_confirm, new DialogInterface.OnClickListener() {
+                       adb.setPositiveButton(R.string.login_confirm, new DialogInterface.OnClickListener()
+                       {
                                @Override
                                public void onClick(DialogInterface dialog, int whichButton)
                                {
@@ -391,7 +404,8 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
                                        activity.prepareVpnService(profileInfo);
                                }
                        });
-                       adb.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+                       adb.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener()
+                       {
                                @Override
                                public void onClick(DialogInterface dialog, int which)
                                {
@@ -424,11 +438,12 @@ public class MainActivity extends Activity implements OnVpnProfileSelectedListen
                {
                        final Bundle arguments = getArguments();
                        final int messageId = arguments.getInt(ERROR_MESSAGE_ID);
-                       return new AlertDialog.Builder(getActivity())
+                       return new Builder(getActivity())
                                .setTitle(R.string.vpn_not_supported_title)
                                .setMessage(messageId)
                                .setCancelable(false)
-                               .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                               .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener()
+                               {
                                        @Override
                                        public void onClick(DialogInterface dialog, int id)
                                        {
index 66d0de2..7e7e870 100644 (file)
 
 package org.strongswan.android.ui;
 
-import java.util.ArrayList;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.view.MenuItem;
 
 import org.strongswan.android.R;
 import org.strongswan.android.logic.imc.RemediationInstruction;
 import org.strongswan.android.ui.RemediationInstructionsFragment.OnRemediationInstructionSelectedListener;
 
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.MenuItem;
+import java.util.ArrayList;
 
-public class RemediationInstructionsActivity extends Activity implements OnRemediationInstructionSelectedListener
+public class RemediationInstructionsActivity extends AppCompatActivity implements OnRemediationInstructionSelectedListener
 {
        @Override
        protected void onCreate(Bundle savedInstanceState)
        {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.remediation_instructions);
-               getActionBar().setDisplayHomeAsUpEnabled(true);
+               getSupportActionBar().setDisplayHomeAsUpEnabled(true);
 
                if (savedInstanceState != null)
                {       /* only update if we're not restoring */
@@ -64,7 +64,7 @@ public class RemediationInstructionsActivity extends Activity implements OnRemed
                                {
                                        finish();
                                }
-                               getActionBar().setTitle(getTitle());
+                               getSupportActionBar().setTitle(getTitle());
                                return true;
                        default:
                                return super.onOptionsItemSelected(item);
@@ -88,7 +88,7 @@ public class RemediationInstructionsActivity extends Activity implements OnRemed
                        frag.setArguments(args);
 
                        getFragmentManager().beginTransaction().replace(R.id.fragment_container, frag).addToBackStack(null).commit();
-                       getActionBar().setTitle(instruction.getTitle());
+                       getSupportActionBar().setTitle(instruction.getTitle());
                }
        }
 }
index 61bd2c9..8e39307 100644 (file)
 
 package org.strongswan.android.ui;
 
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.security.KeyStore;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-
-import org.strongswan.android.R;
-import org.strongswan.android.data.VpnProfileDataSource;
-import org.strongswan.android.logic.TrustedCertificateManager;
-
 import android.annotation.TargetApi;
 import android.app.Activity;
 import android.app.AlertDialog;
@@ -37,19 +26,31 @@ import android.content.Intent;
 import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
 import android.widget.Toast;
 
-public class TrustedCertificateImportActivity extends Activity
+import org.strongswan.android.R;
+import org.strongswan.android.data.VpnProfileDataSource;
+import org.strongswan.android.logic.TrustedCertificateManager;
+
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.security.KeyStore;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+
+public class TrustedCertificateImportActivity extends AppCompatActivity
 {
        private static final int OPEN_DOCUMENT = 0;
        private static final String DIALOG_TAG = "Dialog";
 
        /* same as those listed in the manifest */
        private static final String[] ACCEPTED_MIME_TYPES = {
-                                                                                                                "application/x-x509-ca-cert",
-                                                                                                                "application/x-x509-server-cert",
-                                                                                                                "application/x-pem-file",
-                                                                                                                "application/pkix-cert"
+               "application/x-x509-ca-cert",
+               "application/x-x509-server-cert",
+               "application/x-pem-file",
+               "application/pkix-cert"
        };
 
        @TargetApi(Build.VERSION_CODES.KITKAT)
@@ -97,6 +98,7 @@ public class TrustedCertificateImportActivity extends Activity
 
        /**
         * Import the file pointed to by the given URI as a certificate.
+        *
         * @param uri
         */
        private void importCertificate(Uri uri)
@@ -124,6 +126,7 @@ public class TrustedCertificateImportActivity extends Activity
 
        /**
         * Load the file from the given URI and try to parse it as X.509 certificate.
+        *
         * @param uri
         * @return certificate or null
         */
@@ -151,6 +154,7 @@ public class TrustedCertificateImportActivity extends Activity
 
        /**
         * Try to store the given certificate in the KeyStore.
+        *
         * @param certificate
         * @return whether it was successfully stored
         */
@@ -188,7 +192,8 @@ public class TrustedCertificateImportActivity extends Activity
                                .setIcon(R.drawable.ic_launcher)
                                .setTitle(R.string.import_certificate)
                                .setMessage(certificate.getSubjectDN().toString())
-                               .setPositiveButton(R.string.import_certificate, new DialogInterface.OnClickListener() {
+                               .setPositiveButton(R.string.import_certificate, new DialogInterface.OnClickListener()
+                               {
                                        @Override
                                        public void onClick(DialogInterface dialog, int whichButton)
                                        {
@@ -205,7 +210,8 @@ public class TrustedCertificateImportActivity extends Activity
                                                getActivity().finish();
                                        }
                                })
-                               .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+                               .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener()
+                               {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which)
                                        {
index 8bd39c4..12da596 100644 (file)
 
 package org.strongswan.android.ui;
 
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map.Entry;
-
-import org.strongswan.android.R;
-import org.strongswan.android.logic.TrustedCertificateManager;
-import org.strongswan.android.logic.TrustedCertificateManager.TrustedCertificateSource;
-import org.strongswan.android.security.TrustedCertificateEntry;
-import org.strongswan.android.ui.adapter.TrustedCertificateAdapter;
-
 import android.app.Activity;
-import android.app.ListFragment;
-import android.app.LoaderManager.LoaderCallbacks;
-import android.content.AsyncTaskLoader;
 import android.content.Context;
-import android.content.Loader;
 import android.os.Bundle;
+import android.support.v4.app.ListFragment;
+import android.support.v4.app.LoaderManager;
+import android.support.v4.content.AsyncTaskLoader;
+import android.support.v4.content.Loader;
 import android.text.TextUtils;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -44,7 +31,20 @@ import android.widget.ListView;
 import android.widget.SearchView;
 import android.widget.SearchView.OnQueryTextListener;
 
-public class TrustedCertificateListFragment extends ListFragment implements LoaderCallbacks<List<TrustedCertificateEntry>>, OnQueryTextListener
+import org.strongswan.android.R;
+import org.strongswan.android.logic.TrustedCertificateManager;
+import org.strongswan.android.logic.TrustedCertificateManager.TrustedCertificateSource;
+import org.strongswan.android.security.TrustedCertificateEntry;
+import org.strongswan.android.ui.adapter.TrustedCertificateAdapter;
+
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map.Entry;
+
+public class TrustedCertificateListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<List<TrustedCertificateEntry>>, OnQueryTextListener
 {
        public static final String EXTRA_CERTIFICATE_SOURCE = "certificate_source";
        private OnTrustedCertificateSelectedListener mListener;
@@ -54,7 +54,8 @@ public class TrustedCertificateListFragment extends ListFragment implements Load
        /**
         * The activity containing this fragment should implement this interface
         */
-       public interface OnTrustedCertificateSelectedListener {
+       public interface OnTrustedCertificateSelectedListener
+       {
                public void onTrustedCertificateSelected(TrustedCertificateEntry selected);
        }
 
@@ -186,7 +187,7 @@ public class TrustedCertificateListFragment extends ListFragment implements Load
                public List<TrustedCertificateEntry> loadInBackground()
                {
                        TrustedCertificateManager certman = TrustedCertificateManager.getInstance().load();
-                       Hashtable<String,X509Certificate> certificates = certman.getCACertificates(mSource);
+                       Hashtable<String, X509Certificate> certificates = certman.getCACertificates(mSource);
                        List<TrustedCertificateEntry> selected;
 
                        selected = new ArrayList<TrustedCertificateEntry>();
index 663950c..5f66625 100644 (file)
 
 package org.strongswan.android.ui;
 
-import java.security.KeyStore;
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.view.Menu;
+import android.view.MenuItem;
 
 import org.strongswan.android.R;
 import org.strongswan.android.data.VpnProfileDataSource;
@@ -24,18 +33,9 @@ import org.strongswan.android.logic.TrustedCertificateManager.TrustedCertificate
 import org.strongswan.android.security.TrustedCertificateEntry;
 import org.strongswan.android.ui.CertificateDeleteConfirmationDialog.OnCertificateDeleteListener;
 
-import android.app.ActionBar;
-import android.app.ActionBar.Tab;
-import android.app.Activity;
-import android.app.Fragment;
-import android.app.FragmentTransaction;
-import android.content.Intent;
-import android.os.Build;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
+import java.security.KeyStore;
 
-public class TrustedCertificatesActivity extends Activity implements TrustedCertificateListFragment.OnTrustedCertificateSelectedListener, OnCertificateDeleteListener
+public class TrustedCertificatesActivity extends AppCompatActivity implements TrustedCertificateListFragment.OnTrustedCertificateSelectedListener, OnCertificateDeleteListener
 {
        public static final String SELECT_CERTIFICATE = "org.strongswan.android.action.SELECT_CERTIFICATE";
        private static final String DIALOG_TAG = "Dialog";
@@ -48,29 +48,29 @@ public class TrustedCertificatesActivity extends Activity implements TrustedCert
                super.onCreate(savedInstanceState);
                setContentView(R.layout.trusted_certificates_activity);
 
-               ActionBar actionBar = getActionBar();
+               ActionBar actionBar = getSupportActionBar();
                actionBar.setDisplayHomeAsUpEnabled(true);
                actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
 
                TrustedCertificatesTabListener listener;
                listener = new TrustedCertificatesTabListener(this, "system", TrustedCertificateSource.SYSTEM);
                actionBar.addTab(actionBar
-                       .newTab()
-                       .setText(R.string.system_tab)
-                       .setTag(listener)
-                       .setTabListener(listener));
+                                                        .newTab()
+                                                        .setText(R.string.system_tab)
+                                                        .setTag(listener)
+                                                        .setTabListener(listener));
                listener = new TrustedCertificatesTabListener(this, "user", TrustedCertificateSource.USER);
                actionBar.addTab(actionBar
-                       .newTab()
-                       .setText(R.string.user_tab)
-                       .setTag(listener)
-                       .setTabListener(listener));
+                                                        .newTab()
+                                                        .setText(R.string.user_tab)
+                                                        .setTag(listener)
+                                                        .setTabListener(listener));
                listener = new TrustedCertificatesTabListener(this, "local", TrustedCertificateSource.LOCAL);
                actionBar.addTab(actionBar
-                       .newTab()
-                       .setText(R.string.local_tab)
-                       .setTag(listener)
-                       .setTabListener(listener));
+                                                        .newTab()
+                                                        .setText(R.string.local_tab)
+                                                        .setTag(listener)
+                                                        .setTabListener(listener));
 
                if (savedInstanceState != null)
                {
@@ -83,7 +83,7 @@ public class TrustedCertificatesActivity extends Activity implements TrustedCert
        protected void onSaveInstanceState(Bundle outState)
        {
                super.onSaveInstanceState(outState);
-               outState.putInt("tab", getActionBar().getSelectedNavigationIndex());
+               outState.putInt("tab", getSupportActionBar().getSelectedNavigationIndex());
        }
 
        @Override
@@ -151,7 +151,7 @@ public class TrustedCertificatesActivity extends Activity implements TrustedCert
                else
                {
                        TrustedCertificatesTabListener listener;
-                       listener = (TrustedCertificatesTabListener)getActionBar().getSelectedTab().getTag();
+                       listener = (TrustedCertificatesTabListener)getSupportActionBar().getSelectedTab().getTag();
                        if (listener.mTag == "local")
                        {
                                Bundle args = new Bundle();
@@ -182,9 +182,9 @@ public class TrustedCertificatesActivity extends Activity implements TrustedCert
        private void reloadCertificates()
        {
                TrustedCertificateManager.getInstance().reset();
-               for (int i = 0; i < getActionBar().getTabCount(); i++)
+               for (int i = 0; i < getSupportActionBar().getTabCount(); i++)
                {
-                       Tab tab = getActionBar().getTabAt(i);
+                       ActionBar.Tab tab = getSupportActionBar().getTabAt(i);
                        TrustedCertificatesTabListener listener = (TrustedCertificatesTabListener)tab.getTag();
                        listener.reset();
                }
@@ -196,24 +196,24 @@ public class TrustedCertificatesActivity extends Activity implements TrustedCert
                private final TrustedCertificateSource mSource;
                private Fragment mFragment;
 
-               public TrustedCertificatesTabListener(Activity activity, String tag, TrustedCertificateSource source)
+               public TrustedCertificatesTabListener(AppCompatActivity activity, String tag, TrustedCertificateSource source)
                {
                        mTag = tag;
                        mSource = source;
                        /* check to see if we already have a fragment for this tab, probably
                         * from a previously saved state. if so, deactivate it, because the
                         * initial state is that no tab is shown */
-                       mFragment = activity.getFragmentManager().findFragmentByTag(mTag);
+                       mFragment = activity.getSupportFragmentManager().findFragmentByTag(mTag);
                        if (mFragment != null && !mFragment.isDetached())
                        {
-                               FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
+                               FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction();
                                ft.detach(mFragment);
                                ft.commit();
                        }
                }
 
                @Override
-               public void onTabSelected(Tab tab, FragmentTransaction ft)
+               public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft)
                {
                        if (mFragment == null)
                        {
@@ -230,7 +230,7 @@ public class TrustedCertificatesActivity extends Activity implements TrustedCert
                }
 
                @Override
-               public void onTabUnselected(Tab tab, FragmentTransaction ft)
+               public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft)
                {
                        if (mFragment != null)
                        {
@@ -239,7 +239,7 @@ public class TrustedCertificatesActivity extends Activity implements TrustedCert
                }
 
                @Override
-               public void onTabReselected(Tab tab, FragmentTransaction ft)
+               public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft)
                {
                        /* nothing to be done */
                }
index a8b3daa..24690de 100644 (file)
 
 package org.strongswan.android.ui;
 
-import java.security.cert.X509Certificate;
-
-import org.strongswan.android.R;
-import org.strongswan.android.data.VpnProfile;
-import org.strongswan.android.data.VpnProfileDataSource;
-import org.strongswan.android.data.VpnType;
-import org.strongswan.android.data.VpnType.VpnTypeFeature;
-import org.strongswan.android.logic.TrustedCertificateManager;
-import org.strongswan.android.security.TrustedCertificateEntry;
-
-import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.DialogFragment;
@@ -39,6 +28,7 @@ import android.os.Bundle;
 import android.security.KeyChain;
 import android.security.KeyChainAliasCallback;
 import android.security.KeyChainException;
+import android.support.v7.app.AppCompatActivity;
 import android.text.Html;
 import android.util.Log;
 import android.view.Menu;
@@ -57,7 +47,17 @@ import android.widget.RelativeLayout;
 import android.widget.Spinner;
 import android.widget.TextView;
 
-public class VpnProfileDetailActivity extends Activity
+import org.strongswan.android.R;
+import org.strongswan.android.data.VpnProfile;
+import org.strongswan.android.data.VpnProfileDataSource;
+import org.strongswan.android.data.VpnType;
+import org.strongswan.android.data.VpnType.VpnTypeFeature;
+import org.strongswan.android.logic.TrustedCertificateManager;
+import org.strongswan.android.security.TrustedCertificateEntry;
+
+import java.security.cert.X509Certificate;
+
+public class VpnProfileDetailActivity extends AppCompatActivity
 {
        private static final int SELECT_TRUSTED_CERTIFICATE = 0;
        private static final int MTU_MIN = 1280;
@@ -94,7 +94,7 @@ public class VpnProfileDetailActivity extends Activity
                super.onCreate(savedInstanceState);
 
                /* the title is set when we load the profile, if any */
-               getActionBar().setDisplayHomeAsUpEnabled(true);
+               getSupportActionBar().setDisplayHomeAsUpEnabled(true);
 
                mDataSource = new VpnProfileDataSource(this);
                mDataSource.open();
@@ -465,7 +465,7 @@ public class VpnProfileDetailActivity extends Activity
        {
                String useralias = null, alias = null;
 
-               getActionBar().setTitle(R.string.add_profile);
+               getSupportActionBar().setTitle(R.string.add_profile);
                if (mId != null && mId != 0)
                {
                        mProfile = mDataSource.getVpnProfile(mId);
@@ -482,7 +482,7 @@ public class VpnProfileDetailActivity extends Activity
                                mBlockIPv6.setChecked(mProfile.getSplitTunneling() != null ? (mProfile.getSplitTunneling() & VpnProfile.SPLIT_TUNNELING_BLOCK_IPV6) != 0 : false);
                                useralias = mProfile.getUserCertificateAlias();
                                alias = mProfile.getCertificateAlias();
-                               getActionBar().setTitle(mProfile.getName());
+                               getSupportActionBar().setTitle(mProfile.getName());
                        }
                        else
                        {
index b4d34f5..23b66d3 100644 (file)
 
 package org.strongswan.android.ui;
 
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+
 import org.strongswan.android.R;
 import org.strongswan.android.data.VpnProfile;
 import org.strongswan.android.ui.VpnProfileListFragment.OnVpnProfileSelectedListener;
 
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-
-public class VpnProfileSelectActivity extends Activity implements OnVpnProfileSelectedListener
+public class VpnProfileSelectActivity extends AppCompatActivity implements OnVpnProfileSelectedListener
 {
        @Override
        protected void onCreate(Bundle savedInstanceState)
index 6066cab..8ce4f62 100644 (file)
     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     for more details.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <item
         android:id="@+id/menu_import_certificate"
         android:title="@string/import_certificate"
-        android:showAsAction="withText" />
+        app:showAsAction="withText" />
 
     <item
         android:id="@+id/menu_reload_certs"
         android:title="@string/reload_trusted_certs"
-        android:showAsAction="withText" />
+        app:showAsAction="withText" />
 
 </menu>
index 1af5bd3..cb4c84a 100644 (file)
     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     for more details.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <item
         android:id="@+id/menu_send_log"
         android:title="@string/send_log"
-        android:showAsAction="ifRoom|withText" />
+        app:showAsAction="ifRoom|withText" />
 
 </menu>
index 3dde522..599254a 100644 (file)
     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     for more details.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <item
         android:id="@+id/menu_manage_certs"
         android:title="@string/trusted_certs_title"
-        android:showAsAction="withText" />
+        app:showAsAction="withText" />
 
     <item
         android:id="@+id/menu_show_log"
         android:title="@string/show_log"
-        android:showAsAction="withText" />
+        app:showAsAction="withText" />
 
-</menu>
\ No newline at end of file
+</menu>
index e69020e..280f34d 100644 (file)
     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     for more details.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <item
         android:id="@+id/menu_accept"
         android:title="@string/profile_edit_save"
-        android:showAsAction="always|withText" />
+        app:showAsAction="always|withText" />
 
     <item
         android:id="@+id/menu_cancel"
         android:title="@string/profile_edit_cancel"
-        android:showAsAction="ifRoom" />
+        app:showAsAction="ifRoom" />
 
 </menu>
index 57c9a86..8f8838f 100644 (file)
     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     for more details.
 -->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <item android:id="@+id/add_profile"
         android:title="@string/add_profile"
-        android:showAsAction="always|withText" />
+        app:showAsAction="always|withText" />
 
 </menu>
index e674ae8..1d6a3dc 100644 (file)
@@ -16,9 +16,9 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android" >
 
     <item android:id="@+id/edit_profile"
-        android:title="@string/edit_profile" ></item>
+        android:title="@string/edit_profile" />
 
     <item android:id="@+id/delete_profile"
-        android:title="@string/delete_profile" ></item>
+        android:title="@string/delete_profile" />
 
-</menu>
\ No newline at end of file
+</menu>
index 739ba70..8ae09ff 100644 (file)
@@ -15,7 +15,7 @@
 -->
 <resources xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <style name="ApplicationTheme" parent="@android:style/Theme.Holo">
+    <style name="ApplicationTheme" parent="Theme.AppCompat">
     </style>
 
 </resources>