Skip to content

Commit

Permalink
More Android L design
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKLO committed Nov 13, 2014
1 parent ea0b86d commit bfd8d13
Show file tree
Hide file tree
Showing 197 changed files with 1,216 additions and 1,820 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013-2014.
*/

package org.telegram.ui.Views.ActionBar;
package org.telegram.ui.ActionBar;

import android.content.Context;
import android.content.res.Configuration;
Expand Down Expand Up @@ -47,6 +47,7 @@ public boolean canOpenMenu() {
private ActionBarMenu menu;
private ActionBarMenu actionMode;
private View actionOverlay;

protected boolean isSearchFieldVisible;
protected int itemsBackgroundResourceId;
private boolean isBackOverlayVisible;
Expand All @@ -69,23 +70,6 @@ public ActionBar(Context context) {
titleFrameLayout.setLayoutParams(layoutParams);
titleFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0);
titleFrameLayout.setEnabled(false);

backButtonImageView = new ImageView(getContext());
titleFrameLayout.addView(backButtonImageView);
backButtonImageView.setVisibility(VISIBLE);
backButtonImageView.setScaleType(ImageView.ScaleType.CENTER);
backButtonImageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (isSearchFieldVisible) {
closeSearchField();
return;
}
if (actionBarMenuOnItemClick != null) {
actionBarMenuOnItemClick.onItemClick(-1);
}
}
});
}

private void positionBackImage(int height) {
Expand Down Expand Up @@ -139,13 +123,20 @@ private void positionTitle(int width, int height) {
}

int x = 0;
if (AndroidUtilities.isTablet()) {
x = AndroidUtilities.dp(80);
if (backButtonImageView != null) {
if (AndroidUtilities.isTablet()) {
x = AndroidUtilities.dp(80);
} else {
x = AndroidUtilities.dp(72);
}
} else {
x = AndroidUtilities.dp(72);
if (AndroidUtilities.isTablet()) {
x = AndroidUtilities.dp(26);
} else {
x = AndroidUtilities.dp(18);
}
}


if (menu != null) {
maxTextWidth = Math.min(maxTextWidth, width - menu.getMeasuredWidth() - AndroidUtilities.dp(16));
}
Expand Down Expand Up @@ -191,11 +182,39 @@ public void positionMenu(int width, int height) {
menu.measure(width, height);
}

private void createBackButtonImage() {
if (backButtonImageView != null) {
return;
}
backButtonImageView = new ImageView(getContext());
titleFrameLayout.addView(backButtonImageView);
backButtonImageView.setVisibility(VISIBLE);
backButtonImageView.setScaleType(ImageView.ScaleType.CENTER);
backButtonImageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (isSearchFieldVisible) {
closeSearchField();
return;
}
if (actionBarMenuOnItemClick != null) {
actionBarMenuOnItemClick.onItemClick(-1);
}
}
});
}

public void setBackButtonDrawable(Drawable drawable) {
if (backButtonImageView == null) {
createBackButtonImage();
}
backButtonImageView.setImageDrawable(drawable);
}

public void setBackButtonImage(int resource) {
if (backButtonImageView == null) {
createBackButtonImage();
}
backButtonImageView.setImageResource(resource);
}

