com.hippo.yorozuya.ViewUtils Java Examples

The following examples show how to use com.hippo.yorozuya.ViewUtils. 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: GalleryDetailScene.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
public void setDialog(@Nullable Dialog dialog, String url) {
    mDialog = dialog;
    mProgressView = (ProgressView) ViewUtils.$$(dialog, R.id.progress);
    mErrorText = (TextView) ViewUtils.$$(dialog, R.id.text);
    mListView = (ListView) ViewUtils.$$(dialog, R.id.list_view);
    mListView.setOnItemClickListener(this);

    Context context = getContext2();
    if (context != null) {
        if (mTorrentList == null) {
            mErrorText.setVisibility(View.GONE);
            mListView.setVisibility(View.GONE);
            mRequest = new EhRequest().setMethod(EhClient.METHOD_GET_TORRENT_LIST)
                    .setArgs(url, mGid, mToken)
                    .setCallback(this);
            EhApplication.getEhClient(context).execute(mRequest);
        } else {
            bind(mTorrentList);
        }
    }
}
 
Example #2
Source File: RadioGridGroup.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void onChildViewAdded(View parent, View child) {
    if (parent == RadioGridGroup.this && child instanceof RadioButton) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = ViewUtils.generateViewId();
            child.setId(id);
        }
        ((RadioButton) child).setOnCheckedChangeListener(
                mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
Example #3
Source File: AnalyticsScene.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_analytics, container, false);

    mReject = ViewUtils.$$(view, R.id.reject);
    mAccept = ViewUtils.$$(view, R.id.accept);
    TextView text = (TextView) ViewUtils.$$(view, R.id.text);

    text.setText(Html.fromHtml(getString(R.string.analytics_explain)));
    text.setMovementMethod(LinkMovementMethod2.getInstance());

    mReject.setOnClickListener(this);
    mAccept.setOnClickListener(this);

    return view;
}
 
Example #4
Source File: SecurityScene.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_security, container, false);

    mPatternView = (LockPatternView) ViewUtils.$$(view, R.id.pattern_view);
    mPatternView.setOnPatternListener(this);

    mFingerprintIcon = (ImageView) ViewUtils.$$(view, R.id.fingerprint_icon);
    if (Settings.getEnableFingerprint() && isFingerprintAuthAvailable()) {
        mFingerprintIcon.setVisibility(View.VISIBLE);
        mFingerprintIcon.setImageResource(R.drawable.ic_fp_40px);
    }
    return view;
}
 
Example #5
Source File: GalleryInfoScene.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_gallery_info, container, false);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);

    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
    InfoAdapter adapter = new InfoAdapter();
    mRecyclerView.setAdapter(adapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
            LinearDividerItemDecoration.VERTICAL,
            AttrResources.getAttrColor(context, R.attr.dividerColor),
            LayoutUtils.dp2pix(context, 1));
    decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin));
    mRecyclerView.addItemDecoration(decoration);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setOnItemClickListener(this);
    return view;
}
 
Example #6
Source File: AnalyticsScene.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_analytics, container, false);

    mReject = ViewUtils.$$(view, R.id.reject);
    mAccept = ViewUtils.$$(view, R.id.accept);
    TextView text = (TextView) ViewUtils.$$(view, R.id.text);

    text.setText(Html.fromHtml(getString(R.string.analytics_explain)));
    text.setMovementMethod(LinkMovementMethod2.getInstance());

    mReject.setOnClickListener(this);
    mAccept.setOnClickListener(this);

    return view;
}
 
Example #7
Source File: DirPickerActivity.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dir_picker);
    setNavigationIcon(R.drawable.v_arrow_left_dark_x24);

    mPath = (TextView) ViewUtils.$$(this, R.id.path);
    mDirExplorer = (DirExplorer) ViewUtils.$$(this, R.id.dir_explorer);
    mOk = ViewUtils.$$(this, R.id.ok);

    File file;
    if (null == savedInstanceState) {
        file = onInit();
    } else {
        file = onRestore(savedInstanceState);
    }

    mDirExplorer.setCurrentFile(file);
    mDirExplorer.setOnChangeDirListener(this);

    Ripple.addRipple(mOk, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme));

    mOk.setOnClickListener(this);

    mPath.setText(mDirExplorer.getCurrentFile().getPath());
}
 
