mirror of
https://github.com/status-im/syng-client.git
synced 2025-02-24 00:48:10 +00:00
Merge branch 'master' of https://github.com/syng-io/syng-client
This commit is contained in:
commit
81d71704de
@ -2,6 +2,7 @@ package io.syng.activity;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
@ -20,6 +21,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
@ -31,6 +33,7 @@ import android.widget.ListView;
|
|||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -72,6 +75,10 @@ public abstract class BaseActivity extends AppCompatActivity implements OnItemCl
|
|||||||
|
|
||||||
protected abstract void onDAppClick(String item);
|
protected abstract void onDAppClick(String item);
|
||||||
|
|
||||||
|
private SpinnerAdapter spinnerAdapter;
|
||||||
|
private Profile requestProfile;
|
||||||
|
private int currentPosition;
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
@Override
|
@Override
|
||||||
public void setContentView(final int layoutResID) {
|
public void setContentView(final int layoutResID) {
|
||||||
@ -130,20 +137,71 @@ public abstract class BaseActivity extends AppCompatActivity implements OnItemCl
|
|||||||
mHandler.postDelayed(mRunnable, delayMills);
|
mHandler.postDelayed(mRunnable, delayMills);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void changeProfile(Profile profile) {
|
||||||
|
|
||||||
|
SyngApplication application = (SyngApplication)getApplication();
|
||||||
|
List<String> privateKeys = profile.getPrivateKeys();
|
||||||
|
application.sEthereumConnector.init(privateKeys);
|
||||||
|
currentPosition = spinnerAdapter.getPosition(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void requestChangeProfile(Profile profile) {
|
||||||
|
|
||||||
|
requestProfile = profile;
|
||||||
|
new MaterialDialog.Builder(BaseActivity.this)
|
||||||
|
.title(R.string.request_profile_password)
|
||||||
|
.customView(R.layout.profile_password, 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)
|
||||||
|
.callback(new MaterialDialog.ButtonCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPositive(MaterialDialog dialog) {
|
||||||
|
|
||||||
|
View view = dialog.getCustomView();
|
||||||
|
EditText passwordInput = (EditText) view.findViewById(R.id.passwordInput);
|
||||||
|
if (requestProfile.decrypt(passwordInput.getText().toString())) {
|
||||||
|
changeProfile(requestProfile);
|
||||||
|
} else {
|
||||||
|
dialog.hide();
|
||||||
|
mAccountSpinner.setSelection(currentPosition, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNegative(MaterialDialog dialog) {
|
||||||
|
|
||||||
|
dialog.hide();
|
||||||
|
mAccountSpinner.setSelection(currentPosition, false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build()
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
public void initSpinner() {
|
public void initSpinner() {
|
||||||
|
|
||||||
List<Profile> profilesList = ((SyngApplication) getApplication()).mPreferenceManager.getProfiles();
|
List<Profile> profilesList = ((SyngApplication) getApplication()).mPreferenceManager.getProfiles();
|
||||||
ArrayList<String> spinnerItems = new ArrayList<>();
|
spinnerAdapter = new SpinnerAdapter(this, android.R.layout.simple_dropdown_item_1line, profilesList);
|
||||||
for (Profile profile : profilesList) {
|
mAccountSpinner.setAdapter(spinnerAdapter);
|
||||||
spinnerItems.add(profile.getName());
|
|
||||||
}
|
|
||||||
mAccountSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, spinnerItems.toArray(new String[spinnerItems.size()])));
|
|
||||||
mAccountSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
mAccountSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
//String item = (String) adapterView.getItemAtPosition(i);
|
//String item = (String) adapterView.getItemAtPosition(i);
|
||||||
if (adapterView != null && adapterView.getChildAt(0) != null) {
|
if (adapterView != null && adapterView.getChildAt(0) != null) {
|
||||||
((TextView) adapterView.getChildAt(0)).setTextColor(Color.parseColor("#ffffff"));
|
((TextView) adapterView.getChildAt(0)).setTextColor(Color.parseColor("#ffffff"));
|
||||||
|
}
|
||||||
|
Profile profile = spinnerAdapter.getItem(i);
|
||||||
|
if (profile.getPasswordProtectedProfile()) {
|
||||||
|
requestChangeProfile(profile);
|
||||||
|
} else {
|
||||||
|
changeProfile(profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,4 +326,54 @@ public abstract class BaseActivity extends AppCompatActivity implements OnItemCl
|
|||||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SpinnerAdapter extends ArrayAdapter<Profile> {
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
private List<Profile> values;
|
||||||
|
|
||||||
|
public SpinnerAdapter(Context context, int textViewResourceId, List<Profile> values) {
|
||||||
|
|
||||||
|
super(context, textViewResourceId, values);
|
||||||
|
this.context = context;
|
||||||
|
this.values = values;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
|
||||||
|
return values.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Profile getItem(int position){
|
||||||
|
|
||||||
|
return values.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getItemId(int position){
|
||||||
|
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
|
||||||
|
return getCustomView(position, convertView, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||||
|
|
||||||
|
return getCustomView(position, convertView, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public View getCustomView(int position, View convertView, ViewGroup parent) {
|
||||||
|
|
||||||
|
LayoutInflater inflater = getLayoutInflater();
|
||||||
|
View row=inflater.inflate(android.R.layout.simple_dropdown_item_1line, parent, false);
|
||||||
|
TextView label=(TextView)row.findViewById(android.R.id.text1);
|
||||||
|
label.setText(spinnerAdapter.getItem(position).getName());
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class ProfileManagerActivity extends BaseActivity implements OnFragmentIn
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_profile_manager);
|
setContentView(R.layout.activity_profile_manager);
|
||||||
|
|
||||||
saveProfileLink = (TextView)findViewById(R.id.save_profile_link);
|
saveProfileLink = (TextView) findViewById(R.id.save_profile_link);
|
||||||
saveProfileLink.setOnClickListener(new View.OnClickListener() {
|
saveProfileLink.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
@ -74,9 +74,9 @@ public class ProfileManagerActivity extends BaseActivity implements OnFragmentIn
|
|||||||
.build()
|
.build()
|
||||||
.show();
|
.show();
|
||||||
} else {
|
} else {
|
||||||
profileManagerFragment.addProfile(profile);
|
profileManagerFragment.addProfile(profile);
|
||||||
hideAddProfile();
|
hideAddProfile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addProfileLink = (TextView) findViewById(R.id.add_profile_link);
|
addProfileLink = (TextView) findViewById(R.id.add_profile_link);
|
||||||
@ -91,9 +91,9 @@ public class ProfileManagerActivity extends BaseActivity implements OnFragmentIn
|
|||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
addProfileFragment = new AddProfileFragment();
|
addProfileFragment = new AddProfileFragment();
|
||||||
profileManagerFragment = new ProfileManagerFragment();
|
profileManagerFragment = new ProfileManagerFragment();
|
||||||
getFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
// .add(R.id.profileManagerFragmentContainer, profileManagerFragment)
|
.add(R.id.profileManagerFragmentContainer, profileManagerFragment)
|
||||||
// .add(R.id.addProfileFragmentContainer, addProfileFragment)
|
.add(R.id.addProfileFragmentContainer, addProfileFragment)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,27 +134,6 @@ public class ProfileManagerActivity extends BaseActivity implements OnFragmentIn
|
|||||||
public void onFragmentInteraction(Uri uri) {
|
public void onFragmentInteraction(Uri uri) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
|
||||||
// getMenuInflater().inflate(R.menu.menu_profile_manager, menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
// Handle action bar item clicks here. The action bar will
|
|
||||||
// automatically handle clicks on the Home/Up button, so long
|
|
||||||
// as you specify a parent activity in AndroidManifest.xml.
|
|
||||||
int id = item.getItemId();
|
|
||||||
|
|
||||||
//noinspection SimplifiableIfStatement
|
|
||||||
// if (id == R.id.action_settings) {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDAppClick(String item) {
|
protected void onDAppClick(String item) {
|
||||||
|
@ -1,24 +1,36 @@
|
|||||||
package io.syng.app;
|
package io.syng.app;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Message;
|
||||||
import android.support.multidex.MultiDexApplication;
|
import android.support.multidex.MultiDexApplication;
|
||||||
|
|
||||||
|
import org.ethereum.android.service.ConnectorHandler;
|
||||||
|
import org.ethereum.android.service.EthereumConnector;
|
||||||
|
|
||||||
import com.squareup.leakcanary.LeakCanary;
|
import com.squareup.leakcanary.LeakCanary;
|
||||||
import com.squareup.leakcanary.RefWatcher;
|
import com.squareup.leakcanary.RefWatcher;
|
||||||
|
|
||||||
|
import io.syng.service.EthereumService;
|
||||||
import io.syng.util.PreferenceManager;
|
import io.syng.util.PreferenceManager;
|
||||||
|
|
||||||
|
|
||||||
public class SyngApplication extends MultiDexApplication {
|
public class SyngApplication extends MultiDexApplication implements ConnectorHandler {
|
||||||
|
|
||||||
public PreferenceManager mPreferenceManager;
|
public PreferenceManager mPreferenceManager;
|
||||||
|
|
||||||
|
public static EthereumConnector sEthereumConnector = null;
|
||||||
|
|
||||||
private RefWatcher refWatcher;
|
private RefWatcher refWatcher;
|
||||||
|
|
||||||
@Override public void onCreate() {
|
@Override public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
mPreferenceManager = new PreferenceManager(this);
|
mPreferenceManager = new PreferenceManager(this);
|
||||||
refWatcher = LeakCanary.install(this);
|
refWatcher = LeakCanary.install(this);
|
||||||
|
if (sEthereumConnector == null) {
|
||||||
|
sEthereumConnector = new EthereumConnector(this, EthereumService.class);
|
||||||
|
sEthereumConnector.registerHandler(this);
|
||||||
|
sEthereumConnector.bindService();
|
||||||
|
}
|
||||||
// refWatcher = RefWatcher.DISABLED;
|
// refWatcher = RefWatcher.DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,6 +38,9 @@ public class SyngApplication extends MultiDexApplication {
|
|||||||
public void onTerminate() {
|
public void onTerminate() {
|
||||||
super.onTerminate();
|
super.onTerminate();
|
||||||
mPreferenceManager.close();
|
mPreferenceManager.close();
|
||||||
|
sEthereumConnector.removeHandler(this);
|
||||||
|
sEthereumConnector.unbindService();
|
||||||
|
sEthereumConnector = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -34,6 +49,23 @@ public class SyngApplication extends MultiDexApplication {
|
|||||||
return application.refWatcher;
|
return application.refWatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectorConnected() {
|
||||||
|
sEthereumConnector.startJsonRpc();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectorDisconnected() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getID() {
|
||||||
|
return "1";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleMessage(Message message) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,22 @@ import android.os.Bundle;
|
|||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.text.InputType;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.RadioButton;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -52,6 +60,32 @@ public class AddProfileFragment extends Fragment {
|
|||||||
|
|
||||||
private int dapEditPosition = -1;
|
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) {
|
public void setProfile(Profile profile) {
|
||||||
|
|
||||||
profileName.setText(profile != null ? profile.getName() : "");
|
profileName.setText(profile != null ? profile.getName() : "");
|
||||||
@ -71,7 +105,7 @@ public class AddProfileFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Profile getProfile() {
|
public Profile getProfile() {
|
||||||
Profile profile = new Profile();
|
Profile profile = accountPrivateKey != null ? new Profile(accountPrivateKey) : new Profile();
|
||||||
profile.setName(profileName.getText().toString());
|
profile.setName(profileName.getText().toString());
|
||||||
profile.setPasswordProtectedProfile(profilePasswordProtected.isChecked());
|
profile.setPasswordProtectedProfile(profilePasswordProtected.isChecked());
|
||||||
List<Dapp> dapps = mAdapter.getItems();
|
List<Dapp> dapps = mAdapter.getItems();
|
||||||
@ -105,6 +139,84 @@ public class AddProfileFragment extends Fragment {
|
|||||||
profileName = (EditText) view.findViewById(R.id.profile_name);
|
profileName = (EditText) view.findViewById(R.id.profile_name);
|
||||||
profilePasswordProtected = (Switch) view.findViewById(R.id.profile_password_protected);
|
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);
|
mDappsRecyclerView = (RecyclerView) view.findViewById(R.id.profile_dapps_list);
|
||||||
|
|
||||||
// use this setting to improve performance if you know that changes
|
// use this setting to improve performance if you know that changes
|
||||||
|
@ -50,8 +50,6 @@ public class ConsoleFragment extends Fragment implements ConnectorHandler {
|
|||||||
|
|
||||||
private String mConsoleLog = "";
|
private String mConsoleLog = "";
|
||||||
|
|
||||||
private static EthereumConnector sEthereumConnector;
|
|
||||||
|
|
||||||
private TextView mConsoleText;
|
private TextView mConsoleText;
|
||||||
|
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
@ -100,10 +98,6 @@ 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);
|
||||||
|
|
||||||
if (sEthereumConnector == null) {
|
|
||||||
sEthereumConnector = new EthereumConnector(getActivity(), EthereumService.class);
|
|
||||||
}
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,17 +105,19 @@ public class ConsoleFragment extends Fragment implements ConnectorHandler {
|
|||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mHandler.removeCallbacksAndMessages(null);
|
mHandler.removeCallbacksAndMessages(null);
|
||||||
// sEthereumConnector.removeHandler(this);
|
SyngApplication application = (SyngApplication)getActivity().getApplication();
|
||||||
sEthereumConnector.removeListener(mHandlerIdentifier);
|
application.sEthereumConnector.removeHandler(this);
|
||||||
sEthereumConnector.unbindService();
|
application.sEthereumConnector.removeListener(mHandlerIdentifier);
|
||||||
|
application.sEthereumConnector.unbindService();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
mHandler.post(mRunnable);
|
mHandler.post(mRunnable);
|
||||||
sEthereumConnector.registerHandler(this);
|
SyngApplication application = (SyngApplication)getActivity().getApplication();
|
||||||
sEthereumConnector.bindService();
|
application.sEthereumConnector.registerHandler(this);
|
||||||
|
application.sEthereumConnector.bindService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -150,7 +146,8 @@ public class ConsoleFragment extends Fragment implements ConnectorHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectorConnected() {
|
public void onConnectorConnected() {
|
||||||
sEthereumConnector.addListener(mHandlerIdentifier, EnumSet.allOf(EventFlag.class));
|
SyngApplication application = (SyngApplication)getActivity().getApplication();
|
||||||
|
application.sEthereumConnector.addListener(mHandlerIdentifier, EnumSet.allOf(EventFlag.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -162,9 +159,6 @@ public class ConsoleFragment extends Fragment implements ConnectorHandler {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
RefWatcher refWatcher = SyngApplication.getRefWatcher(getActivity());
|
RefWatcher refWatcher = SyngApplication.getRefWatcher(getActivity());
|
||||||
refWatcher.watch(this);
|
refWatcher.watch(this);
|
||||||
if (getActivity().isFinishing()) {
|
|
||||||
sEthereumConnector = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LogEntry myHandleMessage(Message message) {
|
private LogEntry myHandleMessage(Message message) {
|
||||||
|
@ -19,9 +19,16 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="Name"
|
android:hint="Name"
|
||||||
android:textColor="@color/accent"
|
android:textColor="@color/accent"/>
|
||||||
/>
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
</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
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -32,8 +39,7 @@
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/profile_password_protected"
|
android:text="@string/profile_password_protected"
|
||||||
android:textColor="@color/accent"
|
android:textColor="@color/accent"/>
|
||||||
/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -42,7 +48,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_below="@id/profile_settings"
|
android:layout_below="@id/profile_settings"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"/>
|
||||||
/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/accent"
|
android:textColor="@color/accent"
|
||||||
android:text="@string/create_new_account"/>
|
android:text="@string/create_new_wallet"/>
|
||||||
<RadioButton android:id="@+id/radio_import_file"
|
<RadioButton android:id="@+id/radio_import_file"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/accent"
|
android:textColor="@color/accent"
|
||||||
android:text="@string/import_account_from_file"/>
|
android:text="@string/import_wallet_from_file"/>
|
||||||
<RadioButton android:id="@+id/radio_import_string"
|
<RadioButton android:id="@+id/radio_import_string"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
<string name="title_activity_spash_screen">Syng</string>
|
<string name="title_activity_spash_screen">Syng</string>
|
||||||
|
|
||||||
<string name="account_mode_title">Account</string>
|
<string name="wallet_title">Wallet</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="create_new_account">Create new Account</string>
|
<string name="create_new_wallet">Create new Wallet</string>
|
||||||
<string name="import_account_from_file">Import account from file</string>
|
<string name="import_wallet_from_file">Import wallet from file</string>
|
||||||
<string name="import_account_from_string">Import account from string</string>
|
<string name="import_account_from_string">Import account from string</string>
|
||||||
|
|
||||||
<string name="request_profile_password">Profile Password</string>
|
<string name="request_profile_password">Profile Password</string>
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 6340cc47a4e496c5a25840097d66bfbbb0a557ab
|
Subproject commit a64d216537a4163c5ba422edcf513435a9423b96
|
Loading…
x
Reference in New Issue
Block a user