Transparent toolbar and Continue Search in drawer

This commit is contained in:
Yaroslav Berezanskyi 2015-08-10 19:53:44 +03:00
parent 413cd9a65f
commit 280ca0f549
19 changed files with 140 additions and 73 deletions

View File

@ -62,6 +62,7 @@ public abstract class BaseActivity extends AppCompatActivity implements
private static final int DRAWER_CLOSE_DELAY_LONG = 400; private static final int DRAWER_CLOSE_DELAY_LONG = 400;
private static final String CONTRIBUTE_LINK = "https://github.com/syng-io"; private static final String CONTRIBUTE_LINK = "https://github.com/syng-io";
private static final String CONTINUE_SEARCH_LINK = "dapp://syng.io/store?q=search%20query";
private ArrayList<String> mDAppNamesList = new ArrayList<>(Arrays.asList("Console", "DApps", private ArrayList<String> mDAppNamesList = new ArrayList<>(Arrays.asList("Console", "DApps",
"EtherEx", "TrustDavis", "Augur", "Console", "DApps", "EtherEx", "TrustDavis", "Augur", "Console", "DApps",
@ -99,7 +100,6 @@ public abstract class BaseActivity extends AppCompatActivity implements
private SpinnerAdapter spinnerAdapter; private SpinnerAdapter spinnerAdapter;
private Profile requestProfile; private Profile requestProfile;
private int currentPosition;
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
@Override @Override
@ -117,6 +117,7 @@ public abstract class BaseActivity extends AppCompatActivity implements
Toolbar toolbar = (Toolbar) inflater.inflate(layoutResID, content, true).findViewById(R.id.myToolbar); Toolbar toolbar = (Toolbar) inflater.inflate(layoutResID, content, true).findViewById(R.id.myToolbar);
if (toolbar != null) { if (toolbar != null) {
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(android.R.color.black));
} }
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar,
@ -133,8 +134,6 @@ public abstract class BaseActivity extends AppCompatActivity implements
mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerLayout.setDrawerListener(mDrawerToggle);
// mAccountSpinner = (Spinner) mDrawerLayout.findViewById(R.id.nv_email);
// initSpinner();
mSearchTextView = (EditText) mDrawerLayout.findViewById(R.id.search); mSearchTextView = (EditText) mDrawerLayout.findViewById(R.id.search);
initSearch(); initSearch();
@ -179,7 +178,7 @@ public abstract class BaseActivity extends AppCompatActivity implements
byte[] cbAddr = HashUtil.sha3(secret.getBytes()); byte[] cbAddr = HashUtil.sha3(secret.getBytes());
addresses.add(Hex.toHexString(cbAddr)); addresses.add(Hex.toHexString(cbAddr));
profile.setPrivateKeys(addresses); profile.setPrivateKeys(addresses);
SyngApplication app = (SyngApplication)getApplication(); SyngApplication app = (SyngApplication) getApplication();
if (app.currentProfile == null) { if (app.currentProfile == null) {
changeProfile(profile); changeProfile(profile);
} }
@ -197,17 +196,9 @@ public abstract class BaseActivity extends AppCompatActivity implements
mDApps.add(new Dapp(name)); mDApps.add(new Dapp(name));
} }
mDAppsDrawerAdapter = new DAppDrawerAdapter(new ArrayList<>(mDApps), this); mDAppsDrawerAdapter = new DAppDrawerAdapter(new ArrayList<>(mDApps), this);
initFooter();
mDAppsRecyclerView.setAdapter(mDAppsDrawerAdapter); mDAppsRecyclerView.setAdapter(mDAppsDrawerAdapter);
} }
private void initFooter() {
// ViewGroup header = (ViewGroup) getLayoutInflater().inflate(
// R.layout.quiz_result_header_item, mListView, false);
// mDAppsRecyclerView.addHeaderView(header);
// mListView.setAdapter(mAdapter);
}
private void closeDrawer(int delayMills) { private void closeDrawer(int delayMills) {
mHandler.postDelayed(mRunnable, delayMills); mHandler.postDelayed(mRunnable, delayMills);
@ -328,14 +319,16 @@ public abstract class BaseActivity extends AppCompatActivity implements
} }
protected void updateAppList(String filter) { protected void updateAppList(String filter) {
mDAppsDrawerAdapter.clear(); ArrayList<Dapp> dapps = new ArrayList<>(mDApps.size());
int length = mDAppNamesList.size(); int length = mDApps.size();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
Dapp item = mDApps.get(i); Dapp item = mDApps.get(i);
if (item.getName().toLowerCase().contains(filter.toLowerCase())) { if (item.getName().toLowerCase().contains(filter.toLowerCase())) {
mDAppsDrawerAdapter.add(item); dapps.add(item);
} }
} }
mDAppsDrawerAdapter = new DAppDrawerAdapter(dapps, this);
mDAppsRecyclerView.setAdapter(mDAppsDrawerAdapter);
} }
@Override @Override
@ -422,6 +415,7 @@ public abstract class BaseActivity extends AppCompatActivity implements
private boolean isDrawerFrontViewActive() { private boolean isDrawerFrontViewActive() {
return mFrontView.getVisibility() == VISIBLE; return mFrontView.getVisibility() == VISIBLE;
} }
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
@ -481,6 +475,7 @@ public abstract class BaseActivity extends AppCompatActivity implements
return row; return row;
} }
} }
@Override @Override
public void onDAppItemClick(Dapp dapp) { public void onDAppItemClick(Dapp dapp) {
onDAppClick(dapp); onDAppClick(dapp);
@ -552,6 +547,16 @@ public abstract class BaseActivity extends AppCompatActivity implements
.build().show(); .build().show();
} }
@Override
public void onDAppContinueSearch() {
String url = CONTINUE_SEARCH_LINK;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
@Override @Override
public void onNewProfile() { public void onNewProfile() {
showAccountCreateDialog(); showAccountCreateDialog();

View File

@ -3,10 +3,6 @@ package io.syng.activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import io.syng.R; import io.syng.R;
import io.syng.entity.Dapp; import io.syng.entity.Dapp;
@ -58,22 +54,13 @@ public class MainActivity extends BaseActivity {
} }
} }
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
private void replaceFragment(Fragment fragment) { private void replaceFragment(Fragment fragment) {
getSupportFragmentManager().beginTransaction(). getSupportFragmentManager().beginTransaction().
replace(R.id.container, fragment).commit(); replace(R.id.container, fragment).commit();
Toolbar toolbar = (Toolbar) findViewById(R.id.myToolbar);
ImageView background = (ImageView) findViewById(R.id.iv_background);
if (!(fragment instanceof ConsoleFragment)) {
toolbar.setBackgroundResource(R.color.toolbar_color);
background.setImageResource(0);
} else {
Glide.with(this).load(R.drawable.bg1).into(background);
toolbar.setBackgroundResource(R.drawable.fill);
}
} }
} }

