Skip to content

Commit

Permalink
Merge pull request irssiconnectbot#31 from alademan/master
Browse files Browse the repository at this point in the history
Removing ActionBar is now a user preference.
  • Loading branch information
Iiro Uusitalo committed Jan 6, 2012
2 parents 82b99b5 + 70fbbe8 commit bd8c9e9
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Expand Up @@ -49,7 +49,7 @@
android:description="@string/service_desc"/>

<activity android:name=".ConsoleActivity" android:configChanges="keyboardHidden|orientation"
android:theme="@android:style/Theme.Holo.NoActionBar" android:windowSoftInputMode="stateAlwaysVisible|adjustResize"
android:theme="@style/NoTitle" android:windowSoftInputMode="stateAlwaysVisible|adjustResize"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
Expand Down
5 changes: 5 additions & 0 deletions res/values/strings.xml
Expand Up @@ -198,6 +198,11 @@
<!-- Summary for the haptic feedback (bumpy arrow) preference -->
<string name="pref_bumpyarrows_summary">"Vibrate when sending arrow keys from trackball; useful for laggy connections"</string>

<!-- Name for the action bar preference -->
<string name="pref_actionbar_title">"Action Bar"</string>
<!-- Sumary for the action bar preference -->
<string name="pref_actionbar_summary">"Display Action Bar in a session. Note: Honeycomb and Ice Cream Sandwich users may need the Action Bar to access the menu."</string>

<!-- Category title for the Terminal Bell preferences -->
<string name="pref_bell_category">"Terminal bell"</string>

Expand Down
11 changes: 10 additions & 1 deletion res/xml/preferences.xml
Expand Up @@ -66,7 +66,8 @@
</PreferenceCategory>

<PreferenceCategory
android:title="@string/pref_ui_category">
android:title="@string/pref_ui_category"
android:key="pref_ui_category">

<ListPreference
android:key="rotation"
Expand Down Expand Up @@ -122,6 +123,14 @@
android:summary="@string/pref_bumpyarrows_summary"
android:defaultValue="true"
/>

<CheckBoxPreference
android:key="actionbarsetting"
android:title="@string/pref_actionbar_title"
android:summary="@string/pref_actionbar_summary"
android:defaultValue="true"
/>

</PreferenceCategory>

<PreferenceCategory
Expand Down
16 changes: 16 additions & 0 deletions src/org/woltage/irssiconnectbot/ConsoleActivity.java
Expand Up @@ -27,6 +27,7 @@
import com.bugsense.trace.BugSenseHandler;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ActionBar;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
Expand Down Expand Up @@ -275,6 +276,21 @@ public void onCreate(Bundle icicle) {
clipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
prefs = PreferenceManager.getDefaultSharedPreferences(this);

// hide action bar if requested by user
try
{
ActionBar actionBar = getActionBar();
if (!prefs.getBoolean(PreferenceConstants.ACTIONBAR, true))
{
actionBar.hide();
}
}
catch (NoSuchMethodError error)
{
Log.w(TAG, "Android sdk version pre 11. Not touching ActionBar.");
}


// hide status bar if requested by user
if (prefs.getBoolean(PreferenceConstants.FULLSCREEN, false)) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
Expand Down
14 changes: 14 additions & 0 deletions src/org/woltage/irssiconnectbot/SettingsActivity.java
Expand Up @@ -20,8 +20,11 @@
import org.woltage.irssiconnectbot.util.PreferenceConstants;

import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceManager;
import android.util.Log;

Expand Down Expand Up @@ -51,8 +54,19 @@ protected void onCreate(Bundle savedInstanceState) {
editor.commit();

addPreferencesFromResource(R.xml.preferences);

// Check version of Android running on device and display Action Bar preference accordingly
// This can be extended to hide other HoneyComb or greater settings

}

int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
if (sdkVersion < Build.VERSION_CODES.HONEYCOMB)
{
PreferenceCategory uiCategory = (PreferenceCategory) findPreference("pref_ui_category");
CheckBoxPreference actionBarCheckBox = (CheckBoxPreference) findPreference("actionbarsetting");
uiCategory.removePreference(actionBarCheckBox);
}
// TODO: add parse checking here to make sure we have integer value for scrollback

}
Expand Down
2 changes: 2 additions & 0 deletions src/org/woltage/irssiconnectbot/util/PreferenceConstants.java
Expand Up @@ -68,6 +68,8 @@ public class PreferenceConstants {

public static final String BUMPY_ARROWS = "bumpyarrows";

public static final String ACTIONBAR = "actionbarsetting";

public static final String EULA = "eula";

public static final String SORT_BY_COLOR = "sortByColor";
Expand Down

0 comments on commit bd8c9e9

Please sign in to comment.