set Xiaomi Filter ActionBar Display Options - Android User Interface

Android examples for User Interface:ActionBar

Description

set Xiaomi Filter ActionBar Display Options

Demo Code

/*//w ww.  j  ava2  s  .c  o  m
 * Copyright (C) 2013 Yrom Wang
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.support.v7.app.ActionBar;
import android.view.ViewConfiguration;

public class Main{
    
    public static void setXiaomiFilterDisplayOptions(ActionBar bar,
            boolean showHome) {
        boolean isXiaomi = "Xiaomi".equalsIgnoreCase(Build.MANUFACTURER);
        boolean isJB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
        bar.setDisplayOptions(isXiaomi && !showHome && !isJB ? ActionBar.DISPLAY_SHOW_TITLE
                | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_USE_LOGO
                : ActionBar.DISPLAY_SHOW_TITLE
                        | ActionBar.DISPLAY_HOME_AS_UP
                        | ActionBar.DISPLAY_SHOW_HOME
                        | ActionBar.DISPLAY_USE_LOGO);
    }
}

Related Tutorials