de.keyboardsurfer.android.widget.crouton.Style Java Examples

The following examples show how to use de.keyboardsurfer.android.widget.crouton.Style. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomizedProgressActivity.java    From android-oauth-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onLoadFinished(Loader<Result<Credential>> loader,
        Result<Credential> result) {
    if (loader.getId() == LOADER_GET_TOKEN) {
        message.setText(result.success ? result.data.getAccessToken() : "");
    } else {
        message.setText("");
    }
    if (result.success) {
        if (loader.getId() == LOADER_GET_TOKEN) {
            setButtonText(R.string.delete_token);
        } else {
            setButtonText(R.string.get_token);
        }
    } else {
        setButtonText(R.string.get_token);
        Crouton.makeText(getActivity(), result.errorMessage, Style.ALERT).show();
    }
    getActivity().setProgressBarIndeterminateVisibility(false);
    button.setEnabled(true);
}
 
Example #2
Source File: LoadableDecorator.java    From android-oauth-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onLoadFinished(Loader<Result<T>> loader, Result<T> result) {
    mCallbacks.onLoadFinished(loader, result);
    mActive.delete(loader.getId());
    if (mLoaderId == loader.getId()) {
        if (mListFragment.isResumed()) {
            mListFragment.setListShown(true);
        } else {
            mListFragment.setListShownNoAnimation(true);
        }
        if (!result.success) {
            Crouton.makeText(mListFragment.getActivity(),
                    result.errorMessage, Style.ALERT).show();
            LOGGER.log(Level.WARNING, "error: " + result.errorMessage, result.exception);
        }
        mListFragment.setEmptyText(mListFragment.getString(R.string.empty));
    }
    updateWindowIndeterminateProgress();
}
 
Example #3
Source File: SimpleOAuth10aActivity.java    From android-oauth-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onLoadFinished(Loader<Result<Credential>> loader,
        Result<Credential> result) {
    if (loader.getId() == LOADER_GET_TOKEN) {
        message.setText(result.success ? result.data.getAccessToken() : "");
    } else {
        message.setText("");
    }
    if (result.success) {
        if (loader.getId() == LOADER_GET_TOKEN) {
            setButtonText(R.string.delete_token);
        } else {
            setButtonText(R.string.get_token);
        }
    } else {
        setButtonText(R.string.get_token);
        Crouton.makeText(getActivity(), result.errorMessage, Style.ALERT).show();
    }
    getActivity().setProgressBarIndeterminateVisibility(false);
    button.setEnabled(true);
}
 
Example #4
Source File: SimpleOAuth2ExplicitActivity.java    From android-oauth-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onLoadFinished(Loader<Result<Credential>> loader,
        Result<Credential> result) {
    if (loader.getId() == LOADER_GET_TOKEN) {
        message.setText(result.success ? result.data.getAccessToken() : "");
    } else {
        message.setText("");
    }
    if (result.success) {
        if (loader.getId() == LOADER_GET_TOKEN) {
            setButtonText(R.string.delete_token);
        } else {
            setButtonText(R.string.get_token);
        }
    } else {
        setButtonText(R.string.get_token);
        Crouton.makeText(getActivity(), result.errorMessage, Style.ALERT).show();
    }
    getActivity().setProgressBarIndeterminateVisibility(false);
    button.setEnabled(true);
}
 
Example #5
Source File: StravaActivity.java    From android-oauth-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onLoadFinished(Loader<AsyncResourceLoader.Result<Credential>> loader,
                           AsyncResourceLoader.Result<Credential> result) {
    if (loader.getId() == LOADER_GET_TOKEN) {
        message.setText(result.success ? result.data.getAccessToken() : "");
    } else {
        message.setText("");
    }
    if (result.success) {
        if (loader.getId() == LOADER_GET_TOKEN) {
            setButtonText(R.string.delete_token);
        } else {
            setButtonText(R.string.get_token);
        }
    } else {
        setButtonText(R.string.get_token);
        Crouton.makeText(getActivity(), result.errorMessage, Style.ALERT).show();
    }
    getActivity().setProgressBarIndeterminateVisibility(false);
    button.setEnabled(true);
}
 
