Removing redandant files (achieved profile manager activity), Added favicon in drawer. Tinted icons in drawer. Main activity now is singleTop

This commit is contained in:
Yaroslav Berezanskyi 2015-08-11 17:55:55 +03:00
parent 35adff982a
commit f3bb5165d6
31 changed files with 117 additions and 1244 deletions

View File

@ -33,7 +33,8 @@
<activity
android:name=".activity.MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustNothing">
android:windowSoftInputMode="adjustNothing"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
@ -56,13 +57,8 @@
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.MainActivity"/>
</activity>
<activity
android:name=".activity.ProfileManagerActivity"
android:label="@string/title_activity_profile_manager"/>
<service
android:name=".service.EthereumService"
android:enabled="true"

View File

@ -138,7 +138,6 @@ public abstract class BaseActivity extends AppCompatActivity implements
initSearch();
mDrawerLayout.findViewById(R.id.ll_settings).setOnClickListener(this);
mDrawerLayout.findViewById(R.id.profile_manager).setOnClickListener(this);
mDrawerLayout.findViewById(R.id.ll_contribute).setOnClickListener(this);
mDrawerLayout.findViewById(R.id.drawer_header).setOnClickListener(this);
@ -152,7 +151,7 @@ public abstract class BaseActivity extends AppCompatActivity implements
initProfiles();
ImageView header = (ImageView) mDrawerLayout.findViewById(R.id.iv_header);
Glide.with(this).load(R.drawable.drawer).into(header);
Glide.with(this).load(R.drawable.two).into(header);
super.setContentView(mDrawerLayout);
TextView textView = (TextView) findViewById(R.id.tv_name);
@ -388,10 +387,6 @@ public abstract class BaseActivity extends AppCompatActivity implements
startActivity(new Intent(BaseActivity.this, SettingsActivity.class));
closeDrawer(DRAWER_CLOSE_DELAY_LONG);
break;
case R.id.profile_manager:
startActivity(new Intent(BaseActivity.this, ProfileManagerActivity.class));
closeDrawer(DRAWER_CLOSE_DELAY_LONG);
break;
case R.id.drawer_header:
flipDrawer();
break;
@ -571,6 +566,8 @@ public abstract class BaseActivity extends AppCompatActivity implements
intent.setData(Uri.parse(url));
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
closeDrawer(DRAWER_CLOSE_DELAY_SHORT);
mSearchTextView.getText().clear();
}
}

View File

@ -18,8 +18,15 @@ public class MainActivity extends BaseActivity {
setContentView(R.layout.activity_main);
Intent intent = getIntent();
if (savedInstanceState == null) {
replaceFragment(new ConsoleFragment());
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent.getDataString() != null && intent.getDataString().indexOf("dapp://") == 0) {
WebViewFragment wvF = new WebViewFragment();
Bundle args = new Bundle();
@ -27,10 +34,6 @@ public class MainActivity extends BaseActivity {
wvF.setArguments(args);
replaceFragment(wvF);
}
else if (savedInstanceState == null) {
replaceFragment(new ConsoleFragment());
}
}
@Override
@ -57,5 +60,4 @@ public class MainActivity extends BaseActivity {
}
}

View File