Example #8
Source File: DownloadsScene.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
private void guide() {
    if (Settings.getGuideDownloadThumb() && null != mRecyclerView) {
        mRecyclerView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                if (Settings.getGuideDownloadThumb()) {
                    guideDownloadThumb();
                }
                if (null != mRecyclerView) {
                    ViewUtils.removeOnGlobalLayoutListener(mRecyclerView.getViewTreeObserver(), this);
                }
            }
        });
    } else {
        guideDownloadLabels();
    }
}
 
Example #9
Source File: GalleryInfoScene.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_gallery_info, container, false);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);

    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
    InfoAdapter adapter = new InfoAdapter();
    mRecyclerView.setAdapter(adapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
            LinearDividerItemDecoration.VERTICAL,
            AttrResources.getAttrColor(context, R.attr.dividerColor),
            LayoutUtils.dp2pix(context, 1));
    decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin));
    mRecyclerView.addItemDecoration(decoration);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setOnItemClickListener(this);
    return view;
}
 
Example #10
Source File: SignInScene.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container,
                          @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_login, container, false);

    View loginForm = ViewUtils.$$(view, R.id.login_form);
    mProgress = ViewUtils.$$(view, R.id.progress);
    mUsernameLayout = (TextInputLayout) ViewUtils.$$(loginForm, R.id.username_layout);
    mUsername = mUsernameLayout.getEditText();
    AssertUtils.assertNotNull(mUsername);
    mPasswordLayout = (TextInputLayout) ViewUtils.$$(loginForm, R.id.password_layout);
    mPassword = mPasswordLayout.getEditText();
    AssertUtils.assertNotNull(mPassword);
    mSignIn = ViewUtils.$$(loginForm, R.id.sign_in);
    mSkipSigningIn = (TextView) ViewUtils.$$(loginForm, R.id.skip_signing_in);

    mSkipSigningIn.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
    mPassword.setOnEditorActionListener(this);
    mSignIn.setOnClickListener(this);
    mSkipSigningIn.setOnClickListener(this);
    return view;
}
 
Example #11
Source File: SecurityScene.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_security, container, false);

    mPatternView = (LockPatternView) ViewUtils.$$(view, R.id.pattern_view);
    mPatternView.setOnPatternListener(this);

    mFingerprintIcon = (ImageView) ViewUtils.$$(view, R.id.fingerprint_icon);
    if (Settings.getEnableFingerprint() && isFingerprintAuthAvailable()) {
        mFingerprintIcon.setVisibility(View.VISIBLE);
        mFingerprintIcon.setImageResource(R.drawable.ic_fp_40px);
    }
    return view;
}
 
Example #12
Source File: GalleryAdapter.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
public GalleryAdapter(@NonNull LayoutInflater inflater, @NonNull Resources resources,
        @NonNull RecyclerView recyclerView, int type, boolean showFavourited) {
    mInflater = inflater;
    mResources = resources;
    mRecyclerView = recyclerView;
    mLayoutManager = new AutoStaggeredGridLayoutManager(0, StaggeredGridLayoutManager.VERTICAL);
    mPaddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar);
    mShowFavourited = showFavourited;

    mRecyclerView.setAdapter(this);
    mRecyclerView.setLayoutManager(mLayoutManager);

    View calculator = inflater.inflate(R.layout.item_gallery_list_thumb_height, null);
    ViewUtils.measureView(calculator, 1024, ViewGroup.LayoutParams.WRAP_CONTENT);
    mListThumbHeight = calculator.getMeasuredHeight();
    mListThumbWidth = mListThumbHeight * 2 / 3;

    setType(type);

    mDownloadManager = EhApplication.getDownloadManager(inflater.getContext());
}
 