Example #6
Source File: SimpleOAuth2ImplicitActivity.java    From android-oauth-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onLoadFinished(Loader<Result<Credential>> loader,
        Result<Credential> result) {
    if (loader.getId() == LOADER_GET_TOKEN) {
        message.setText(result.success ? result.data.getAccessToken() : "");
    } else {
        message.setText("");
    }
    if (result.success) {
        if (loader.getId() == LOADER_GET_TOKEN) {
            setButtonText(R.string.delete_token);
        } else {
            setButtonText(R.string.get_token);
        }
    } else {
        setButtonText(R.string.get_token);
        Crouton.makeText(getActivity(), result.errorMessage, Style.ALERT).show();
    }
    getActivity().setProgressBarIndeterminateVisibility(false);
    button.setEnabled(true);
}
 
Example #7
Source File: QuickReturnBaseActivity.java    From QuickReturn with Apache License 2.0 6 votes vote down vote up
private void showCrouton(int colorRes, int messageRes) {
        Style croutonStyle = new Style.Builder()
                .setHeight(QuickReturnUtils.dp2px(this, 50))
//                                .setTextColor(getResources().getColor(R.color.white))
                .setGravity(Gravity.CENTER)
                .setBackgroundColor(colorRes)
                .build();

        Crouton.makeText(this, messageRes, croutonStyle)
                .setConfiguration(new Configuration.Builder()
                        .setDuration(Configuration.DURATION_SHORT)
                        .setInAnimation(R.anim.crouton_in_delayed)
                        .setOutAnimation(R.anim.crouton_out)
                        .build())
                .show();
    }
 
Example #8
Source File: QuickReturnBaseActivity.java    From QuickReturn with Apache License 2.0 6 votes vote down vote up
private void showCrouton(int colorRes, String message) {
        Style croutonStyle = new Style.Builder()
                .setHeight(QuickReturnUtils.dp2px(this, 50))
//                                .setTextColor(getResources().getColor(R.color.white))
                .setGravity(Gravity.CENTER)
                .setBackgroundColor(colorRes)
                .build();

        Crouton.makeText(this, message, croutonStyle)
                .setConfiguration(new Configuration.Builder()
                        .setDuration(Configuration.DURATION_SHORT)
                        .setInAnimation(R.anim.crouton_in_delayed)
                        .setOutAnimation(R.anim.crouton_out)
                        .build())
                .show();
    }
 
Example #9
Source File: SimpleOAuth2ExplicitActivity.java    From android-oauth-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onLoadFinished(Loader<Result<Credential>> loader,
        Result<Credential> result) {
    if (loader.getId() == LOADER_GET_TOKEN) {
        message.setText(result.success ? result.data.getAccessToken() : "");
    } else {
        message.setText("");
    }
    if (result.success) {
        if (loader.getId() == LOADER_GET_TOKEN) {
            setButtonText(R.string.delete_token);
        } else {
            setButtonText(R.string.get_token);
        }
    } else {
        setButtonText(R.string.get_token);
        Crouton.makeText(getActivity(), result.errorMessage, Style.ALERT).show();
    }
    getActivity().setProgressBarIndeterminateVisibility(false);
    button.setEnabled(true);
}
 
Example #10
Source File: Notificator.java    From SmileEssence with MIT License 6 votes vote down vote up
private Style getStyle() {
    Configuration.Builder conf = new Configuration.Builder();
    conf.setDuration(DURATION);
    Style.Builder style = new Style.Builder();
    style.setConfiguration(conf.build());
    switch (type) {
        case INFO: {
            style.setBackgroundColorValue(Style.holoBlueLight);
            break;
        }
        case ALERT: {
            style.setBackgroundColorValue(Style.holoRedLight);
            break;
        }
    }
    return style.build();
}
 
Example #11
Source File: HomeActivity.java    From line-sdk-starter-android with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.login_button)
public void login() {
	LineAuthManager authManager = LineSdkContextManager.getSdkContext().getAuthManager();
	authManager.login(this).addFutureListener(
			new LineLoginFutureListener() {
				@Override
				public void loginComplete(LineLoginFuture future) {
					switch (future.getProgress()) {
					case SUCCESS:
						SharedPreferences settings = getSharedPreferences("lineauth", MODE_PRIVATE);
						// Store credentials to, for example, send in a webview activity to a server.
						// Developers should not have to worry about these values if they are only calling
						// APIs from the Android application.
						settings.edit()
								.putString("mid", future.getAccessToken().mid)
								.putString("accesstoken", future.getAccessToken().accessToken)
								.putString("refreshtoken", future.getAccessToken().refreshToken)
								.putLong("expire", future.getAccessToken().expire)
								.apply();
						displayCroutonOnMainThread("Logged in!", Style.INFO);
						logger.info("Login success!");
						break;
					case CANCELED:
						displayCroutonOnMainThread("Don't cancel login!", Style.ALERT);
						logger.info("Login canceled!");
						break;
					default:
						displayCroutonOnMainThread("An error occurred. Please try again.", Style.ALERT);
						logger.info("Login error!");
						break;
					}
				}
			});
}
 
