|
@@ -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;
|