Search in sources :

Example 16 with TargetApi

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());
}
Also used : NonNull(android.support.annotation.NonNull) TestHnItem(io.github.hidroh.materialistic.data.TestHnItem) PopupMenu(android.widget.PopupMenu) ShadowPopupMenu(org.robolectric.shadows.ShadowPopupMenu) Test(org.junit.Test) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) TargetApi(android.annotation.TargetApi)

Example 17 with TargetApi

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);
}
Also used : SystemUiHider(cn.edu.cqupt.nmid.headline.ui.activity.util.SystemUiHider) Intent(android.content.Intent) TargetApi(android.annotation.TargetApi) InjectView(butterknife.InjectView) PhotoView(uk.co.senab.photoview.PhotoView) View(android.view.View)

Example 18 with TargetApi

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);
}
Also used : Window(android.view.Window) TargetApi(android.annotation.TargetApi)

Example 19 with TargetApi

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;
    }
}
Also used : Vibrator(android.os.Vibrator) TargetApi(android.annotation.TargetApi)

Example 20 with TargetApi

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();
    }
}
Also used : Uri(android.net.Uri) TargetApi(android.annotation.TargetApi)

Aggregations

TargetApi (android.annotation.TargetApi)1367 Intent (android.content.Intent)153 View (android.view.View)148 Test (org.junit.Test)119 SuppressLint (android.annotation.SuppressLint)115 Uri (android.net.Uri)70 ArrayList (java.util.ArrayList)68 Animator (android.animation.Animator)67 Point (android.graphics.Point)64 Window (android.view.Window)56 TextView (android.widget.TextView)56 IOException (java.io.IOException)56 ViewGroup (android.view.ViewGroup)54 Matchers.anyString (org.mockito.Matchers.anyString)53 SharedPreferences (android.content.SharedPreferences)44 File (java.io.File)44 Field (java.lang.reflect.Field)44 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)43 Bitmap (android.graphics.Bitmap)43 ImageView (android.widget.ImageView)40