Java Code Examples for de.keyboardsurfer.android.widget.crouton.Crouton

The following are top voted examples for showing how to use de.keyboardsurfer.android.widget.crouton.Crouton. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Every-Sample   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        context = this;

        textView = (TextView) findViewById(R.id.textView);
        button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Style style = new Style.Builder()
                        .setImageResource(R.mipmap.ic_launcher)
                        .setTextShadowRadius(10)
                        .setGravity(Gravity.CENTER)
                        .build();
                Crouton.makeText((Activity) context, "data: ", style).show();
//                Crouton.make((Activity) context, LayoutInflater.from(context).inflate(R.layout.crouton_view, null), R.id.content).show();
                requestJSON();


            }
        });
    }
 
Example 2
Project: croperino   File: CropImage.java   View source code 6 votes vote down vote up
public static void showStorageToast(Activity activity, int remaining) {
    String noStorageText = null;
    if (remaining == NO_STORAGE_ERROR) {
        String state = Environment.getExternalStorageState();
        if (state.equals(Environment.MEDIA_CHECKING)) {
            noStorageText = activity.getString(R.string.preparing_card);
        } else {
            noStorageText = activity.getString(R.string.no_storage_card);
        }
    } else if (remaining < 1) {
        noStorageText = activity.getString(R.string.not_enough_space);
    }

    if (noStorageText != null) {
        Crouton.makeText(activity, noStorageText, Style.ALERT).show();
    }
}
 
Example 3
Project: pedefacil   File: PlaceRemoteProvider.java   View source code 6 votes vote down vote up
private Response.ErrorListener createPlaceRequestErrorListener() {
    return new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (BuildConfig.DEBUG) {
                Log.e(YourApplication.LOG_TAG, "PlaceRemoteProvider.onErrorResponse", error.getCause());
            }
            PlaceRemoteProvider.this.mRequestRunning = false ;

            Crouton.makeText(
                    PlaceRemoteProvider.this.mFragment.getActivity(),
                    PlaceRemoteProvider.this.mFragment.getString(R.string.error_retrievingdata),
                    Style.ALERT).show();
        }
    };
}
 
Example 4
Project: pedefacil   File: AirportListFragment.java   View source code 6 votes vote down vote up
private Response.ErrorListener createAirportRequestErrorListener() {
	return new Response.ErrorListener() {
		@Override
		public void onErrorResponse(VolleyError error) {
               if (BuildConfig.DEBUG) {
                   Log.i(YourApplication.LOG_TAG, "AirportListFragment.onErrorResponse");
               }
               AirportListFragment.this.mSwipeRefreshWidget.setRefreshing(false);
			AirportListFragment.this.mRequestRunning = false ;

               if ( !isDetached()) {
                   Crouton.makeText(
                           AirportListFragment.this.getActivity(),
                           getString(R.string.error_retrievingdata),
                           Style.ALERT).show();
               }
		}
	};
}
 
Example 5
Project: PEP---Notes   File: PasswordActivity.java   View source code 6 votes vote down vote up
private void removePassword() {
    unlockAllNotes();
    passwordCheck.setText("");
    password.setText("");
    question.setText("");
    answer.setText("");
    answerCheck.setText("");
    prefs.edit()
            .remove(Constants.PREF_PASSWORD)
            .remove(Constants.PREF_PASSWORD_QUESTION)
            .remove(Constants.PREF_PASSWORD_ANSWER)
            .remove("settings_password_access")
            .apply();
    Crouton.makeText(mActivity, R.string.password_successfully_removed,
            ONStyle.ALERT, crouton_handle).show();
}
 
Example 6
Project: geopin   File: MainMapActivity.java   View source code 6 votes vote down vote up
public void enableLocationCapture(int action){
    expectingLocation = true;
    expectingAction = action;

    int msg_res;
    switch (action) {
        case ACTION_NEW_PIN:  msg_res = R.string.tap_to_pin;
            break;
        case ACTION_GET_ORIGIN:  msg_res = R.string.tap_origin;
            break;
        case ACTION_GET_DESTINATION:  msg_res = R.string.tap_destination;
            break;
        default: msg_res = R.string.error;
            break;
    }

    final Crouton crouton = Crouton.makeText(this, msg_res, new Style.Builder()
            .setBackgroundColorValue(getResources().getColor(R.color.purple)).setHeight(getActionbarHeight()).build(),
            (RelativeLayout)findViewById(R.id.root_layout))
            .setConfiguration(new Configuration.Builder().setDuration(Configuration.DURATION_INFINITE).build());

    crouton.show();
}
 