Example #12
Source File: UsageTips.java    From glimmr with Apache License 2.0 5 votes vote down vote up
/**
 * Show a usage tip via an INFO style crouton.  Tips are shown once per session unless the
 * force param is true.
 * @param activity
 * @param tip
 * @param force
 */
public void show(Activity activity, String tip, boolean force) {
    SharedPreferences defaultSharedPrefs =
            PreferenceManager.getDefaultSharedPreferences(activity);
    boolean enable = defaultSharedPrefs.getBoolean(Constants.KEY_ENABLE_USAGE_TIPS, false);
    if (!enable) {
        if (BuildConfig.DEBUG) Log.d(TAG, "Usage tips disabled in preferences");
        return;
    }
    if (!force && !mShownTips.contains(tip)) {
        Crouton.cancelAllCroutons();
        Crouton.makeText(activity, tip, Style.INFO).show();
        mShownTips.add(tip);
    }
}
 
Example #13
Source File: ConfigurationActivity.java    From Noyze with Apache License 2.0 5 votes vote down vote up
private void openNotification() {
    Intent notifications = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
    try {
        startActivity(notifications);
    } catch (ActivityNotFoundException e) {
        LOGE(TAG, "Error opening NotificationListener.", e);
        Crouton.showText(getActivity(), R.string.accessibility_error, Style.ALERT);
    }
}
 
Example #14
Source File: ConfigurationActivity.java    From Noyze with Apache License 2.0 5 votes vote down vote up
private void openAccessibility() {
    Intent accessibility = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
    try {
        startActivity(accessibility);
    } catch (ActivityNotFoundException e) {
        LOGE(TAG, "Error opening Accessibility.", e);
        Crouton.showText(getActivity(), R.string.accessibility_error, Style.ALERT);
    }
}
 
Example #15
Source File: ConfigurationActivity.java    From Noyze with Apache License 2.0 5 votes vote down vote up
private void launchGooglePlus() {
    Intent google = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.google_plus_url)));
    if (google.resolveActivity(getPackageManager()) != null) {
        startActivity(google);
    } else {
        Crouton.showText(this, R.string.url_error, Style.ALERT);
    }
}
 
Example #16
Source File: ConfigurationActivity.java    From Noyze with Apache License 2.0 5 votes vote down vote up
private void openNotification() {
    Intent notifications = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
    try {
        startActivity(notifications);
    } catch (ActivityNotFoundException e) {
        LOGE(TAG, "Error opening NotificationListener.", e);
        Crouton.showText(getActivity(), R.string.accessibility_error, Style.ALERT);
    }
}
 
Example #17
Source File: ConfigurationActivity.java    From Noyze with Apache License 2.0 5 votes vote down vote up
private void openAccessibility() {
    Intent accessibility = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
    try {
        startActivity(accessibility);
    } catch (ActivityNotFoundException e) {
        LOGE(TAG, "Error opening Accessibility.", e);
        Crouton.showText(getActivity(), R.string.accessibility_error, Style.ALERT);
    }
}
 
Example #18
Source File: ConfigurationActivity.java    From Noyze with Apache License 2.0 5 votes vote down vote up
private void launchGooglePlus() {
    Intent google = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.google_plus_url)));
    if (google.resolveActivity(getPackageManager()) != null) {
        startActivity(google);
    } else {
        Crouton.showText(this, R.string.url_error, Style.ALERT);
    }
}
 
Example #19
Source File: HomeActivity.java    From line-sdk-starter-android with Apache License 2.0 5 votes vote down vote up
private void displayCroutonOnMainThread(final String text, final Style style) {
	final Activity activity = this;
	mainThread.post(new Runnable() {
		@Override
		public void run() {
			Crouton.makeText(activity, text, style).show();
		}
	});
}
 
