mirror of
https://github.com/gsantner/dandelion
synced 2024-12-22 10:58:01 +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.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
@ -107,11 +105,7 @@ public class AboutActivity extends ThemedActivity
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (getAppSettings().isIntellihideToolbars()) {
|
||||
this.enableToolbarHiding();
|
||||
} else {
|
||||
this.disableToolbarHiding();
|
||||
}
|
||||
setToolbarIntellihide(getAppSettings().isIntellihideToolbars());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,20 +115,16 @@ public class AboutActivity extends ThemedActivity
|
|||
ThemeHelper.setPrimaryColorAsBackground(_linearLayout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableToolbarHiding() {
|
||||
AppLog.d(this, "Enable Intellihide");
|
||||
public void setToolbarIntellihide(boolean enable) {
|
||||
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) _linearLayout.getLayoutParams();
|
||||
//scroll|enterAlways|snap
|
||||
params.setScrollFlags(toolbarDefaultScrollFlags);
|
||||
_appBarLayout.setExpanded(true, true);
|
||||
}
|
||||
if (enable) {
|
||||
AppLog.d(this, "Enable Intellihide");
|
||||
params.setScrollFlags(toolbarDefaultScrollFlags);
|
||||
|
||||
@Override
|
||||
public void disableToolbarHiding() {
|
||||
AppLog.d(this, "Disable Intellihide");
|
||||
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) _linearLayout.getLayoutParams();
|
||||
params.setScrollFlags(0); // clear all scroll flags
|
||||
} else {
|
||||
AppLog.d(this, "Disable Intellihide");
|
||||
params.setScrollFlags(0); // clear all scroll flags
|
||||
}
|
||||
_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.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
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 java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
@ -366,11 +365,7 @@ public class MainActivity extends ThemedActivity
|
|||
AppLog.v(this, "Fragment was not visible. Replace it.");
|
||||
fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit();
|
||||
invalidateOptionsMenu();
|
||||
if (_appSettings.isIntellihideToolbars() && fragment.isAllowedIntellihide()) {
|
||||
this.enableToolbarHiding();
|
||||
} else {
|
||||
this.disableToolbarHiding();
|
||||
}
|
||||
setToolbarIntellihide(_appSettings.isIntellihideToolbars() && fragment.isAllowedIntellihide());
|
||||
} else {
|
||||
AppLog.v(this, "Fragment was already visible. Do nothing.");
|
||||
}
|
||||
|
@ -654,10 +649,9 @@ public class MainActivity extends ThemedActivity
|
|||
if (_appSettings.isRecreateMainActivity()) {
|
||||
recreate();
|
||||
}
|
||||
if (_appSettings.isIntellihideToolbars()) {
|
||||
enableToolbarHiding();
|
||||
} else {
|
||||
disableToolbarHiding();
|
||||
setToolbarIntellihide(_appSettings.isIntellihideToolbars());
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(AppSettings.get().isShowTitleInMainView());
|
||||
}
|
||||
updateNavigationViewEntryVisibilities();
|
||||
}
|
||||
|
@ -679,13 +673,12 @@ public class MainActivity extends ThemedActivity
|
|||
|
||||
CustomFragment top = getTopFragment();
|
||||
if (top != null) {
|
||||
boolean isPodSel = top.getFragmentTag().equals(PodSelectionFragment.TAG);
|
||||
|
||||
// Extended notifications
|
||||
cache = _appSettings.isExtendedNotificationsActivated();
|
||||
getMenuInflater().inflate(R.menu.main__menu_top, menu);
|
||||
menu.findItem(R.id.action_notifications).setVisible(!cache);
|
||||
menu.findItem(R.id.action_notifications_extended).setVisible(cache);
|
||||
if (!top.getFragmentTag().equals(PodSelectionFragment.TAG)) {
|
||||
cache = _appSettings.isExtendedNotificationsActivated();
|
||||
getMenuInflater().inflate(R.menu.main__menu_top, menu);
|
||||
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());
|
||||
|
@ -1222,20 +1215,16 @@ public class MainActivity extends ThemedActivity
|
|||
toolbarTop.setPopupTheme(popupTheme);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableToolbarHiding() {
|
||||
AppLog.d(this, "Enable Intellihide");
|
||||
public void setToolbarIntellihide(boolean enable) {
|
||||
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarTop.getLayoutParams();
|
||||
//scroll|enterAlways|snap
|
||||
params.setScrollFlags(toolbarDefaultScrollFlags);
|
||||
appBarLayout.setExpanded(true, true);
|
||||
}
|
||||
if (enable) {
|
||||
AppLog.d(this, "Enable Intellihide");
|
||||
params.setScrollFlags(toolbarDefaultScrollFlags);
|
||||
|
||||
@Override
|
||||
public void disableToolbarHiding() {
|
||||
AppLog.d(this, "Disable Intellihide");
|
||||
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarTop.getLayoutParams();
|
||||
params.setScrollFlags(0); // clear all scroll flags
|
||||
} else {
|
||||
AppLog.d(this, "Disable Intellihide");
|
||||
params.setScrollFlags(0); // clear all scroll flags
|
||||
}
|
||||
appBarLayout.setExpanded(true, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Build;
|
||||
|
|
|
@ -190,8 +190,7 @@ public class SettingsActivity extends ThemedActivity implements SharedPreference
|
|||
/** Usability */
|
||||
else if (settings.isKeyEqual(key, R.string.pref_key__is_overview_statusbar_hidden)) {
|
||||
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);
|
||||
}
|
||||
/** Network */
|
||||
|
|
|
@ -26,8 +26,6 @@ import android.support.v7.widget.AppCompatImageView;
|
|||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
|
|
@ -10,7 +10,5 @@ import android.support.design.widget.AppBarLayout;
|
|||
public interface IntellihideToolbarActivityListener {
|
||||
int toolbarDefaultScrollFlags = AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP;
|
||||
|
||||
void enableToolbarHiding();
|
||||
|
||||
void disableToolbarHiding();
|
||||
void setToolbarIntellihide(boolean enable);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package com.github.dfa.diaspora_android.ui;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.AppCompatTextView;
|
||||
import android.text.Html;
|
||||
|
|
|
@ -20,8 +20,6 @@ package com.github.dfa.diaspora_android.ui.theme;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
||||
/**
|
||||
* 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.app.ActivityManager;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Build;
|
||||
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.ContextUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Activity that supports color schemes
|
||||
* Created by vanitas on 06.10.16.
|
||||
|
|
|
@ -448,4 +448,8 @@ public class AppSettings extends AppSettingsBase {
|
|||
setRecreateMainActivity(false);
|
||||
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.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
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__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__show_title" translatable="false">pref_key__show_title</string>
|
||||
</resources>
|
||||
|
|
|
@ -96,4 +96,6 @@
|
|||
<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_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>
|
||||
|
|
|
@ -80,6 +80,13 @@
|
|||
android:summary="@string/pref_desc__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
|
||||
android:defaultValue="@string/rotation_val_system"
|
||||
android:entries="@array/pref_entries__screen_rotation"
|
||||
|
|
Loading…
Reference in a new issue