<uses-permission-sdk-23 android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission-sdk-23 android:name="android.permission.GET_TASKS" />
+ <uses-permission-sdk-23 android:name="android.permission.WRITE_SETTINGS" />
<uses-feature
android:name="android.hardware.touchscreen"
package com.farmerbb.taskbar.activity;
import android.os.Bundle;
+import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
+import android.provider.Settings;
import com.farmerbb.taskbar.R;
+import com.farmerbb.taskbar.service.TaskbarService;
import com.farmerbb.taskbar.util.U;
public class NavigationBarButtonsActivity extends PreferenceActivity implements Preference.OnPreferenceClickListener {
findPreference("button_back").setOnPreferenceClickListener(this);
findPreference("button_home").setOnPreferenceClickListener(this);
findPreference("button_recents").setOnPreferenceClickListener(this);
+
+ if(U.hasSupportLibrary(this))
+ findPreference("auto_hide_navbar").setOnPreferenceClickListener(this);
+ else
+ getPreferenceScreen().removePreference(findPreference("auto_hide_navbar_category"));
}
@Override
public boolean onPreferenceClick(Preference preference) {
- U.restartTaskbar(this);
+ switch(preference.getKey()) {
+ case "auto_hide_navbar":
+ if(U.isServiceRunning(this, TaskbarService.class)) {
+ boolean isChecked = ((CheckBoxPreference) preference).isChecked();
+
+ try {
+ Settings.System.putInt(getContentResolver(), "navigation_bar_show", isChecked ? 0 : 1);
+ } catch (Exception e) { /* Gracefully fail */ }
+ }
+ break;
+ default:
+ U.restartTaskbar(this);
+ break;
+ }
return true;
}
}
\ No newline at end of file
editor.putBoolean("full_length", true);
}
- if(intent.hasExtra("enable_navigation_bar_buttons")) {
+ if(intent.hasExtra("enable_navigation_bar_buttons") && U.isSystemApp(context)) {
editor.putBoolean("dashboard", true);
editor.putBoolean("button_back", true);
editor.putBoolean("button_home", true);
editor.putBoolean("button_recents", true);
+ editor.putBoolean("auto_hide_navbar", true);
}
editor.apply();
else if(!pref.getBoolean("collapsed", false) && pref.getBoolean("taskbar_active", false))
toggleTaskbar();
+ if(pref.getBoolean("auto_hide_navbar", false))
+ try {
+ Settings.System.putInt(getContentResolver(), "navigation_bar_show", 0);
+ } catch (Exception e) { /* Gracefully fail */ }
+
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
lbm.unregisterReceiver(showReceiver);
windowManager.removeView(layout);
} catch (IllegalArgumentException e) { /* Gracefully fail */ }
+ SharedPreferences pref = U.getSharedPreferences(this);
+ if(pref.getBoolean("skip_auto_hide_navbar", false)) {
+ pref.edit().remove("skip_auto_hide_navbar").apply();
+ } else if(pref.getBoolean("auto_hide_navbar", false))
+ try {
+ Settings.System.putInt(getContentResolver(), "navigation_bar_show", 1);
+ } catch (Exception e) { /* Gracefully fail */ }
+
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
lbm.unregisterReceiver(showReceiver);
public static void restartTaskbar(Context context) {
SharedPreferences pref = getSharedPreferences(context);
if(pref.getBoolean("taskbar_active", false) && !pref.getBoolean("is_hidden", false)) {
- pref.edit().putBoolean("is_restarting", true).apply();
+ pref.edit()
+ .putBoolean("is_restarting", true)
+ .putBoolean("skip_auto_hide_navbar", true)
+ .apply();
stopTaskbarService(context, true);
startTaskbarService(context, true);
} else if(isServiceRunning(context, StartMenuService.class)) {
+ pref.edit().putBoolean("skip_auto_hide_navbar", true).apply();
+
stopTaskbarService(context, false);
startTaskbarService(context, false);
}
<string name="freeform_on">Freeform on</string>
<string name="freeform_off">Freeform off</string>
+ <string name="auto_hide_navbar">Automatically control the system navigation bar</string>
+ <string name="auto_hide_navbar_description">Hide the navigation bar when Taskbar is active, and show it when Taskbar is inactive</string>
+
</resources>
<string name="freeform_on">Freeform on</string>
<string name="freeform_off">Freeform off</string>
+ <string name="auto_hide_navbar">Automatically control the system navigation bar</string>
+ <string name="auto_hide_navbar_description">Hide the navigation bar when Taskbar is active, and show it when Taskbar is inactive</string>
+
</resources>
<string name="freeform_on">Freeform on</string>
<string name="freeform_off">Freeform off</string>
+ <string name="auto_hide_navbar">Automatically control the system navigation bar</string>
+ <string name="auto_hide_navbar_description">Hide the navigation bar when Taskbar is active, and show it when Taskbar is inactive</string>
+
</resources>
<string name="freeform_on">Freeform on</string>
<string name="freeform_off">Freeform off</string>
+ <string name="auto_hide_navbar">Automatically control the system navigation bar</string>
+ <string name="auto_hide_navbar_description">Hide the navigation bar when Taskbar is active, and show it when Taskbar is inactive</string>
+
</resources>
android:key="button_recents"
android:title="@string/button_recents" />
+ <PreferenceCategory android:key="auto_hide_navbar_category" >
+
+ <CheckBoxPreference
+ android:defaultValue="false"
+ android:key="auto_hide_navbar"
+ android:title="@string/auto_hide_navbar"
+ android:summary="@string/auto_hide_navbar_description" />
+
+ </PreferenceCategory>
+
</PreferenceScreen>