Example #20
Source File: AmuleRemoteApplication.java    From aMuleRemote with GNU General Public License v3.0 5 votes vote down vote up
public void notifyErrorOnGUI(CharSequence errorText) {
    if (mOnTopActivity != null) {
        Crouton.makeText(mOnTopActivity, errorText, Style.ALERT).show();
    } else {
        Toast.makeText(this, "aMuleRemote: " + errorText, Toast.LENGTH_LONG).show();
    }
}
 
Example #21
Source File: AddToGroupDialogFragment.java    From glimmr with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    mLayout = (LinearLayout) inflater.inflate(
            R.layout.add_to_group_fragment, container, false);

    mTitleView = (TextView) mLayout.findViewById(R.id.titleText);
    mTextUtils.setFont(mTitleView, TextUtils.FONT_ROBOTOBOLD);
    mProgressBar =
        (ProgressBar) mLayout.findViewById(R.id.progressIndicator);
    mProgressBar.setVisibility(View.VISIBLE);

    /* Nested fragments have to be added this way, not from xml */
    FragmentTransaction ft = getChildFragmentManager().beginTransaction();
    final boolean retainInstance = false;
    final PhotoStreamGridFragment frag =
        PhotoStreamGridFragment.newInstance(mOAuth.getUser(),
                retainInstance, ListView.CHOICE_MODE_MULTIPLE);
    ft.replace(R.id.photoStreamFragment, frag);
    ft.commit();

    /* When add button is clicked, get selected ids and add to queue */
    mLayout.findViewById(R.id.buttonAddToGroup).setOnClickListener(
            new View.OnClickListener() {
                public void onClick(View v) {
                    List<Photo> selectedPhotos = frag.getSelectedPhotos();
                    if (mRemaining < 0 || selectedPhotos.size() == 0) {
                        Log.e(TAG, "None or too many items selected");
                        return;
                    }
                    for (Photo photo : selectedPhotos) {
                        mQueue.add(new AddItemToGroupTask(mGroup.getId(),
                                photo.getId(), mOAuth));
                    }
                    mActivity.startService(new Intent(mActivity,
                                AddToGroupTaskQueueService.class));
                    dismiss();
                    Crouton.makeText(mActivity,
                        R.string.photos_will_be_added,
                        Style.CONFIRM).show();
                }
            });

    return mLayout;
}
 
Example #22
Source File: AddToGroupDialogFragment.java    From glimmr with Apache License 2.0 4 votes vote down vote up
@Override
public void onGroupInfoReady(Group group, Exception e) {
    if (BuildConfig.DEBUG) Log.d(TAG, "onGroupInfoReady");
    mProgressBar.setVisibility(View.GONE);

    if (FlickrHelper.getInstance().handleFlickrUnavailable(mActivity, e)) {
        return;
    }

    /* If trouble getting group info we can't proceed */
    if (group == null) {
        dismiss();
        Crouton.makeText(mActivity, R.string.group_info_fetch_error,
            Style.ALERT).show();
        return;
    }

    /* Get group throttle info */
    Throttle throttle = group.getThrottle();
    if ("none".equals(throttle.getMode())) {
        mCount = ADD_AT_A_TIME;
        mRemaining = ADD_AT_A_TIME;
    } else {
        mRemaining = throttle.getRemaining();
        mCount = throttle.getCount();
    }

    if (mRemaining == 0) {
        dismiss();
        Crouton.makeText(mActivity, R.string.group_limit_reached,
            Style.INFO).show();
        return;
    }

    String title = String.format("%s/%s %s", mRemaining, mCount,
            getString(R.string.remaining));
    mTitleView.setText(title);

    if (BuildConfig.DEBUG) {
        Log.d(TAG, String.format("Remaining: %d, Mode: %s, Count: %d",
                throttle.getRemaining(), throttle.getMode(),
                throttle.getCount()));
    }
}
 
