Browse Source

disclaimer now showing on first start; navigation drawer now opens on first start

Alexander Brakowski 10 years ago
parent
commit
a8c8f4cd9b

+ 1 - 0
res/values-de/strings.xml

@@ -72,6 +72,7 @@
     <string name="drawer_profile_manager">Profile</string>
     <string name="drawer_app_info">&#220;ber diese App</string>
     <string name="drawer_statistics">Statistiken</string>
+	<string name="drawer_help">Hilfe videos</string>
 
     <string name="hostage_with_url"><a href="http://www.tk.informatik.tu-darmstadt.de/de/research/secure-smart-infrastructures/hostage">HosTaGe</a></string>
 

+ 33 - 0
res/values-de/strings_disclaimer.xml

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+	<string name="hostage_disclaimer">
+		<![CDATA[
+		<p>
+		The product is protected by Federal Copyright Law. [COMPANY NAME] retains the title to and ownership of the Product. You are licensed to use this Product on the following terms and conditions:
+		</p>
+		<p>
+		<b>LICENSE</b> - The licensee is defined as the individual or company utilizing the Software Product. [COMPANY NAME] hereby grants the licensee a nonexclusive license authorizing the licensee to use the enclosed Product on one computer at a time. The licensee is also permitted to distribute this product to one, and only one web server to host the Program. Please contact [COMPANY NAME] if you require additional licenses. Use of this product by more than one individual or by anyone other than the licensee terminates, without notification, this license and the right to use this product.
+		</p>
+		<p>
+	    <b>YOU MAY NOT:</b> Distribute, rent, sub-license or otherwise make available to others the software or documentation or copies thereof, except as expressly permitted in this License without prior written consent from [COMPANY NAME]. In the case of an authorized transfer, the transferee must agree to be bound by the terms and conditions of this License Agreement.
+		</p>
+		<p>
+	    <b>RESTRICTIONS:</b> - You may use this Product in your business as long as:
+	    <br>The software serial number and user must be registered with [COMPANY NAME] in order to receive support or distribution rights.
+	    <br>You may not remove any proprietary notices, labels, trademarks on the software or documentation.
+	    <br>You may not modify, de-compile, disassemble, reverse engineer or translate the software.
+		</p>
+		<p>
+	    <b>US GOVERNMENT RESTRICTED RIGHTS</b> - Use, duplication or disclosure by the United States Government is subject to restrictions as set forth under DFARS 252.227-7013 or in FARS 52.227-19 Commercial Computer Software - Restricted Rights.
+		</p>
+		<p>
+	    <b>TERM</b> - You may terminate your License and this Agreement at anytime by destroying all copies of the Product and Product Documentation. They will also terminate automatically if you fail to comply with any term or condition in this Agreement.
+		</p>
+		<p>
+	    <b>LIMITED WARRANTY</b> - This software and documentation are sold "as is" without any warranty as to their performance, merchantability or fitness for any particular purpose. The licensee assumes the entire risk as to the quality and performance of the software. [COMPANY NAME] warrants that the diskettes on which the Program is furnished will be free from any defects in materials. Exclusive remedy in the event of a defect is expressly limited to the replacement of diskettes. In no event shall [COMPANY NAME] or anyone else who has been involved in the creation, development, production, or delivery of this software be liable for any direct, incidental or consequential damages, such as, but not limited to, loss of anticipated profits, benefits, use, or data resulting from the use of this software, or arising out of any breach of warranty.
+		</p>
+		]]>
+	</string>
+	<string name="agree">Agree</string>
+	<string name="disagree">Disagree</string>
+</resources>

+ 1 - 0
res/values/strings.xml

@@ -74,6 +74,7 @@
     <string name="drawer_profile_manager">Profiles</string>
     <string name="drawer_app_info">Application info</string>
 	<string name="drawer_statistics">Statistics</string>
+	<string name="drawer_help">Help videos</string>
 
     <string name="button_title_apply">Apply</string>
     <string name="button_title_cancel">Cancel</string>