@ -1,141 +0,0 @@
package io.syng.activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.afollestad.materialdialogs.MaterialDialog;
import io.syng.R;
import io.syng.entity.Dapp;
import io.syng.entity.Profile;
import io.syng.fragment.AddProfileFragment;
import io.syng.fragment.ProfileManagerFragment;
import io.syng.interfaces.OnFragmentInteractionListener;
public class ProfileManagerActivity extends BaseActivity implements OnFragmentInteractionListener {
private AddProfileFragment addProfileFragment;
private ProfileManagerFragment profileManagerFragment;
private TextView saveProfileLink;
private TextView addProfileLink;
private View profileManagerContainer;
private View addProfileContainer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile_manager);
saveProfileLink = (TextView) findViewById(R.id.save_profile_link);
saveProfileLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Profile profile = addProfileFragment.getProfile();
if (profile.getPasswordProtectedProfile()) {
new MaterialDialog.Builder(ProfileManagerActivity.this)
.title(R.string.request_profile_password)
.customView(R.layout.profile_password, true)
.positiveText(R.string.ok)
.negativeText(R.string.cancel)
// .contentColor(R.color.accent) // notice no 'res' postfix for literal color
.dividerColorRes(R.color.accent)
.backgroundColorRes(R.color.primary_dark)
.positiveColorRes(R.color.accent)
.negativeColorRes(R.color.accent)
.widgetColorRes(R.color.accent)
.callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog dialog) {
View view = dialog.getCustomView();
EditText passwordInput = (EditText) view.findViewById(R.id.passwordInput);
profile.encrypt(passwordInput.getText().toString());
profileManagerFragment.addProfile(profile);
hideAddProfile();
}
@Override
public void onNegative(MaterialDialog dialog) {
dialog.hide();
// spinner.setSelection(currentPosition, false);
}
})
.build()
.show();
} else {
profileManagerFragment.addProfile(profile);
hideAddProfile();
}
}
});
addProfileLink = (TextView) findViewById(R.id.add_profile_link);
addProfileLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
profileManagerFragment.resetProfilePosition();
showAddProfile(null);
}
});
if (savedInstanceState == null) {
addProfileFragment = new AddProfileFragment();
profileManagerFragment = new ProfileManagerFragment();
getSupportFragmentManager().beginTransaction()
.add(R.id.profileManagerFragmentContainer, profileManagerFragment)
.add(R.id.addProfileFragmentContainer, addProfileFragment)
.commit();
}
addProfileContainer = findViewById(R.id.addProfileFragmentContainer);
profileManagerContainer = findViewById(R.id.profileManagerFragmentContainer);
hideAddProfile();
}
public void showAddProfile(Profile profile) {
profileManagerContainer.setVisibility(View.INVISIBLE);
addProfileLink.setVisibility(View.INVISIBLE);
addProfileContainer.setVisibility(View.VISIBLE);
saveProfileLink.setVisibility(View.VISIBLE);
addProfileFragment.setProfile(profile);
getSupportActionBar().setTitle(R.string.add_profile);
}
public void hideAddProfile() {
addProfileContainer.setVisibility(View.INVISIBLE);
profileManagerContainer.setVisibility(View.VISIBLE);
addProfileLink.setVisibility(View.VISIBLE);
saveProfileLink.setVisibility(View.INVISIBLE);
getSupportActionBar().setTitle(R.string.profile_manager_title);
}
public void addProfile(Profile profile) {
profileManagerFragment.addProfile(profile);
}
@Override
public void onFragmentInteraction(Uri uri) {
}
@Override
protected void onDAppClick(Dapp dapp) {
}
}

View File

