Search in sources :

Example 1 with ExtendedLayout

use of com.spazedog.mounts2sd.tools.ExtendedLayout in project mounts2sd by SpazeDog.

the class ActivityAppSettings method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    mPreferences = Preferences.getInstance((Context) this);
    setTheme(mPreferences.theme());
    super.onCreate(savedInstanceState);
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ExtendedLayout layoutOuter = (ExtendedLayout) inflater.inflate(R.layout.activity_app_settings, null);
    if (mPreferences.applicationSettings.use_tablet_settings() || getResources().getString(R.string.config_screen_type).equals("xlarge")) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setBackgroundDrawable(new ColorDrawable(0));
        layoutOuter.setOnMeasure(this);
        setContentView(layoutOuter, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    } else {
        ViewGroup layout = (ViewGroup) ((ViewGroup) layoutOuter.getChildAt(0)).getChildAt(0);
        ((ViewGroup) layoutOuter.getChildAt(0)).removeView(layout);
        setContentView(layout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    }
    mCheckboxTheme = (LinearLayout) findViewById(R.id.settings_style_item_theme);
    mCheckboxTheme.setOnTouchListener(new ViewEventHandler(this));
    mCheckboxLayout = (LinearLayout) findViewById(R.id.settings_style_item_layout);
    mCheckboxLayout.setOnTouchListener(new ViewEventHandler(this));
    mCheckboxDialog = (LinearLayout) findViewById(R.id.settings_style_item_dialog);
    if (getResources().getString(R.string.config_screen_type).equals("normal")) {
        mCheckboxDialog.setOnTouchListener(new ViewEventHandler(this));
    } else {
        Utils.removeView(mCheckboxDialog, false);
    }
    mCheckboxBusybox = (LinearLayout) findViewById(R.id.settings_general_item_busybox);
    if (mPreferences.deviceSetup.environment_multiple_binaries() && mPreferences.isUserOwner()) {
        mCheckboxBusybox.setOnTouchListener(new ViewEventHandler(this));
    } else {
        mCheckboxBusybox.setEnabled(false);
    }
    mTextScriptButton = (TextView) findViewById(R.id.settings_script_item_button);
    if (mPreferences.isUserOwner()) {
        mTextScriptButton.setOnTouchListener(new ViewEventHandler(this));
    } else {
        mTextScriptButton.setEnabled(false);
    }
    mViewSqlite = (LinearLayout) findViewById(R.id.settings_general_item_sqlite);
    if (mPreferences.isUserOwner()) {
        mViewSqlite.setOnTouchListener(new ViewEventHandler(this));
    } else {
        mViewSqlite.setEnabled(false);
    }
    mTextScriptInstalled = (TextView) findViewById(R.id.settings_script_item_installed);
    mTextScriptBundled = (TextView) findViewById(R.id.settings_script_item_bundled);
    handleViewContent();
}
Also used : Context(android.content.Context) ColorDrawable(android.graphics.drawable.ColorDrawable) ViewEventHandler(com.spazedog.mounts2sd.tools.ViewEventHandler) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) ExtendedLayout(com.spazedog.mounts2sd.tools.ExtendedLayout) LinearLayout(android.widget.LinearLayout)

Example 2 with ExtendedLayout

use of com.spazedog.mounts2sd.tools.ExtendedLayout in project mounts2sd by SpazeDog.

the class FragmentDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    mArguments = getArguments();
    if (savedInstanceState != null) {
        mExtra = savedInstanceState.getBundle("extra");
    } else {
        mExtra = mArguments.getBundle("extra");
        if (mExtra == null) {
            mExtra = new Bundle();
        }
    }
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Dialog dialog = (Dialog) new Dialog(getActivity(), Preferences.getInstance(getActivity()).theme());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
    dialog.setCanceledOnTouchOutside(false);
    ExtendedLayout layout = null;
    if (mArguments.getString("type").equals("message")) {
        layout = (ExtendedLayout) inflater.inflate(R.layout.dialog_message, null);
        layout.findViewById(R.id.dialog_close_button).setOnTouchListener(new ViewEventHandler(this));
    } else {
        layout = (ExtendedLayout) inflater.inflate(R.layout.dialog_confirm, null);
        layout.findViewById(R.id.dialog_cancel_button).setOnTouchListener(new ViewEventHandler(this));
        layout.findViewById(R.id.dialog_okay_button).setOnTouchListener(new ViewEventHandler(this));
    }
    ((TextView) layout.findViewById(R.id.dialog_title)).setText(mArguments.getString("title"));
    if (mArguments.getBoolean("custom")) {
        ViewGroup scroller = (ViewGroup) layout.findViewById(R.id.dialog_textbox).getParent();
        scroller.removeView(layout.findViewById(R.id.dialog_textbox));
        scroller.addView(((IDialogCustomLayout) mListener).onDialogCreateView(mArguments.getString("tag"), inflater, scroller, mExtra));
    } else {
        ((TextView) layout.findViewById(R.id.dialog_textbox)).setText(mArguments.getString("message"));
    }
    layout.setOnMeasure(this);
    dialog.addContentView(layout, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    return dialog;
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ViewEventHandler(com.spazedog.mounts2sd.tools.ViewEventHandler) Bundle(android.os.Bundle) Dialog(android.app.Dialog) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) ExtendedLayout(com.spazedog.mounts2sd.tools.ExtendedLayout) TextView(android.widget.TextView)

Example 3 with ExtendedLayout

use of com.spazedog.mounts2sd.tools.ExtendedLayout in project mounts2sd by SpazeDog.

the class FragmentDialog method spec.

@Override
public void spec(View view, Integer height, Integer width) {
    ((ExtendedLayout) view).removeOnMeasure();
    float density = getResources().getDisplayMetrics().density;
    // 14 * 2
    Integer newWidthMargin = Math.round((float) 28 * density);
    // 25 * 2
    Integer newHeightMargin = Math.round((float) 28 * density);
    Integer newWidth = Math.round((float) 600 * density);
    Integer newHeight = height - newHeightMargin;
    if (width < newWidth) {
        newWidth = width - newWidthMargin;
    } else {
        newWidth -= newWidthMargin;
    }
    if (getResources().getString(R.string.config_screen_type).equals("xlarge")) {
        Integer testHeight = width * 2;
        if (height > width && testHeight < height) {
            newHeight = testHeight;
            if ((height - testHeight) < newHeightMargin) {
                newHeight -= (newHeightMargin - (height - testHeight));
            }
        }
    }
    ExtendedLayout layout = (ExtendedLayout) ((ViewGroup) view).getChildAt(0);
    layout.setLayoutParams(new LinearLayout.LayoutParams(newWidth, LinearLayout.LayoutParams.WRAP_CONTENT));
    layout.setMaxHeight(newHeight);
}
Also used : ExtendedLayout(com.spazedog.mounts2sd.tools.ExtendedLayout) LinearLayout(android.widget.LinearLayout)

Aggregations

ExtendedLayout (com.spazedog.mounts2sd.tools.ExtendedLayout)3 ColorDrawable (android.graphics.drawable.ColorDrawable)2 LayoutInflater (android.view.LayoutInflater)2 ViewGroup (android.view.ViewGroup)2 LinearLayout (android.widget.LinearLayout)2 ViewEventHandler (com.spazedog.mounts2sd.tools.ViewEventHandler)2 Dialog (android.app.Dialog)1 Context (android.content.Context)1 Bundle (android.os.Bundle)1 FrameLayout (android.widget.FrameLayout)1 TextView (android.widget.TextView)1