From 00e238a02891f9464b7f6bdd989fac39a0114b45 Mon Sep 17 00:00:00 2001 From: vanitasvitae Date: Thu, 10 Nov 2016 14:18:22 +0100 Subject: [PATCH] Added back stream loading on topbar click. Made it toggleable in settings --- .../activity/MainActivity.java | 18 ++++++++++++++++++ .../dfa/diaspora_android/util/AppSettings.java | 4 ++++ .../res/drawable/ic_touch_app_black_24px.xml | 16 ++++++++++++++++ .../main/res/values/strings-preferences.xml | 6 ++++++ app/src/main/res/xml/preferences__master.xml | 13 +++++++++++++ 5 files changed, 57 insertions(+) create mode 100644 app/src/main/res/drawable/ic_touch_app_black_24px.xml diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java index 7e894bb4..6eda596b 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java @@ -38,6 +38,7 @@ import android.support.v4.app.FragmentManager; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AlertDialog; import android.support.v7.widget.ActionMenuView; @@ -82,6 +83,7 @@ import com.github.dfa.diaspora_android.web.custom_tab.CustomTabActivityHelper; import butterknife.BindView; import butterknife.ButterKnife; +import butterknife.OnClick; public class MainActivity extends ThemedActivity implements NavigationView.OnNavigationItemSelectedListener, @@ -223,6 +225,10 @@ public class MainActivity extends ThemedActivity // Setup toolbar setSupportActionBar(toolbarTop); + ActionBar actionBar = getSupportActionBar(); + if(actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true); + } toolbarBottom.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { CustomFragment top = getTopFragment(); @@ -408,6 +414,18 @@ public class MainActivity extends ThemedActivity } } + /** + * Forward toolbar clicks to onNavigationItemSelected + * @param view selected view + */ + @OnClick(R.id.main__topbar) + public void onToolBarClicked(View view) { + AppLog.i(this, "onToolBarClicked()"); + if(appSettings.isTopbarStreamShortcutEnabled()) { + onNavigationItemSelected(navView.getMenu().findItem(R.id.nav_stream)); + } + } + /** * Forward incoming intents to handleIntent() * diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/AppSettings.java b/app/src/main/java/com/github/dfa/diaspora_android/util/AppSettings.java index 5c363fd1..57e651f9 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/AppSettings.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/AppSettings.java @@ -398,6 +398,10 @@ public class AppSettings { return getBoolean(prefApp, R.string.pref_key__visibility_nav__reports, false); } + public boolean isTopbarStreamShortcutEnabled() { + return getBoolean(prefApp, R.string.pref_key__topbar_stream_shortcut, false); + } + public void setPrimaryColorSettings(int base, int shade) { setInt(prefApp, R.string.pref_key__primary_color_base, base); setInt(prefApp, R.string.pref_key__primary_color_shade, shade); diff --git a/app/src/main/res/drawable/ic_touch_app_black_24px.xml b/app/src/main/res/drawable/ic_touch_app_black_24px.xml new file mode 100644 index 00000000..1c1e60b3 --- /dev/null +++ b/app/src/main/res/drawable/ic_touch_app_black_24px.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings-preferences.xml b/app/src/main/res/values/strings-preferences.xml index 89bb1126..e1651112 100644 --- a/app/src/main/res/values/strings-preferences.xml +++ b/app/src/main/res/values/strings-preferences.xml @@ -14,6 +14,7 @@ pref_key__chrome_custom_tabs_enabled pref_key__http_proxy_load_tor_preset pref_key__extended_notifications + pref_key__topbar_stream_shortcut @string/pref_key__primary_color_shade @@ -29,6 +30,10 @@ pref_key_proxy_port wasProxyEnabled + + Top toolbar loads stream + Click an empty space in the top toolbar to open the stream + pref_key__visibility_navslider__exit pref_key__visibility_nav__help_license @@ -64,6 +69,7 @@ Network Pod settings @string/nav_menu_more + Operability diff --git a/app/src/main/res/xml/preferences__master.xml b/app/src/main/res/xml/preferences__master.xml index 87be0a87..0e149c44 100644 --- a/app/src/main/res/xml/preferences__master.xml +++ b/app/src/main/res/xml/preferences__master.xml @@ -33,6 +33,12 @@ android:title="@string/pref_title__intellihide_toolbars" android:icon="@drawable/ic_zoom_out_map_black_24px"/> + + + + + + +