Example usage for android.content.res Resources getSystem

List of usage examples for android.content.res Resources getSystem

Introduction

In this page you can find the example usage for android.content.res Resources getSystem.

Prototype

public static Resources getSystem() 

Source Link

Document

Return a global shared Resources object that provides access to only system resources (no application resources), and is not configured for the current screen (can not use dimension units, does not change based on orientation, etc).

Usage

From source file:com.mobicage.rogerthat.util.ui.SendMessageView.java

private void setVideoSelected() {
    if (!new File(mUriSavedFile.getPath()).exists()) {
        UIUtils.showLongToast(mActivity, mActivity.getString(R.string.error_please_try_again));
        return;/*from   ww  w  .java 2s  . c  o  m*/
    }
    Bitmap bitmap = UIUtils.createVideoThumbnail(mActivity, mUriSavedFile.getPath(),
            UIUtils.convertDipToPixels(mActivity, 200));
    Drawable d = new BitmapDrawable(Resources.getSystem(), bitmap);
    mAttachmentPreview.setImageDrawable(d);
    mAttachmentContainer.setVisibility(View.VISIBLE);

    mHasVideoSelected = true;
    initImageButtonsNavigation();
}

From source file:org.miaowo.miaowo.util.Html.java

private static void endFont(Editable text) {
    int len = text.length();
    Font f = getLast(text, Font.class);
    int where = text.getSpanStart(f);
    text.removeSpan(f);//from   w ww  .  ja  v a 2  s  .com

    if (where != len) {
        if (!TextUtils.isEmpty(f.mColor)) {
            if (f.mColor.startsWith("@")) {
                Resources res = Resources.getSystem();
                String name = f.mColor.substring(1);
                int colorRes = res.getIdentifier(name, "color", "android");
                if (colorRes != 0) {
                    ColorStateList colors = ResourcesCompat.getColorStateList(res, colorRes, null);
                    text.setSpan(new TextAppearanceSpan(null, 0, 0, colors, null), where, len,
                            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
            } else {
                int c = Color.parseColor(f.mColor);
                if (c != -1) {
                    text.setSpan(new ForegroundColorSpan(c | 0xFF000000), where, len,
                            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
            }
        }

        if (f.mFace != null) {
            text.setSpan(new TypefaceSpan(f.mFace), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
}

From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java

public void initNaverMap() {
    naverFragment = new FragmentMapview();
    naverFragment.setArguments(new Bundle());

    final Button expandView = (Button) mainArView.findViewById(R.id.ar_mixview_naverview_expand);
    expandView.setOnClickListener(new View.OnClickListener() {
        boolean isFull = false;

        @Override/*from  ww  w .j a  v  a  2  s.co  m*/
        public void onClick(View view) {
            RelativeLayout navermapWrapper = (RelativeLayout) mainArView
                    .findViewById(R.id.ar_mixview_naverview_wrapper);
            if (isFull) {
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                        (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, naver_map_width,
                                Resources.getSystem().getDisplayMetrics()),
                        (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, naver_map_height,
                                Resources.getSystem().getDisplayMetrics()));
                int tenMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
                        Resources.getSystem().getDisplayMetrics());
                params.setMargins(0, tenMargin, tenMargin, 0);
                params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                navermapWrapper.setLayoutParams(params);
                expandView.setBackgroundResource(R.drawable.ic_minimap_zoom_in);
                isFull = false;
            } else {
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                        LayoutParams.MATCH_PARENT);
                params.setMargins(0, 0, 0, 0);
                navermapWrapper.setLayoutParams(params);
                expandView.setBackgroundResource(R.drawable.ic_minimap_zoom_out);
                isFull = true;
            }
        }
    });

    try {
        FragmentTransaction fragmentTransaction = ((FragmentActivity) context).getSupportFragmentManager()
                .beginTransaction();
        fragmentTransaction.add(R.id.ar_mixview_naverview, naverFragment);
        fragmentTransaction.commit();
    } catch (Exception e) {
        e.printStackTrace();
        Log.i(TAG, "Only FragmentActivity can use naver maps");
    }
}

From source file:androidx.media.widget.VideoView2.java

private int retrieveOrientation() {
    DisplayMetrics dm = Resources.getSystem().getDisplayMetrics();
    int width = dm.widthPixels;
    int height = dm.heightPixels;

    return (height > width) ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
            : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
}

From source file:org.catrobat.catroid.uitest.util.UiTestUtils.java

public static void acceptAndCloseActionMode(Solo solo) {
    View doneButton;// www  . ja v a 2s  . co  m

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        doneButton = solo
                .getView(Resources.getSystem().getIdentifier("action_mode_close_button", "id", "android"));
    } else {
        doneButton = solo.getCurrentActivity().findViewById(R.id.abs__action_mode_close_button);
    }

    solo.clickOnView(doneButton);
    solo.sleep(200);
}

From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java

public static void init() {
      if (!init) {
          init = true;/*ww  w . j  a  v  a 2s .  c o  m*/
          instance = LuckyApp.getInstance();
          if (firstrun == null) {
              firstrun = Boolean.valueOf(true);
          }
          luckyPackage = LuckyApp.getInstance().getApplicationInfo().packageName;
          startUnderRoot = Boolean.valueOf(false);
          api = Build.VERSION.SDK_INT;
      }
      try {
          versionCodeLocal = getPkgMng().getPackageInfo(LuckyApp.getInstance().getPackageName(), 0).versionCode;
          version = getPkgMng().getPackageInfo(LuckyApp.getInstance().getPackageName(), 0).versionName;
          System.out.println("LuckyPatcher " + version + ": Application Start!");
          if (getConfig().getBoolean("fast_start", false)) {
              fast_start = true;
          }
          localObject2 = getConfig().getString("force_language", "default");
      } catch (Exception localException2) {
          try {
              if (((String) localObject2).equals("default")) {
                  localObject1 = Resources.getSystem().getConfiguration().locale;
                  Locale.setDefault(Locale.getDefault());
                  localObject2 = new Configuration();
                  ((Configuration) localObject2).locale = ((Locale) localObject1);
                  LuckyApp.getInstance().getResources().updateConfiguration((Configuration) localObject2,
                          LuckyApp.getInstance().getResources().getDisplayMetrics());
                  boot_pat = new ArrayList();
              }
          } catch (Exception localException2) {
              try {
                  for (;;) {
                      Object localObject2;
                      toolfilesdir = LuckyApp.getInstance().getFilesDir().getAbsolutePath();
                      supath = LuckyApp.getInstance().getPackageCodePath();
                      int i = getConfig().getInt("root_force", 0);
                      if ((i == 0) && ((new File("/system/bin/su").exists())
                              || (new File("/system/xbin/su").exists()) || (new File("/su/bin/su").exists()))) {
                          su = true;
                      }
                      if (i == 1) {
                          su = true;
                      }
                      if (i == 2) {
                          su = false;
                      }
                      Object localObject1 = "";
                      extStorageDirectory = Environment.getExternalStorageDirectory().getAbsolutePath();
                      basepath = extStorageDirectory + "/LuckyPatcher";
                      try {
                          if (api > 18) {
                              basepath = LuckyApp.getInstance().getExternalFilesDir("LuckyPatcher")
                                      .getAbsolutePath();
                          }
                          basepath = extStorageDirectory + "/LuckyPatcher";
                          if (getConfig().getBoolean("manual_path", false)) {
                              basepath = getConfig().getString("basepath", basepath);
                          }
                          if (new File("/system/bin/dalvikvm").exists()) {
                              localObject1 = "/system/bin/dalvikvm";
                          }
                          if (new File("/system/bin/dalvikvm32").exists()) {
                              localObject1 = "/system/bin/dalvikvm32";
                          }
                          localObject2 = localObject1;
                          if (((String) localObject1).equals("")) {
                              localObject2 = localObject1;
                              if (su) {
                                  localFile = new File(LuckyApp.getInstance().getFilesDir() + "/dalvikvm");
                                  if (localFile.exists()) {
                                      break label1151;
                                  }
                                  localObject2 = localObject1;
                                  if (Utils.getRawToFile(2131099654, localFile)) {
                                      Utils.run_all("chmod 777 " + localFile.getAbsolutePath());
                                      Utils.run_all("chown 0.0 " + localFile.getAbsolutePath());
                                      Utils.run_all("chown 0:0 " + localFile.getAbsolutePath());
                                      localObject2 = localFile.getAbsolutePath();
                                  }
                              }
                          }
                          dalvikruncommand = (String) localObject2 + " -Xbootclasspath:"
                                  + System.getenv("BOOTCLASSPATH") + " -Xverify:none -Xdexopt:none -cp "
                                  + LuckyApp.getInstance().getPackageCodePath() + " com.chelpus.root.utils";
                          dalvikruncommandWithFramework = (String) localObject2 + " -Xbootclasspath:"
                                  + System.getenv("BOOTCLASSPATH") + " -Xverify:none -Xdexopt:none -cp "
                                  + LuckyApp.getInstance().getPackageCodePath()
                                  + " com.android.internal.util.WithFramework" + " com.chelpus.root.utils";
                          if ((runtime.equals("")) || (runtime == null)) {
                              localObject1 = "UNKNOWN";
                          }
                          try {
                              localObject2 = Utils.checkRuntimeFromCache(
                                      getPkgMng().getPackageInfo(getInstance().getPackageName(),
                                              0).applicationInfo.sourceDir);
                              localObject1 = localObject2;
                          } catch (PackageManager.NameNotFoundException localNameNotFoundException) {
                              for (;;) {
                                  Locale localLocale;
                                  String str1;
                                  localNameNotFoundException.printStackTrace();
                                  continue;
                                  new Thread(new Runnable() {
                                      public void run() {
                                          Utils.run_all("mkdir /data/lp");
                                          Utils.run_all("chmod 777 /data/lp");
                                          if (new Utils("").cmdRoot(new String[] { "getenforce" }).toLowerCase()
                                                  .contains("enforcing")) {
                                              listAppsFragment.selinux = "enforce";
                                          }
                                          Utils.save_text_to_file(this.val$link_to_utils,
                                                  listAppsFragment.toolfilesdir + "%chelpus%"
                                                          + listAppsFragment.api + "%chelpus%"
                                                          + listAppsFragment.runtime + "%chelpus%"
                                                          + listAppsFragment.selinux);
                                          Utils.run_all("chmod 777 /data/lp/lp_utils");
                                          Utils.initXposedParam();
                                      }
                                  }).start();
                              }
                          }
                          System.out.println("Runtime:" + (String) localObject1);
                          runtime = (String) localObject1;
                          if ((su) && (!new File("/data/lp/lp_utils").exists())) {
                              System.out.println("Tools not found in /data. Try create.");
                              localObject1 = new File("/data/lp/lp_utils");
                              if (!((File) localObject1).exists()) {
                              }
                          } else {
                              days = getConfig().getInt("days_on_up", 1);
                              getLaunchIntent();
                              return;
                              localException1 = localException1;
                              localException1.printStackTrace();
                              continue;
                              localLocale = null;
                              localObject2 = ((String) localObject2).split("_");
                              if (localObject2.length == 1) {
                                  localLocale = new Locale(localObject2[0]);
                              }
                              if (localObject2.length == 2) {
                                  localLocale = new Locale(localObject2[0], localObject2[1], "");
                                  if (localObject2[1].equals("rBR")) {
                                      localLocale = new Locale(localObject2[0], "BR");
                                  }
                              }
                              if (localObject2.length == 3) {
                                  localLocale = new Locale(localObject2[0], localObject2[1], localObject2[2]);
                              }
                              Locale.setDefault(localLocale);
                              localObject2 = new Configuration();
                              ((Configuration) localObject2).locale = localLocale;
                              LuckyApp.getInstance().getResources().updateConfiguration(
                                      (Configuration) localObject2,
                                      LuckyApp.getInstance().getResources().getDisplayMetrics());
                              continue;
                              localException2 = localException2;
                              localException2.printStackTrace();
                          }
                      } catch (Exception localException4) {
                          for (;;) {
                              File localFile;
                              localException4.printStackTrace();
                              new File(extStorageDirectory + "/Android/data/" + luckyPackage
                                      + "/files/LuckyPatcher").mkdirs();
                              basepath = extStorageDirectory + "/Android/data/" + luckyPackage
                                      + "/files/LuckyPatcher";
                              continue;
                              label1151: str1 = localFile.getAbsolutePath();
                              Utils.run_all("chmod 777 " + localFile.getAbsolutePath());
                              Utils.run_all("chown 0.0 " + localFile.getAbsolutePath());
                              Utils.run_all("chown 0:0 " + localFile.getAbsolutePath());
                          }
                      }
                  }
              } catch (Exception localException3) {
                  for (;;) {
                  }
              }
          }
      }
  }