Different backgrounds on drawer header long press
@ -47,6 +47,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.syng.R;
|
import io.syng.R;
|
||||||
|
import io.syng.adapter.BackgroundArrayAdapter;
|
||||||
import io.syng.adapter.DAppDrawerAdapter;
|
import io.syng.adapter.DAppDrawerAdapter;
|
||||||
import io.syng.adapter.DAppDrawerAdapter.OnDAppClickListener;
|
import io.syng.adapter.DAppDrawerAdapter.OnDAppClickListener;
|
||||||
import io.syng.adapter.ProfileDrawerAdapter;
|
import io.syng.adapter.ProfileDrawerAdapter;
|
||||||
@ -61,7 +62,7 @@ import static android.view.View.VISIBLE;
|
|||||||
import static org.ethereum.config.SystemProperties.CONFIG;
|
import static org.ethereum.config.SystemProperties.CONFIG;
|
||||||
|
|
||||||
public abstract class BaseActivity extends AppCompatActivity implements
|
public abstract class BaseActivity extends AppCompatActivity implements
|
||||||
OnClickListener, OnDAppClickListener, OnProfileClickListener {
|
OnClickListener, OnDAppClickListener, OnProfileClickListener, View.OnLongClickListener {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger("SyngApplication");
|
private static final Logger logger = LoggerFactory.getLogger("SyngApplication");
|
||||||
|
|
||||||
@ -94,6 +95,7 @@ public abstract class BaseActivity extends AppCompatActivity implements
|
|||||||
};
|
};
|
||||||
private List<Profile> mProfiles;
|
private List<Profile> mProfiles;
|
||||||
private List<Dapp> mDApps;
|
private List<Dapp> mDApps;
|
||||||
|
private ImageView mHeaderImageView;
|
||||||
|
|
||||||
protected abstract void onDAppClick(Dapp dapp);
|
protected abstract void onDAppClick(Dapp dapp);
|
||||||
|
|
||||||
@ -134,8 +136,8 @@ public abstract class BaseActivity extends AppCompatActivity implements
|
|||||||
findViewById(R.id.ll_import_wallet).setOnClickListener(this);
|
findViewById(R.id.ll_import_wallet).setOnClickListener(this);
|
||||||
findViewById(R.id.ll_settings).setOnClickListener(this);
|
findViewById(R.id.ll_settings).setOnClickListener(this);
|
||||||
findViewById(R.id.ll_contribute).setOnClickListener(this);
|
findViewById(R.id.ll_contribute).setOnClickListener(this);
|
||||||
findViewById(R.id.drawer_header).setOnClickListener(this);
|
findViewById(R.id.drawer_header_item).setOnClickListener(this);
|
||||||
|
findViewById(R.id.drawer_header_item).setOnLongClickListener(this);
|
||||||
mFrontView = findViewById(R.id.ll_front_view);
|
mFrontView = findViewById(R.id.ll_front_view);
|
||||||
mBackView = findViewById(R.id.ll_back_view);
|
mBackView = findViewById(R.id.ll_back_view);
|
||||||
|
|
||||||
@ -150,8 +152,8 @@ public abstract class BaseActivity extends AppCompatActivity implements
|
|||||||
mDAppsRecyclerView.setLayoutManager(layoutManager1);
|
mDAppsRecyclerView.setLayoutManager(layoutManager1);
|
||||||
initDApps();
|
initDApps();
|
||||||
|
|
||||||
ImageView header = (ImageView) findViewById(R.id.iv_header);
|
mHeaderImageView = (ImageView) findViewById(R.id.iv_header);
|
||||||
Glide.with(this).load(R.drawable.drawer).into(header);
|
Glide.with(this).load(R.drawable.bg0).into(mHeaderImageView);
|
||||||
|
|
||||||
GeneralUtil.showWarningDialogIfNeed(this);
|
GeneralUtil.showWarningDialogIfNeed(this);
|
||||||
}
|
}
|
||||||
@ -339,7 +341,7 @@ public abstract class BaseActivity extends AppCompatActivity implements
|
|||||||
startActivity(new Intent(BaseActivity.this, SettingsActivity.class));
|
startActivity(new Intent(BaseActivity.this, SettingsActivity.class));
|
||||||
closeDrawer(DRAWER_CLOSE_DELAY_LONG);
|
closeDrawer(DRAWER_CLOSE_DELAY_LONG);
|
||||||
break;
|
break;
|
||||||
case R.id.drawer_header:
|
case R.id.drawer_header_item:
|
||||||
flipDrawer();
|
flipDrawer();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -598,4 +600,22 @@ public abstract class BaseActivity extends AppCompatActivity implements
|
|||||||
showAccountCreateDialog();
|
showAccountCreateDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
if (v.getId() == R.id.drawer_header_item) {
|
||||||
|
new MaterialDialog.Builder(this)
|
||||||
|
.adapter(new BackgroundArrayAdapter(this),
|
||||||
|
new MaterialDialog.ListCallback() {
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
@Override
|
||||||
|
public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
|
||||||
|
BackgroundArrayAdapter adapter = (BackgroundArrayAdapter) dialog.getListView().getAdapter();
|
||||||
|
Glide.with(BaseActivity.this).load(adapter.getImageResourceIdByPosition(which)).into(mHeaderImageView);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package io.syng.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.syng.R;
|
||||||
|
|
||||||
|
|
||||||
|
public class BackgroundArrayAdapter extends ArrayAdapter<Integer> {
|
||||||
|
|
||||||
|
private static final List<Integer> sItems = new ArrayList<>(
|
||||||
|
Arrays.asList(R.drawable.bg0_resized, R.drawable.bg1_resized, R.drawable.bg2_resized, R.drawable.bg3_resized));
|
||||||
|
|
||||||
|
public BackgroundArrayAdapter(Context context) {
|
||||||
|
super(context, 0, sItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
ViewHolder viewHolder;
|
||||||
|
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = LayoutInflater.from(parent.getContext())
|
||||||
|
.inflate(R.layout.backround_list_item, parent, false);
|
||||||
|
viewHolder = new ViewHolder(convertView);
|
||||||
|
convertView.setTag(viewHolder);
|
||||||
|
} else {
|
||||||
|
viewHolder = (ViewHolder) convertView.getTag();
|
||||||
|
}
|
||||||
|
Glide.with(getContext()).load(getItem(position)).into(viewHolder.backgroundImage);
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static class ViewHolder {
|
||||||
|
|
||||||
|
View backgroundView;
|
||||||
|
ImageView backgroundImage;
|
||||||
|
|
||||||
|
public ViewHolder(View view) {
|
||||||
|
backgroundView = view.findViewById(R.id.ll_background);
|
||||||
|
backgroundImage = (ImageView) view.findViewById(R.id.iv_background);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getImageResourceIdByPosition(int position) {
|
||||||
|
return sItems.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -80,7 +80,7 @@ public class ConsoleFragment extends Fragment implements ConnectorHandler {
|
|||||||
mConsoleText.setMovementMethod(new ScrollingMovementMethod());
|
mConsoleText.setMovementMethod(new ScrollingMovementMethod());
|
||||||
|
|
||||||
ImageView background = (ImageView) view.findViewById(R.id.iv_background);
|
ImageView background = (ImageView) view.findViewById(R.id.iv_background);
|
||||||
Glide.with(this).load(R.drawable.bg1).into(background);
|
Glide.with(this).load(R.drawable.console_bg).into(background);
|
||||||
|
|
||||||
ImageView syngLogo = (ImageView) view.findViewById(R.id.iv_syng_logo);
|
ImageView syngLogo = (ImageView) view.findViewById(R.id.iv_syng_logo);
|
||||||
ImageView syngText = (ImageView) view.findViewById(R.id.iv_syng_text);
|
ImageView syngText = (ImageView) view.findViewById(R.id.iv_syng_text);
|
||||||
|
BIN
app/src/main/res/drawable/bg0.png
Normal file
After Width: | Height: | Size: 186 KiB |
BIN
app/src/main/res/drawable/bg0_resized.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
app/src/main/res/drawable/bg1.png
Normal file
After Width: | Height: | Size: 212 KiB |
BIN
app/src/main/res/drawable/bg1_resized.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
app/src/main/res/drawable/bg2.png
Normal file
After Width: | Height: | Size: 197 KiB |
BIN
app/src/main/res/drawable/bg2_resized.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
app/src/main/res/drawable/bg3.png
Normal file
After Width: | Height: | Size: 254 KiB |
BIN
app/src/main/res/drawable/bg3_resized.jpg
Normal file
After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 26 KiB |
20
app/src/main/res/layout/backround_list_item.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/ll_background"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="150dp"
|
||||||
|
android:maxWidth="320dp"
|
||||||
|
android:background="?selectableItemBackground"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_background"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
tools:src="@drawable/two"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -1,5 +1,5 @@
|
|||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/drawer_header"
|
android:id="@+id/drawer_header_item"
|
||||||
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="120dp"
|
android:layout_height="120dp"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<item name="android:layout_width">fill_parent</item>
|
<item name="android:layout_width">fill_parent</item>
|
||||||
<item name="android:layout_height">match_parent</item>
|
<item name="android:layout_height">match_parent</item>
|
||||||
<item name="android:layout_gravity">start</item>
|
<item name="android:layout_gravity">start</item>
|
||||||
<item name="android:background">@drawable/bg1</item>
|
<item name="android:background">@drawable/console_bg</item>
|
||||||
<item name="android:orientation">vertical</item>
|
<item name="android:orientation">vertical</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|