Expand Down Expand Up @@ -485,7 +504,9 @@ private void positionBackOverlay(int widthMeasureSpec, int heightMeasureSpec) {

public void setItemsBackground(int resourceId) {
itemsBackgroundResourceId = resourceId;
backButtonImageView.setBackgroundResource(resourceId);
if (backButtonImageView != null) {
backButtonImageView.setBackgroundResource(resourceId);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013-2014.
*/

package org.telegram.ui.Views.ActionBar;
package org.telegram.ui.ActionBar;

import android.app.Activity;
import android.content.Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013-2014.
*/

package org.telegram.ui.Views.ActionBar;
package org.telegram.ui.ActionBar;

import android.content.Context;
import android.util.AttributeSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013-2014.
*/

package org.telegram.ui.Views.ActionBar;
package org.telegram.ui.ActionBar;

import android.content.Context;
import android.graphics.Rect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

//Thanks to https://github.com/JakeWharton/ActionBarSherlock/

package org.telegram.ui.Views.ActionBar;
package org.telegram.ui.ActionBar;

import android.content.Context;
import android.util.AttributeSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013.
*/

package org.telegram.ui.Views.ActionBar;
package org.telegram.ui.ActionBar;

import android.app.Activity;
import android.app.AlertDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013-2014.
*/

package org.telegram.ui.Views.ActionBar;
package org.telegram.ui.ActionBar;

import android.app.Activity;
import android.content.Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013-2014.
*/

package org.telegram.ui.Views.ActionBar;
package org.telegram.ui.ActionBar;

import android.graphics.Canvas;
import android.graphics.ColorFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@

public class BaseFragmentAdapter extends BaseAdapter {

public void onFragmentCreate() {
}

public void onFragmentDestroy() {
}

@Override
public int getCount() {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public final int getSectionForPosition(int position) {
}
sectionStart = sectionEnd;
}
return 0;
return -1;
}

public int getPositionInSectionForPosition(int position) {
Expand All @@ -139,7 +139,7 @@ public int getPositionInSectionForPosition(int position) {
}
sectionStart = sectionEnd;
}
return 0;
return -1;
}

public abstract int getSectionCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
import java.util.ArrayList;
import java.util.HashMap;

public class ContactsActivityAdapter extends BaseSectionsAdapter {
public class ContactsAdapter extends BaseSectionsAdapter {

private Context mContext;
private boolean onlyUsers;
private boolean needPhonebook;
private HashMap<Integer, TLRPC.User> ignoreUsers;

public ContactsActivityAdapter(Context context, boolean arg1, boolean arg2, HashMap<Integer, TLRPC.User> arg3) {
public ContactsAdapter(Context context, boolean arg1, boolean arg2, HashMap<Integer, TLRPC.User> arg3) {
mContext = context;
onlyUsers = arg1;
needPhonebook = arg2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,32 @@
import org.telegram.messenger.Utilities;
import org.telegram.ui.Cells.GreySectionCell;
import org.telegram.ui.Cells.ProfileSearchCell;
import org.telegram.ui.Cells.UserCell;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Timer;
import java.util.TimerTask;

public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
public class ContactsSearchAdapter extends BaseContactsSearchAdapter {
private Context mContext;
private HashMap<Integer, TLRPC.User> ignoreUsers;
private ArrayList<TLRPC.User> searchResult = new ArrayList<TLRPC.User>();
private ArrayList<CharSequence> searchResultNames = new ArrayList<CharSequence>();
private Timer searchTimer;
private boolean allowUsernameSearch;
private boolean useUserCell;

public ContactsActivitySearchAdapter(Context context, HashMap<Integer, TLRPC.User> arg1, boolean usernameSearch) {
public ContactsSearchAdapter(Context context, HashMap<Integer, TLRPC.User> arg1, boolean usernameSearch) {
mContext = context;
ignoreUsers = arg1;
allowUsernameSearch = usernameSearch;
}

public void setUseUserCell(boolean value) {
useUserCell = value;
}

public void searchDialogs(final String query) {
try {
if (searchTimer != null) {
Expand Down Expand Up @@ -202,10 +208,13 @@ public View getView(int i, View view, ViewGroup viewGroup) {
}
} else {
if (view == null) {
view = new ProfileSearchCell(mContext);
if (useUserCell) {
view = new UserCell(mContext, 1);
} else {
view = new ProfileSearchCell(mContext);
}
}

((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != searchResult.size() - 1);
TLRPC.User user = getItem(i);
if (user != null) {
CharSequence username = null;
Expand All @@ -227,13 +236,16 @@ public View getView(int i, View view, ViewGroup viewGroup) {
}
}

((ProfileSearchCell) view).setData(user, null, null, name, username);

if (ignoreUsers != null) {
if (ignoreUsers.containsKey(user.id)) {
((ProfileSearchCell) view).drawAlpha = 0.5f;
} else {
((ProfileSearchCell) view).drawAlpha = 1.0f;
if (useUserCell) {
((UserCell) view).setData(user, name, username, 0);
} else {
((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != searchResult.size() - 1);
if (ignoreUsers != null) {
if (ignoreUsers.containsKey(user.id)) {
((ProfileSearchCell) view).drawAlpha = 0.5f;
} else {
((ProfileSearchCell) view).drawAlpha = 1.0f;
}
}
}
}
Expand Down
Loading

0 comments on commit bfd8d13

Please sign in to comment.