Example 7
Project: geopin   File: MainMapActivity.java   View source code 6 votes vote down vote up
/**
 * This callback is executed when a click occurs somewhere in map.
 * If there is
 * @param point
 */
@Override
public void onMapClick(LatLng point) {
    if(expectingLocation){
        Crouton.cancelAllCroutons();
        expectingLocation=false;

        if(expectingAction == ACTION_NEW_PIN){
            new EditPinDialog(this, new Place(point.latitude, point.longitude), this).show();
            expectingAction = ACTION_NONE;
        }
        else if(expectingAction == ACTION_GET_ORIGIN){
            new ReverseGeocodingTask(getBaseContext()).execute(point.latitude, point.longitude);
        }
        else if(expectingAction == ACTION_GET_DESTINATION){
            new ReverseGeocodingTask(getBaseContext()).execute(point.latitude, point.longitude);
        }

    }
    else{
        removeSelectedMarker();
    }
}
 
Example 8
Project: geopin   File: MainMapActivity.java   View source code 6 votes vote down vote up
/**
 * This executed when place data are submitted through the dialog.
 */
@Override
public void onSubmit(Place place) {
    if(place!=null && place.isValid()){
        int id = (int) db.insertOrReplacePlace(place);
        if(place.isNew()){
            place.setId(id);
            PlaceMarker pm = PlaceMarker.fromPlace(place);
            mClusterManager.addItem(pm);
            mClusterManager.cluster();
        }
        else{
            removeSelectedMarker();
            reloadItems();

        }
        Crouton.makeText(this, R.string.pin_saved, Style.CONFIRM, (RelativeLayout)findViewById(R.id.root_layout)).show();
    }
}
 
Example 9
Project: shikimori   File: AuthFragment.java   View source code 6 votes vote down vote up
/**
 * Ответ от сервера
 * @param res
 */
@Override
public void onQuerySuccess(ShikiStatusResult res) {
    if(activity == null)
        return;
    activity.getAC().getLoaderController().hide();
    // success auth
    if(res.isSuccess() && activity.getAC().getShikiUser().getId()!=null){
        activity.startActivity(new Intent(activity, MainActivity.class));
        activity.finish();
    // error auth
    } else if(res.isError() && !TextUtils.isEmpty(res.getMsg())){
        Crouton.cancelAllCroutons();
        Crouton.makeText(activity, res.getMsg(), Style.ALERT).show();
    }
}
 
Example 10
Project: shikimori   File: AboutFragment.java   View source code 6 votes vote down vote up
@Override
public void onClick(View v) {
    if (v.getId() == R.id.bLoadApk) {
        if(versionUrl == null){
            Crouton.showText(activity, R.string.url_apk_notfound, Style.ALERT);
            return;
        }
        h.setVisible(pbLoaderApk);
        h.setVisibleGone(bLoadApk);

        permission.checkPermission(PermissionSontroller.WRITE_EXTERNAL_STORAGE, new BasePermissionController.OnRequestPermission() {
            @Override
            public void requestDone(boolean allow) {
                if(allow){
                    new UpdateApp(activity)
                            .setProgresListener(AboutFragment.this)
                            .startLoad(versionUrl);
                } else {
                    h.setVisibleGone(pbLoaderApk);
                    h.setVisible(bLoadApk);
                    h.showMsg(activity, R.string.access_sd);
                }
            }
        });
    }
}
 
Example 11
Project: pronounceit   File: StatisticsActivity.java   View source code 6 votes vote down vote up
@Override
public void onLoginSuccess(final int networkId) {
    ((StatisticsActivity) getActivity()).hideProgress();
    SocialNetwork socialNetwork = mSocialNetworkManager.getSocialNetwork(networkId);
    if (networkId == GooglePlusSocialNetwork.ID
            && !ConnChecker.isOnline(getActivity())) {
        socialNetwork.logout();
        Crouton.makeText(getActivity(),
                getActivity().getString(R.string.wrong_msg), Style.INFO).show();
        return;
    }
    setLoginState(true, networkId);
    socialNetwork.setOnRequestCurrentPersonCompleteListener(this);
    socialNetwork.requestCurrentPerson();
    aQuery.id(R.id.share).enabled(true);
}
 
