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();
}
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);
}
}
}
}
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());
}
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);
}
}
}
}
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));
}
}
Aggregations