Java Code Examples for com.readystatesoftware.systembartint.SystemBarTintManager#setTintColor()

The following examples show how to use com.readystatesoftware.systembartint.SystemBarTintManager#setTintColor() . 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: SomeActivity.java    From something.apk with MIT License 6 votes vote down vote up
private void configureActionbar(){
    ActionBar bar = getActionBar();
    bar.setHomeButtonEnabled(true);
    bar.setDisplayShowHomeEnabled(false);

    tint = new SystemBarTintManager(this);
    TypedValue tintColor = new TypedValue();
    if(getTheme().resolveAttribute(R.attr.statusBarBackground, tintColor, true)){
        tint.setStatusBarTintEnabled(true);
        tint.setTintColor(tintColor.data);
        defaultActionbarColor = tintColor.data;
        currentActionbarColor = tintColor.data;
    }else{
        tint.setStatusBarTintEnabled(false);
    }

    TypedValue actionbarBackground = new TypedValue();
    if(getTheme().resolveAttribute(R.attr.actionbarBackgroundLayerList, actionbarBackground, false)){
        actionbarBackgroundList = (LayerDrawable) getResources().getDrawable(actionbarBackground.data);
        actionbarBackgroundList.mutate();
        actionbarColor = (ColorDrawable) actionbarBackgroundList.findDrawableByLayerId(R.id.actionbar_background_color);
        actionbarColor.mutate();
        bar.setBackgroundDrawable(actionbarBackgroundList);
    }

}
 
Example 2
Source File: BaseActivity.java    From NMSAlphabetAndroidApp with MIT License 5 votes vote down vote up
private void tintBars(){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setTranslucentStatusAndNavigationBar();
    }
    tintManager = new SystemBarTintManager(this);
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setNavigationBarTintEnabled(true);
    tintManager.setTintColor(ThemeUtil.getPrimaryColor(this));
}
 
Example 3
Source File: UiUtils.java    From droidddle with Apache License 2.0 5 votes vote down vote up
@SuppressLint("NewApi")
    public static void initSystemBarTint(Activity activity) {
        int color = ThemeUtil.getThemeColor(activity, R.attr.colorPrimaryDark);
        if (hasLollipop()) {
//            activity.getWindow().setNavigationBarColor(color);
            //            activity.getWindow().setStatusBarColor(color);
            //            activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
            return;
        }
        int orientation = activity.getResources().getConfiguration().orientation;
        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            if (!activity.getResources().getBoolean(R.bool.enable_system_bar)) {
                return;
            }
        }
        // create our manager instance after the content view is set
        SystemBarTintManager tintManager = new SystemBarTintManager(activity);
        // enable status bar tint
        tintManager.setStatusBarTintEnabled(true);
        // enable navigation bar tint
        tintManager.setNavigationBarTintEnabled(false);

        // set a custom tint color for all system bars
        tintManager.setTintColor(TINT_COLOR);
        // set a custom navigation bar resource
        ColorDrawable drawable = new ColorDrawable(color);
        tintManager.setNavigationBarTintDrawable(drawable);
        // set a custom status bar drawable
        tintManager.setStatusBarTintDrawable(drawable);
    }
 
Example 4
Source File: Util.java    From polling-station-app with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Sets up a top-padding for the given app bar equal to the height of the status bar.
 * This increases the length of the app bar so it fits nicely below the status bar.
 * This method also sets the status bar transparency.
 *
 * @param appBar   Toolbar to set padding to
 * @param activity Activity - current activity
 */
public static void setupAppBar(Toolbar appBar, Activity activity) {
    appBar.setPadding(0, getStatusBarHeight(activity.getResources()), 0, 0);

    SystemBarTintManager tintManager = new SystemBarTintManager(activity);
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setNavigationBarTintEnabled(true);
    tintManager.setTintColor(Color.parseColor("#10000000"));
}
 
