Example usage for android.content.res Configuration ORIENTATION_LANDSCAPE

List of usage examples for android.content.res Configuration ORIENTATION_LANDSCAPE

Introduction

In this page you can find the example usage for android.content.res Configuration ORIENTATION_LANDSCAPE.

Prototype

int ORIENTATION_LANDSCAPE

To view the source code for android.content.res Configuration ORIENTATION_LANDSCAPE.

Click Source Link

Document

Constant for #orientation , value corresponding to the land resource qualifier.

Usage

From source file:com.farmerbb.notepad.fragment.NoteEditFragment.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override/*from w  w  w .j ava2s  .c  o  m*/
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // Set values
    setRetainInstance(true);
    setHasOptionsMenu(true);

    // Show the Up button in the action bar.
    ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Animate elevation change
    if (getActivity() instanceof MainActivity
            && getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")
            && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        LinearLayout noteViewEdit = getActivity().findViewById(R.id.noteViewEdit);
        LinearLayout noteList = getActivity().findViewById(R.id.noteList);

        noteList.animate().z(0f);
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
            noteViewEdit.animate()
                    .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land));
        else
            noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation));
    }

    // Set up content view
    noteContents = getActivity().findViewById(R.id.editText1);

    // Apply theme
    SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences",
            Context.MODE_PRIVATE);
    ScrollView scrollView = getActivity().findViewById(R.id.scrollView1);
    String theme = pref.getString("theme", "light-sans");

    if (theme.contains("light")) {
        noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary));
        noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background));
        scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background));
    }

    if (theme.contains("dark")) {
        noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary_dark));
        noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark));
        scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark));
    }

    if (theme.contains("sans"))
        noteContents.setTypeface(Typeface.SANS_SERIF);

    if (theme.contains("serif"))
        noteContents.setTypeface(Typeface.SERIF);

    if (theme.contains("monospace"))
        noteContents.setTypeface(Typeface.MONOSPACE);

    switch (pref.getString("font_size", "normal")) {
    case "smallest":
        noteContents.setTextSize(12);
        break;
    case "small":
        noteContents.setTextSize(14);
        break;
    case "normal":
        noteContents.setTextSize(16);
        break;
    case "large":
        noteContents.setTextSize(18);
        break;
    case "largest":
        noteContents.setTextSize(20);
        break;
    }

    // Get filename
    try {
        if (!getArguments().getString("filename").equals("new")) {
            filename = getArguments().getString("filename");
            if (!filename.equals("draft"))
                isSavedNote = true;
        }
    } catch (NullPointerException e) {
        filename = "new";
    }

    // Load note from existing file
    if (isSavedNote) {
        try {
            contentsOnLoad = listener.loadNote(filename);
        } catch (IOException e) {
            showToast(R.string.error_loading_note);
            finish(null);
        }

        // Set TextView contents
        length = contentsOnLoad.length();
        noteContents.setText(contentsOnLoad);

        if (!pref.getBoolean("direct_edit", false))
            noteContents.setSelection(length, length);
    } else if (filename.equals("draft")) {
        SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
        String draftContents = sharedPref.getString("draft-contents", null);
        length = draftContents.length();
        noteContents.setText(draftContents);

        if (!pref.getBoolean("direct_edit", false))
            noteContents.setSelection(length, length);
    }

    // Show soft keyboard
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(noteContents, InputMethodManager.SHOW_IMPLICIT);

}

From source file:com.cypress.cysmart.BLEServiceFragments.RGBFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        rootView = inflater.inflate(R.layout.rgb_view_landscape, container, false);
    } else {//from   w  w  w  . ja  v  a  2s. co m
        rootView = inflater.inflate(R.layout.rgb_view_portrait, container, false);
    }
    getActivity().getActionBar().setTitle(R.string.rgb_led);
    setUpControls();
    setDefaultColorPickerPositionColor();
    setHasOptionsMenu(true);
    return rootView;
}

From source file:com.ohso.omgubuntu.BaseFragment.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE
            || newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        if (footerView.isShown())
            footerView.setVisibility(TextView.GONE);
        gridView.setNumColumns(getColumnByScreenSize());
        adapter.setColumns(getColumnByScreenSize());
    }//from ww  w .j  a  va2  s.c  om
}

From source file:com.android.contacts.list.ContactsUnavailableFragment.java

private void updateButtonVisibilty(int visibility) {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        mAddAccountButton.setVisibility(visibility);
        mImportContactsButton.setVisibility(visibility);
        mButtonsContainer.setVisibility(visibility);
    } else {/*w w w.j a  v a 2  s  .c  o m*/
        mAddAccountButton.setVisibility(visibility);
        mImportContactsButton.setVisibility(visibility);
    }
}