View File

@ -1,6 +1,7 @@
package io.syng.adapter; package io.syng.adapter;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -16,6 +17,7 @@ public class DAppDrawerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
private static final int TYPE_FOOTER = 10; private static final int TYPE_FOOTER = 10;
private static final int TYPE_SIMPLE_ITEM = 20; private static final int TYPE_SIMPLE_ITEM = 20;
private static final int TYPE_CONTINUE_SEARCH = 30;
private final OnDAppClickListener mListener; private final OnDAppClickListener mListener;
@ -26,13 +28,17 @@ public class DAppDrawerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
void onDAppPress(Dapp dapp); void onDAppPress(Dapp dapp);
void onDAppAdd(); void onDAppAdd();
void onDAppContinueSearch();
} }
private List<Dapp> mDataSet; private List<Dapp> mDataSet;
private boolean continueSearch;
public DAppDrawerAdapter(List<Dapp> data, OnDAppClickListener listener) { public DAppDrawerAdapter(@NonNull List<Dapp> data, OnDAppClickListener listener) {
this.mDataSet = data; this.mDataSet = data;
mListener = listener; mListener = listener;
continueSearch = data.isEmpty();
} }
@Override @Override
@ -41,10 +47,13 @@ public class DAppDrawerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
View v; View v;
if (viewType == TYPE_SIMPLE_ITEM) { if (viewType == TYPE_SIMPLE_ITEM) {
v = LayoutInflater.from(parent.getContext()).inflate(R.layout.dapp_drawer_list_item, parent, false); v = LayoutInflater.from(parent.getContext()).inflate(R.layout.dapp_drawer_list_item, parent, false);
return new DappSimpleViewHolder(v); return new SimpleViewHolder(v);
} else if (viewType == TYPE_FOOTER) { } else if (viewType == TYPE_FOOTER) {
v = LayoutInflater.from(parent.getContext()).inflate(R.layout.dapp_drawer_add_item, parent, false); v = LayoutInflater.from(parent.getContext()).inflate(R.layout.dapp_drawer_add_item, parent, false);
return new DappFooterViewHolder(v); return new FooterViewHolder(v);
} else if (viewType == TYPE_CONTINUE_SEARCH) {
v = LayoutInflater.from(parent.getContext()).inflate(R.layout.dapp_drawer_continue_search_item, parent, false);
return new ContinueSearchViewHolder(v);
} }
throw new RuntimeException("there is no type that matches the type " + viewType + " + make sure your using types correctly"); throw new RuntimeException("there is no type that matches the type " + viewType + " + make sure your using types correctly");
@ -52,8 +61,8 @@ public class DAppDrawerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
@Override @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof DappSimpleViewHolder) { if (holder instanceof SimpleViewHolder) {
DappSimpleViewHolder myHolder = (DappSimpleViewHolder) holder; SimpleViewHolder myHolder = (SimpleViewHolder) holder;
final Dapp dapp = mDataSet.get(position); final Dapp dapp = mDataSet.get(position);
myHolder.nameTextView.setText(dapp.getName()); myHolder.nameTextView.setText(dapp.getName());
myHolder.nameTextView.setOnClickListener(new View.OnClickListener() { myHolder.nameTextView.setOnClickListener(new View.OnClickListener() {
@ -74,8 +83,8 @@ public class DAppDrawerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} }
}); });
} }
if (holder instanceof DappFooterViewHolder) { if (holder instanceof FooterViewHolder) {
DappFooterViewHolder myHolder = (DappFooterViewHolder) holder; FooterViewHolder myHolder = (FooterViewHolder) holder;
myHolder.addView.setOnClickListener(new View.OnClickListener() { myHolder.addView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -85,11 +94,23 @@ public class DAppDrawerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} }
}); });
} }
if (holder instanceof ContinueSearchViewHolder) {
ContinueSearchViewHolder myHolder = (ContinueSearchViewHolder) holder;
myHolder.continueSearchView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mListener != null) {
mListener.onDAppContinueSearch();
}
}
});
}
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return mDataSet.size() + 1; return continueSearch ? mDataSet.size() + 2 : mDataSet.size() + 1;
} }
@Override @Override
@ -97,11 +118,18 @@ public class DAppDrawerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
if (isPositionFooter(position)) if (isPositionFooter(position))
return TYPE_FOOTER; return TYPE_FOOTER;
if (isPositionContinueItem(position))
return TYPE_CONTINUE_SEARCH;
return TYPE_SIMPLE_ITEM; return TYPE_SIMPLE_ITEM;
} }
private boolean isPositionFooter(int position) { private boolean isPositionFooter(int position) {
return position == mDataSet.size(); return continueSearch ? position == mDataSet.size() + 1 : position == mDataSet.size();
}
private boolean isPositionContinueItem(int position) {
return continueSearch && position == mDataSet.size();
} }
@ -115,25 +143,36 @@ public class DAppDrawerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
notifyDataSetChanged(); notifyDataSetChanged();
} }
static class DappSimpleViewHolder extends RecyclerView.ViewHolder { static class SimpleViewHolder extends RecyclerView.ViewHolder {
private TextView nameTextView; private TextView nameTextView;
public DappSimpleViewHolder(View v) { public SimpleViewHolder(View v) {
super(v); super(v);
nameTextView = (TextView) v.findViewById(R.id.text); nameTextView = (TextView) v.findViewById(R.id.text);
} }
} }
static class DappFooterViewHolder extends RecyclerView.ViewHolder { static class FooterViewHolder extends RecyclerView.ViewHolder {
private View addView; private View addView;
public DappFooterViewHolder(View v) { public FooterViewHolder(View v) {
super(v); super(v);
addView = v.findViewById(R.id.ll_add); addView = v.findViewById(R.id.ll_add);
} }
} }
static class ContinueSearchViewHolder extends RecyclerView.ViewHolder {
private View continueSearchView;
public ContinueSearchViewHolder(View v) {
super(v);
continueSearchView = v.findViewById(R.id.ll_continue_search);
}
}
} }

