private void updateTitleBackground(float progress) { ColorDrawable drawable = new ColorDrawable(toolbarBackgroundColor); if (progress <= 1) { drawable.setAlpha((int) (progress * 255)); } else { drawable.setAlpha(255); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) toolbar.setBackground(drawable); else toolbar.setBackgroundDrawable(drawable); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.report_search_date_view); curDate = getIntent().getStringExtra("curDate"); dateTitle = (TextView) findViewById(R.id.textViewDate); dateTitle.setText(curDate); MyAdapter adapter = new MyAdapter(this, generateData()); ListView listView = (ListView) findViewById(R.id.listViewDate); listView.setAdapter(adapter); // Ophalen van de applicatiekleuren SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); int appBackColor = SP.getInt("applicationBackColor", 0); int appBackColorR = SP.getInt("applicationBackColorR", 0); int appBackColorG = SP.getInt("applicationBackColorG", 0); int appBackColorB = SP.getInt("applicationBackColorB", 0); int appColor = SP.getInt("applicationColor", 0); int appColorR = SP.getInt("applicationColorR", 0); int appColorG = SP.getInt("applicationColorG", 0); int appColorB = SP.getInt("applicationColorB", 0); boolean appStandardColor = SP.getBoolean("colorStandard", true); if (appStandardColor) { getWindow().getDecorView().setBackgroundColor(Color.rgb(238, 233, 233)); toolbar.setBackgroundDrawable(new ColorDrawable(Color.rgb(59, 89, 152))); } else { if (appBackColor != 0) { getWindow() .getDecorView() .setBackgroundColor(Color.rgb(appBackColorR, appBackColorG, appBackColorB)); } if (appColor != 0) { toolbar.setBackgroundDrawable( new ColorDrawable(Color.rgb(appColorR, appColorG, appColorB))); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.report_export_excel); SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); appConfirm = SP.getBoolean("applicationConfirmation", true); WorkbookSettings wbSettings = new WorkbookSettings(); wbSettings.setUseTemporaryFileDuringWrite(true); wbfile = new File(getFilesDir() + File.separator + "try.xls"); WritableWorkbook wb = null; try { wb = Workbook.createWorkbook(wbfile, wbSettings); WritableSheet sheet = wb.createSheet("IBS Report", 0); createCell(sheet, 0, 0, "Storage Places"); createCell(sheet, 0, 1, "Categories"); wb.write(); wb.close(); } catch (Exception ex) { ex.printStackTrace(); } if (wbfile == null) { Log.d("----FILE----", "NULL"); } else { Log.d("----FILE----", "Not Null"); } Log.d("File", getFilesDir() + File.separator + "try.xls"); emailaddressEditText = (EditText) findViewById(R.id.email); excelButton = (Button) findViewById(R.id.excelButton); excelButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { emailaddress = emailaddressEditText.getText().toString(); Mail m = new Mail( "*****@*****.**", "IngloriousBrewStarsApp"); // email, wachtwoord m.setReceiver(emailaddress); try { m.addAttachment(wbfile.getAbsolutePath()); if (m.send()) { Toast.makeText( ReportExportExcel.this, "Email was sent successfully.", Toast.LENGTH_LONG) .show(); } else { Toast.makeText(ReportExportExcel.this, "Email was not sent.", Toast.LENGTH_LONG) .show(); } } catch (Exception e) { // Toast.makeText(MailApp.this, "There was a problem sending the email.", // Toast.LENGTH_LONG).show(); Log.e("MailApp", "Could not send email", e); } } }); // Ophalen van de applicatiekleuren SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); int appBackColor = SP.getInt("applicationBackColor", 0); int appBackColorR = SP.getInt("applicationBackColorR", 0); int appBackColorG = SP.getInt("applicationBackColorG", 0); int appBackColorB = SP.getInt("applicationBackColorB", 0); int appColor = SP.getInt("applicationColor", 0); int appColorR = SP.getInt("applicationColorR", 0); int appColorG = SP.getInt("applicationColorG", 0); int appColorB = SP.getInt("applicationColorB", 0); boolean appStandardColor = SP.getBoolean("colorStandard", true); if (appStandardColor) { getWindow().getDecorView().setBackgroundColor(Color.rgb(238, 233, 233)); toolbar.setBackgroundDrawable(new ColorDrawable(Color.rgb(59, 89, 152))); } else { if (appBackColor != 0) { getWindow() .getDecorView() .setBackgroundColor(Color.rgb(appBackColorR, appBackColorG, appBackColorB)); } if (appColor != 0) { toolbar.setBackgroundDrawable( new ColorDrawable(Color.rgb(appColorR, appColorG, appColorB))); } } }
@Override public void setBackgroundDrawable(Drawable d) { //noinspection deprecation mToolbar.setBackgroundDrawable(d); }