Example 12
Project: pronounceit   File: GameActivity.java   View source code 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case REQ_CODE_SPEECH_INPUT: {
            if (resultCode == RESULT_OK && data != null) {
                ArrayList<String> result = data
                        .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
                gameHandler.sendResultToHandler(result.get(0));
            } else {
                Crouton.makeText(this, getString(R.string.error_with_input), Style.INFO).show();
                gameHandler.skip();
            }
            break;
        }
    }
}
 
Example 13
Project: pacterapulse-android   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public void onError(Exception exc)
{
	if (progressDialog != null && progressDialog.isShowing())
	{
		progressDialog.dismiss();
	}
	Log.d("AuthResult", exc.getClass().getName() + "   err " + exc.getLocalizedMessage());
	if (exc instanceof AuthenticationCancelError)
	{
		SinglePaneActivity.start(IntroductionFragment.class, this);
		finish();
	}
	else
	{
		/**
		 * If activity destroyed, just do nothing
		 */
		if (!isDestoryed)
		{
			Crouton.makeText(this, R.string.login_error, Style.ALERT).show();
		}
	}

}
 
Example 14
Project: MarketAndroid   File: LoginActivity.java   View source code 6 votes vote down vote up
@Subscribe
public void onAccountResetSent(OnAccountPasswordResetEvent event) {
    Crouton c = getInfoCrouton(getString(R.string.reset_link_sent));
    c.setLifecycleCallback(new LifecycleCallback() {
        @Override
        public void onDisplayed() {

        }

        @Override
        public void onRemoved() {
            finish();
        }
    });
    c.show();
}
 
Example 15
Project: Matrixulcation   File: MatrixActivity.java   View source code 6 votes vote down vote up
/**
 * Set up for "Incorrect Dimensions" Crouton
 *
 **/

public void aPlusB(View view) {
    CreateA_Array();
    CreateB_Array();

    if (matrix_A_array.length == matrix_B_array.length &&
        matrix_A_array[0].length == matrix_B_array[0].length) {
        if (dimension_good) Equal_AplusB();
        if (dimension_good) SetResult();
        if (dimension_good) ShowResultDialog();

    } else {

        Configuration croutonConfiguration = new Configuration.Builder().setDuration(700).build();
        Style croutonStyle = new Style.Builder()
                .setConfiguration(croutonConfiguration)
                .setBackgroundColorValue(getResources().getColor(R.color.crouton_color))
                .build();
        String croutonText = getString(R.string.crouton_incorrect_dimension);

        Crouton.showText(this, croutonText, croutonStyle);
        // Crouton.showText(this, getString(R.string.crouton_incorrect_dimension), Style.ALERT);
    }
}
 
Example 16
Project: Matrixulcation   File: MatrixActivity.java   View source code 6 votes vote down vote up
public void aTimesB(View view) {
    CreateA_Array();
    CreateB_Array();
    if (matrix_A_array[0].length == matrix_B_array.length) {
        Equal_AxB();
        SetResult();
        ShowResultDialog();
    } else {
        Configuration croutonConfiguration = new Configuration.Builder().setDuration(700).build();
        Style croutonStyle = new Style.Builder()
                .setConfiguration(croutonConfiguration)
                .setBackgroundColorValue(getResources().getColor(R.color.crouton_color))
                .build();
        String croutonText = getString(R.string.crouton_incorrect_dimension);
        Crouton.showText(this, croutonText, croutonStyle);        }
}
 
Example 17
Project: Matrixulcation   File: MatrixActivity.java   View source code 6 votes vote down vote up
public void transposeB(View view) {
    CreateB_Array();
    if (matrix_B_array.length < matrix_B_array[0].length ||
        matrix_B_array.length > matrix_B_array[0].length ||
        matrix_B_array.length == matrix_B_array[0].length) {
            Transpose_B();
            SetResult();
            ShowResultDialog();
    } else {
        Configuration croutonConfiguration = new Configuration.Builder().setDuration(700).build();
        Style croutonStyle = new Style.Builder()
                .setConfiguration(croutonConfiguration)
                .setBackgroundColorValue(getResources().getColor(R.color.crouton_color))
                .build();
        String croutonText = getString(R.string.crouton_incorrect_dimension);
        Crouton.showText(this, croutonText, croutonStyle);
    }
}
 