+ 33 - 0
res/values/strings_disclaimer.xml

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+	<string name="hostage_disclaimer">
+		<![CDATA[
+		<p>
+		The product is protected by Federal Copyright Law. [COMPANY NAME] retains the title to and ownership of the Product. You are licensed to use this Product on the following terms and conditions:
+		</p>
+		<p>
+		<b>LICENSE</b> - The licensee is defined as the individual or company utilizing the Software Product. [COMPANY NAME] hereby grants the licensee a nonexclusive license authorizing the licensee to use the enclosed Product on one computer at a time. The licensee is also permitted to distribute this product to one, and only one web server to host the Program. Please contact [COMPANY NAME] if you require additional licenses. Use of this product by more than one individual or by anyone other than the licensee terminates, without notification, this license and the right to use this product.
+		</p>
+		<p>
+	    <b>YOU MAY NOT:</b> Distribute, rent, sub-license or otherwise make available to others the software or documentation or copies thereof, except as expressly permitted in this License without prior written consent from [COMPANY NAME]. In the case of an authorized transfer, the transferee must agree to be bound by the terms and conditions of this License Agreement.
+		</p>
+		<p>
+	    <b>RESTRICTIONS:</b> - You may use this Product in your business as long as:
+	    <br>The software serial number and user must be registered with [COMPANY NAME] in order to receive support or distribution rights.
+	    <br>You may not remove any proprietary notices, labels, trademarks on the software or documentation.
+	    <br>You may not modify, de-compile, disassemble, reverse engineer or translate the software.
+		</p>
+		<p>
+	    <b>US GOVERNMENT RESTRICTED RIGHTS</b> - Use, duplication or disclosure by the United States Government is subject to restrictions as set forth under DFARS 252.227-7013 or in FARS 52.227-19 Commercial Computer Software - Restricted Rights.
+		</p>
+		<p>
+	    <b>TERM</b> - You may terminate your License and this Agreement at anytime by destroying all copies of the Product and Product Documentation. They will also terminate automatically if you fail to comply with any term or condition in this Agreement.
+		</p>
+		<p>
+	    <b>LIMITED WARRANTY</b> - This software and documentation are sold "as is" without any warranty as to their performance, merchantability or fitness for any particular purpose. The licensee assumes the entire risk as to the quality and performance of the software. [COMPANY NAME] warrants that the diskettes on which the Program is furnished will be free from any defects in materials. Exclusive remedy in the event of a defect is expressly limited to the replacement of diskettes. In no event shall [COMPANY NAME] or anyone else who has been involved in the creation, development, production, or delivery of this software be liable for any direct, incidental or consequential damages, such as, but not limited to, loss of anticipated profits, benefits, use, or data resulting from the use of this software, or arising out of any breach of warranty.
+		</p>
+		]]>
+	</string>
+	<string name="agree">Agree</string>
+	<string name="disagree">Disagree</string>
+</resources>

+ 2 - 2
src/de/tudarmstadt/informatik/hostage/persistence/ProfileManager.java