Example #23
Source File: AddToPhotosetDialogFragment.java    From glimmr with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    mLayout = (LinearLayout) inflater.inflate(
            R.layout.add_to_photoset_fragment, container, false);

    TextView titleTextView = (TextView)
            mLayout.findViewById(R.id.titleText);
    titleTextView.setText(R.string.add_photos);
    mTextUtils.setFont(titleTextView, TextUtils.FONT_ROBOTOBOLD);
    //ProgressBar progressBar = (ProgressBar)
    //        mLayout.findViewById(R.id.progressIndicator);

    /* Nested fragments have to be added this way, not from xml */
    FragmentTransaction ft = getChildFragmentManager().beginTransaction();
    final boolean retainInstance = false;
    final PhotoStreamGridFragment frag =
        PhotoStreamGridFragment.newInstance(mOAuth.getUser(),
                retainInstance, ListView.CHOICE_MODE_MULTIPLE);
    ft.replace(R.id.photoStreamFragment, frag);
    ft.commit();

    /* When add button is clicked, get selected ids and add to queue */
    mLayout.findViewById(R.id.buttonAddToPhotoset).setOnClickListener(
            new View.OnClickListener() {
                public void onClick(View v) {
                    List<Photo> selectedPhotos = frag.getSelectedPhotos();
                    for (Photo photo : selectedPhotos) {
                        mQueue.add(new AddItemToPhotosetTask(
                                mPhotoset.getId(), photo.getId(), mOAuth));
                    }
                    mActivity.startService(new Intent(mActivity,
                                AddToPhotosetTaskQueueService.class));
                    dismiss();
                    Crouton.makeText(mActivity,
                        R.string.photos_will_be_added,
                        Style.CONFIRM).show();
                }
            });

    return mLayout;
}
 
Example #24
Source File: MainActivity.java    From discreet-app-rate with Apache License 2.0 4 votes vote down vote up
private void updateValueDisplay() {
    currentCount.setText(String.valueOf(settings.getInt(PreferencesConstants.KEY_COUNT, 0)));
    hasBeenClicked.setText(String.valueOf(settings.getBoolean(PreferencesConstants.KEY_CLICKED, false)));
    isElpased.setText(String.valueOf(settings.getBoolean(PreferencesConstants.KEY_ELAPSED_TIME, false)));
    monitoredTime.setText(String.valueOf(settings.getLong(PreferencesConstants.KEY_MONITOR_TOTAL, 0L) / 1000) + " seconds");
    long lastCrashTime = settings.getLong(PreferencesConstants.KEY_LAST_CRASH, 0L);
    if (lastCrashTime == 0L) {
        lastCrash.setText("Never");
    } else {
        lastCrash.setText(String.valueOf((System.currentTimeMillis() - lastCrashTime) / 1000) + " seconds ago");
    }

    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Process process = Runtime.getRuntime().exec("logcat -d");
                BufferedReader bufferedReader = new BufferedReader(
                        new InputStreamReader(process.getInputStream()));

                final StringBuilder log = new StringBuilder();
                String line = "";
                while ((line = bufferedReader.readLine()) != null) {
                    if (line.contains("DicreetAppRate")) {
                        int index = line.indexOf(":");

                        if (!TextUtils.isEmpty(log.toString())) log.append("\n");
                        log.append(line.substring(index + 1));

                    }
                }


                final Style style = new Style.Builder(Style.INFO).setConfiguration(new Configuration.Builder()
                        .setDuration(Configuration.DURATION_LONG)
                        .build()).build();

                runOnUiThread(new Runnable() {
                    public void run() {
                        if (!TextUtils.isEmpty(log.toString())) {
                            Crouton.clearCroutonsForActivity(MainActivity.this);
                            Crouton.makeText(MainActivity.this, log.toString(), style).show();

                        }
                    }
                });
                Runtime.getRuntime().exec("logcat -c");

            } catch (IOException e) {
            }
        }
    }).start();
}
 
Example #25
Source File: CroutonSampleActivity.java    From android-opensource-library-56 with Apache License 2.0 4 votes vote down vote up
private void alertStyle() {
    Crouton.makeText(this, "Hello Crouton!!", Style.ALERT).show();
}
 
Example #26
Source File: CroutonSampleActivity.java    From android-opensource-library-56 with Apache License 2.0 4 votes vote down vote up
private void infoStyle() {
    Crouton.makeText(this, "Hello Crouton!!", Style.INFO).show();
}
 
Example #27
Source File: CroutonSampleActivity.java    From android-opensource-library-56 with Apache License 2.0 4 votes vote down vote up
private void confirmStyle() {
    Crouton.makeText(this, "Hello Crouton!!", Style.CONFIRM).show();
}
 
Example #28
Source File: MainActivity.java    From HeartbeatFixerForGCM with Apache License 2.0 4 votes vote down vote up
private void toastHeartbeatFixerState(boolean enabled) {
    final int msgResId = enabled ? R.string.toast_heartbeat_fixer_on : R.string.toast_heartbeat_fixer_off;
    Crouton.makeText(MainActivity.this, msgResId, Style.INFO, R.id.container).show();
}