@Override public void onClick(View inButton) { boolean isErr = false; if (mTitle.getText().toString().length() == 0) { mTitle.setError("Required"); mTitle.setEms(10); isErr = true; } if (mDesc.getText().toString().length() == 0) { mDesc.setActivated(true); mDesc.setError("Required"); isErr = true; } if (inButton.getId() == openWeb.getId()) web.setVisibility(View.VISIBLE); else if (inButton.getId() == mAvail.getId()) startActivity(new Intent(this, CheckActivity.class)); else if (inButton.getId() == mBack.getId()) finish(); else if (inButton.getId() == mSub.getId()) { AlertDialog.Builder al = new AlertDialog.Builder(this); if (isErr) return; else al.setTitle("Continue?") .setIcon(R.drawable.ornament) .setMessage("Your listing is going to be submitted to your chosen category.") .setPositiveButton( "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int x) { payment = new ArrayList<String>(); if (mCard.isChecked()) payment.add("Card"); if (mCheck.isChecked()) payment.add("Check"); if (mOnline.isChecked()) payment.add("Online"); if (mCash.isChecked()) payment.add("Cash"); // Toast.makeText(getApplicationContext(), payment.toString(), // Toast.LENGTH_LONG).show(); Intent intent = new Intent(getApplicationContext(), StartActivity.class); intent.putExtra("Payment", payment); intent.putExtra("Category", mChosenCategory); intent.putExtra("Title", mTitle.getText().toString()); intent.putExtra("Price", mPrice.getText().toString()); intent.putExtra("Description", mDesc.getText().toString()); intent.putExtra("Location", mLocation.getText().toString()); intent.putExtra("Photo", jpegData); startActivity(intent); } }) .setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int x) {} }) .show(); } else startActivityForResult( new Intent(this, com.lightbox.android.camera.activities.Camera.class), REQ); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.profile); findViews(); /*Select Category work */ final String[] categories = getIntent().getStringArrayExtra("Options"); ArrayAdapter<String> catadapt; catadapt = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories); mCatSpin.setAdapter(catadapt); mCatSpin.setOnItemSelectedListener( new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) { mChosenCategory = categories[pos]; } public void onNothingSelected(AdapterView<?> parent) {} }); /*Availability selection work*/ mAvail = (Button) findViewById(R.id.editavail); mAvail.setOnClickListener(this); /*Submit/Back button work*/ mSub = (Button) findViewById(R.id.submitbutton); mSub.setOnClickListener(this); mBack.setOnClickListener(this); /*Web View & Camera uploader work*/ openCam.setOnClickListener(this); openWeb.setOnClickListener(this); web.getSettings().setJavaScriptEnabled(true); web.loadUrl("http://www.monkbananas.com/uploader/index.php"); // ------Everything below this line was found on StackOverflow-------------------- web.setWebChromeClient( new WebChromeClient() { @Override public boolean shouldOverrideUrlLoading(WebView v, String url) { web.loadUrl(url); return true; } // The undocumented magic method override // Eclipse will swear at you if you try to put @Override here // For Android 3.0+ public void openFileChooser(ValueCallback<Uri> uploadMsg) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } // For Android 3.0+ public void openFileChooser(ValueCallback uploadMsg, String acceptType) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE); } // For Android 4.1 public void openFileChooser( ValueCallback<Uri> uploadMsg, String acceptType, String capture) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } }); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { try { mSharedPreferences = Prefs.getSharedPreferences(this); } catch (NullPointerException e) { if (BuildConfig.DEBUG) { Log.w("[" + TAG + "]", "mSharedPreferences == NullPointerException :" + e.getMessage()); } } mSharedPreferences.registerOnSharedPreferenceChangeListener(this); if (Prefs.getThemeType(this) == false) { mThemeId = R.style.AppTheme_Light; setTheme(mThemeId); } else { mThemeId = R.style.AppTheme_Dark; setTheme(mThemeId); } // Eula.showDisclaimer( this ); Eula.showEula(this, getApplicationContext()); mActionBar = getActionBar(); if (mActionBar != null) { mActionBar.setDisplayHomeAsUpEnabled(false); mActionBar.setDisplayShowHomeEnabled(true); mActionBar.setDisplayShowTitleEnabled(true); } else { if (BuildConfig.DEBUG) { Log.w("[" + TAG + "]", "mActionBar == null"); } } Bundle extras = getIntent().getExtras(); if (extras != null) { this.setTitle(extras.getString("dir") + " :: " + getString(R.string.app_name)); } else { this.setTitle(" :: " + getString(R.string.app_name)); } super.onCreate(savedInstanceState); setContentView(R.layout.main); tvDisplay = (TextView) findViewById(R.id.tvDisplay); bRename = (Button) findViewById(R.id.bRename); bSettings = (Button) findViewById(R.id.bSettings); bHelp = (Button) findViewById(R.id.bHelp); bExit = (Button) findViewById(R.id.bExit); bRename.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { Intent openAndroidFileBrowser = new Intent("com.scto.filerenamer.ANDROIDFILEBROWSER"); openAndroidFileBrowser.putExtra("what", "renamer"); openAndroidFileBrowser.putExtra("theme", mThemeId); startActivity(openAndroidFileBrowser); } }); bSettings.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { Intent openPreferencesActivity = new Intent("com.scto.filerenamer.PREFERENCESACTIVITY"); startActivity(openPreferencesActivity); } }); bHelp.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { FragmentManager fm = getSupportFragmentManager(); HelpDialog helpDialog = new HelpDialog(); helpDialog.show(fm, "dlg_help"); } }); bExit.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { FragmentManager fm = getSupportFragmentManager(); ExitDialog exitDialog = new ExitDialog(); exitDialog.show(fm, "dlg_exit"); } }); /* ChangeLog cl = new ChangeLog( this ); if( cl.firstRun() ) { cl.getLogDialog().show(); } */ init(); }