use of android.support.v4.widget.Space in project toshi-android-client by toshiapp.
the class ChatInputView method showSendButton.
private void showSendButton() {
final ImageButton sendButton = (ImageButton) findViewById(R.id.send_button);
final Space sendSpacing = (Space) findViewById(R.id.send_spacing);
sendButton.setVisibility(View.VISIBLE);
sendSpacing.setVisibility(View.GONE);
ViewCompat.animate(sendButton).alpha(1f).setDuration(50);
}
use of android.support.v4.widget.Space in project Taskbar by farmerbb.
the class TaskbarService method drawTaskbar.
@SuppressLint("RtlHardcoded")
private void drawTaskbar() {
IconCache.getInstance(this).clearCache();
// Initialize layout params
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
U.setCachedRotation(windowManager.getDefaultDisplay().getRotation());
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, CompatUtils.getOverlayType(), WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, PixelFormat.TRANSLUCENT);
// Determine where to show the taskbar on screen
switch(U.getTaskbarPosition(this)) {
case "bottom_left":
layoutId = R.layout.taskbar_left;
params.gravity = Gravity.BOTTOM | Gravity.LEFT;
positionIsVertical = false;
break;
case "bottom_vertical_left":
layoutId = R.layout.taskbar_vertical;
params.gravity = Gravity.BOTTOM | Gravity.LEFT;
positionIsVertical = true;
break;
case "bottom_right":
layoutId = R.layout.taskbar_right;
params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
positionIsVertical = false;
break;
case "bottom_vertical_right":
layoutId = R.layout.taskbar_vertical;
params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
positionIsVertical = true;
break;
case "top_left":
layoutId = R.layout.taskbar_left;
params.gravity = Gravity.TOP | Gravity.LEFT;
positionIsVertical = false;
break;
case "top_vertical_left":
layoutId = R.layout.taskbar_top_vertical;
params.gravity = Gravity.TOP | Gravity.LEFT;
positionIsVertical = true;
break;
case "top_right":
layoutId = R.layout.taskbar_right;
params.gravity = Gravity.TOP | Gravity.RIGHT;
positionIsVertical = false;
break;
case "top_vertical_right":
layoutId = R.layout.taskbar_top_vertical;
params.gravity = Gravity.TOP | Gravity.RIGHT;
positionIsVertical = true;
break;
}
// Initialize views
SharedPreferences pref = U.getSharedPreferences(this);
boolean altButtonConfig = pref.getBoolean("alt_button_config", false);
layout = (LinearLayout) LayoutInflater.from(U.wrapContext(this)).inflate(layoutId, null);
taskbar = U.findViewById(layout, R.id.taskbar);
scrollView = U.findViewById(layout, R.id.taskbar_scrollview);
if (altButtonConfig) {
space = U.findViewById(layout, R.id.space_alt);
layout.findViewById(R.id.space).setVisibility(View.GONE);
} else {
space = U.findViewById(layout, R.id.space);
layout.findViewById(R.id.space_alt).setVisibility(View.GONE);
}
space.setOnClickListener(v -> toggleTaskbar());
startButton = U.findViewById(layout, R.id.start_button);
int padding;
if (pref.getBoolean("app_drawer_icon", false)) {
startButton.setImageDrawable(ContextCompat.getDrawable(this, U.isBlissOs(this) ? R.drawable.bliss : R.mipmap.ic_launcher));
padding = getResources().getDimensionPixelSize(R.dimen.app_drawer_icon_padding_alt);
} else {
startButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.all_apps_button_icon));
padding = getResources().getDimensionPixelSize(R.dimen.app_drawer_icon_padding);
}
startButton.setPadding(padding, padding, padding, padding);
startButton.setOnClickListener(ocl);
startButton.setOnLongClickListener(view -> {
openContextMenu();
return true;
});
startButton.setOnGenericMotionListener((view, motionEvent) -> {
if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY)
openContextMenu();
return false;
});
refreshInterval = (int) (Float.parseFloat(pref.getString("refresh_frequency", "2")) * 1000);
if (refreshInterval == 0)
refreshInterval = 100;
sortOrder = pref.getString("sort_order", "false");
runningAppsOnly = pref.getString("recents_amount", "past_day").equals("running_apps_only");
switch(pref.getString("recents_amount", "past_day")) {
case "past_day":
searchInterval = System.currentTimeMillis() - AlarmManager.INTERVAL_DAY;
break;
case "app_start":
long appStartTime = pref.getLong("time_of_service_start", System.currentTimeMillis());
long deviceStartTime = System.currentTimeMillis() - SystemClock.elapsedRealtime();
searchInterval = deviceStartTime > appStartTime ? deviceStartTime : appStartTime;
break;
case "show_all":
searchInterval = 0;
break;
}
Intent intent = new Intent("com.farmerbb.taskbar.HIDE_START_MENU");
LocalBroadcastManager.getInstance(TaskbarService.this).sendBroadcast(intent);
if (altButtonConfig) {
button = U.findViewById(layout, R.id.hide_taskbar_button_alt);
layout.findViewById(R.id.hide_taskbar_button).setVisibility(View.GONE);
} else {
button = U.findViewById(layout, R.id.hide_taskbar_button);
layout.findViewById(R.id.hide_taskbar_button_alt).setVisibility(View.GONE);
}
try {
button.setTypeface(Typeface.createFromFile("/system/fonts/Roboto-Regular.ttf"));
} catch (RuntimeException e) {
/* Gracefully fail */
}
updateButton(false);
button.setOnClickListener(v -> toggleTaskbar());
LinearLayout buttonLayout = U.findViewById(layout, altButtonConfig ? R.id.hide_taskbar_button_layout_alt : R.id.hide_taskbar_button_layout);
if (buttonLayout != null)
buttonLayout.setOnClickListener(v -> toggleTaskbar());
LinearLayout buttonLayoutToHide = U.findViewById(layout, altButtonConfig ? R.id.hide_taskbar_button_layout : R.id.hide_taskbar_button_layout_alt);
if (buttonLayoutToHide != null)
buttonLayoutToHide.setVisibility(View.GONE);
int backgroundTint = U.getBackgroundTint(this);
int accentColor = U.getAccentColor(this);
dashboardButton = U.findViewById(layout, R.id.dashboard_button);
navbarButtons = U.findViewById(layout, R.id.navbar_buttons);
dashboardEnabled = pref.getBoolean("dashboard", false);
if (dashboardEnabled) {
layout.findViewById(R.id.square1).setBackgroundColor(accentColor);
layout.findViewById(R.id.square2).setBackgroundColor(accentColor);
layout.findViewById(R.id.square3).setBackgroundColor(accentColor);
layout.findViewById(R.id.square4).setBackgroundColor(accentColor);
layout.findViewById(R.id.square5).setBackgroundColor(accentColor);
layout.findViewById(R.id.square6).setBackgroundColor(accentColor);
dashboardButton.setOnClickListener(v -> LocalBroadcastManager.getInstance(TaskbarService.this).sendBroadcast(new Intent("com.farmerbb.taskbar.TOGGLE_DASHBOARD")));
} else
dashboardButton.setVisibility(View.GONE);
if (pref.getBoolean("button_back", false)) {
navbarButtonsEnabled = true;
ImageView backButton = U.findViewById(layout, R.id.button_back);
backButton.setVisibility(View.VISIBLE);
backButton.setOnClickListener(v -> {
U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_BACK);
if (U.shouldCollapse(this, false))
hideTaskbar(true);
});
backButton.setOnLongClickListener(v -> {
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.showInputMethodPicker();
if (U.shouldCollapse(this, false))
hideTaskbar(true);
return true;
});
backButton.setOnGenericMotionListener((view13, motionEvent) -> {
if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.showInputMethodPicker();
if (U.shouldCollapse(this, false))
hideTaskbar(true);
}
return true;
});
}
if (pref.getBoolean("button_home", false)) {
navbarButtonsEnabled = true;
ImageView homeButton = U.findViewById(layout, R.id.button_home);
homeButton.setVisibility(View.VISIBLE);
homeButton.setOnClickListener(v -> {
U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_HOME);
if (U.shouldCollapse(this, false))
hideTaskbar(true);
});
homeButton.setOnLongClickListener(v -> {
Intent voiceSearchIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
voiceSearchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
startActivity(voiceSearchIntent);
} catch (ActivityNotFoundException e) {
/* Gracefully fail */
}
if (U.shouldCollapse(this, false))
hideTaskbar(true);
return true;
});
homeButton.setOnGenericMotionListener((view13, motionEvent) -> {
if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
Intent voiceSearchIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
voiceSearchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
startActivity(voiceSearchIntent);
} catch (ActivityNotFoundException e) {
/* Gracefully fail */
}
if (U.shouldCollapse(this, false))
hideTaskbar(true);
}
return true;
});
}
if (pref.getBoolean("button_recents", false)) {
navbarButtonsEnabled = true;
ImageView recentsButton = U.findViewById(layout, R.id.button_recents);
recentsButton.setVisibility(View.VISIBLE);
recentsButton.setOnClickListener(v -> {
U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_RECENTS);
if (U.shouldCollapse(this, false))
hideTaskbar(true);
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
recentsButton.setOnLongClickListener(v -> {
U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN);
if (U.shouldCollapse(this, false))
hideTaskbar(true);
return true;
});
recentsButton.setOnGenericMotionListener((view13, motionEvent) -> {
if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN);
if (U.shouldCollapse(this, false))
hideTaskbar(true);
}
return true;
});
}
}
if (!navbarButtonsEnabled)
navbarButtons.setVisibility(View.GONE);
layout.setBackgroundColor(backgroundTint);
layout.findViewById(R.id.divider).setBackgroundColor(accentColor);
button.setTextColor(accentColor);
if (isFirstStart && FreeformHackHelper.getInstance().isInFreeformWorkspace())
showTaskbar(false);
else if (!pref.getBoolean("collapsed", false) && pref.getBoolean("taskbar_active", false))
toggleTaskbar();
if (pref.getBoolean("auto_hide_navbar", false))
U.showHideNavigationBar(this, false);
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
lbm.unregisterReceiver(showReceiver);
lbm.unregisterReceiver(hideReceiver);
lbm.unregisterReceiver(tempShowReceiver);
lbm.unregisterReceiver(tempHideReceiver);
lbm.unregisterReceiver(startMenuAppearReceiver);
lbm.unregisterReceiver(startMenuDisappearReceiver);
lbm.registerReceiver(showReceiver, new IntentFilter("com.farmerbb.taskbar.SHOW_TASKBAR"));
lbm.registerReceiver(hideReceiver, new IntentFilter("com.farmerbb.taskbar.HIDE_TASKBAR"));
lbm.registerReceiver(tempShowReceiver, new IntentFilter("com.farmerbb.taskbar.TEMP_SHOW_TASKBAR"));
lbm.registerReceiver(tempHideReceiver, new IntentFilter("com.farmerbb.taskbar.TEMP_HIDE_TASKBAR"));
lbm.registerReceiver(startMenuAppearReceiver, new IntentFilter("com.farmerbb.taskbar.START_MENU_APPEARING"));
lbm.registerReceiver(startMenuDisappearReceiver, new IntentFilter("com.farmerbb.taskbar.START_MENU_DISAPPEARING"));
startRefreshingRecents();
windowManager.addView(layout, params);
isFirstStart = false;
}
use of android.support.v4.widget.Space in project MaterialNavigationDrawer by neokree.
the class MaterialNavigationDrawer method onCreate.
@SuppressWarnings("unchecked")
@Override
protected /**
* Do not Override this method!!! <br>
* Use init() instead
*/
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Resources.Theme theme = this.getTheme();
TypedValue typedValue = new TypedValue();
theme.resolveAttribute(R.attr.drawerType, typedValue, true);
drawerHeaderType = typedValue.data;
theme.resolveAttribute(R.attr.rippleBackport, typedValue, false);
rippleSupport = typedValue.data != 0;
theme.resolveAttribute(R.attr.uniqueToolbarColor, typedValue, false);
uniqueToolbarColor = typedValue.data != 0;
theme.resolveAttribute(R.attr.singleAccount, typedValue, false);
singleAccount = typedValue.data != 0;
theme.resolveAttribute(R.attr.multipaneSupport, typedValue, false);
multiPaneSupport = typedValue.data != 0;
theme.resolveAttribute(R.attr.learningPattern, typedValue, false);
learningPattern = typedValue.data != 0;
theme.resolveAttribute(R.attr.drawerColor, typedValue, true);
drawerColor = typedValue.data;
theme.resolveAttribute(R.attr.defaultSectionLoaded, typedValue, true);
defaultSectionLoaded = typedValue.data;
theme.resolveAttribute(R.attr.toolbarElevation, typedValue, false);
toolbarElevation = typedValue.data != 0;
if (drawerHeaderType == DRAWERHEADER_ACCOUNTS)
super.setContentView(R.layout.activity_material_navigation_drawer);
else
super.setContentView(R.layout.activity_material_navigation_drawer_customheader);
// init Typeface
fontManager = new TypefaceManager(this.getAssets());
// init toolbar & status bar
statusBar = (ImageView) findViewById(R.id.statusBar);
toolbar = (Toolbar) findViewById(R.id.toolbar);
// init drawer components
layout = (MaterialDrawerLayout) this.findViewById(R.id.drawer_layout);
content = (RelativeLayout) this.findViewById(R.id.content);
drawer = (RelativeLayout) this.findViewById(R.id.drawer);
if (drawerHeaderType == DRAWERHEADER_ACCOUNTS) {
username = (TextView) this.findViewById(R.id.user_nome);
usermail = (TextView) this.findViewById(R.id.user_email);
userphoto = (ImageView) this.findViewById(R.id.user_photo);
userSecondPhoto = (ImageView) this.findViewById(R.id.user_photo_2);
userThirdPhoto = (ImageView) this.findViewById(R.id.user_photo_3);
usercover = (ImageView) this.findViewById(R.id.user_cover);
usercoverSwitcher = (ImageView) this.findViewById(R.id.user_cover_switcher);
userButtonSwitcher = (ImageButton) this.findViewById(R.id.user_switcher);
// set Roboto Fonts
username.setTypeface(fontManager.getRobotoMedium());
usermail.setTypeface(fontManager.getRobotoRegular());
// get and set username and mail text colors
theme.resolveAttribute(R.attr.accountStyle, typedValue, true);
TypedArray attributes = theme.obtainStyledAttributes(typedValue.resourceId, R.styleable.MaterialAccount);
try {
username.setTextColor(attributes.getColor(R.styleable.MaterialAccount_titleColor, 0xFFF));
usermail.setTextColor(attributes.getColor(R.styleable.MaterialAccount_subtitleColor, 0xFFF));
} finally {
attributes.recycle();
}
// set the button image
if (!singleAccount) {
userButtonSwitcher.setImageResource(R.drawable.ic_arrow_drop_down_white_24dp);
userButtonSwitcher.setOnClickListener(accountSwitcherListener);
}
} else
customDrawerHeader = (LinearLayout) this.findViewById(R.id.drawer_header);
sections = (LinearLayout) this.findViewById(R.id.sections);
bottomSections = (LinearLayout) this.findViewById(R.id.bottom_sections);
// init lists
sectionList = new LinkedList<>();
bottomSectionList = new LinkedList<>();
accountManager = new LinkedList<>();
accountSectionList = new LinkedList<>();
subheaderList = new LinkedList<>();
elementsList = new LinkedList<>();
childFragmentStack = new LinkedList<>();
childTitleStack = new LinkedList<>();
// init listeners
if (drawerHeaderType == DRAWERHEADER_ACCOUNTS) {
userphoto.setOnClickListener(currentAccountListener);
if (singleAccount)
usercover.setOnClickListener(currentAccountListener);
else
usercover.setOnClickListener(accountSwitcherListener);
userSecondPhoto.setOnClickListener(secondAccountListener);
userThirdPhoto.setOnClickListener(thirdAccountListener);
}
// set drawer backgrond color
drawer.setBackgroundColor(drawerColor);
// get resources and density
resources = this.getResources();
density = resources.getDisplayMetrics().density;
// set the right drawer width
DrawerLayout.LayoutParams drawerParams = (android.support.v4.widget.DrawerLayout.LayoutParams) drawer.getLayoutParams();
drawerParams.width = Utils.getDrawerWidth(resources);
drawer.setLayoutParams(drawerParams);
// get primary color
theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
primaryColor = typedValue.data;
theme.resolveAttribute(R.attr.colorPrimaryDark, typedValue, true);
primaryDarkColor = typedValue.data;
// if device is kitkat
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
TypedArray windowTraslucentAttribute = theme.obtainStyledAttributes(new int[] { android.R.attr.windowTranslucentStatus });
kitkatTraslucentStatusbar = windowTraslucentAttribute.getBoolean(0, false);
if (kitkatTraslucentStatusbar) {
Window window = this.getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
RelativeLayout.LayoutParams statusParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, resources.getDimensionPixelSize(R.dimen.traslucentStatusMargin));
statusBar.setLayoutParams(statusParams);
statusBar.setImageDrawable(new ColorDrawable(darkenColor(primaryColor)));
if (drawerHeaderType == DRAWERHEADER_ACCOUNTS) {
RelativeLayout.LayoutParams photoParams = (RelativeLayout.LayoutParams) userphoto.getLayoutParams();
photoParams.setMargins((int) (16 * density), resources.getDimensionPixelSize(R.dimen.traslucentPhotoMarginTop), 0, 0);
userphoto.setLayoutParams(photoParams);
}
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
// INIT TOOLBAR ELEVATION
if (toolbarElevation) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// 4 dp elevation
toolbar.setElevation(4 * density);
} else {
View elevation = LayoutInflater.from(this).inflate(R.layout.layout_toolbar_elevation, content, false);
content.addView(elevation);
}
}
// INIT ACTION BAR
this.setSupportActionBar(toolbar);
actionBar = getSupportActionBar();
// DEVELOPER CALL TO INIT
init(savedInstanceState);
if (sectionList.size() == 0) {
throw new RuntimeException("You must add at least one Section to top list.");
}
if (deviceSupportMultiPane()) {
// se il multipane e' attivo, si e' in landscape e si e' un tablet allora si passa in multipane mode
layout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, drawer);
DrawerLayout.LayoutParams params = new DrawerLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
params.setMargins((int) (320 * density), 0, 0, 0);
content.setLayoutParams(params);
layout.setScrimColor(Color.TRANSPARENT);
layout.openDrawer(drawer);
layout.setMultipaneSupport(true);
} else {
// se non si sta lavorando in multiPane allora si inserisce il pulsante per aprire/chiudere
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
pulsante = new MaterialActionBarDrawerToggle<Fragment>(this, layout, toolbar, R.string.nothing, R.string.nothing) {
@Override
public void onDrawerClosed(View view) {
// creates call to onPrepareOptionsMenu()
invalidateOptionsMenu();
// abilita il touch del drawer
setDrawerTouchable(true);
if (drawerListener != null)
drawerListener.onDrawerClosed(view);
if (hasRequest()) {
MaterialSection section = getRequestedSection();
changeToolbarColor(section);
setFragment((Fragment) section.getTargetFragment(), section.getTitle(), (Fragment) currentSection.getTargetFragment());
afterFragmentSetted((Fragment) section.getTargetFragment(), section.getTitle());
this.removeRequest();
}
}
@Override
public void onDrawerOpened(View drawerView) {
// creates call to onPrepareOptionsMenu()
invalidateOptionsMenu();
if (drawerListener != null)
drawerListener.onDrawerOpened(drawerView);
}
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
// if user wants the sliding arrow it compare
if (slidingDrawerEffect)
super.onDrawerSlide(drawerView, slideOffset);
else
super.onDrawerSlide(drawerView, 0);
if (drawerListener != null)
drawerListener.onDrawerSlide(drawerView, slideOffset);
}
@Override
public void onDrawerStateChanged(int newState) {
super.onDrawerStateChanged(newState);
if (drawerListener != null)
drawerListener.onDrawerStateChanged(newState);
}
};
pulsante.setToolbarNavigationClickListener(toolbarToggleListener);
layout.setDrawerListener(pulsante);
layout.setMultipaneSupport(false);
}
// si procede con gli altri elementi dopo la creazione delle viste
ViewTreeObserver vto = drawer.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// quando l'immagine e' stata caricata
// change user space to 16:9
int width = drawer.getWidth();
int heightCover = 0;
switch(drawerHeaderType) {
default:
case DRAWERHEADER_ACCOUNTS:
case DRAWERHEADER_IMAGE:
case DRAWERHEADER_CUSTOM:
// si fa il rapporto in 16 : 9
heightCover = (9 * width) / 16;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
heightCover += (int) (24 * density);
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT && kitkatTraslucentStatusbar)
heightCover += (int) (25 * density);
break;
case DRAWERHEADER_NO_HEADER:
break;
}
// set user space
if (drawerHeaderType == DRAWERHEADER_ACCOUNTS) {
usercover.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, heightCover));
usercoverSwitcher.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, heightCover));
} else {
customDrawerHeader.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, heightCover));
}
// adding status bar height for other version of android that not have traslucent status bar
if ((Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT && !kitkatTraslucentStatusbar) || Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
heightCover += (int) (25 * density);
}
// heightCover (DRAWER HEADER) + 8 (PADDING) + sections + 8 (PADDING) + 1 (DIVISOR) + bottomSections + subheaders
int heightDrawer = (int) (((8 + 8) * density) + 1 + heightCover + sections.getHeight() + ((density * 48) * bottomSectionList.size()) + (subheaderList.size() * (35 * density)));
// create the divisor
View divisor = new View(MaterialNavigationDrawer.this);
divisor.setBackgroundColor(Color.parseColor("#8f8f8f"));
// si aggiungono le bottom sections
if (heightDrawer >= Utils.getScreenHeight(MaterialNavigationDrawer.this)) {
// add the divisor to the section view
LinearLayout.LayoutParams paramDivisor = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1);
paramDivisor.setMargins(0, (int) (8 * density), 0, (int) (8 * density));
sections.addView(divisor, paramDivisor);
for (MaterialSection section : bottomSectionList) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (48 * density));
sections.addView(section.getView(), params);
}
} else {
// add the divisor to the bottom section listview
LinearLayout.LayoutParams paramDivisor = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1);
bottomSections.addView(divisor, paramDivisor);
for (MaterialSection section : bottomSectionList) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (48 * density));
bottomSections.addView(section.getView(), params);
}
}
ViewTreeObserver obs = drawer.getViewTreeObserver();
// si rimuove il listener
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else {
obs.removeGlobalOnLayoutListener(this);
}
}
});
MaterialSection section;
if (savedInstanceState == null) {
// init account views
if (accountManager.size() > 0) {
currentAccount = accountManager.get(0);
notifyAccountDataChanged();
}
// init section
if (defaultSectionLoaded < 0 || defaultSectionLoaded >= sectionList.size()) {
throw new RuntimeException("You are trying to open at startup a section that does not exist");
}
section = sectionList.get(defaultSectionLoaded);
if (section.getTarget() != MaterialSection.TARGET_FRAGMENT)
throw new RuntimeException("The first section added must have a fragment as target");
} else {
ArrayList<Integer> accountNumbers = savedInstanceState.getIntegerArrayList(STATE_ACCOUNT);
// ripristina gli account | restore accounts
for (int i = 0; i < accountNumbers.size(); i++) {
MaterialAccount account = accountManager.get(i);
account.setAccountNumber(accountNumbers.get(i));
if (account.getAccountNumber() == MaterialAccount.FIRST_ACCOUNT) {
currentAccount = account;
}
}
notifyAccountDataChanged();
int sectionSelected = savedInstanceState.getInt(STATE_SECTION);
int sectionListType = savedInstanceState.getInt(STATE_LIST);
if (sectionListType == Element.TYPE_SECTION) {
section = sectionList.get(sectionSelected);
} else
section = bottomSectionList.get(sectionSelected);
if (section.getTarget() != MaterialSection.TARGET_FRAGMENT) {
section = sectionList.get(0);
}
}
title = section.getTitle();
currentSection = section;
section.select();
setFragment((Fragment) section.getTargetFragment(), section.getTitle(), null, savedInstanceState != null);
// change the toolbar color for the first section
changeToolbarColor(section);
// add the first section to the child stack
childFragmentStack.add((Fragment) section.getTargetFragment());
childTitleStack.add(section.getTitle());
// learning pattern
if (learningPattern) {
layout.openDrawer(drawer);
disableLearningPattern();
}
}
use of android.support.v4.widget.Space in project material-components-android by material-components.
the class TextInputLayout method addIndicator.
private void addIndicator(TextView indicator, int index) {
if (mIndicatorArea == null) {
mIndicatorArea = new LinearLayout(getContext());
mIndicatorArea.setOrientation(LinearLayout.HORIZONTAL);
addView(mIndicatorArea, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
// Add a flexible spacer in the middle so that the left/right views stay pinned
final Space spacer = new Space(getContext());
final LinearLayout.LayoutParams spacerLp = new LinearLayout.LayoutParams(0, 0, 1f);
mIndicatorArea.addView(spacer, spacerLp);
if (mEditText != null) {
adjustIndicatorPadding();
}
}
mIndicatorArea.setVisibility(View.VISIBLE);
mIndicatorArea.addView(indicator, index);
mIndicatorsAdded++;
}
use of android.support.v4.widget.Space in project WordPress-Android by wordpress-mobile.
the class ReaderPostListFragment method setupRecyclerToolbar.
/*
* adds a menu to the recycler's toolbar containing settings & search items - only called
* for followed tags
*/
private void setupRecyclerToolbar() {
Menu menu = mRecyclerView.addToolbarMenu(R.menu.reader_list);
mSettingsMenuItem = menu.findItem(R.id.menu_reader_settings);
mSearchMenuItem = menu.findItem(R.id.menu_reader_search);
mSettingsMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
ReaderActivityLauncher.showReaderSubs(getActivity());
return true;
}
});
mSearchView = (SearchView) mSearchMenuItem.getActionView();
mSearchView.setQueryHint(getString(R.string.reader_hint_post_search));
mSearchView.setSubmitButtonEnabled(false);
mSearchView.setIconifiedByDefault(true);
mSearchView.setIconified(true);
// force the search view to take up as much horizontal space as possible (without this
// it looks truncated on landscape)
int maxWidth = DisplayUtils.getDisplayPixelWidth(getActivity());
mSearchView.setMaxWidth(maxWidth);
// this is hacky, but we want to change the SearchView's autocomplete to show suggestions
// after a single character is typed, and there's no less hacky way to do this...
View view = mSearchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
if (view instanceof AutoCompleteTextView) {
((AutoCompleteTextView) view).setThreshold(1);
}
MenuItemCompat.setOnActionExpandListener(mSearchMenuItem, new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
if (getPostListType() != ReaderPostListType.SEARCH_RESULTS) {
AnalyticsTracker.track(AnalyticsTracker.Stat.READER_SEARCH_LOADED);
}
resetPostAdapter(ReaderPostListType.SEARCH_RESULTS);
showSearchMessage();
mSettingsMenuItem.setVisible(false);
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
hideSearchMessage();
resetSearchSuggestionAdapter();
mSettingsMenuItem.setVisible(true);
mCurrentSearchQuery = null;
// return to the followed tag that was showing prior to searching
resetPostAdapter(ReaderPostListType.TAG_FOLLOWED);
return true;
}
});
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
submitSearchQuery(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
if (TextUtils.isEmpty(newText)) {
showSearchMessage();
} else {
populateSearchSuggestionAdapter(newText);
}
return true;
}
});
}
Aggregations