Search in sources :

Example 86 with Activity

use of android.app.Activity in project android_frameworks_base by ResurrectionRemix.

the class VersionDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();
    // Need to use our library's resources for showing the dialog.
    final Context context;
    try {
        context = activity.createPackageContext(SharedLibraryMain.LIBRARY_PACKAGE, 0);
    } catch (PackageManager.NameNotFoundException e) {
        throw new IllegalStateException("Can't find my package!", e);
    }
    final Resources res = context.getResources();
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(res.getText(R.string.upgrade_title));
    builder.setMessage(res.getString(R.string.upgrade_body, activity.getApplicationInfo().loadLabel(activity.getPackageManager()), context.getApplicationInfo().loadLabel(context.getPackageManager())));
    builder.setPositiveButton(res.getText(R.string.upgrade_button), new Dialog.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Launch play store into the details of our app.
            try {
                activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + SharedLibraryMain.LIBRARY_PACKAGE)));
            } catch (android.content.ActivityNotFoundException anfe) {
                activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + SharedLibraryMain.LIBRARY_PACKAGE)));
            }
        }
    });
    return builder.create();
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Activity(android.app.Activity) Intent(android.content.Intent) PackageManager(android.content.pm.PackageManager) AlertDialog(android.app.AlertDialog) Dialog(android.app.Dialog) Resources(android.content.res.Resources)

Example 87 with Activity

use of android.app.Activity in project android_frameworks_base by ResurrectionRemix.

the class SwipeDismissLayout method updateSwiping.

private void updateSwiping(MotionEvent ev) {
    boolean oldSwiping = mSwiping;
    if (!mSwiping) {
        float deltaX = ev.getRawX() - mDownX;
        float deltaY = ev.getRawY() - mDownY;
        if ((deltaX * deltaX) + (deltaY * deltaY) > mSlop * mSlop) {
            mSwiping = deltaX > mSlop * 2 && Math.abs(deltaY) < Math.abs(deltaX);
        } else {
            mSwiping = false;
        }
    }
    if (mSwiping && !oldSwiping) {
        // Swiping has started
        if (!mIsWindowNativelyTranslucent) {
            Activity activity = findActivity();
            if (activity != null) {
                mActivityTranslucencyConverted = activity.convertToTranslucent(null, null);
            }
        }
    }
}
Also used : Activity(android.app.Activity)

Example 88 with Activity

use of android.app.Activity in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InstrumentedFragment method onPause.

@Override
public void onPause() {
    Activity activity = getActivity();
    if (mReceiver != null && activity != null) {
        SurveyFeatureProvider.unregisterReceiver(activity, mReceiver);
        mReceiver = null;
    }
    super.onPause();
    MetricsLogger.hidden(getActivity(), getMetricsCategory());
}
Also used : Activity(android.app.Activity)

Example 89 with Activity

use of android.app.Activity in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InstrumentedFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    MetricsLogger.visible(getActivity(), getMetricsCategory());
    Activity activity = getActivity();
    // guard against the activity not existing yet or the feature being disabled
    if (activity != null) {
        SurveyFeatureProvider provider = FeatureFactory.getFactory(activity).getSurveyFeatureProvider(activity);
        if (provider != null) {
            // Try to download a survey if there is none available, show the survey otherwise
            String id = provider.getSurveyId(activity, getClass().getSimpleName());
            if (provider.getSurveyExpirationDate(activity, id) <= -1) {
                // register the receiver to show the survey on completion.
                mReceiver = provider.createAndRegisterReceiver(activity);
                provider.downloadSurvey(activity, id, null);
            } else {
                provider.showSurveyIfAvailable(activity, id);
            }
        }
    }
}
Also used : SurveyFeatureProvider(com.android.settings.overlay.SurveyFeatureProvider) Activity(android.app.Activity)

Example 90 with Activity

use of android.app.Activity in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ManageAccountsSettings method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final Activity activity = getActivity();
    final View view = getView();
    mErrorInfoView = (TextView) view.findViewById(R.id.sync_settings_error_info);
    mErrorInfoView.setVisibility(View.GONE);
    mAuthorities = activity.getIntent().getStringArrayExtra(AUTHORITIES_FILTER_KEY);
    Bundle args = getArguments();
    if (args != null && args.containsKey(KEY_ACCOUNT_LABEL)) {
        getActivity().setTitle(args.getString(KEY_ACCOUNT_LABEL));
    }
}
Also used : Bundle(android.os.Bundle) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) View(android.view.View) TextView(android.widget.TextView)

Aggregations

Activity (android.app.Activity)3220 Intent (android.content.Intent)612 View (android.view.View)535 Test (org.junit.Test)456 TextView (android.widget.TextView)263 Context (android.content.Context)220 ArrayList (java.util.ArrayList)201 Bundle (android.os.Bundle)197 DialogInterface (android.content.DialogInterface)167 SettingsActivity (com.android.settings.SettingsActivity)167 ViewGroup (android.view.ViewGroup)133 ImageView (android.widget.ImageView)116 AlertDialog (android.app.AlertDialog)109 LayoutInflater (android.view.LayoutInflater)109 Preference (android.support.v7.preference.Preference)83 PackageManager (android.content.pm.PackageManager)76 Uri (android.net.Uri)76 EditText (android.widget.EditText)72 ComponentName (android.content.ComponentName)71 Handler (android.os.Handler)71