Example #13
Source File: DownloadsScene.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
@Override
public void onDestroyView() {
    super.onDestroyView();

    if (null != mShowcaseView) {
        ViewUtils.removeFromParent(mShowcaseView);
        mShowcaseView = null;
    }
    if (null != mRecyclerView) {
        mRecyclerView.stopScroll();
        mRecyclerView = null;
    }
    if (null != mFabLayout) {
        removeAboveSnackView(mFabLayout);
        mFabLayout = null;
    }

    mRecyclerView = null;
    mViewTransition = null;
    mAdapter = null;
    mLayoutManager = null;
}
 
Example #14
Source File: WarningScene.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_warning, container, false);

    mReject = ViewUtils.$$(view, R.id.reject);
    mAccept = ViewUtils.$$(view, R.id.accept);

    mReject.setOnClickListener(this);
    mAccept.setOnClickListener(this);

    return view;
}
 
Example #15
Source File: FilterActivity.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
public void setDialog(AlertDialog dialog) {
    mDialog = dialog;
    mSpinner = (Spinner) ViewUtils.$$(dialog, R.id.spinner);
    mInputLayout = (TextInputLayout) ViewUtils.$$(dialog, R.id.text_input_layout);
    mEditText = mInputLayout.getEditText();
    View button = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
    if (null != button) {
        button.setOnClickListener(this);
    }
}
 
Example #16
Source File: ProgressScene.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_progress, container, false);
    View progress = ViewUtils.$$(view, R.id.progress);
    mTip = (TextView) ViewUtils.$$(view, R.id.tip);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);

    Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_sad_pandroid);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    mTip.setCompoundDrawables(null, drawable, null, null);
    mTip.setOnClickListener(this);
    mTip.setText(mError);

    mViewTransition = new ViewTransition(progress, mTip);

    if (mValid) {
        mViewTransition.showView(0, false);
    } else {
        mViewTransition.showView(1, false);
    }

    return view;
}
 
Example #17
Source File: HistoryScene.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
public HistoryAdapter() {
    mInflater = getLayoutInflater2();

    View calculator = mInflater.inflate(R.layout.item_gallery_list_thumb_height, null);
    ViewUtils.measureView(calculator, 1024, ViewGroup.LayoutParams.WRAP_CONTENT);
    mListThumbHeight = calculator.getMeasuredHeight();
    mListThumbWidth = mListThumbHeight * 2 / 3;
}
 
Example #18
Source File: FavoritesScene.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
private void guideCollections() {
    Activity activity = getActivity2();
    if (null == activity || !Settings.getGuideCollections()) {
        return;
    }

    Display display = activity.getWindowManager().getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);

    mShowcaseView = new ShowcaseView.Builder(activity)
            .withMaterialShowcase()
            .setStyle(R.style.Guide)
            .setTarget(new PointTarget(point.x, point.y / 3))
            .blockAllTouches()
            .setContentTitle(R.string.guide_collections_title)
            .setContentText(R.string.guide_collections_text)
            .replaceEndButton(R.layout.button_guide)
            .setShowcaseEventListener(new SimpleShowcaseEventListener() {
                @Override
                public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
                    mShowcaseView = null;
                    ViewUtils.removeFromParent(showcaseView);
                    Settings.putGuideCollections(false);
                    openDrawer(Gravity.RIGHT);
                }
            }).build();
}
 
Example #19
Source File: GalleryDetailScene.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
public void setDialog(Dialog dialog, float rating) {
    mRatingText = (TextView) ViewUtils.$$(dialog, R.id.rating_text);
    mRatingBar = (GalleryRatingBar) ViewUtils.$$(dialog, R.id.rating_view);
    mRatingText.setText(getRatingText(rating, getResources2()));
    mRatingBar.setRating(rating);
    mRatingBar.setOnUserRateListener(this);
}
 