From source file:com.poinsart.votar.VotarMain.java

private void adjustLayoutForOrientation(int orientation) {
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        mainLayout.setOrientation(LinearLayout.HORIZONTAL);
        controlLayout/*from   w  ww  .j a  v a2s  . c  o  m*/
                .setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1));
    } else if (orientation == Configuration.ORIENTATION_PORTRAIT) {
        mainLayout.setOrientation(LinearLayout.VERTICAL);
        controlLayout
                .setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1));
    }
}

From source file:com.silentcircle.silenttext.util.DeviceUtils.java

public static JSONObject getDebugInformationJSON(Context context) {

    try {/*www .  ja v a 2  s.co  m*/

        JSONObject json = new JSONObject();

        json.put("timestamp", JSONUtils.getDate(System.currentTimeMillis()));

        JSONObject android = new JSONObject();

        android.put("version", Build.VERSION.RELEASE);
        android.put("api", Build.VERSION.SDK_INT);
        android.put("build", Build.FINGERPRINT);

        json.put("android", android);

        JSONObject application = new JSONObject();

        try {

            PackageInfo pinfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);

            application.put("version_name", pinfo.versionName);
            application.put("version_code", pinfo.versionCode);
            setInstallAndUpdateTimes(pinfo, application);

        } catch (NameNotFoundException impossible) {
            throw new RuntimeException(impossible);
        }

        json.put("application", application);

        JSONObject device = new JSONObject();

        Configuration resourceConfiguration = context.getResources().getConfiguration();

        device.put("locale", resourceConfiguration.locale);
        device.put("orientation",
                resourceConfiguration.orientation == Configuration.ORIENTATION_LANDSCAPE ? "landscape"
                        : "portrait");
        device.put("density", getScreenDensity(resourceConfiguration));
        device.put("screen", getScreenDimensions(resourceConfiguration));

        device.put("manufacturer", Build.MANUFACTURER);
        device.put("model", Build.MODEL);

        JSONObject encryption = new JSONObject();

        encryption.put("supported", isFullDiskEncryptionSupported(context));
        encryption.put("enabled", isEncrypted(context));

        device.put("encryption", encryption);

        json.put("device", device);

        JSONObject build = new JSONObject();

        build.put("date", context.getString(R.string.build_date));
        build.put("version", context.getString(R.string.build_version));
        build.put("commit", context.getString(R.string.build_commit));

        json.put("build", build);

        JSONObject connection = new JSONObject();

        SilentTextApplication global = SilentTextApplication.from(context);

        XMPPTransport client = global.getXMPPTransport();

        JSONObject xmpp = new JSONObject();

        xmpp.put("status", global.getXMPPTransportConnectionStatus());

        if (client != null) {

            boolean online = client.isConnected();

            xmpp.put("online", online);

            if (online) {
                xmpp.put("host", client.getServerHost());
                xmpp.put("port", client.getServerPort());
            }

        }

        connection.put("xmpp", xmpp);

        json.put("connection", connection);

        ServiceConfiguration serviceConfig = ServiceConfiguration.getInstance();

        JSONObject services = new JSONObject();

        services.put("debug", serviceConfig.debug);
        services.put("experimental", serviceConfig.experimental);
        services.put("logging_enabled", serviceConfig.loggingEnabled);
        services.put("environment", serviceConfig.environment);
        services.put("dns.use_custom_server", serviceConfig.useCustomDNS);
        if (serviceConfig.useCustomDNS) {
            services.put("dns.custom_server", serviceConfig.customDNS);
        }
        services.put("validate_certificates", serviceConfig.shouldValidateCertificates);
        services.put("api.override", serviceConfig.api.override);
        services.put("api.perform_srv_lookup", serviceConfig.api.performSRVLookup);
        services.put("api.host", serviceConfig.api.host);
        services.put("api.port", serviceConfig.api.port);
        services.put("api.service_name", serviceConfig.api.serviceName);
        services.put("feature.check_user_availability", serviceConfig.features.checkUserAvailability);
        services.put("feature.generate_default_avatars", serviceConfig.features.generateDefaultAvatars);
        services.put("gcm.sender_id", serviceConfig.gcm.senderID);
        services.put("gcm.target", serviceConfig.gcm.target);
        services.put("scimp.enable_pki", serviceConfig.scimp.enablePKI);
        services.put("scloud.url", serviceConfig.scloud.url);
        services.put("xmpp.override", serviceConfig.xmpp.override);
        services.put("xmpp.perform_srv_lookup", serviceConfig.xmpp.performSRVLookup);
        services.put("xmpp.host", serviceConfig.xmpp.host);
        services.put("xmpp.port", serviceConfig.xmpp.port);
        services.put("xmpp.service_name", serviceConfig.xmpp.serviceName);
        services.put("xmpp.background", serviceConfig.xmpp.background);
        services.put("passcode_set", !OptionsDrawer.isEmptyPasscode(context));
        services.put("silent_contacts_v1", SilentContactRepositoryV1.supports(context));
        services.put("silent_contacts_v2", SilentContactRepositoryV2.supports(context));
        services.put("silent_phone", SilentPhone.supports(context));

        json.put("configuration", services);

        return json;

    } catch (JSONException impossible) {
        throw new RuntimeException(impossible);
    }

}

