use of android.annotation.TargetApi in project materialistic by hidroh.
the class BaseListActivityLandTest method testSelectItemOpenStory.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testSelectItemOpenStory() {
assertThat(activity.findViewById(R.id.empty_selection)).isVisible();
activity.onItemSelected(new TestHnItem(1L) {
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
@Override
public String getUrl() {
return "http://example.com";
}
});
assertThat(activity.findViewById(R.id.empty_selection)).isNotVisible();
assertStoryMode();
shadowOf(activity).clickMenuItem(R.id.menu_share);
PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
assertNotNull(popupMenu);
assertThat(popupMenu.getMenu()).hasItem(R.id.menu_article).hasItem(R.id.menu_comments);
shadowOf(activity).clickMenuItem(R.id.menu_external);
assertNotNull(ShadowPopupMenu.getLatestPopupMenu());
}
use of android.annotation.TargetApi in project nmid-headline by miao1007.
the class PhotoViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_photo_view);
ButterKnife.inject(this);
Intent intent = getIntent();
image_full = intent.getStringExtra(IMAGE_SIEZ_FULL);
image_previous = intent.getStringExtra(IMAGE_SIEZ_PREVIOUS);
Picasso.with(this).load(image_full).into(mIvPhotoView);
// Set up an instance of SystemUiHider to control the system UI for
// this activity.
mSystemUiHider = SystemUiHider.getInstance(this, mFullscreenContentControls, HIDER_FLAGS);
mSystemUiHider.setup();
mSystemUiHider.setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
// Cached values.
int mControlsHeight;
int mShortAnimTime;
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public void onVisibilityChange(boolean visible) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
// screen.
if (mControlsHeight == 0) {
mControlsHeight = mFullscreenContentControls.getHeight();
}
if (mShortAnimTime == 0) {
mShortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
}
mFullscreenContentControls.animate().translationY(visible ? 0 : mControlsHeight).setDuration(mShortAnimTime);
} else {
// If the ViewPropertyAnimator APIs aren't
// available, simply show or hide the in-layout UI
// controls.
mFullscreenContentControls.setVisibility(visible ? View.VISIBLE : View.GONE);
}
if (visible && AUTO_HIDE) {
// Schedule a hide().
delayedHide(AUTO_HIDE_DELAY_MILLIS);
}
}
});
// Set up the user interaction to manually show or hide the system UI.
mFullscreenContentControls.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (TOGGLE_ON_CLICK) {
mSystemUiHider.toggle();
} else {
mSystemUiHider.show();
}
}
});
// Upon interacting with UI controls, delay any scheduled hide()
// operations to prevent the jarring behavior of controls going away
// while interacting with the UI.
findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);
}
use of android.annotation.TargetApi in project android-oss by kickstarter.
the class StatusBarUtils method apply.
@SuppressWarnings("InlinedApi")
@TargetApi(21)
public static void apply(@NonNull final BaseActivity activity, @ColorInt final int color) {
if (!ApiCapabilities.canSetStatusBarColor()) {
return;
}
final Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(color);
}
use of android.annotation.TargetApi in project Signal-Android by WhisperSystems.
the class IncomingRinger method shouldVibrateNew.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private boolean shouldVibrateNew(Context context, int ringerMode) {
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
if (vibrator == null || !vibrator.hasVibrator()) {
return false;
}
boolean vibrateWhenRinging = Settings.System.getInt(context.getContentResolver(), "vibrate_when_ringing", 0) != 0;
if (vibrateWhenRinging) {
return ringerMode != AudioManager.RINGER_MODE_SILENT;
} else {
return ringerMode == AudioManager.RINGER_MODE_VIBRATE;
}
}
use of android.annotation.TargetApi in project SeriesGuide by UweTrottmann.
the class AutoBackupFragment method onActivityResult.
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != Activity.RESULT_OK || !isAdded() || data == null) {
return;
}
if (requestCode == REQUEST_CODE_SHOWS_EXPORT_URI || requestCode == REQUEST_CODE_LISTS_EXPORT_URI || requestCode == REQUEST_CODE_MOVIES_EXPORT_URI) {
Uri uri = data.getData();
// persist read and write permission for this URI across device reboots
try {
getContext().getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
} catch (SecurityException e) {
Timber.e(e, "Could not persist r/w permission for backup file URI.");
}
if (requestCode == REQUEST_CODE_SHOWS_EXPORT_URI) {
BackupSettings.storeFileUri(getContext(), BackupSettings.KEY_AUTO_BACKUP_SHOWS_EXPORT_URI, uri);
} else if (requestCode == REQUEST_CODE_LISTS_EXPORT_URI) {
BackupSettings.storeFileUri(getContext(), BackupSettings.KEY_AUTO_BACKUP_LISTS_EXPORT_URI, uri);
} else {
BackupSettings.storeFileUri(getContext(), BackupSettings.KEY_AUTO_BACKUP_MOVIES_EXPORT_URI, uri);
}
updateFileViews();
}
}
Aggregations