@ -22,8 +22,11 @@ public class DAppDrawerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
public interface OnDAppClickListener {
void onDAppItemClick(Dapp dapp);
void onDAppPress(Dapp dapp);
void onDAppAdd();
void onDAppContinueSearch();
}
@ -60,7 +63,7 @@ public class DAppDrawerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
SimpleViewHolder myHolder = (SimpleViewHolder) holder;
final Dapp dapp = mDataSet.get(position);
myHolder.nameTextView.setText(dapp.getName());
myHolder.nameTextView.setOnClickListener(new View.OnClickListener() {
myHolder.item.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mListener != null) {
@ -68,7 +71,7 @@ public class DAppDrawerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
}
}
});
myHolder.nameTextView.setOnLongClickListener(new View.OnLongClickListener() {
myHolder.item.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (mListener != null) {
@ -141,10 +144,12 @@ public class DAppDrawerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
static class SimpleViewHolder extends RecyclerView.ViewHolder {
private TextView nameTextView;
private View item;
public SimpleViewHolder(View v) {
super(v);
nameTextView = (TextView) v.findViewById(R.id.text);
item = v.findViewById(R.id.ll_dapp_item);
}
}

View File

@ -1,98 +0,0 @@
package io.syng.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import co.dift.ui.SwipeToAction;
import io.syng.R;
import io.syng.entity.Dapp;
public class DappAdapter extends RecyclerView.Adapter<DappAdapter.DappViewHolder> {
private ArrayList<Dapp> mDataSet;
public void add(int position, Dapp item) {
mDataSet.add(position, item);
notifyItemInserted(position);
}
public void set(int position, Dapp item) {
mDataSet.set(position, item);
notifyItemChanged(position);
}
public void add(Dapp item) {
mDataSet.add(item);
int position = mDataSet.indexOf(item);
notifyItemInserted(position);
}
public void remove(Dapp item) {
int position = mDataSet.indexOf(item);
mDataSet.remove(position);
notifyItemRemoved(position);
}
public void clear() {
mDataSet.clear();
notifyDataSetChanged();
}
public int getPosition(Dapp dapp) {
return mDataSet.indexOf(dapp);
}
public ArrayList<Dapp> getItems() {
return mDataSet;
}
public DappAdapter(ArrayList<Dapp> dataset) {
this.mDataSet = dataset;
}
@Override
public DappAdapter.DappViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.dapp_item, parent, false);
return new DappViewHolder(v);
}
// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(DappViewHolder holder, int position) {
// - get element from your dataset at this position
// - replace the contents of the view with that element
final Dapp dapp = mDataSet.get(position);
DappViewHolder viewHolder = (DappViewHolder) holder;
viewHolder.data = dapp;
holder.txtHeader.setText(mDataSet.get(position).getName());
holder.txtFooter.setText("Footer: " + mDataSet.get(position).getName());
}
// Return the size of your dataset (invoked by the layout manager)
@Override
public int getItemCount() {
return mDataSet.size();
}
static class DappViewHolder extends SwipeToAction.ViewHolder<Dapp> {
public TextView txtHeader;
public TextView txtFooter;
public DappViewHolder(View v) {
super(v);
txtHeader = (TextView) v.findViewById(R.id.firstLine);
txtFooter = (TextView) v.findViewById(R.id.secondLine);
}
}
}

View File

@ -1,112 +0,0 @@
package io.syng.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import co.dift.ui.SwipeToAction;
import io.syng.R;
import io.syng.entity.Profile;
public class ProfileAdapter extends RecyclerView.Adapter<ProfileAdapter.ProfileViewHolder> {
private ArrayList<Profile> mDataSet;
public void add(int position, Profile item) {
mDataSet.add(position, item);
notifyItemInserted(position);
}
public void set(int position, Profile item) {
mDataSet.set(position, item);
notifyItemChanged(position);
}
public void add(Profile item) {
mDataSet.add(item);
int position = mDataSet.indexOf(item);
notifyItemInserted(position);
}
public void remove(Profile item) {
int position = mDataSet.indexOf(item);
mDataSet.remove(position);
notifyItemRemoved(position);
}
public void clear() {
mDataSet.clear();
notifyDataSetChanged();
}
public int getPosition(Profile item) {
return mDataSet.indexOf(item);
}
public ArrayList<Profile> getItems() {
return (ArrayList<Profile>) mDataSet.clone();
}
public ProfileAdapter(ArrayList<Profile> dataset) {
this.mDataSet = dataset;
}
@Override
public ProfileAdapter.ProfileViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
// create a new view
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.profile_item, parent, false);
// set the view's size, margins, paddings and layout parameters
ProfileViewHolder vh = new ProfileViewHolder(v);
return vh;
}
// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(ProfileViewHolder holder, int position) {
// - get element from your dataset at this position
// - replace the contents of the view with that element
final Profile profile = mDataSet.get(position);
ProfileViewHolder viewHolder = holder;
viewHolder.data = profile;
holder.txtHeader.setText(mDataSet.get(position).getName());
holder.txtFooter.setText("Footer: " + mDataSet.get(position).getName());
}
// Return the size of your dataset (invoked by the layout manager)
@Override
public int getItemCount() {
return mDataSet.size();
}
public class ProfileViewHolder extends SwipeToAction.ViewHolder<Profile> {
public TextView txtHeader;
public TextView txtFooter;
public ProfileViewHolder(View v) {
super(v);
txtHeader = (TextView) v.findViewById(R.id.firstLine);
txtFooter = (TextView) v.findViewById(R.id.secondLine);
}
}
}