Example #20
Source File: FavoritesScene.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroyView() {
    super.onDestroyView();

    if (null != mShowcaseView) {
        ViewUtils.removeFromParent(mShowcaseView);
        mShowcaseView = null;
    }

    if (null != mHelper) {
        mHelper.destroy();
        if (1 == mHelper.getShownViewIndex()) {
            mHasFirstRefresh = false;
        }
    }
    if (null != mRecyclerView) {
        mRecyclerView.stopScroll();
        mRecyclerView = null;
    }
    if (null != mFabLayout) {
        removeAboveSnackView(mFabLayout);
        mFabLayout = null;
    }

    mAdapter = null;

    mSearchBar = null;

    mSearchBarMover = null;
    mLeftDrawable = null;

    mOldFavCat = null;
    mOldKeyword = null;
}
 
Example #21
Source File: GalleryListScene.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroyView() {
    super.onDestroyView();

    if (null != mShowcaseView) {
        ViewUtils.removeFromParent(mShowcaseView);
        mShowcaseView = null;
    }
    if (null != mSearchBarMover) {
        mSearchBarMover.cancelAnimation();
        mSearchBarMover = null;
    }
    if (null != mHelper) {
        mHelper.destroy();
        if (1 == mHelper.getShownViewIndex()) {
            mHasFirstRefresh = false;
        }
    }
    if (null != mRecyclerView) {
        mRecyclerView.stopScroll();
        mRecyclerView = null;
    }
    if (null != mFabLayout) {
        removeAboveSnackView(mFabLayout);
        mFabLayout = null;
    }

    mAdapter = null;
    mSearchLayout = null;
    mSearchBar = null;
    mSearchFab = null;
    mViewTransition = null;
    mLeftDrawable = null;
    mRightDrawable = null;
    mActionFabDrawable = null;
}
 
Example #22
Source File: FilterActivity.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
public FilterHolder(View itemView) {
    super(itemView);
    text = (TextView) ViewUtils.$$(itemView, R.id.text);
    icon = itemView.findViewById(R.id.icon);

    if (null != icon) {
        icon.setOnClickListener(this);
    }
    // click on the filter text to enable/disable it
    text.setOnClickListener(this);
}
 
Example #23
Source File: SearchBarMover.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    if (mHelper.isValidView(recyclerView)) {
        int oldBottom = (int) ViewUtils.getY2(mSearchBar);
        int offsetYStep = MathUtils.clamp(-dy, -oldBottom, -(int) mSearchBar.getTranslationY());
        if (offsetYStep != 0) {
            ViewUtils.translationYBy(mSearchBar, offsetYStep);
        }
    }
}
 
Example #24
Source File: ImageSearchLayout.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public void init(Context context) {
    setOrientation(VERTICAL);
    setDividerDrawable(context.getResources().getDrawable(R.drawable.spacer_keyline));
    setShowDividers(SHOW_DIVIDER_MIDDLE);
    LayoutInflater.from(context).inflate(R.layout.widget_image_search, this);

    mPreview = (ImageView) ViewUtils.$$(this, R.id.preview);
    mSelectImage = ViewUtils.$$(this, R.id.select_image);
    mSearchUSS = (CheckBox) ViewUtils.$$(this, R.id.search_uss);
    mSearchOSC = (CheckBox) ViewUtils.$$(this, R.id.search_osc);
    mSearchSE = (CheckBox) ViewUtils.$$(this, R.id.search_se);

    mSelectImage.setOnClickListener(this);
}
 
Example #25
Source File: GalleryGuideView.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (mStep) {
        case 0:
            mStep++;
            bind();
            break;
        default:
        case 1:
            Settings.putGuideGallery(false);
            ViewUtils.removeFromParent(this);
            break;
    }
}
 
Example #26
Source File: SeekBarPanel.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
    if (mSeekBar == null) {
        return super.onTouchEvent(event);
    } else {
        ViewUtils.getLocationInAncestor(mSeekBar, mLocation, this);
        final float offsetX = -mLocation[0];
        final float offsetY = -mLocation[1];
        event.offsetLocation(offsetX, offsetY);
        mSeekBar.onTouchEvent(event);
        event.offsetLocation(-offsetX, -offsetY);
        return true;
    }
}
 