Example 18
Project: Shorcial   File: Response.java   View source code 6 votes vote down vote up
public static void responseEditarPlaya(Activity activity, JSONObject response){
    try {

        if ((response.optString("res") != null) && (response.optString("res").equals("ok"))) {

            Intent intent = new Intent(activity, Home.class);
            intent.putExtra("editaplaya", true);

            // Para eliminar el historial de activities visitadas ya que volvemos al HOME y asi el boton ATRAS no tenga ningun comportamiento, se resetee.
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            activity.startActivity(intent);
            activity.finish();
        } else {
            Crouton.makeText(activity, R.string.error_bbdd, Style.ALERT).show();
        }
    } catch (Exception e) {
        Crouton.makeText(activity, R.string.error_bbdd, Style.ALERT).show();
        System.out.println("FALLO RESPONSEEDITARPLAYA: "+e.getMessage());
        return;
    }
}
 
Example 19
Project: Shorcial   File: Response.java   View source code 6 votes vote down vote up
public static void responsePeticionBorradoPlaya (Activity activity, JSONObject response, ProgressDialog pd){
    try {
        if ((response.optString("res") != null) && (response.optString("res").equals("ok"))) {
            Intent intent = new Intent(activity, Playas.class);
            intent.putExtra("peticionborrado", true);
            pd.dismiss();
            activity.startActivity(intent);
            activity.finish();
        } else {
            Crouton.makeText(activity, R.string.error_bbdd, Style.ALERT).show();
        }
    } catch (Exception e) {
        Crouton.makeText(activity, R.string.error_bbdd, Style.ALERT).show();
        System.out.println("FALLO RESPONSEEDITARPLAYA: "+e.getMessage());
        pd.dismiss();
        return;
    }
}
 
Example 20
Project: Shorcial   File: Response.java   View source code 6 votes vote down vote up
public static void responseMensajeBotellaPlaya(Activity activity, JSONObject response, MensajeBotella mb, ProgressDialog pd){
    try {
        if ((response.optString("res") != null) && (response.optString("res").equals("ok"))) {
            Intent intent = new Intent(activity, Playas.class);
            if (ValidacionPlaya.mensajesBotella == null)
                ValidacionPlaya.mensajesBotella = new ArrayList<MensajeBotella>();
            ValidacionPlaya.mensajesBotella.add(mb);

            intent.putExtra("nuevomensajebotella", true);
            pd.dismiss();
            activity.startActivity(intent);
            activity.finish();
        } else {
            pd.dismiss();
            Crouton.makeText(activity, R.string.error_bbdd, Style.ALERT).show();
        }
    } catch (Exception e) {
        pd.dismiss();
        Crouton.makeText(activity, R.string.error_bbdd, Style.ALERT).show();
        System.out.println("FALLO RESPONSENUEVAPLAYA: "+e.getMessage());
        return;
    }
}
 
Example 21
Project: Shorcial   File: Response.java   View source code 6 votes vote down vote up
public static void responseCheckinPlaya(Activity activity, JSONObject response, ProgressDialog pd){
    try {
        if ((response.optString("res") != null) && (response.optString("res").equals("ok"))){
            pd.dismiss();
            Crouton.makeText(activity, R.string.checkinexito, Style.CONFIRM).show();
        } else if ((response.optString("res") != null) && (response.optString("res").equals("existe"))) {
            Crouton.makeText(activity, R.string.checkinrepetido, Style.INFO).show();
            pd.dismiss();
        } else {
            Crouton.makeText(activity, R.string.error_bbdd, Style.ALERT).show();
            pd.dismiss();
        }
    } catch (Exception e) {
        Crouton.makeText(activity, R.string.error_bbdd, Style.ALERT).show();
        System.out.println("FALLO RESPONSENUEVAPLAYA: "+e.getMessage());
        pd.dismiss();
        return;
    }
}
 
