Search in sources :

Example 1 with ActionBarCompat

use of jackpal.androidterm.compat.ActionBarCompat in project Android-Terminal-Emulator by jackpal.

the class Term method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Log.v(TermDebug.LOG_TAG, "onCreate");
    mPrivateAlias = new ComponentName(this, RemoteInterface.PRIVACT_ACTIVITY_ALIAS);
    if (icicle == null)
        onNewIntent(getIntent());
    final SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mSettings = new TermSettings(getResources(), mPrefs);
    mPrefs.registerOnSharedPreferenceChangeListener(this);
    Intent broadcast = new Intent(ACTION_PATH_BROADCAST);
    if (AndroidCompat.SDK >= 12) {
        broadcast.addFlags(FLAG_INCLUDE_STOPPED_PACKAGES);
    }
    mPendingPathBroadcasts++;
    sendOrderedBroadcast(broadcast, PERMISSION_PATH_BROADCAST, mPathReceiver, null, RESULT_OK, null, null);
    broadcast = new Intent(broadcast);
    broadcast.setAction(ACTION_PATH_PREPEND_BROADCAST);
    mPendingPathBroadcasts++;
    sendOrderedBroadcast(broadcast, PERMISSION_PATH_PREPEND_BROADCAST, mPathReceiver, null, RESULT_OK, null, null);
    TSIntent = new Intent(this, TermService.class);
    startService(TSIntent);
    if (AndroidCompat.SDK >= 11) {
        int actionBarMode = mSettings.actionBarMode();
        mActionBarMode = actionBarMode;
        if (AndroidCompat.V11ToV20) {
            switch(actionBarMode) {
                case TermSettings.ACTION_BAR_MODE_ALWAYS_VISIBLE:
                    setTheme(R.style.Theme_Holo);
                    break;
                case TermSettings.ACTION_BAR_MODE_HIDES:
                    setTheme(R.style.Theme_Holo_ActionBarOverlay);
                    break;
            }
        }
    } else {
        mActionBarMode = TermSettings.ACTION_BAR_MODE_ALWAYS_VISIBLE;
    }
    setContentView(R.layout.term_activity);
    mViewFlipper = (TermViewFlipper) findViewById(VIEW_FLIPPER);
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TermDebug.LOG_TAG);
    WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    int wifiLockMode = WifiManager.WIFI_MODE_FULL;
    if (AndroidCompat.SDK >= 12) {
        wifiLockMode = WIFI_MODE_FULL_HIGH_PERF;
    }
    mWifiLock = wm.createWifiLock(wifiLockMode, TermDebug.LOG_TAG);
    ActionBarCompat actionBar = ActivityCompat.getActionBar(this);
    if (actionBar != null) {
        mActionBar = actionBar;
        actionBar.setNavigationMode(ActionBarCompat.NAVIGATION_MODE_LIST);
        actionBar.setDisplayOptions(0, ActionBarCompat.DISPLAY_SHOW_TITLE);
        if (mActionBarMode == TermSettings.ACTION_BAR_MODE_HIDES) {
            actionBar.hide();
        }
    }
    mHaveFullHwKeyboard = checkHaveFullHwKeyboard(getResources().getConfiguration());
    updatePrefs();
    mAlreadyStarted = true;
}
Also used : PowerManager(android.os.PowerManager) ActionBarCompat(jackpal.androidterm.compat.ActionBarCompat) WifiManager(android.net.wifi.WifiManager) SharedPreferences(android.content.SharedPreferences) TermSettings(jackpal.androidterm.util.TermSettings) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 2 with ActionBarCompat

use of jackpal.androidterm.compat.ActionBarCompat in project Android-Terminal-Emulator by jackpal.

the class WindowList method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    ListView listView = getListView();
    View newWindow = getLayoutInflater().inflate(R.layout.window_list_new_window, listView, false);
    listView.addHeaderView(newWindow, null, true);
    setResult(RESULT_CANCELED);
    // Display up indicator on action bar home button
    if (AndroidCompat.SDK >= 11) {
        ActionBarCompat bar = ActivityCompat.getActionBar(this);
        if (bar != null) {
            bar.setDisplayOptions(ActionBarCompat.DISPLAY_HOME_AS_UP, ActionBarCompat.DISPLAY_HOME_AS_UP);
        }
    }
}
Also used : ActionBarCompat(jackpal.androidterm.compat.ActionBarCompat) ListView(android.widget.ListView) ImageView(android.widget.ImageView) View(android.view.View) ListView(android.widget.ListView)

Example 3 with ActionBarCompat

use of jackpal.androidterm.compat.ActionBarCompat in project Android-Terminal-Emulator by jackpal.

the class TermPreferences method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);
    // Remove the action bar pref on older platforms without an action bar
    if (AndroidCompat.SDK < 11) {
        Preference actionBarPref = findPreference(ACTIONBAR_KEY);
        PreferenceCategory screenCategory = (PreferenceCategory) findPreference(CATEGORY_SCREEN_KEY);
        if ((actionBarPref != null) && (screenCategory != null)) {
            screenCategory.removePreference(actionBarPref);
        }
    }
    // Display up indicator on action bar home button
    if (AndroidCompat.V11ToV20) {
        ActionBarCompat bar = ActivityCompat.getActionBar(this);
        if (bar != null) {
            bar.setDisplayOptions(ActionBarCompat.DISPLAY_HOME_AS_UP, ActionBarCompat.DISPLAY_HOME_AS_UP);
        }
    }
}
Also used : ActionBarCompat(jackpal.androidterm.compat.ActionBarCompat) Preference(android.preference.Preference) PreferenceCategory(android.preference.PreferenceCategory)

Aggregations

ActionBarCompat (jackpal.androidterm.compat.ActionBarCompat)3 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 WifiManager (android.net.wifi.WifiManager)1 PowerManager (android.os.PowerManager)1 Preference (android.preference.Preference)1 PreferenceCategory (android.preference.PreferenceCategory)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TermSettings (jackpal.androidterm.util.TermSettings)1