Example #27
Source File: SeekBarPanel.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
    if (mSeekBar == null) {
        return super.onTouchEvent(event);
    } else {
        ViewUtils.getLocationInAncestor(mSeekBar, mLocation, this);
        final float offsetX = -mLocation[0];
        final float offsetY = -mLocation[1];
        event.offsetLocation(offsetX, offsetY);
        mSeekBar.onTouchEvent(event);
        event.offsetLocation(-offsetX, -offsetY);
        return true;
    }
}
 
Example #28
Source File: ExcludedLanguagesActivity.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.scene_excluded_languages);
    setNavigationIcon(R.drawable.v_arrow_left_dark_x24);

    if (null == savedInstanceState) {
        onInit();
    } else {
        onRestore(savedInstanceState);
    }

    mCancel = ViewUtils.$$(this, R.id.cancel);
    mOk = ViewUtils.$$(this, R.id.ok);
    mSelectAll = ViewUtils.$$(this, R.id.select_all);
    mDeselectAll = ViewUtils.$$(this, R.id.deselect_all);
    mInvertSelection = ViewUtils.$$(this, R.id.invert_selection);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(this, R.id.recycler_view);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setClipToPadding(false);
    mAdapter = new LanguageAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    mCancel.setOnClickListener(this);
    mOk.setOnClickListener(this);
    mSelectAll.setOnClickListener(this);
    mDeselectAll.setOnClickListener(this);
    mInvertSelection.setOnClickListener(this);

    boolean isDarkTheme = !AttrResources.getAttrBoolean(this, R.attr.isLightTheme);
    Ripple.addRipple(mCancel, isDarkTheme);
    Ripple.addRipple(mOk, isDarkTheme);
    Ripple.addRipple(mSelectAll, isDarkTheme);
    Ripple.addRipple(mDeselectAll, isDarkTheme);
    Ripple.addRipple(mInvertSelection, isDarkTheme);
}
 
Example #29
Source File: SetSecurityActivity.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_set_security);
    setNavigationIcon(R.drawable.v_arrow_left_dark_x24);

    mPatternView = (LockPatternView) ViewUtils.$$(this, R.id.pattern_view);
    mCancel = ViewUtils.$$(this, R.id.cancel);
    mSet = ViewUtils.$$(this, R.id.set);
    mFingerprint = (CheckBox) ViewUtils.$$(this, R.id.fingerprint_checkbox);

    String pattern = Settings.getSecurity();
    if (!TextUtils.isEmpty(pattern)) {
        mPatternView.setPattern(LockPatternView.DisplayMode.Correct,
                LockPatternUtils.stringToPattern(pattern));
    }

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
        FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class);
        // The line below prevents the false positive inspection from Android Studio
        // noinspection ResourceType
        if (fingerprintManager != null && hasEnrolledFingerprints(fingerprintManager)) {
            mFingerprint.setVisibility(View.VISIBLE);
            mFingerprint.setChecked(Settings.getEnableFingerprint());
        }
    }

    mCancel.setOnClickListener(this);
    mSet.setOnClickListener(this);
}
 
Example #30
Source File: GalleryPreviewsScene.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
public void setDialog(@NonNull AlertDialog dialog) {
    mDialog = dialog;

    ((TextView) ViewUtils.$$(dialog, R.id.start)).setText(String.format(Locale.US, "%d", 1));
    ((TextView) ViewUtils.$$(dialog, R.id.end)).setText(String.format(Locale.US, "%d", mPages));
    mSlider = (Slider) ViewUtils.$$(dialog, R.id.slider);
    mSlider.setRange(1, mPages);
    mSlider.setProgress(mCurrentPage + 1);

    dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(this);
    dialog.setOnDismissListener(this);
}