// Path: src/main/java/org/ligi/axt/extensions/misc/CommonIntentStarter.java
// public class CommonIntentStarter {
// 
//     public final Context context;
//     // defaults to true as a common pitfall is to forget FLAG_ACTIVITY_NEW_TASK when needed
//     private boolean asNewTask = true;
// 
//     public CommonIntentStarter(final Context context) {
//         this.context = context;
//     }
// 
//     public void openUrl(final String urlString) {
//         final Intent intent = new Intent(Intent.ACTION_VIEW);
//         intent.setData(Uri.parse(urlString));
//         start(intent);
//     }
// 
//     public void shareUrl(final String urlString) {
//         final Intent intent = new Intent(Intent.ACTION_SEND);
//         intent.putExtra(Intent.EXTRA_TEXT, urlString);
//         intent.setType("text/plain");
//         startChooser(intent);
//     }
// 
//     public void activityFromClass(Class class2start) {
//         final Intent intent = new Intent(context, class2start);
//         start(intent);
//     }
// 
//     public CommonIntentStarter noNewTask() {
//         asNewTask = false;
//         return this;
//     }
// 
//     private void startChooser(final Intent intent) {
//         final Intent chooserIntent = Intent.createChooser(intent, null);
//         start(chooserIntent);
//     }
// 
//     private void start(Intent intent) {
//         if (asNewTask) {
//             intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//         }
//         context.startActivity(intent);
//     }
// }


import android.content.Context;
import android.view.ViewConfiguration;
import java.lang.reflect.Field;
import org.ligi.axt.extensions.misc.CommonIntentStarter;
package org.ligi.axt.extensions;


public class ContextAXT {

    private final Context context;

    public ContextAXT(Context context) {
        this.context = context;
    }

    /**
     * a little hack because I strongly disagree with the style guide here
     * ;-)
     * not having the Actionbar overfow menu also with devices with hardware
     * key really helps discoverability
     * http://stackoverflow.com/questions/9286822/how-to-force-use-of-overflow-menu-on-devices-with-menu-button
     */
    public void forceOverFlowMenuEvenThoughDeviceHasPhysical() {

        try {
            ViewConfiguration config = ViewConfiguration.get(context);
            Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
            if (menuKeyField != null) {
                menuKeyField.setAccessible(true);
                menuKeyField.setBoolean(config, false);
            }
        } catch (Exception ex) {
            // Ignore - but at least we tried ;-)
        }
    }

// Path: src/main/java/org/ligi/axt/extensions/misc/CommonIntentStarter.java
// public class CommonIntentStarter {
// 
//     public final Context context;
//     // defaults to true as a common pitfall is to forget FLAG_ACTIVITY_NEW_TASK when needed
//     private boolean asNewTask = true;
// 
//     public CommonIntentStarter(final Context context) {
//         this.context = context;
//     }
// 
//     public void openUrl(final String urlString) {
//         final Intent intent = new Intent(Intent.ACTION_VIEW);
//         intent.setData(Uri.parse(urlString));
//         start(intent);
//     }
// 
//     public void shareUrl(final String urlString) {
//         final Intent intent = new Intent(Intent.ACTION_SEND);
//         intent.putExtra(Intent.EXTRA_TEXT, urlString);
//         intent.setType("text/plain");
//         startChooser(intent);
//     }
// 
//     public void activityFromClass(Class class2start) {
//         final Intent intent = new Intent(context, class2start);
//         start(intent);
//     }
// 
//     public CommonIntentStarter noNewTask() {
//         asNewTask = false;
//         return this;
//     }
// 
//     private void startChooser(final Intent intent) {
//         final Intent chooserIntent = Intent.createChooser(intent, null);
//         start(chooserIntent);
//     }
// 
//     private void start(Intent intent) {
//         if (asNewTask) {
//             intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//         }
//         context.startActivity(intent);
//     }
// }


// Path: src/main/java/org/ligi/axt/extensions/ContextAXT.java
import android.content.Context;
import android.view.ViewConfiguration;
import java.lang.reflect.Field;
import org.ligi.axt.extensions.misc.CommonIntentStarter;

package org.ligi.axt.extensions;


public class ContextAXT {

    private final Context context;

    public ContextAXT(Context context) {
        this.context = context;
    }

    /**
     * a little hack because I strongly disagree with the style guide here
     * ;-)
     * not having the Actionbar overfow menu also with devices with hardware
     * key really helps discoverability
     * http://stackoverflow.com/questions/9286822/how-to-force-use-of-overflow-menu-on-devices-with-menu-button
     */
    public void forceOverFlowMenuEvenThoughDeviceHasPhysical() {

        try {
            ViewConfiguration config = ViewConfiguration.get(context);
            Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
            if (menuKeyField != null) {
                menuKeyField.setAccessible(true);
                menuKeyField.setBoolean(config, false);
            }
        } catch (Exception ex) {
            // Ignore - but at least we tried ;-)
        }
    }

    public CommonIntentStarter startCommonIntent() {