Example 22
Project: Check-Me-In   File: AddSearchActivity.java   View source code 6 votes vote down vote up
@Background
protected void loadMayors(){
    loading();
    try {
        Result<VenueHistoryGroup> userResult = api.mayorships("self");
        String error = userResult.getMeta().getErrorDetail();
        if(error != null && !error.equals("")){
            error(error);
            return;
        }
        setMayors(userResult.getResult().getItems());
    } catch (FoursquareApiException e) {
        Crouton.makeText(this, e.getMessage(), Style.ALERT);
    }
    loadingDone();
}
 
Example 23
Project: Check-Me-In   File: HistoryActivity.java   View source code 6 votes vote down vote up
@Background
protected void loadHistory() {
    loading();
    try {
        Result<CheckinGroup> userResult = api.usersCheckins("self", 20, 0, null, null);
        String error = userResult.getMeta().getErrorDetail();
        if(error != null && !error.equals("")){
            error(error);
            return;
        }
        setCheckins(userResult.getResult().getItems());
    } catch (FoursquareApiException e) {
        Crouton.makeText(this, e.getMessage(), Style.ALERT);
    }
    loadingDone();
}
 
Example 24
Project: Shorcial   File: Utilities.java   View source code 6 votes vote down vote up
public static boolean validarBusqueda(RadioGroup busqueda, EditText nombrePlaya, Activity activity, LatLng porCercania){
    if (busqueda.getCheckedRadioButtonId() == R.id.searchByName){
        if (!nombrePlaya.getText().toString().equals("")) {
            return true;
        } else {
            Crouton.makeText(activity, R.string.error_search_name, Style.ALERT).show();
        }
    } else if (busqueda.getCheckedRadioButtonId() == R.id.searchByAddress){
        if (porCercania != null){
            return true;
        } else {
            Crouton.makeText(activity, R.string.error_search_address, Style.ALERT).show();
        }
    }
    return false;
}
 
Example 25
Project: vendafacil   File: NewProduct.java   View source code 6 votes vote down vote up
private boolean validate() {
	if (code.getText().toString().isEmpty()) {
		Crouton.makeText(NewProduct.this, "Campo código é obrigatório!", Style.ALERT).show();
		return false;
	} else if (name.getText().toString().isEmpty()) {
		Crouton.makeText(NewProduct.this, "Campo nome é obrigatório!", Style.ALERT).show();
		return false;
	} else if (price.getText().toString().isEmpty()) {
		Crouton.makeText(NewProduct.this, "Campo preço é obrigatório!", Style.ALERT).show();
		return false;
	} else if (stock.getText().toString().isEmpty()) {
		Crouton.makeText(NewProduct.this, "Campo estoque é obrigatório!", Style.ALERT).show();
		return false;
	}
	return true;
}
 
Example 26
Project: vtu-life-android   File: VTULifePreferencesActivity.java   View source code 6 votes vote down vote up
public void clearButtonClick(View v) {
	boolean result;
	if (((String) v.getTag()).equals("0")) {
		result = VTULifeDataBase.clearUSNHistory(getApplicationContext());
	} else {
		result = VTULifeDataBase
				.clearClassUSNHistory(getApplicationContext());
	}
	if (result) {
		String text = ((Button) v).getText().toString();
		Crouton.makeText(this,
				getString(R.string.usn_history_cleared, text), Style.INFO)
				.show();
	} else
		Toast.makeText(getApplicationContext(),
				R.string.no_search_history_available, Toast.LENGTH_SHORT)
				.show();
}
 
Example 27
Project: omni-note   File: DetailFragment.java   View source code 6 votes vote down vote up
private void maskUnmask(){
	// Empty password has been set
	if (prefs.getString(Constants.PREF_PASSWORD, null) == null) {
		Crouton.makeText(getActivity(), R.string.password_not_set, ONStyle.WARN).show();
		return;
	}
	// Otherwise masking is performed
	if (noteTmp.isLocked()) {
		Crouton.makeText(getActivity(), R.string.save_note_to_unlock_it, ONStyle.INFO).show();
		getActivity().supportInvalidateOptionsMenu();
	} else {
		Crouton.makeText(getActivity(), R.string.save_note_to_lock_it, ONStyle.INFO).show();
		getActivity().supportInvalidateOptionsMenu();
	}
	noteTmp.setLocked(!noteTmp.isLocked());
	noteTmp.setPasswordChecked(true);			
}
 
