@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.wallchanger); mProgressBar = (ProgressBar) findViewById(R.id.progress_progress); mProgressPanel = findViewById(R.id.progress_progress); mProgressLabel = (TextView) findViewById(R.id.progress_label); mProgressCancel = (Button) findViewById(R.id.progress_cancel); if (isGTV()) { showToast("Welcome, GoogleTV user!"); } if (true) getActionBar().hide(); else findViewById(R.id.title_frame).setVisibility(View.GONE); MediaUtils.init(getApplicationContext()); try { if (!MediaUtils.writeFile("pewp", new byte[] {}, true)) Logger.LogWarning("Unable to write to pewp"); else Logger.LogInfo("Wrote to pewp!"); } catch (IOException fnfe) { Logger.LogError("Unable to write to pewp!", fnfe); } mUseMultiplePanes = (null != findViewById(R.id.detail_container)); if (null == savedInstanceState) { FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); mFragHash.put("list", new ProfileMakerList()); ft.replace(R.id.list, mFragHash.get("list"), "list"); ft.commit(); ShowDetailFragment(new PreviewFragment(), "preview"); ShowPreview(((BitmapDrawable) getWallpaper()).getBitmap()); } }
public void setWeatherLocation(String location) { if (location.equals("")) return; Logger.LogInfo("New Location: " + location); mWeatherLocation = location; /// TODO: Fix Weather location update /* if(mBtnWeatherLocation != null) { mBtnWeatherLocation.setText(location); mBtnWeatherLocation.setTextColor(Color.BLACK); } */ }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_settings: Logger.LogInfo("Settings menu selected"); startActivityForResult( new Intent(getApplicationContext(), Settings.class), WallChanger.REQ_SETTINGS); break; case R.id.menu_help: Logger.LogInfo("Help menu selected"); startActivity(new Intent(getApplicationContext(), Help.class)); break; case R.id.menu_feedback: Logger.LogInfo("Feedback menu selected"); ShowDetailFragment(new Feedback(), "feedback"); // startActivity(new Intent(getApplicationContext(), Feedback.class)); break; default: if (item.getTitle().equals("Old UI")) startActivity(new Intent(getApplicationContext(), ProfileMaker.class)); break; } return super.onOptionsItemSelected(item); }
public void setWeatherPosition(int index) { Logger.LogInfo("New Position: " + mWeatherPosition); mWeatherPosition = index; /* if(mBtnWeatherPosition != null) { Bitmap bmp = null; if(mWeatherPosition == 4) bmp = BitmapFactory.decodeResource(mResources, R.drawable.arrow_green_center); else bmp = ImageUtilities.rotateImage(BitmapFactory.decodeResource(mResources, R.drawable.arrow_green), SelectPosition.getDegreesFromIndex(mWeatherPosition)); if(bmp != null) { LayerDrawable ld = new LayerDrawable(new Drawable[]{mResources.getDrawable(android.R.drawable.btn_default) , new BitmapDrawable(bmp)}); mBtnWeatherPosition.setBackgroundDrawable(ld); } } */ }
private Bitmap downloadBitmap(String url) { Bitmap ret = null; InputStream s = null; try { if (url.startsWith("/")) { ret = MediaUtils.readFileBitmap(url, true); if (ret != null) return ret; } Logger.LogDebug("Trying to download " + url); HttpURLConnection uc = (HttpURLConnection) new URL(url).openConnection(); uc.setConnectTimeout(15000); uc.connect(); publishProgress(0); if (uc.getResponseCode() >= 400) throw new IOException(uc.getResponseCode() + " on " + url); Integer length = uc.getContentLength(); Logger.LogInfo("Response received. " + length + " bytes."); publishProgress(-2); s = new BufferedInputStream(uc.getInputStream(), WallChanger.DOWNLOAD_CHUNK_SIZE); ByteArrayBuffer bab = new ByteArrayBuffer(length <= 0 ? 32 : length); byte[] b = new byte[WallChanger.DOWNLOAD_CHUNK_SIZE]; int read = 0; int position = 0; while ((read = s.read(b, 0, WallChanger.DOWNLOAD_CHUNK_SIZE)) > 0) { position += read; bab.append(b, 0, read); publishProgress(position, length > position ? length : position + s.available()); } b = bab.toByteArray(); MediaUtils.writeFile(url.substring(url.lastIndexOf("/") + 1), b, true); ret = BitmapFactory.decodeByteArray(b, 0, b.length); } catch (IOException ex) { Logger.LogError("Couldn't download base image. " + url, ex); } finally { try { if (s != null) s.close(); } catch (IOException ex) { Logger.LogError("Error closing stream while downloading base image.", ex); } } return ret; }