View File

@ -6,6 +6,7 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.text.method.ScrollingMovementMethod; import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -86,6 +87,9 @@ public class ConsoleFragment extends Fragment implements ConnectorHandler {
ImageView ethereumText = (ImageView) view.findViewById(R.id.iv_ethereum_text); ImageView ethereumText = (ImageView) view.findViewById(R.id.iv_ethereum_text);
Glide.with(this).load(R.drawable.ethereum_text).into(ethereumText); Glide.with(this).load(R.drawable.ethereum_text).into(ethereumText);
Glide.with(this).load(R.drawable.ethereum_icon).into(ethereumIcon); Glide.with(this).load(R.drawable.ethereum_icon).into(ethereumIcon);
((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(true);
return view; return view;
} }

View File

@ -7,6 +7,7 @@ import android.graphics.Color;
import android.media.AudioManager; import android.media.AudioManager;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -66,7 +67,7 @@ public class WebViewFragment extends Fragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
loadConfig(); loadConfig();
((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(false);
/* /*
TODO: it's can be only in activity before adding content and we may need it in Cordova Dapps TODO: it's can be only in activity before adding content and we may need it in Cordova Dapps
if(!preferences.getBoolean("ShowTitle", false)) if(!preferences.getBoolean("ShowTitle", false))

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

View File

@ -4,24 +4,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ImageView <FrameLayout
android:id="@+id/iv_background" android:id="@+id/container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"/>
android:scaleType="centerCrop"/>
<LinearLayout <include layout="@layout/app_toolbar"/>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/app_toolbar"/>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
</FrameLayout> </FrameLayout>

View File

@ -0,0 +1,26 @@
<LinearLayout
android:id="@+id/ll_continue_search"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeightSmall"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_search_black_24dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Base.TextAppearance.AppCompat.Body2"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:textColor="@android:color/black"
android:text="Continue Search"/>
</LinearLayout>

View File

@ -3,7 +3,8 @@
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:fitsSystemWindows="true">
<FrameLayout <FrameLayout
android:id="@+id/content" android:id="@+id/content"
@ -12,12 +13,13 @@
</FrameLayout> </FrameLayout>
<FrameLayout <android.support.design.widget.NavigationView
android:layout_width="305dp" android:layout_width="305dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="start"> android:layout_gravity="start">
<include layout="@layout/drawer_content"/> <include layout="@layout/drawer_content"/>
</FrameLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>

View File

@ -12,7 +12,8 @@
android:id="@+id/drawer_main_content" android:id="@+id/drawer_main_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1"> android:layout_weight="1"
>
<include layout="@layout/drawer_back_view"/> <include layout="@layout/drawer_back_view"/>

View File

@ -28,8 +28,8 @@
android:textSize="16sp"/> android:textSize="16sp"/>
<ImageView <ImageView
android:layout_width="18dp" android:layout_width="wrap_content"
android:layout_height="18dp" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
@ -39,7 +39,7 @@
android:layout_marginRight="25dp" android:layout_marginRight="25dp"
android:layout_marginStart="25dp" android:layout_marginStart="25dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:src="@drawable/search"/> android:src="@drawable/ic_search_black_24dp"/>
</RelativeLayout> </RelativeLayout>

View File

@ -1,10 +1,11 @@
<FrameLayout <FrameLayout
android:id="@+id/drawer_header" android:id="@+id/drawer_header"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="120dp"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:soundEffectsEnabled="false" > android:soundEffectsEnabled="false"
android:fitsSystemWindows="true">
<ImageView <ImageView
android:id="@+id/iv_header" android:id="@+id/iv_header"
@ -18,7 +19,10 @@
<TextView <TextView
android:id="@+id/tv_name" android:id="@+id/tv_name"
style="@style/TextDrawer320"/> style="@style/TextDrawer320"
android:layout_alignTop="@+id/drawer_indicator"
android:layout_toRightOf="@+id/nv_email"
android:layout_toEndOf="@+id/nv_email"/>
<Spinner <Spinner
android:id="@+id/nv_email" android:id="@+id/nv_email"

View File

@ -1,5 +1,13 @@
<resources> <resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimaryDark">@android:color/black</item>
<item name="colorAccent">@color/accent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="SettingsTheme" parent="@android:style/Theme.Material.Light"> <style name="SettingsTheme" parent="@android:style/Theme.Material.Light">
</style> </style>

View File

@ -19,11 +19,12 @@
<style name="TextDrawer320"> <style name="TextDrawer320">
<item name="android:layout_width">match_parent</item> <item name="android:layout_gravity">start</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">20dp</item> <item name="android:layout_marginLeft">20dp</item>
<item name="android:layout_marginStart">20dp</item> <item name="android:layout_marginStart">20dp</item>
<item name="android:layout_marginTop">15dp</item> <item name="android:layout_marginBottom">15dp</item>
<item name="android:text">Jarrad Hope</item> <item name="android:text">Jarrad Hope</item>
<item name="android:textColor">#ffffff</item> <item name="android:textColor">#ffffff</item>
<item name="android:textSize">20sp</item> <item name="android:textSize">20sp</item>

View File

@ -10,4 +10,5 @@
<style name="SettingsTheme" parent="Theme.AppCompat.Light"> <style name="SettingsTheme" parent="Theme.AppCompat.Light">
</style> </style>
</resources> </resources>