Example 28
Project: EvGuide   File: OrganizerEvInfosFragment.java   View source code 6 votes vote down vote up
@Override
protected void onPostExecute(Void result) {
	super.onPostExecute(result);
	// Dismiss the progress dialog
	if (pDialog.isShowing())
		pDialog.dismiss();
	System.out.println("done "  ); 
	Crouton crouton ;
	if (EvmaApp.isError) {
		crouton = Crouton.makeText(getActivity(), "une erreur est survenue lors la mise jour", de.keyboardsurfer.android.widget.crouton.Style.ALERT);
	}else{
		crouton = Crouton.makeText(getActivity(), "L'�v�nement a �t� mise jour avec succ�s", de.keyboardsurfer.android.widget.crouton.Style.CONFIRM);
		
	}
    crouton.show();
	 
	
}
 
Example 29
Project: EvGuide   File: OrderOverview.java   View source code 6 votes vote down vote up
@Override
protected void onPostExecute(Void result) {
	super.onPostExecute(result);
	// Dismiss the progress dialog
	if (pDialog.isShowing())
		pDialog.dismiss();
	Crouton crouton;
	if (EvmaApp.isError) {
		crouton = Crouton.makeText(OrderOverview.this,
				"une erreur est survenue lors la creation du commande",
				de.keyboardsurfer.android.widget.crouton.Style.ALERT);
	} else {

		crouton = Crouton.makeText(OrderOverview.this,
				"Vous y serez! Nous avons Saved une place pour vous.",
				de.keyboardsurfer.android.widget.crouton.Style.CONFIRM);

	}
	crouton.show();
	Intent intx = new Intent(OrderOverview.this,OrderBilletOverview.class);
	intx.putExtra("uuids", CommandeController.UnkUUID);
	intx.putExtra("pack_id",pack_id);
	//evpk
	startActivity(intx);

}
 
Example 30
Project: omni-note   File: ListFragment.java   View source code 6 votes vote down vote up
@Override
public void onPause() {
	super.onPause();

	commitPending();
	stopJingles();
	Crouton.cancelAllCroutons();

	// Clears data structures
	// selectedNotes.clear();
	if (mAdapter != null) {
		mAdapter.clearSelectedItems();
	}
	listView.clearChoices();
	if (mActionMode != null) {
		mActionMode.finish();
	}
}
 
Example 31
Project: omni-note   File: DetailFragment.java   View source code 6 votes vote down vote up
private void startRecording() {
	File f = StorageManager.createNewAttachmentFile(getActivity(), Constants.MIME_TYPE_AUDIO_EXT);
	if (f == null) {
		Crouton.makeText(getActivity(), R.string.error, ONStyle.ALERT).show();
		return;
	}
	recordName = f.getAbsolutePath();
	mRecorder = new MediaRecorder();
	mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
	mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
	mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
	mRecorder.setAudioEncodingBitRate(16);
	mRecorder.setOutputFile(recordName);

	try {
		mRecorder.prepare();
		audioRecordingTimeStart = Calendar.getInstance().getTimeInMillis();
		mRecorder.start();
	} catch (IOException e) {
		Log.e(Constants.TAG, "prepare() failed");
	}
}
 
Example 32
Project: omni-note   File: SketchFragment.java   View source code 6 votes vote down vote up
public void save() {
		
		Bitmap bitmap = mSketchView.getBitmap();		
		if (bitmap != null) {
		
			try {			
				Uri uri = getArguments().getParcelable(MediaStore.EXTRA_OUTPUT);
				File bitmapFile = new File(uri.getPath());
				FileOutputStream out = new FileOutputStream(bitmapFile);
				bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
				out.close();
				if (bitmapFile.exists()) {
//					if (mOnSketchSavedListener != null) {
//						mOnSketchSavedListener.onSketchSaved(uri);
//					}					
					mActivity.sketchUri = uri;
				} else {
					Crouton.makeText(mActivity, R.string.error, ONStyle.ALERT).show();
				}
	
			} catch (Exception e) {
				Log.d(Constants.TAG, "Error writing sketch image data", e);
			}
		}
//		mActivity.getSupportFragmentManager().popBackStack(); 
	}
 