View File

@ -1,325 +0,0 @@
package io.syng.fragment;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.InputType;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import com.afollestad.materialdialogs.MaterialDialog;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import co.dift.ui.SwipeToAction;
import io.syng.R;
import io.syng.adapter.DappAdapter;
import io.syng.entity.Dapp;
import io.syng.entity.Profile;
import io.syng.interfaces.OnFragmentInteractionListener;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link OnFragmentInteractionListener} interface
* to handle interaction events.
*/
public class AddProfileFragment extends Fragment {
private EditText profileName;
private Switch profilePasswordProtected;
private RecyclerView mDappsRecyclerView;
private DappAdapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
private SwipeToAction swipeToAction;
private ArrayList<Dapp> mDappsList = new ArrayList<>();
private OnFragmentInteractionListener mListener;
private MaterialDialog dappDialog;
private EditText dappName;
private EditText dappUrl;
private Dapp addDapp = new Dapp("new_app_id", "Add new dapp");
private int dapEditPosition = -1;
private TextView walletModeButton;
private MaterialDialog walletModeDialog;
private RadioButton walletCreate;
private RadioButton walletImportFile;
private RadioButton accountModeImportString;
private EditText walletImportSource;
private int accountMode;
private String accountPrivateKey = null;
protected View.OnClickListener accountModeListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
accountMode = view.getId();
switch(accountMode) {
case R.id.radio_new_account:
walletImportSource.setInputType(InputType.TYPE_NULL);
break;
case R.id.radio_import_file:
case R.id.radio_import_string:
walletImportSource.setInputType(InputType.TYPE_CLASS_TEXT);
break;
}
}
};
public void setProfile(Profile profile) {
profileName.setText(profile != null ? profile.getName() : "");
profilePasswordProtected.setChecked(profile != null ? profile.getPasswordProtectedProfile() : false);
resetDapps();
if (profile != null) {
for (Dapp dapp : profile.getDapps()) {
mAdapter.add(dapp);
}
}
}
protected void resetDapps() {
mAdapter.clear();
mAdapter.add(addDapp);
}
public Profile getProfile() {
Profile profile = accountPrivateKey != null ? new Profile(accountPrivateKey) : new Profile();
profile.setName(profileName.getText().toString());
profile.setPasswordProtectedProfile(profilePasswordProtected.isChecked());
List<Dapp> dapps = mAdapter.getItems();
dapps.remove(addDapp);
profile.setDapps(dapps);
return profile;
}
protected void editDapp(Dapp dapp) {
dapEditPosition = mAdapter.getPosition(dapp);
dappName.setText(dapp.getName());
dappUrl.setText(dapp.getUrl());
dappDialog.show();
}
protected void createDapp() {
dapEditPosition = -1;
Dapp dapp = new Dapp();
dappName.setText(dapp.getName());
dappUrl.setText(dapp.getUrl());
dappDialog.show();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_add_profile, container, false);
profileName = (EditText) view.findViewById(R.id.profile_name);
profilePasswordProtected = (Switch) view.findViewById(R.id.profile_password_protected);
walletModeButton = (TextView)view.findViewById(R.id.wallet_mode);
walletModeDialog = new MaterialDialog.Builder(getActivity())
.title(R.string.wallet_title)
.customView(R.layout.wallet_creation_mode, true)
.positiveText(R.string.ok)
.negativeText(R.string.cancel)
.contentColor(getResources().getColor(R.color.accent))
.dividerColorRes(R.color.accent)
.backgroundColorRes(R.color.primary_dark)
.positiveColorRes(R.color.accent)
.negativeColorRes(R.color.accent)
.widgetColorRes(R.color.accent)
.autoDismiss(false)
.callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog dialog) {
boolean hideDialog = true;
accountPrivateKey = null;
switch (accountMode) {
case R.id.radio_new_account:
break;
case R.id.radio_import_file:
File file = new File(walletImportSource.getText().toString());
if (file.exists()) {
StringBuilder text = new StringBuilder();
try {
BufferedReader buffer = new BufferedReader(new FileReader(file));
String line;
while ((line = buffer.readLine()) != null) {
text.append(line);
}
buffer.close();
accountPrivateKey = text.toString();
} catch (IOException e) {
}
} else {
Toast.makeText(getActivity(), "File not found", Toast.LENGTH_LONG).show();
hideDialog = false;
}
break;
case R.id.radio_import_string:
accountPrivateKey = walletImportSource.getText().toString();
break;
}
if (hideDialog) {
dialog.hide();
}
}
@Override
public void onNegative(MaterialDialog dialog) {
dialog.hide();
}
})
.build();
walletModeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
walletModeDialog.show();
}
});
View accountModeView = walletModeDialog.getCustomView();
walletCreate = (RadioButton)accountModeView.findViewById(R.id.radio_new_account);
walletImportFile = (RadioButton)accountModeView.findViewById(R.id.radio_import_file);
accountModeImportString = (RadioButton)accountModeView.findViewById(R.id.radio_import_string);
walletImportSource = (EditText)accountModeView.findViewById(R.id.accout_import_source);
walletCreate.setOnClickListener(accountModeListener);
walletImportFile.setOnClickListener(accountModeListener);
accountModeImportString.setOnClickListener(accountModeListener);
mDappsRecyclerView = (RecyclerView) view.findViewById(R.id.profile_dapps_list);
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
mDappsRecyclerView.setHasFixedSize(true);
// use a linear layout manager
mLayoutManager = new LinearLayoutManager(getActivity());
mDappsRecyclerView.setLayoutManager(mLayoutManager);
mAdapter = new DappAdapter(mDappsList);
resetDapps();
mDappsRecyclerView.setAdapter(mAdapter);
swipeToAction = new SwipeToAction(mDappsRecyclerView, new SwipeToAction.SwipeListener<Dapp>() {
@Override
public boolean swipeLeft(final Dapp itemData) {
mAdapter.remove(itemData);
return false; //true will move the front view to its starting position
}
@Override
public boolean swipeRight(Dapp itemData) {
return true;
}
@Override
public void onClick(Dapp itemData) {
if (itemData.getId() == "new_app_id") {
createDapp();
} else {
editDapp(itemData);
}
}
@Override
public void onLongClick(Dapp itemData) {
}
});
boolean wrapInScrollView = true;
dappDialog = new MaterialDialog.Builder(getActivity())
.title(R.string.dapp_dialog_title)
.customView(R.layout.dapp_form, wrapInScrollView)
.positiveText(R.string.save)
.negativeText(R.string.cancel)
.contentColor(getResources().getColor(R.color.accent)) // notice no 'res' postfix for literal color
.dividerColorRes(R.color.accent)
.backgroundColorRes(R.color.primary_dark)
.positiveColorRes(R.color.accent)
.negativeColorRes(R.color.accent)
.widgetColorRes(R.color.accent)
.callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog dialog) {
View view = dialog.getCustomView();
Dapp dapp = new Dapp();
dapp.setName(dappName.getText().toString());
dapp.setUrl(dappUrl.getText().toString());
if (dapEditPosition > -1) {
mAdapter.set(dapEditPosition, dapp);
} else {
mAdapter.add(dapp);
}
}
@Override
public void onNegative(MaterialDialog dialog) {
dialog.hide();
}
})
.build();
dappName = (EditText) dappDialog.findViewById(R.id.dapp_name);
dappUrl = (EditText) dappDialog.findViewById(R.id.dapp_url);
return view;
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (OnFragmentInteractionListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
}