Example 5
Source File: BaseActivity.java    From AppPlus with MIT License 5 votes vote down vote up
/**
 * 为Android 4.4以上设备使用沉浸时效果
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setTintLayout() {
    mBarTintManager = new SystemBarTintManager(this);
    mBarTintManager.setStatusBarTintEnabled(true);
    mBarTintManager.setNavigationBarTintEnabled(true);
    mBarTintManager.setTintColor(Utils.getThemePrimaryColor(this));
}
 
Example 6
Source File: ConfigurationActivity.java    From Noyze with Apache License 2.0 5 votes vote down vote up
public static void setupActionBar(Activity activity) {

        // Tint the status bar, if available.
        SystemBarTintManager tintManager = new SystemBarTintManager(activity);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setTintColor(activity.getResources().getColor(R.color.action_bar_dark));

        ActionBar actionBar = activity.getActionBar();
        if (null != actionBar) {
            actionBar.setIcon(DateUtils.AppIcon());
            actionBar.setDisplayHomeAsUpEnabled(!activity.isTaskRoot());
            actionBar.setDisplayShowTitleEnabled(true);
        }
    }
 
Example 7
Source File: MainActivity.java    From mCalendar with Apache License 2.0 5 votes vote down vote up
private void changeStatusBarColor(){
    if (Build.VERSION.SDK_INT > 18){
        Window window = getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(false);
        tintManager.setTintColor(getResources().getColor(R.color.colorPrimaryDark));
    }
}
 
Example 8
Source File: ConfigurationActivity.java    From Noyze with Apache License 2.0 5 votes vote down vote up
public static void setupActionBar(Activity activity) {

        // Tint the status bar, if available.
        SystemBarTintManager tintManager = new SystemBarTintManager(activity);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setTintColor(activity.getResources().getColor(R.color.action_bar_dark));

        ActionBar actionBar = activity.getActionBar();
        if (null != actionBar) {
            actionBar.setIcon(DateUtils.AppIcon());
            actionBar.setDisplayHomeAsUpEnabled(!activity.isTaskRoot());
            actionBar.setDisplayShowTitleEnabled(true);
        }
    }
 
Example 9
Source File: AboutActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_about);

    // set indicator enable
    Toolbar mToolbar = findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mToolbar);
    final Drawable upArrow = getResources().getDrawable(R.drawable.ic_svg_back);
    if(getSupportActionBar() != null && upArrow != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        upArrow.setColorFilter(getResources().getColor(R.color.default_white), PorterDuff.Mode.SRC_ATOP);
        getSupportActionBar().setHomeAsUpIndicator(upArrow);
    }

    // change status bar color tint, and this require SDK16
    if (Build.VERSION.SDK_INT >= 16 ) {
        // create our manager instance after the content view is set
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        // enable all tint
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setTintAlpha(0.15f);
        tintManager.setNavigationBarAlpha(0.0f);
        // set all color
        tintManager.setTintColor(getResources().getColor(android.R.color.black));
        // set Navigation bar color
        if(Build.VERSION.SDK_INT >= 21)
            getWindow().setNavigationBarColor(getResources().getColor(R.color.myNavigationColor));
    }

    // get version code
    TextView tvVersion = findViewById(R.id.app_version);
    tvVersion.setText(String.format(getResources().getString(R.string.about_version_template), BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE));
}
 
Example 10
Source File: MainActivity.java    From discreet-app-rate with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        winParams.flags |= bits;
        bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
        winParams.flags |= bits;
        win.setAttributes(winParams);
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        // enable status bar tint
        tintManager.setStatusBarTintEnabled(true);
        // enable navigation bar tint
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setTintColor(Color.parseColor("#DDDDDD"));
    }

    manageViews();

    settings = getSharedPreferences(PreferencesConstants.PREFS_NAME, 0);
    editor = settings.edit();

    updateValueDisplay();


    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            switch (actionSpinner.getSelectedItemPosition()) {
                case 0:
                    getAppRate().checkAndShow();
                    break;
                case 1:
                    getAppRate().reset();
                    break;
                case 2:
                    getAppRate().forceShow();
                    break;
                case 3:
                    getAppRate().neverShowAgain();
                    break;
                case 4:
                    editor.putLong(PreferencesConstants.KEY_LAST_CRASH, System.currentTimeMillis());
                    editor.commit();
                    Toast.makeText(MainActivity.this, "App has crashed just now", Toast.LENGTH_LONG).show();
                    break;
            }

            updateValueDisplay();
        }
    });
}
 
Example 11
Source File: UserInfoActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_account_info);

    // set indicator enable
    Toolbar mToolbar = findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mToolbar);
    if(getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        final Drawable upArrow = getResources().getDrawable(R.drawable.ic_svg_back);
        if(upArrow != null)
            upArrow.setColorFilter(getResources().getColor(R.color.default_white), PorterDuff.Mode.SRC_ATOP);
        getSupportActionBar().setHomeAsUpIndicator(upArrow);
    }

    // change status bar color tint, and this require SDK16
    if (Build.VERSION.SDK_INT >= 16 ) { //&& Build.VERSION.SDK_INT <= 21) {
        // Android API 22 has more effects on status bar, so ignore

        // create our manager instance after the content view is set
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        // enable all tint
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setTintAlpha(0.15f);
        tintManager.setNavigationBarAlpha(0.0f);
        // set all color
        tintManager.setTintColor(getResources().getColor(android.R.color.black));
        // set Navigation bar color
        if(Build.VERSION.SDK_INT >= 21)
            getWindow().setNavigationBarColor(getResources().getColor(R.color.myNavigationColor));
    }

    // get views
    rivAvatar = findViewById(R.id.user_avatar);
    tvUserName = findViewById(R.id.username);
    tvNickyName = findViewById(R.id.nickname);
    tvScore = findViewById(R.id.score);
    tvExperience = findViewById(R.id.experience);
    tvRank = findViewById(R.id.rank);
    tvLogout = findViewById(R.id.btn_logout);

    // sync get info
    agui = new AsyncGetUserInfo();
    agui.execute();

}
 
Example 12
Source File: SearchResultActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_search_result);

    // get arguments
    String searchKey = getIntent().getStringExtra("key");

    // set indicator enable
    Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mToolbar);
    if(getSupportActionBar() != null ) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
    }

    // change status bar color tint, and this require SDK16
    if (Build.VERSION.SDK_INT >= 16 ) { //&& Build.VERSION.SDK_INT <= 21) {
        // Android API 22 has more effects on status bar, so ignore

        // create our manager instance after the content view is set
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        // enable all tint
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setTintAlpha(0.15f);
        tintManager.setNavigationBarAlpha(0.0f);
        // set all color
        tintManager.setTintColor(getResources().getColor(android.R.color.black));
        // set Navigation bar color
        if(Build.VERSION.SDK_INT >= 21)
            getWindow().setNavigationBarColor(getResources().getColor(R.color.myNavigationColorWhite));
    }

    // set action bat title
    TextView mTextView = (TextView) findViewById(R.id.search_result_title);
    if(mTextView != null)
        mTextView.setText(getResources().getString(R.string.title_search) + searchKey);

    // init values
    Bundle bundle = new Bundle();
    bundle.putString("type", "search");
    bundle.putString("key", searchKey);

    // UIL setting
    if(ImageLoader.getInstance() == null || !ImageLoader.getInstance().isInited()) {
        GlobalConfig.initImageLoader(this);
    }

    // This code will produce more than one activity in stack, so I jump to new SearchActivity to escape it.
    getSupportFragmentManager().beginTransaction()
            .replace(R.id.result_fragment, NovelItemListFragment.newInstance(bundle), "fragment")
            .setTransitionStyle(FragmentTransaction.TRANSIT_NONE)
            .commit();

}
 
Example 13
Source File: SearchActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_search);

    // bind views
    toolbarSearchView = findViewById(R.id.search_view);
    View searchClearButton = findViewById(R.id.search_clear);

    // Clear search text when clear button is tapped
    searchClearButton.setOnClickListener(v -> toolbarSearchView.setText(""));

    // set indicator enable
    Toolbar mToolbar = findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mToolbar);
    if(getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
    }

    // change status bar color tint, and this require SDK16
    if (Build.VERSION.SDK_INT >= 16 ) { //&& Build.VERSION.SDK_INT <= 21) {
        // Android API 22 has more effects on status bar, so ignore

        // create our manager instance after the content view is set
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        // enable all tint
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setTintAlpha(0.15f);
        tintManager.setNavigationBarAlpha(0.0f);
        // set all color
        tintManager.setTintColor(getResources().getColor(android.R.color.black));
        // set Navigation bar color
        if(Build.VERSION.SDK_INT >= 21)
            getWindow().setNavigationBarColor(getResources().getColor(R.color.myNavigationColorWhite));
    }

    // set search clear icon color
    ImageView searchClearIcon = findViewById(R.id.search_clear_icon);
    searchClearIcon.setColorFilter(getResources().getColor(R.color.mySearchToggleColor), PorterDuff.Mode.SRC_ATOP);

    // set history list
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);

    RecyclerView mRecyclerView = this.findViewById(R.id.search_history_list);
    mRecyclerView.setHasFixedSize(true); // set variable size
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(mLayoutManager);

    historyList = GlobalConfig.getSearchHistory();
    adapter = new SearchHistoryAdapter(historyList);
    adapter.setOnItemClickListener(this); // add item click listener
    adapter.setOnItemLongClickListener(this); // add item click listener
    mRecyclerView.setAdapter(adapter);

    // set search action
    toolbarSearchView.setOnEditorActionListener((v, actionId, event) -> {
        // purify
        String temp = toolbarSearchView.getText().toString().trim();
        if(temp.length()==0) return false;

        // real action
        //Toast.makeText(MyApp.getContext(), temp, Toast.LENGTH_SHORT).show();
        GlobalConfig.addSearchHistory(temp);
        refreshHistoryList();

        // jump to search
        Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
        intent.putExtra("key", temp);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); // long-press will cause repetitions
        startActivity(intent);
        overridePendingTransition( R.anim.fade_in, R.anim.hold);

        return false;
    });
}
 
Example 14
Source File: NovelReviewListActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_novel_review_list);

    // fetch values
    aid = getIntent().getIntExtra("aid", 1);

    // set indicator enable
    Toolbar mToolbar = findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mToolbar);
    final Drawable upArrow = getResources().getDrawable(R.drawable.ic_svg_back);
    if(getSupportActionBar() != null && upArrow != null) {
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        upArrow.setColorFilter(getResources().getColor(R.color.default_white), PorterDuff.Mode.SRC_ATOP);
        getSupportActionBar().setHomeAsUpIndicator(upArrow);
    }

    // change status bar color tint, and this require SDK16
    if (Build.VERSION.SDK_INT >= 16 ) {
        // create our manager instance after the content view is set
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        // enable all tint
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setTintAlpha(0.15f);
        tintManager.setNavigationBarAlpha(0.0f);
        // set all color
        tintManager.setTintColor(getResources().getColor(android.R.color.black));
        // set Navigation bar color
        if(Build.VERSION.SDK_INT >= 21)
            getWindow().setNavigationBarColor(getResources().getColor(R.color.myNavigationColor));
    }

    // get views and set title
    // get views
    mLoadingLayout = findViewById(R.id.list_loading);
    mSwipeRefreshLayout = findViewById(R.id.swipe_refresh_layout);
    mRecyclerView = findViewById(R.id.review_item_list);
    mLoadingStatusTextView = findViewById(R.id.list_loading_status);
    mLoadingButton = findViewById(R.id.btn_loading);

    mRecyclerView.setHasFixedSize(false);
    // use a linear layout manager
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);

    // Listener
    mRecyclerView.addOnScrollListener(new MyOnScrollListener());

    // set click event for retry and cancel loading
    mLoadingButton.setOnClickListener(v -> new AsyncReviewListLoader(this, mSwipeRefreshLayout, aid, reviewList).execute()); // retry loading

    mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.myAccentColor));
    mSwipeRefreshLayout.setOnRefreshListener(() -> {
        // reload all
        reviewList = new ReviewList();
        mAdapter = null;
        new AsyncReviewListLoader(this, mSwipeRefreshLayout, aid, reviewList).execute();
    });

    // load initial content
    new AsyncReviewListLoader(this, mSwipeRefreshLayout, aid, reviewList).execute();
}
 
Example 15
Source File: MainActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_main); // have 3 styles
    initialApp();

    // UIL setting
    if (ImageLoader.getInstance() == null || !ImageLoader.getInstance().isInited()) {
        GlobalConfig.initImageLoader(this);
    }

    // UMeng initialization
    UMConfigure.init(MyApp.getContext(), UMConfigure.DEVICE_TYPE_PHONE, null);

    // Update old save files ----------------


    // set Toolbar
    Toolbar mToolbar = findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mToolbar);
    // getSupportActionBar().setDisplayShowHomeEnabled(true);

    // set Tool button
    mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_drawer);
    mNavigationDrawerFragment.setup(R.id.fragment_drawer, findViewById(R.id.drawer), mToolbar);

    // find search box
    mToolbar.setOnMenuItemClickListener(item -> {
        //Toast.makeText(MyApp.getContext(),"called button",Toast.LENGTH_SHORT).show();
        if (item.getItemId() == R.id.action_search) {
            // start search activity
            startActivity(new Intent(MainActivity.this, SearchActivity.class));
            overridePendingTransition(R.anim.fade_in, R.anim.hold); // fade in animation

        }
        return true;
    });

    // change status bar color tint, and this require SDK16
    if (Build.VERSION.SDK_INT >= 16) { //&& Build.VERSION.SDK_INT <= 21) {
        // Android API 22 has more effects on status bar, so ignore

        // create our manager instance after the content view is set
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        // enable all tint
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setTintAlpha(0.15f);
        tintManager.setNavigationBarAlpha(0.0f);
        // set all color
        tintManager.setTintColor(getResources().getColor(android.R.color.black));
        // set Navigation bar color
        if (Build.VERSION.SDK_INT >= 21)
            getWindow().setNavigationBarColor(getResources().getColor(R.color.myNavigationColor));
    }
}
 
Example 16
Source File: NovelReviewReplyListActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_novel_review_reply_list);

        // fetch values
        rid = getIntent().getIntExtra("rid", 1);
        reviewTitle = getIntent().getStringExtra("title");

        // set indicator enable
        Toolbar mToolbar = findViewById(R.id.toolbar_actionbar);
        setSupportActionBar(mToolbar);
        final Drawable upArrow = getResources().getDrawable(R.drawable.ic_svg_back);
        if(getSupportActionBar() != null && upArrow != null) {
            getSupportActionBar().setHomeButtonEnabled(true);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            upArrow.setColorFilter(getResources().getColor(R.color.default_white), PorterDuff.Mode.SRC_ATOP);
            getSupportActionBar().setHomeAsUpIndicator(upArrow);
        }

        // change status bar color tint, and this require SDK16
        if (Build.VERSION.SDK_INT >= 16 ) {
            // create our manager instance after the content view is set
            SystemBarTintManager tintManager = new SystemBarTintManager(this);
            // enable all tint
            tintManager.setStatusBarTintEnabled(true);
            tintManager.setNavigationBarTintEnabled(true);
            tintManager.setTintAlpha(0.15f);
            tintManager.setNavigationBarAlpha(0.0f);
            // set all color
            tintManager.setTintColor(getResources().getColor(android.R.color.black));
            // set Navigation bar color
            if(Build.VERSION.SDK_INT >= 21)
                getWindow().setNavigationBarColor(getResources().getColor(R.color.myNavigationColor));
        }

        // get views and set title
        // get views
        mLoadingLayout = findViewById(R.id.list_loading);
        mSwipeRefreshLayout = findViewById(R.id.swipe_refresh_layout);
        mRecyclerView = findViewById(R.id.review_item_list);
        mLoadingStatusTextView = findViewById(R.id.list_loading_status);
        mLoadingButton = findViewById(R.id.btn_loading);
        etReplyText = findViewById(R.id.review_reply_edit_text);
        LinearLayout llReplyButton = findViewById(R.id.review_reply_send);

        mRecyclerView.setHasFixedSize(false);
        DividerItemDecoration horizontalDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
        Drawable horizontalDivider = ContextCompat.getDrawable(getApplication(), R.drawable.divider_horizontal);
        if (horizontalDivider != null) {
            horizontalDecoration.setDrawable(horizontalDivider);
            mRecyclerView.addItemDecoration(horizontalDecoration);
        }
        // use a linear layout manager
        mLayoutManager = new LinearLayoutManager(this);
        mRecyclerView.setLayoutManager(mLayoutManager);

        // Listener
        mRecyclerView.addOnScrollListener(new MyOnScrollListener());

        // set click event for retry and cancel loading
        mLoadingButton.setOnClickListener(v -> new AsyncReviewReplyListLoader(this, mSwipeRefreshLayout, rid, reviewReplyList).execute()); // retry loading

        mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.myAccentColor));
        mSwipeRefreshLayout.setOnRefreshListener(this::refreshReviewReplyList);

        llReplyButton.setOnClickListener(ignored -> {
            // FIXME: enable these
            Toast.makeText(getApplication(), getResources().getString(R.string.system_api_error), Toast.LENGTH_SHORT).show();

//            String temp = etReplyText.getText().toString();
//            String badWord = Wenku8API.searchBadWords(temp);
//            if (badWord != null) {
//                Toast.makeText(getApplication(), String.format(getResources().getString(R.string.system_containing_bad_word), badWord), Toast.LENGTH_SHORT).show();
//            } else if (temp.length() < Wenku8API.MIN_REPLY_TEXT) {
//                Toast.makeText(getApplication(), getResources().getString(R.string.system_review_too_short), Toast.LENGTH_SHORT).show();
//            } else {
//                // hide ime
//                InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
//                View view = getCurrentFocus();
//                if (view == null) view = new View(this);
//                if (imm != null) imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
//
//                // submit
//                new AsyncPublishReply(etReplyText, this, rid, temp).execute();
//            }
        });

        // load initial content
        new AsyncReviewReplyListLoader(this, mSwipeRefreshLayout, rid, reviewReplyList).execute();
    }
 
Example 17
Source File: UserLoginActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_user_login);

    // set indicator enable
    Toolbar mToolbar = findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mToolbar);
    if(getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        final Drawable upArrow = getResources().getDrawable(R.drawable.ic_svg_back);
        if(upArrow != null)
            upArrow.setColorFilter(getResources().getColor(R.color.default_white), PorterDuff.Mode.SRC_ATOP);
        getSupportActionBar().setHomeAsUpIndicator(upArrow);
    }

    // change status bar color tint, and this require SDK16
    if (Build.VERSION.SDK_INT >= 16 ) { //&& Build.VERSION.SDK_INT <= 21) {
        // Android API 22 has more effects on status bar, so ignore

        // create our manager instance after the content view is set
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        // enable all tint
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setTintAlpha(0.15f);
        tintManager.setNavigationBarAlpha(0.0f);
        // set all color
        tintManager.setTintColor(getResources().getColor(android.R.color.black));
        // set Navigation bar color
        if(Build.VERSION.SDK_INT >= 21)
            getWindow().setNavigationBarColor(getResources().getColor(R.color.myNavigationColor));

    }

    // get views
    etUserName = findViewById(R.id.edit_username);
    etPassword = findViewById(R.id.edit_password);
    TextView tvLogin = findViewById(R.id.btn_login);
    TextView tvRegister = findViewById(R.id.btn_register);

    // listeners
    tvLogin.setOnClickListener(v -> {
        if(etUserName.getText().toString().length() == 0 || etUserName.getText().toString().length() > 30
                || etPassword.getText().toString().length() == 0 || etPassword.getText().toString().length() > 30) {
            Toast.makeText(UserLoginActivity.this, getResources().getString(R.string.system_info_fill_not_complete), Toast.LENGTH_SHORT).show();
            return;
        }

        // async login
        AsyncLoginTask alt = new AsyncLoginTask();
        alt.execute(etUserName.getText().toString(), etPassword.getText().toString());
    });

    tvRegister.setOnClickListener(v -> new MaterialDialog.Builder(UserLoginActivity.this)
            .onPositive((dialog, which) -> {
                // show browser list
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(Wenku8API.REGISTER_URL));
                String title = getResources().getString(R.string.system_choose_browser);
                Intent chooser = Intent.createChooser(intent, title);
                startActivity(chooser);
            })
            .theme(Theme.LIGHT)
            .backgroundColorRes(R.color.dlgBackgroundColor)
            .contentColorRes(R.color.dlgContentColor)
            .positiveColorRes(R.color.dlgPositiveButtonColor)
            .negativeColorRes(R.color.dlgNegativeButtonColor)
            .content(R.string.dialog_content_verify_register)
            .contentGravity(GravityEnum.CENTER)
            .positiveText(R.string.dialog_positive_ok)
            .negativeText(R.string.dialog_negative_pass)
            .show());
}
 
Example 18
Source File: MenuBackgroundSelectorActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_menu_background_selector);

    // set indicator enable
    Toolbar mToolbar = findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mToolbar);
    final Drawable upArrow = getResources().getDrawable(R.drawable.ic_svg_back);
    if(getSupportActionBar() != null && upArrow != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        upArrow.setColorFilter(getResources().getColor(R.color.default_white), PorterDuff.Mode.SRC_ATOP);
        getSupportActionBar().setHomeAsUpIndicator(upArrow);
    }

    // change status bar color tint, and this require SDK16
    if (Build.VERSION.SDK_INT >= 16 ) {
        // create our manager instance after the content view is set
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        // enable all tint
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setTintAlpha(0.15f);
        tintManager.setNavigationBarAlpha(0.0f);
        // set all color
        tintManager.setTintColor(getResources().getColor(android.R.color.black));
        // set Navigation bar color
        if(Build.VERSION.SDK_INT >= 21)
            getWindow().setNavigationBarColor(getResources().getColor(R.color.myNavigationColor));
    }

    // listeners
    findViewById(R.id.bg01).setOnClickListener(v -> {
        GlobalConfig.setToAllSetting(GlobalConfig.SettingItems.menu_bg_id, "1");
        MenuBackgroundSelectorActivity.this.finish();
    });
    findViewById(R.id.bg02).setOnClickListener(v -> {
        GlobalConfig.setToAllSetting(GlobalConfig.SettingItems.menu_bg_id, "2");
        MenuBackgroundSelectorActivity.this.finish();
    });
    findViewById(R.id.bg03).setOnClickListener(v -> {
        GlobalConfig.setToAllSetting(GlobalConfig.SettingItems.menu_bg_id, "3");
        MenuBackgroundSelectorActivity.this.finish();
    });
    findViewById(R.id.bg04).setOnClickListener(v -> {
        GlobalConfig.setToAllSetting(GlobalConfig.SettingItems.menu_bg_id, "4");
        MenuBackgroundSelectorActivity.this.finish();
    });
    findViewById(R.id.bg05).setOnClickListener(v -> {
        GlobalConfig.setToAllSetting(GlobalConfig.SettingItems.menu_bg_id, "5");
        MenuBackgroundSelectorActivity.this.finish();
    });
}
 
Example 19
Source File: Wenku8ReaderActivityV1.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.layout_reader_swipe_temp);

        // fetch values
        aid = getIntent().getIntExtra("aid", 1);
        volumeList = (VolumeList) getIntent().getSerializableExtra("volume");
        cid = getIntent().getIntExtra("cid", 1);
        from = getIntent().getStringExtra("from");
        forcejump = getIntent().getStringExtra("forcejump");
        if(forcejump == null || forcejump.length() == 0) forcejump = "no";
//        tempNavBarHeight = LightTool.getNavigationBarSize(this).y;

        // set indicator enable
        Toolbar mToolbar = findViewById(R.id.toolbar_actionbar);
        setSupportActionBar(mToolbar);
        if(getSupportActionBar() != null) {
            getSupportActionBar().setTitle(volumeList.volumeName);
            final Drawable upArrow = getResources().getDrawable(R.drawable.ic_back);
            if (upArrow != null)
                upArrow.setColorFilter(getResources().getColor(R.color.default_white), PorterDuff.Mode.SRC_ATOP);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setHomeButtonEnabled(true);
            getSupportActionBar().setHomeAsUpIndicator(upArrow);
        }

        if (Build.VERSION.SDK_INT >= 16 ) {
            // Android API 22 has more effects on status bar, so ignore

            // create our manager instance after the content view is set
            tintManager = new SystemBarTintManager(this);
            // enable all tint
            tintManager.setStatusBarTintEnabled(true);
            tintManager.setNavigationBarTintEnabled(true);
            tintManager.setTintAlpha(0.0f);
            // set all color
            tintManager.setTintColor(getResources().getColor(android.R.color.black));
        }

        // find views
        mSliderHolder = findViewById(R.id.slider_holder);

        // UIL setting
        if(ImageLoader.getInstance() == null || !ImageLoader.getInstance().isInited()) {
            GlobalConfig.initImageLoader(this);
        }

        // async tasks
        ContentValues cv = Wenku8API.getNovelContent(aid, cid, GlobalConfig.getCurrentLang());
        AsyncNovelContentTask ast = new AsyncNovelContentTask();
        ast.execute(cv);
    }
 
Example 20
Source File: LinkActivity.java    From AirFree-Client with GNU General Public License v3.0 4 votes vote down vote up
private void init() {
    iLanguage();
    app = (ApplicationUtil) LinkActivity.this.getApplication();
    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setNavigationBarTintEnabled(true);
    tintManager.setTintColor(Color.parseColor("#FCFCFC"));
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
            .detectDiskReads()
            .detectDiskWrites()
            .detectNetwork()
            .penaltyLog()
            .build());
    StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
            .detectLeakedSqlLiteObjects()
            .penaltyLog()
            .penaltyDeath()
            .build());
    etIP = (EditText) findViewById(R.id.et_ip);
    etIP.setHint(strIPAddressHint);
    cbRemember = (CheckBox) findViewById(R.id.cb_remember);
    cbRemember.setText(strRememberConnection);
    btnLink = (Button) findViewById(R.id.btn_link);
    btnLink.setText(strInputIPAddress);
    btnLink.setOnClickListener(onLinkClickListener);
    btnScan = (Button) findViewById(R.id.btn_scan);
    btnScan.setText(strScanQRCode);
    btnScan.setOnClickListener(onScanClickListener);
    boolean isRemember = pref.getBoolean(getString(R.string.is_remember), false);
    if (isRemember) {
        String ip = pref.getString(getString(R.string.is_ip), "");
        etIP.setText(ip);
        cbRemember.setChecked(true);
    }
    boom = ExplosionField.attach2Window(this);
    if (app.isExplosing()) {
        listen(findViewById(R.id.ll_icon));
        listen(findViewById(R.id.cb_remember));
        listen(findViewById(R.id.btn_link));
        listen(findViewById(R.id.btn_scan));
    }
}