Example 33
Project: omni-note   File: DetailFragment.java   View source code 6 votes vote down vote up
/**
 * Adding shortcut on Home screen
 */
private void addShortcut() {
	Intent shortcutIntent = new Intent(getActivity(), MainActivity.class);
	shortcutIntent.putExtra(Constants.INTENT_KEY, noteTmp.get_id());
	shortcutIntent.setAction(Constants.ACTION_SHORTCUT);
	
	Intent addIntent = new Intent();
	addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
	String shortcutTitle = note.getTitle().length() > 0 ? note.getTitle() : note.getCreationShort(getActivity());
	addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutTitle);
	addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
			Intent.ShortcutIconResource.fromContext(getActivity(), R.drawable.ic_shortcut));
	addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
	
	getActivity().sendBroadcast(addIntent);
	Crouton.makeText(getActivity(), R.string.shortcut_added, ONStyle.INFO).show();		
}
 
Example 34
Project: omni-note   File: ListFragment.java   View source code 6 votes vote down vote up
/**
 * Performs notes permanent deletion after confirmation by the user
 */
private void deleteSelectedNotes2() {
	for (Note note : selectedNotes) {
		mAdapter.remove(note);
		((MainActivity) getActivity()).deleteNote(note);
	}

	// Clears data structures
	mAdapter.clearSelectedItems();
	listView.clearChoices();

	finishActionMode();

	// Refresh view
	// ListView l = (ListView) ((MainActivity)getActivity()).findViewById(R.id.notes_list);
	// l.invalidateViews();

	// If list is empty again Mr Jingles will appear again
	if (mAdapter.getCount() == 0)
		listView.setEmptyView(((MainActivity) getActivity()).findViewById(R.id.empty_list));

	// Advice to user
	Crouton.makeText(((MainActivity) getActivity()), R.string.note_deleted, ONStyle.ALERT).show();
}
 
Example 35
Project: omni-note   File: DetailFragment.java   View source code 6 votes vote down vote up
private void takePhoto() {
	// Checks for camera app available
	Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
	if (!IntentChecker.isAvailable(getActivity(), intent, new String[]{PackageManager.FEATURE_CAMERA})) {
		Crouton.makeText(getActivity(), R.string.feature_not_available_on_this_device, ONStyle.ALERT).show();
		return;
	}	
	// Checks for created file validity
	File f = StorageManager.createNewAttachmentFile(getActivity(), Constants.MIME_TYPE_IMAGE_EXT);
	if (f == null) {
		Crouton.makeText(getActivity(), R.string.error, ONStyle.ALERT).show();
		return;
	}
	// Launches intent
	attachmentUri = Uri.fromFile(f);		
	intent.putExtra(MediaStore.EXTRA_OUTPUT, attachmentUri);
	startActivityForResult(intent, TAKE_PHOTO);
}
 
Example 36
Project: omni-note   File: DetailFragment.java   View source code 6 votes vote down vote up
private void takeVideo() {
	Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
	if (!IntentChecker.isAvailable(getActivity(), takeVideoIntent, new String[]{PackageManager.FEATURE_CAMERA})) {
		Crouton.makeText(getActivity(), R.string.feature_not_available_on_this_device, ONStyle.ALERT).show();
		return;
	}		
	// File is stored in custom ON folder to speedup the attachment 
	if(Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
		File f = StorageManager.createNewAttachmentFile(getActivity(), Constants.MIME_TYPE_VIDEO_EXT);
		if (f == null) {
			Crouton.makeText(getActivity(), R.string.error, ONStyle.ALERT).show();
			return;
		}
		attachmentUri = Uri.fromFile(f);	
		takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, attachmentUri);
	}
	String maxVideoSizeStr = "".equals(prefs.getString("settings_max_video_size", "")) ? "0" : prefs.getString("settings_max_video_size", "");
	int maxVideoSize = Integer.parseInt(maxVideoSizeStr);
	takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, Long.valueOf(maxVideoSize*1024*1024));
    startActivityForResult(takeVideoIntent, TAKE_VIDEO);
}
 