From source file:com.example.app_2.utils.Utils.java

public static void setWallpaper(android.view.ViewGroup vg, int reqWidth, int reqHeight, Bitmap wallpaper,
        ScalingLogic sl) {// w w  w  .  j ava 2 s  .  co m

    if (wallpaper == null) {
        WallpaperManager wallpaperManager = WallpaperManager.getInstance(App_2.getAppContext());
        Drawable wallpaperDrawable = wallpaperManager.getDrawable();
        wallpaper = BitmapCalc.drawableToBitmap(wallpaperDrawable);
    }

    if (reqHeight == 0 || reqWidth == 0) {
        reqHeight = App_2.getMaxHeight();
        reqWidth = App_2.getMaxWidth();
    }

    Resources r = App_2.getAppContext().getResources();
    int orientation = r.getConfiguration().orientation;

    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE: // landscape
        Bitmap wallpaperLandscape = ScalingUtilities.createScaledBitmap(wallpaper, reqHeight, reqWidth, sl);
        if (Utils.hasJellyBean())
            vg.setBackground(new BitmapDrawable(r, wallpaperLandscape));
        else {
            if (vg instanceof LinearLayout) {
                LinearLayout ll = (LinearLayout) vg;
                ll.setBackgroundDrawable(new BitmapDrawable(r, wallpaperLandscape));
            } else if (vg instanceof DrawerLayout) {
                DrawerLayout dl = (DrawerLayout) vg;
                dl.setBackgroundDrawable(new BitmapDrawable(r, wallpaperLandscape));
            }

        }
        //wallpaperLandscape.recycle();
        break;
    case Configuration.ORIENTATION_PORTRAIT: // portrait
        Bitmap wallpaperPortrait = ScalingUtilities.createScaledBitmap(wallpaper, reqWidth, reqHeight, sl);

        if (Utils.hasJellyBean())
            vg.setBackground(new BitmapDrawable(r, wallpaperPortrait));
        else {
            if (vg instanceof LinearLayout) {
                LinearLayout ll = (LinearLayout) vg;
                ll.setBackgroundDrawable(new BitmapDrawable(r, wallpaperPortrait));
            } else if (vg instanceof DrawerLayout) {
                DrawerLayout dl = (DrawerLayout) vg;
                dl.setBackgroundDrawable(new BitmapDrawable(r, wallpaperPortrait));
            }
        }
        //wallpaperPortrait.recycle();
        break;
    default:
        //ll.setBackgroundDrawable(App_2.wallpaperDrawable);
        break;
    }
}

From source file:com.danielme.muspyforandroid.activities.base.AbstractActivity.java

private void changeButtonRotation(Button button, Configuration newConfig, int icon) {
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        button.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
        button.setTextSize(18);//from w  w  w. j a va2 s .  c om

    } else {
        button.setCompoundDrawablesWithIntrinsicBounds(0, icon, 0, 0);
        button.setTextSize(11);
    }
}

From source file:com.gnufabio.costituzione.DetailedActivity.java

@SuppressWarnings("deprecation")
public void heuristicSetTytle(Configuration config) {
    if (mIsTablet) {
        setTitle(R.string.app_name);/*from   w  w w.  ja  v a2s.c  om*/
    } else {
        int orientation = config.orientation;
        switch (orientation) {
        case Configuration.ORIENTATION_LANDSCAPE:
        case Configuration.ORIENTATION_SQUARE:
            setTitle(R.string.app_name);
            break;
        case Configuration.ORIENTATION_PORTRAIT:
            setTitle(null);
            break;
        default:
            setTitle(R.string.app_name);
            break;
        }
    }
}