View File

@ -1,161 +0,0 @@
package io.syng.fragment;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import co.dift.ui.SwipeToAction;
import io.syng.R;
import io.syng.activity.BaseActivity;
import io.syng.activity.ProfileManagerActivity;
import io.syng.adapter.ProfileAdapter;
import io.syng.entity.Profile;
import io.syng.interfaces.OnFragmentInteractionListener;
import io.syng.util.PrefsUtil;
/**
* A placeholder fragment containing a simple view.
*/
public class ProfileManagerFragment extends Fragment {
private RecyclerView recyclerView;
private ProfileAdapter adapter;
private RecyclerView.LayoutManager layoutManager;
private ArrayList<Profile> profiles = new ArrayList<>();
private SwipeToAction swipeToAction;
private OnFragmentInteractionListener mListener;
public int profileEditPosition = -1;
public static ProfileManagerFragment newInstance(String param1, String param2) {
ProfileManagerFragment fragment = new ProfileManagerFragment();
return fragment;
}
public ProfileManagerFragment() {
}
public void addProfile(Profile profile) {
if (profileEditPosition > -1) {
adapter.set(profileEditPosition, profile);
} else {
adapter.add(profile);
}
updateProfiles();
}
public void resetProfilePosition() {
profileEditPosition = -1;
}
public void updateProfiles() {
BaseActivity activity = (BaseActivity)getActivity();
PrefsUtil.saveProfiles(adapter.getItems());
activity.initSpinner();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_profile_manager, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.profile_recycler_view);
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
recyclerView.setHasFixedSize(true);
// use a linear layout manager
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
// specify an adapter (see also next example)
profiles = PrefsUtil.getProfiles();
adapter = new ProfileAdapter(profiles);
recyclerView.setAdapter(adapter);
swipeToAction = new SwipeToAction(recyclerView, new SwipeToAction.SwipeListener<Profile>() {
@Override
public boolean swipeLeft(final Profile itemData) {
adapter.remove(itemData);
updateProfiles();
return false; //true will move the front view to its starting position
}
@Override
public boolean swipeRight(Profile itemData) {
//do something
return true;
}
@Override
public void onClick(Profile itemData) {
profileEditPosition = adapter.getPosition(itemData);
ProfileManagerActivity activity = (ProfileManagerActivity)getActivity();
activity.showAddProfile(itemData);
}
@Override
public void onLongClick(Profile itemData) {
//do something
}
});
return view;
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (OnFragmentInteractionListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
}

View File

@ -1,19 +0,0 @@
package io.syng.interfaces;
import android.net.Uri;
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p/>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B

View File

@ -12,7 +12,8 @@
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_add_black_24dp"/>
android:src="@drawable/ic_add_black_24dp"
android:tint="@color/drawer_icons_color"/>
<TextView
android:id="@+id/tv_add_account"

View File

@ -17,6 +17,7 @@
<TextView
android:id="@+id/tv_account_name"
style="@style/Base.TextAppearance.AppCompat.Body2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"

View File

@ -1,57 +0,0 @@
<RelativeLayout
android:id="@+id/profileManagerContainer"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:title="@string/manage_profiles"
tools:context="io.syng.activity.ProfileManagerActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/myToolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="@color/primary_dark"
android:gravity="end">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/add_profile_link"
style="@style/ToolbarIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/add_profile"
android:textColor="@color/accent"/>
<TextView
android:id="@+id/save_profile_link"
style="@style/ToolbarIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/save"
android:textColor="@color/accent"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<FrameLayout
android:id="@+id/profileManagerFragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/myToolbar"
android:visibility="visible">
</FrameLayout>
<FrameLayout
android:id="@+id/addProfileFragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/myToolbar"
android:visibility="invisible">
</FrameLayout>
</RelativeLayout>

View File

@ -1,26 +1,43 @@
<LinearLayout
android:id="@+id/ll_add"
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">
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_add_black_24dp"/>
<View
android:layout_width="match_parent"
android:layout_height="0.05dp"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:background="#D7D7D7"
/>
<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="Add new app"/>
<LinearLayout
android:id="@+id/ll_add"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeightSmall"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
>
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_add_black_24dp"
android:tint="@color/drawer_icons_color"/>
<TextView
style="@style/Base.TextAppearance.AppCompat.Body2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:text="Add new app"
android:textColor="@android:color/black"/>
</LinearLayout>
</LinearLayout>

View File

@ -12,7 +12,8 @@
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_search_black_24dp"/>
android:src="@drawable/ic_search_black_24dp"
android:tint="@color/drawer_icons_color"/>
<TextView
android:layout_width="wrap_content"

View File

@ -1,13 +1,33 @@
<TextView
android:id="@+id/text"
<LinearLayout
android:id="@+id/ll_dapp_item"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="?attr/listPreferredItemHeightSmall"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:textColor="@android:color/black"
android:background="?attr/selectableItemBackground"/>
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_favorite_black_24dp"
android:tint="@color/drawer_icons_color"/>
<TextView
android:id="@+id/text"
style="@style/Base.TextAppearance.AppCompat.Body2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:textColor="@android:color/black"
tools:text="Test text"
/>
</LinearLayout>

View File

@ -1,83 +0,0 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:tag="reveal-right">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:tint="@color/icons"/>
</RelativeLayout>
<!-- this view reveals when swipe left -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/red"
android:tag="reveal-left">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:src="@drawable/ic_delete_black_24dp"
android:tint="@color/icons"/>
</RelativeLayout>
<!-- this is the item front view -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primary_dark"
android:tag="front">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:contentDescription="TODO"
android:src="@drawable/ico_display"/>
<TextView
android:id="@+id/secondLine"
android:layout_width="fill_parent"
android:layout_height="26dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/icon"
android:ellipsize="marquee"
android:singleLine="true"
android:text="Description"
android:textColor="@color/accent"
android:textSize="12sp"/>
<TextView
android:id="@+id/firstLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/secondLine"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:layout_toRightOf="@id/icon"
android:gravity="center_vertical"
android:text="Example profile"
android:textColor="@color/accent"
android:textSize="16sp"/>
</RelativeLayout>
</RelativeLayout>

View File

@ -17,20 +17,6 @@
android:orientation="vertical"
>
<TextView
android:id="@+id/profile_manager"
style="@style/Base.TextAppearance.AppCompat.Body2"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeightSmall"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:paddingLeft="32dp"
android:paddingStart="32dp"
android:text="Profile Manager"
android:textAllCaps="true"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/ll_settings"
android:layout_width="match_parent"
@ -44,7 +30,8 @@
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_settings_black_24dp"/>
android:src="@drawable/ic_settings_black_24dp"
android:tint="@color/drawer_icons_color"/>
<TextView
android:id="@+id/settings"
@ -60,7 +47,6 @@
</LinearLayout>
<LinearLayout
android:id="@+id/ll_contribute"
android:layout_width="match_parent"
@ -74,7 +60,8 @@
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_github_circle_black_24dp"/>
android:src="@drawable/ic_github_circle_black_24dp"
android:tint="@color/drawer_icons_color"/>
<TextView
android:id="@+id/tv_contribute"

View File

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

View File

@ -39,7 +39,8 @@
android:layout_marginRight="25dp"
android:layout_marginStart="25dp"
android:gravity="center_vertical"
android:src="@drawable/ic_search_black_24dp"/>
android:src="@drawable/ic_search_black_24dp"
android:tint="@color/drawer_icons_color"/>
</RelativeLayout>

View File

@ -4,8 +4,8 @@
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="?attr/selectableItemBackground"
android:soundEffectsEnabled="false"
android:fitsSystemWindows="true">
android:fitsSystemWindows="true"
android:soundEffectsEnabled="false">
<ImageView
android:id="@+id/iv_header"
@ -19,10 +19,18 @@
<TextView
android:id="@+id/tv_name"
style="@style/TextDrawer320"
style="@style/Base.TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/drawer_indicator"
android:layout_gravity="start"
android:layout_marginBottom="15dp"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_toEndOf="@+id/nv_email"
android:layout_toRightOf="@+id/nv_email"
android:layout_toEndOf="@+id/nv_email"/>
android:text="Jarrad Hope"
android:textColor="#ffffff"/>
<Spinner
android:id="@+id/nv_email"
@ -31,8 +39,8 @@
<ImageView
android:id="@+id/drawer_indicator"
android:tint="@android:color/white"
style="@style/ViewDrawer320"/>
style="@style/ViewDrawer320"
android:tint="@android:color/white"/>
</RelativeLayout>

View File

@ -1,53 +0,0 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="io.syng.fragment.AddProfileFragment">
<LinearLayout
android:id="@+id/profile_settings"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/profile_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name"
android:textColor="@color/accent"/>
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/wallet_mode"
android:text="@string/wallet_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/accent"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/accent">
<Switch
android:id="@+id/profile_password_protected"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/profile_password_protected"
android:textColor="@color/accent"/>
</LinearLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/profile_dapps_list"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/profile_settings"
android:scrollbars="vertical"/>
</RelativeLayout>

View File

@ -1,85 +0,0 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip" >
<RelativeLayout
android:tag="reveal-right"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="20dp"
android:tint="@color/icons"/>
</RelativeLayout>
<!-- this view reveals when swipe left -->
<RelativeLayout
android:tag="reveal-left"
android:background="@color/red"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="20dp"
android:tint="@color/icons"
android:src="@drawable/ic_delete_black_24dp"/>
</RelativeLayout>
<!-- this is the item front view -->
<RelativeLayout
android:tag="front"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/profile">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="6dip"
android:contentDescription="TODO"
android:src="@drawable/profile" />
<TextView
android:id="@+id/secondLine"
android:layout_width="fill_parent"
android:layout_height="26dip"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_toEndOf="@id/icon"
android:ellipsize="marquee"
android:singleLine="true"
android:text="Description"
android:textColor="@color/accent"
android:textSize="12sp" />
<TextView
android:id="@+id/firstLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/secondLine"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:layout_toEndOf="@id/icon"
android:gravity="center_vertical"
android:text="Example profile"
android:textColor="@color/accent"
android:textSize="16sp" />
</RelativeLayout>
</RelativeLayout>

View File

@ -1,9 +0,0 @@
<TextView android:id="@android:id/text1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingEnd="32dp"
android:paddingStart="32dp"
android:textAppearance="?android:attr/textAppearanceListItemSmall"/>

View File

@ -3,15 +3,12 @@
<color name="white">#ffffff</color>
<color name="red">#fa0000</color>
<color name="toolbar">#fafafa</color>
<color name="icons">#fafafa</color>
<color name="profile">#161c30</color>
<color name="primary">#e7333333</color>
<color name="primary_dark">#303030</color>
<color name="accent">#536DFE</color>
<color name="black_overlay">#66000000</color>
<color name="toolbar_color">#efefef</color>
<color name="fab_dark_color">#cfcfcf</color>
<color name="drawer_icons_color">#737373</color>
</resources>

View File

@ -18,21 +18,6 @@
</style>
<style name="TextDrawer320">
<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_marginLeft">20dp</item>
<item name="android:layout_marginStart">20dp</item>
<item name="android:layout_marginBottom">15dp</item>
<item name="android:text">Jarrad Hope</item>
<item name="android:textColor">#ffffff</item>
<item name="android:textSize">20sp</item>
<item name="android:shadowColor">#000000</item>
<item name="android:shadowDy">1.2</item>
<item name="android:shadowRadius">1.2</item>
</style>
<style name="SpinnerDrawer320">
<item name="android:background">@null</item>
<item name="android:layout_width">match_parent</item>