Ejemplo n.º 1
1
    @Override
    public void handleMessage(Message msg) {
      Context context = getContext();
      if (context == null) {
        Log.e(TAG, "error handling message, getContext() returned null");
        return;
      }
      switch (msg.arg1) {
        case COMMAND_CHANGE_TITLE:
          if (context instanceof Activity) {
            ((Activity) context).setTitle((String) msg.obj);
          } else {
            Log.e(TAG, "error handling message, getContext() returned no Activity");
          }
          break;
        case COMMAND_TEXTEDIT_HIDE:
          if (mTextEdit != null) {
            mTextEdit.setVisibility(View.GONE);

            InputMethodManager imm =
                (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
          }
          break;

        default:
          if ((context instanceof SDLActivity)
              && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) {
            Log.e(TAG, "error handling message, command is " + msg.arg1);
          }
      }
    }
Ejemplo n.º 2
0
 Class<?> getPluginClass(String packageName, String className)
     throws NameNotFoundException, ClassNotFoundException {
   Context pluginContext =
       this.mAppContext.createPackageContext(
           packageName, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
   ClassLoader pluginCL = pluginContext.getClassLoader();
   return pluginCL.loadClass(className);
 }
Ejemplo n.º 3
0
  public MapView(Context ctx, boolean allowNetAccess, int mode) {
    super(ctx);

    Display display;

    this.allowNetAccess = allowNetAccess;

    geoUtils = new GeoUtils(mode);

    setBackgroundColor(0xFF555570);
    display = ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    scrWidth = display.getWidth();
    scrHeight = display.getHeight();
    setMinimumHeight(scrWidth);
    setMinimumWidth(scrHeight);
    tileWidth = (int) Math.ceil(scrWidth / 256.0) + 1;
    tileHeight = (int) Math.ceil(scrHeight / 256.0) + 1;
    gestureDetector = new GestureDetector(ctx, new GestureListener());

    zoomOutButton = new Button(ctx);
    zoomOutButton.setText("  -  ");
    zoomOutButton.setOnClickListener(this);

    zoomInButton = new Button(ctx);
    zoomInButton.setText("  +  ");
    zoomInButton.setOnClickListener(this);

    updateUI(true);
    addView(zoomOutButton);
    addView(zoomInButton);
  }
Ejemplo n.º 4
0
  public void background(int r, int g, int b) {
    Log.d("Pepper", "back " + r + ' ' + g + ' ' + b);
    canvas.drawARGB(255, r, g, b);

    Context c = App.self;
    Class cls = c.getClass();
    Method[] methods = cls.getMethods();
    Field[] fields = cls.getFields();
    /*
    for (Method m : methods) {
        Log.d("Pepper", "method " + m.getName() + "; " + m);
    }
    for (Field f : fields) {
        Log.d("Pepper", "field " + f.getName());
    }
    */
  }
Ejemplo n.º 5
0
  // Startup
  public SDLSurface(Context context) {
    super(context);
    getHolder().addCallback(this);

    setFocusable(true);
    setFocusableInTouchMode(true);
    requestFocus();
    setOnKeyListener(this);
    setOnTouchListener(this);

    mDisplay =
        ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);

    // Some arbitrary defaults to avoid a potential division by zero
    mWidth = 1.0f;
    mHeight = 1.0f;
  }
Ejemplo n.º 6
0
    @Override
    public void handleMessage(Message msg) {
      Context context = getContext();
      if (context == null) {
        Log.e(TAG, "error handling message, getContext() returned null");
        return;
      }
      switch (msg.arg1) {
        case COMMAND_CHANGE_TITLE:
          if (context instanceof Activity) {
            ((Activity) context).setTitle((String) msg.obj);
          } else {
            Log.e(TAG, "error handling message, getContext() returned no Activity");
          }
          break;
        case COMMAND_TEXTEDIT_HIDE:
          if (mTextEdit != null) {
            mTextEdit.setVisibility(View.GONE);

            InputMethodManager imm =
                (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
          }
          break;
        case COMMAND_SET_KEEP_SCREEN_ON:
          {
            Window window = ((Activity) context).getWindow();
            if (window != null) {
              if ((msg.obj instanceof Integer) && (((Integer) msg.obj).intValue() != 0)) {
                window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
              } else {
                window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
              }
            }
            break;
          }
        default:
          if ((context instanceof SDLActivity)
              && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) {
            Log.e(TAG, "error handling message, command is " + msg.arg1);
          }
      }
    }
Ejemplo n.º 7
0
  // Startup
  public SDLSurface(Context context) {
    super(context);
    getHolder().addCallback(this);

    setFocusable(true);
    setFocusableInTouchMode(true);
    requestFocus();
    setOnKeyListener(this);
    setOnTouchListener(this);

    mSensorManager = (SensorManager) context.getSystemService("sensor");
  }
Ejemplo n.º 8
0
 /** Load the images into memory. */
 public static void LoadImages(Context context) {
   if (images != null) {
     return;
   }
   images = new Bitmap[13];
   Resources res = context.getResources();
   images[2] = BitmapFactory.decodeResource(res, R.drawable.two);
   images[3] = BitmapFactory.decodeResource(res, R.drawable.three);
   images[4] = BitmapFactory.decodeResource(res, R.drawable.four);
   images[6] = BitmapFactory.decodeResource(res, R.drawable.six);
   images[8] = BitmapFactory.decodeResource(res, R.drawable.eight);
   images[9] = BitmapFactory.decodeResource(res, R.drawable.nine);
   images[12] = BitmapFactory.decodeResource(res, R.drawable.twelve);
 }
Ejemplo n.º 9
0
  private Bitmap getAppDrawable(String path) throws OutOfMemoryError {
    Bitmap bitsat;
    try {
      PackageManager pm = mContext.getPackageManager();
      PackageInfo pi = pm.getPackageArchiveInfo(path, 0);
      // // the secret are these two lines....
      pi.applicationInfo.sourceDir = path;
      pi.applicationInfo.publicSourceDir = path;
      // //
      Drawable d = pi.applicationInfo.loadIcon(pm);

      Bitmap d1 = null;
      d1 = ((BitmapDrawable) d).getBitmap();
      bitsat = d1;
    } catch (Exception e) {
      Drawable apk = ContextCompat.getDrawable(mContext, R.drawable.ic_doc_apk_grid);
      Bitmap apk1 = ((BitmapDrawable) apk).getBitmap();
      bitsat = apk1;
    }
    return bitsat;
  }
Ejemplo n.º 10
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View v = convertView;
   if (v == null) {
     LayoutInflater vi =
         (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     v = vi.inflate(R.layout.row, null);
   }
   Message m = items.get(position);
   // if (m != null) {
   m.createColorFromString(m.from);
   TextView tt = (TextView) v.findViewById(R.id.username);
   TextView bt = (TextView) v.findViewById(R.id.message);
   if (isMonospaced) {
     tt.setTypeface(Typeface.MONOSPACE);
     bt.setTypeface(Typeface.MONOSPACE);
   }
   tt.setText(m.getFrom());
   tt.setTextColor(m.color);
   bt.setText(m.getMessage());
   // }
   return v;
 }
Ejemplo n.º 11
0
  public IconHolder(Context context, boolean useThumbs, boolean grid) {
    super();
    this.mContext = context;
    this.mUseThumbs = useThumbs;
    this.mRequests = new HashMap<ImageView, String>();
    this.mIcons = new HashMap<String, Bitmap>();
    this.mAppIcons =
        new LinkedHashMap<String, Bitmap>(MAX_CACHE, .75F, true) {
          private static final long serialVersionUID = 1L;

          @Override
          protected boolean removeEldestEntry(Entry<String, Bitmap> eldest) {
            return size() > MAX_CACHE;
          }
        };
    this.mAlbums = new HashMap<String, Long>();
    this.grid = grid;
    Resources res = mContext.getResources();
    int dp = 50;
    if (grid) {
      dp = 150;
    }
    px = (int) (dp * (res.getDisplayMetrics().densityDpi / 160));
  }
Ejemplo n.º 12
0
 public MyView(Context context) {
   super(context);
   mBack = BitmapFactory.decodeResource(context.getResources(), R.drawable.family);
   mHandler.sendEmptyMessageDelayed(0, DELAY);
 }