@@ -569,7 +569,7 @@ public class ProfileManager {
 
 		serverHTTP.mActiveProtocols.put("HTTP", true);
 		serverHTTP.mActiveProtocols.put("HTTPS", true);
-		serverHTTP.mActiveProtocols.put("MYSQL", true);
+		serverHTTP.mActiveProtocols.put("MySQL", true);
 
 		this.addProfile(serverHTTP, false);
 
@@ -611,7 +611,7 @@ public class ProfileManager {
 		linuxMachine.mActiveProtocols.put("TELNET", true);
 		linuxMachine.mActiveProtocols.put("HTTP", true);
 		linuxMachine.mActiveProtocols.put("HTTPS", true);
-		linuxMachine.mActiveProtocols.put("MYSQL", true);
+		linuxMachine.mActiveProtocols.put("MySQL", true);
 
 		this.addProfile(linuxMachine, false);
 

+ 66 - 8
src/de/tudarmstadt/informatik/hostage/ui2/activity/MainActivity.java

@@ -7,23 +7,28 @@ import java.util.List;
 import android.app.ActionBar;
 import android.app.Activity;
 import android.app.ActivityManager;
+import android.app.AlertDialog;
 import android.app.Fragment;
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
+import android.content.SharedPreferences;
 import android.content.pm.ActivityInfo;
 import android.content.res.Configuration;
 import android.content.res.TypedArray;
+import android.net.Uri;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.support.v4.app.ActionBarDrawerToggle;
 import android.support.v4.content.LocalBroadcastManager;
 import android.support.v4.widget.DrawerLayout;
+import android.text.Html;
 import android.util.Log;
 import android.view.Gravity;
 import android.view.KeyEvent;
@@ -121,6 +126,8 @@ public class MainActivity extends Activity {
 
 	private boolean mCloseWarning = false;
 
+	private SharedPreferences mSharedPreferences;
+
 	/**
 	 * Retrieve the singleton latest instance of the activity
 	 * 
@@ -185,6 +192,7 @@ public class MainActivity extends Activity {
 		mDrawerItems.add(new DrawerListItem(R.string.drawer_services, R.drawable.ic_menu_set_as));
 		mDrawerItems.add(new DrawerListItem(R.string.drawer_profile_manager, R.drawable.ic_menu_allfriends));
 		mDrawerItems.add(new DrawerListItem(R.string.drawer_settings, R.drawable.ic_menu_preferences));
+		mDrawerItems.add(new DrawerListItem(R.string.drawer_help, R.drawable.ic_menu_help));
 		mDrawerItems.add(new DrawerListItem(R.string.drawer_app_info, R.drawable.ic_menu_info_details));
 
 		DrawerListAdapter listAdapter = new DrawerListAdapter(this, mDrawerItems);
@@ -197,13 +205,13 @@ public class MainActivity extends Activity {
 		getActionBar().setDisplayShowHomeEnabled(true);
 
 		mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
-		mDrawerLayout, /* DrawerLayout object */
-		R.drawable.ic_navigation_drawer, /*
-										 * nav drawer image to replace 'Up'
-										 * caret
-										 */
-		R.string.drawer_open, /* "open drawer" description for accessibility */
-		R.string.drawer_close /* "close drawer" description for accessibility */
+			mDrawerLayout, /* DrawerLayout object */
+			R.drawable.ic_navigation_drawer, /*
+											 * nav drawer image to replace 'Up'
+											 * caret
+											 */
+			R.string.drawer_open, /* "open drawer" description for accessibility */
+			R.string.drawer_close /* "close drawer" description for accessibility */
 		) {
 			public void onDrawerClosed(View view) {
 				getActionBar().setTitle(mTitle);
@@ -217,16 +225,57 @@ public class MainActivity extends Activity {
 											// onPrepareOptionsMenu()
 			}
 		};
+
 		mDrawerLayout.setDrawerListener(mDrawerToggle);
 
 		startAndBind();
 
+		mSharedPreferences = getSharedPreferences(getString(R.string.shared_preference_path), Hostage.MODE_PRIVATE);
+
+		if(mSharedPreferences.getBoolean("isFirstRun", true)){
+			mDrawerLayout.postDelayed(new Runnable() {
+				@Override
+				public void run() {
+					mDrawerLayout.openDrawer(Gravity.LEFT);
+				}
+			}, 1000);
+
+			onFirstRun();
+		}
+
+
 		if (savedInstanceState == null) {
 			// on first time display view for first nav item
 			displayView(0);
 		}
 	}
 
+	private void onFirstRun(){
+		AlertDialog.Builder builder = new AlertDialog.Builder(this);
+		builder.setMessage(Html.fromHtml(getString(R.string.hostage_disclaimer)))
+				.setCancelable(false)
+				.setPositiveButton(getString(R.string.agree), new DialogInterface.OnClickListener() {
+					public void onClick(DialogInterface dialog, int id) {
+						// and, if the user accept, you can execute something like this:
+						// We need an Editor object to make preference changes.
+						// All objects are from android.context.Context
+						SharedPreferences.Editor editor = mSharedPreferences.edit();
+						editor.putBoolean("isFirstRun", false);
+						// Commit the edits!
+						editor.commit();
+					}
+				})
+				.setNegativeButton(getString(R.string.disagree), new DialogInterface.OnClickListener() {
+					public void onClick(DialogInterface dialog, int id) {
+						getHostageService().stopListeners();
+						stopAndUnbind();
+						finish();
+					}
+				});
+		AlertDialog alert = builder.create();
+		alert.show();
+	}
+
 	private void registerReceiver() {
 		LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, new IntentFilter(getString(R.string.broadcast)));
 	}
@@ -390,6 +439,14 @@ public class MainActivity extends Activity {
 			return;
 		}
 
+		if(menuItemPosition == MainMenuItem.HELP){
+			Intent intent = new Intent(Intent.ACTION_VIEW);
+			intent.setData(Uri.parse("https://www.youtube.com/playlist?list=PLJyUmtMldh3s1XtRfE4YFaQ8ME7xjf7Gx"));
+			startActivity(intent);
+
+			return;
+		}
+
 		Fragment fragment = null;
 
 		try {
@@ -570,7 +627,8 @@ public class MainActivity extends Activity {
 		SERVICES(4, ServicesFragment.class),
 		PROFILE_MANAGER(5, ProfileManagerFragment.class),
 		SETTINGS(6, SettingsFragment.class),
-		APPLICATION_INFO(7, AboutFragment.class);
+		HELP(7, Class.class),
+		APPLICATION_INFO(8, AboutFragment.class);
 
 		private int value;
 		private Class<?> klass;