mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 04:12:08 +01:00
Modify toolbar item positions
This commit is contained in:
parent
d1d2d7b4d1
commit
086f056216
17 changed files with 43 additions and 81 deletions
|
@ -34,8 +34,6 @@ import android.support.v4.app.FragmentPagerAdapter;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
@ -107,11 +105,7 @@ public class AboutActivity extends ThemedActivity
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (getAppSettings().isIntellihideToolbars()) {
|
setToolbarIntellihide(getAppSettings().isIntellihideToolbars());
|
||||||
this.enableToolbarHiding();
|
|
||||||
} else {
|
|
||||||
this.disableToolbarHiding();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,20 +115,16 @@ public class AboutActivity extends ThemedActivity
|
||||||
ThemeHelper.setPrimaryColorAsBackground(_linearLayout);
|
ThemeHelper.setPrimaryColorAsBackground(_linearLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setToolbarIntellihide(boolean enable) {
|
||||||
public void enableToolbarHiding() {
|
|
||||||
AppLog.d(this, "Enable Intellihide");
|
|
||||||
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) _linearLayout.getLayoutParams();
|
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) _linearLayout.getLayoutParams();
|
||||||
//scroll|enterAlways|snap
|
if (enable) {
|
||||||
params.setScrollFlags(toolbarDefaultScrollFlags);
|
AppLog.d(this, "Enable Intellihide");
|
||||||
_appBarLayout.setExpanded(true, true);
|
params.setScrollFlags(toolbarDefaultScrollFlags);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
} else {
|
||||||
public void disableToolbarHiding() {
|
AppLog.d(this, "Disable Intellihide");
|
||||||
AppLog.d(this, "Disable Intellihide");
|
params.setScrollFlags(0); // clear all scroll flags
|
||||||
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) _linearLayout.getLayoutParams();
|
}
|
||||||
params.setScrollFlags(0); // clear all scroll flags
|
|
||||||
_appBarLayout.setExpanded(true, true);
|
_appBarLayout.setExpanded(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,6 @@ import android.support.v7.widget.AppCompatImageView;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
|
@ -90,7 +90,6 @@ import com.github.dfa.diaspora_android.web.custom_tab.CustomTabActivityHelper;
|
||||||
import net.gsantner.opoc.util.SimpleMarkdownParser;
|
import net.gsantner.opoc.util.SimpleMarkdownParser;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
@ -366,11 +365,7 @@ public class MainActivity extends ThemedActivity
|
||||||
AppLog.v(this, "Fragment was not visible. Replace it.");
|
AppLog.v(this, "Fragment was not visible. Replace it.");
|
||||||
fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit();
|
fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit();
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
if (_appSettings.isIntellihideToolbars() && fragment.isAllowedIntellihide()) {
|
setToolbarIntellihide(_appSettings.isIntellihideToolbars() && fragment.isAllowedIntellihide());
|
||||||
this.enableToolbarHiding();
|
|
||||||
} else {
|
|
||||||
this.disableToolbarHiding();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
AppLog.v(this, "Fragment was already visible. Do nothing.");
|
AppLog.v(this, "Fragment was already visible. Do nothing.");
|
||||||
}
|
}
|
||||||
|
@ -654,10 +649,9 @@ public class MainActivity extends ThemedActivity
|
||||||
if (_appSettings.isRecreateMainActivity()) {
|
if (_appSettings.isRecreateMainActivity()) {
|
||||||
recreate();
|
recreate();
|
||||||
}
|
}
|
||||||
if (_appSettings.isIntellihideToolbars()) {
|
setToolbarIntellihide(_appSettings.isIntellihideToolbars());
|
||||||
enableToolbarHiding();
|
if (getSupportActionBar() != null) {
|
||||||
} else {
|
getSupportActionBar().setDisplayShowTitleEnabled(AppSettings.get().isShowTitleInMainView());
|
||||||
disableToolbarHiding();
|
|
||||||
}
|
}
|
||||||
updateNavigationViewEntryVisibilities();
|
updateNavigationViewEntryVisibilities();
|
||||||
}
|
}
|
||||||
|
@ -679,13 +673,12 @@ public class MainActivity extends ThemedActivity
|
||||||
|
|
||||||
CustomFragment top = getTopFragment();
|
CustomFragment top = getTopFragment();
|
||||||
if (top != null) {
|
if (top != null) {
|
||||||
boolean isPodSel = top.getFragmentTag().equals(PodSelectionFragment.TAG);
|
if (!top.getFragmentTag().equals(PodSelectionFragment.TAG)) {
|
||||||
|
cache = _appSettings.isExtendedNotificationsActivated();
|
||||||
// Extended notifications
|
getMenuInflater().inflate(R.menu.main__menu_top, menu);
|
||||||
cache = _appSettings.isExtendedNotificationsActivated();
|
menu.findItem(R.id.action_notifications).setVisible(!cache);
|
||||||
getMenuInflater().inflate(R.menu.main__menu_top, menu);
|
menu.findItem(R.id.action_notifications_extended).setVisible(cache);
|
||||||
menu.findItem(R.id.action_notifications).setVisible(!cache);
|
}
|
||||||
menu.findItem(R.id.action_notifications_extended).setVisible(cache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean darkBg = ContextUtils.get().shouldColorOnTopBeLight(AppSettings.get().getPrimaryColor());
|
final boolean darkBg = ContextUtils.get().shouldColorOnTopBeLight(AppSettings.get().getPrimaryColor());
|
||||||
|
@ -1222,20 +1215,16 @@ public class MainActivity extends ThemedActivity
|
||||||
toolbarTop.setPopupTheme(popupTheme);
|
toolbarTop.setPopupTheme(popupTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setToolbarIntellihide(boolean enable) {
|
||||||
public void enableToolbarHiding() {
|
|
||||||
AppLog.d(this, "Enable Intellihide");
|
|
||||||
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarTop.getLayoutParams();
|
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarTop.getLayoutParams();
|
||||||
//scroll|enterAlways|snap
|
if (enable) {
|
||||||
params.setScrollFlags(toolbarDefaultScrollFlags);
|
AppLog.d(this, "Enable Intellihide");
|
||||||
appBarLayout.setExpanded(true, true);
|
params.setScrollFlags(toolbarDefaultScrollFlags);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
} else {
|
||||||
public void disableToolbarHiding() {
|
AppLog.d(this, "Disable Intellihide");
|
||||||
AppLog.d(this, "Disable Intellihide");
|
params.setScrollFlags(0); // clear all scroll flags
|
||||||
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarTop.getLayoutParams();
|
}
|
||||||
params.setScrollFlags(0); // clear all scroll flags
|
|
||||||
appBarLayout.setExpanded(true, true);
|
appBarLayout.setExpanded(true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.ColorStateList;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
|
@ -190,8 +190,7 @@ public class SettingsActivity extends ThemedActivity implements SharedPreference
|
||||||
/** Usability */
|
/** Usability */
|
||||||
else if (settings.isKeyEqual(key, R.string.pref_key__is_overview_statusbar_hidden)) {
|
else if (settings.isKeyEqual(key, R.string.pref_key__is_overview_statusbar_hidden)) {
|
||||||
AppSettings.get().setRecreateMainActivity(true);
|
AppSettings.get().setRecreateMainActivity(true);
|
||||||
}
|
} else if (settings.isKeyEqual(key, R.string.pref_key__language)) {
|
||||||
else if (settings.isKeyEqual(key, R.string.pref_key__language)) {
|
|
||||||
AppSettings.get().setRecreateMainActivity(true);
|
AppSettings.get().setRecreateMainActivity(true);
|
||||||
}
|
}
|
||||||
/** Network */
|
/** Network */
|
||||||
|
|
|
@ -26,8 +26,6 @@ import android.support.v7.widget.AppCompatImageView;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
|
@ -10,7 +10,5 @@ import android.support.design.widget.AppBarLayout;
|
||||||
public interface IntellihideToolbarActivityListener {
|
public interface IntellihideToolbarActivityListener {
|
||||||
int toolbarDefaultScrollFlags = AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP;
|
int toolbarDefaultScrollFlags = AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP;
|
||||||
|
|
||||||
void enableToolbarHiding();
|
void setToolbarIntellihide(boolean enable);
|
||||||
|
|
||||||
void disableToolbarHiding();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package com.github.dfa.diaspora_android.ui;
|
package com.github.dfa.diaspora_android.ui;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v7.widget.AppCompatTextView;
|
import android.support.v7.widget.AppCompatTextView;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
|
|
@ -20,8 +20,6 @@ package com.github.dfa.diaspora_android.ui.theme;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customized abstract Fragment class with some useful methods
|
* Customized abstract Fragment class with some useful methods
|
||||||
|
|
|
@ -21,7 +21,6 @@ package com.github.dfa.diaspora_android.ui.theme;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
@ -31,8 +30,6 @@ import com.github.dfa.diaspora_android.R;
|
||||||
import com.github.dfa.diaspora_android.util.AppSettings;
|
import com.github.dfa.diaspora_android.util.AppSettings;
|
||||||
import com.github.dfa.diaspora_android.util.ContextUtils;
|
import com.github.dfa.diaspora_android.util.ContextUtils;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity that supports color schemes
|
* Activity that supports color schemes
|
||||||
* Created by vanitas on 06.10.16.
|
* Created by vanitas on 06.10.16.
|
||||||
|
|
|
@ -448,4 +448,8 @@ public class AppSettings extends AppSettingsBase {
|
||||||
setRecreateMainActivity(false);
|
setRecreateMainActivity(false);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShowTitleInMainView() {
|
||||||
|
return getBool(R.string.pref_key__show_title, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,6 @@ import android.os.Environment;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
tools:context="com.github.dfa.diaspora_android.activity.MainActivity"
|
|
||||||
tools:ignore="AlwaysShowAction">
|
|
||||||
|
|
||||||
</menu>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
tools:ignore="AlwaysShowAction">
|
|
||||||
|
|
||||||
|
|
||||||
</menu>
|
|
|
@ -126,4 +126,5 @@
|
||||||
<string name="pref_key__adblock_enable" translatable="false">pref_key__adblock_enable</string>
|
<string name="pref_key__adblock_enable" translatable="false">pref_key__adblock_enable</string>
|
||||||
<string name="pref_key__is_overview_statusbar_hidden" translatable="false">pref_key__is_overview_statusbar_hidden</string>
|
<string name="pref_key__is_overview_statusbar_hidden" translatable="false">pref_key__is_overview_statusbar_hidden</string>
|
||||||
<string name="pref_key__recreate_main_activity" translatable="false">pref_key__recreate_main_activity</string>
|
<string name="pref_key__recreate_main_activity" translatable="false">pref_key__recreate_main_activity</string>
|
||||||
|
<string name="pref_key__show_title" translatable="false">pref_key__show_title</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -96,4 +96,6 @@
|
||||||
<string name="jump_to_last_visited_timestamp_in_stream">Jump to last visited page in stream?</string>
|
<string name="jump_to_last_visited_timestamp_in_stream">Jump to last visited page in stream?</string>
|
||||||
<string name="pref_summary__is_statusbar_hidden">Hide statusbar at main view</string>
|
<string name="pref_summary__is_statusbar_hidden">Hide statusbar at main view</string>
|
||||||
<string name="pref_title__is_statusbar_hidden">Hide statusbar</string>
|
<string name="pref_title__is_statusbar_hidden">Hide statusbar</string>
|
||||||
|
<string name="pref_summary__show_title">Show title in the main view</string>
|
||||||
|
<string name="pref_title__show_title">Show title</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -80,6 +80,13 @@
|
||||||
android:summary="@string/pref_desc__topbar_stream_shortcut"
|
android:summary="@string/pref_desc__topbar_stream_shortcut"
|
||||||
android:title="@string/pref_title__topbar_stream_shortcut"/>
|
android:title="@string/pref_title__topbar_stream_shortcut"/>
|
||||||
|
|
||||||
|
<com.github.dfa.diaspora_android.ui.theme.ThemedCheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:icon="@drawable/ic_visibility_black_24dp"
|
||||||
|
android:key="@string/pref_key__show_title"
|
||||||
|
android:summary="@string/pref_summary__show_title"
|
||||||
|
android:title="@string/pref_title__show_title"/>
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:defaultValue="@string/rotation_val_system"
|
android:defaultValue="@string/rotation_val_system"
|
||||||
android:entries="@array/pref_entries__screen_rotation"
|
android:entries="@array/pref_entries__screen_rotation"
|
||||||
|
|
Loading…
Reference in a new issue