Example 37
Project: omni-note   File: DetailFragment.java   View source code 6 votes vote down vote up
private void takeSketch(Attachment attachment) {
	
	File f = StorageManager.createNewAttachmentFile(getActivity(), Constants.MIME_TYPE_SKETCH_EXT);
	if (f == null) {
		Crouton.makeText(getActivity(), R.string.error, ONStyle.ALERT).show();
		return;
	}
	attachmentUri = Uri.fromFile(f);	
	
	// Forces potrait orientation to this fragment only
	getActivity().setRequestedOrientation(
            ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
	
	// Fragments replacing
	FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
	((MainActivity)getActivity()).animateTransition(transaction, ((MainActivity)getActivity()).TRANSITION_HORIZONTAL);
	SketchFragment mSketchFragment = new SketchFragment();
	Bundle b = new Bundle();
	b.putParcelable(MediaStore.EXTRA_OUTPUT, attachmentUri);
	if (attachment != null) {
		b.putParcelable("base", attachment.getUri());
	}
	mSketchFragment.setArguments(b);
	transaction.replace(R.id.fragment_container, mSketchFragment, ((MainActivity)getActivity()).FRAGMENT_SKETCH_TAG).addToBackStack(((MainActivity)getActivity()).FRAGMENT_DETAIL_TAG).commit();
}
 
Example 38
Project: Android-NFC-Paycard-Reader   File: CroutonUtils.java   View source code 5 votes vote down vote up
/**
 * Method used to display message in an activity
 *
 * @param pActivity
 *            activity
 * @param msg
 * @param success
 */
public static void display(final Activity pActivity, final CharSequence msg, final CoutonColor coutonColor) {

	int color = 0;
	switch (coutonColor) {
	case GREEN:
		color = pActivity.getResources().getColor(R.color.green_success);
		break;
	case ORANGE:
		color = pActivity.getResources().getColor(R.color.orange);
		break;
	case BLACK:
	default:
		color = pActivity.getResources().getColor(R.color.black_error);
	}

	// Remove all previous crouton
	Crouton.cancelAllCroutons();
	// Build style
	Style style = new Style.Builder().setBackgroundColorValue(color) //
			.setPaddingDimensionResId(R.dimen.crouton_padding) //
			.setGravity(Gravity.CENTER) //
			.setTextAppearance(R.style.Crouton_TextApparence) //
			.build();

	Crouton.showText(pActivity, msg, style, R.id.crouton);
}
 
Example 39
Project: Android-NFC-Paycard-Reader   File: HomeActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
	if (mActionBarDrawerToggle.onOptionsItemSelected(item)) {
		Crouton.cancelAllCroutons();
		return true;
	}
	return super.onOptionsItemSelected(item);
}
 
Example 40
Project: croperino   File: CropImage.java   View source code 5 votes vote down vote up
private void saveOutput(Bitmap croppedImage) {
    if (mSaveUri != null) {
        OutputStream outputStream = null;
        try {
            outputStream = mContentResolver.openOutputStream(mSaveUri);
            if (outputStream != null) {
                croppedImage.compress(mOutputFormat, 80, outputStream);
            }
        } catch (IOException ex) {
            Log.e(TAG, "Cannot open file: " + mSaveUri, ex);

            runOnUiThread(new Runnable() {
                public void run() {
                    Crouton.makeText(CropImage.this, "Cannot access file due to app storage encryption, Please use camera or other apps to open gallery", Style.ALERT).show();
                }
            });

            setResult(RESULT_CANCELED);
            finish();
            return;
        } finally {
            CropUtil.closeSilently(outputStream);
        }

        Bundle extras = new Bundle();
        Intent intent = new Intent(mSaveUri.toString());
        intent.putExtras(extras);
        intent.putExtra(IMAGE_PATH, mImagePath);
        intent.putExtra(ORIENTATION_IN_DEGREES, CropUtil.getOrientationInDegree(this));
        setResult(RESULT_OK, intent);
    } else {
        runOnUiThread(new Runnable() {
            public void run() {
                Crouton.makeText(CropImage.this, "Image URL does not exist please try again", Style.ALERT).show();
            }
        });
    }
    croppedImage.recycle();
    finish();
}