diff --git a/app/app.iml b/app/app.iml
deleted file mode 100644
index da723db..0000000
--- a/app/app.iml
+++ /dev/null
@@ -1,140 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugAndroidTestSources
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 121af34..da6c947 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -6,7 +6,7 @@ android {
defaultConfig {
applicationId "io.syng"
- minSdkVersion 17
+ minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
@@ -45,14 +45,19 @@ dependencies {
exclude group: "org.codehaus.jackson", module: "jackson-mapper-asl"
exclude group: "org.mapdb", module: "mapdb"
}
- compile 'com.android.support:multidex:1.0.0'
+ compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
- compile 'com.android.support:design:22.2.+'
+// compile 'com.android.support:support-v4:22.2.1'
+ compile 'com.android.support:design:22.2.1'
compile 'co.dift.ui.swipetoaction:library:1.1'
- compile 'de.hdodenhof:circleimageview:1.3.0'
+// compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.getbase:floatingactionbutton:1.9.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.2'
compile 'com.afollestad:material-dialogs:0.7.7.0'
- compile 'com.android.support:support-v4:22.2.1'
+ compile 'com.github.bumptech.glide:glide:3.6.1'
+
+ compile 'com.netflix.rxjava:rxjava-android:0.20.7'
+
+ debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 7eab040..5041bc9 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,53 +1,57 @@
-
+
-
-
-
-
+
+
+
+
-
+ android:theme="@style/AppTheme">
-
-
-
-
-
+
+
-
-
-
-
+ android:name=".activity.MainActivity"
+ android:label="@string/app_name"
+ android:windowSoftInputMode="adjustNothing">
-
+
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/io/syng/AddProfileFragment.java b/app/src/main/java/io/syng/AddProfileFragment.java
deleted file mode 100644
index 2a43024..0000000
--- a/app/src/main/java/io/syng/AddProfileFragment.java
+++ /dev/null
@@ -1,266 +0,0 @@
-package io.syng;
-
-import android.app.Activity;
-import android.net.Uri;
-import android.os.Bundle;
-import android.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 android.widget.EditText;
-import android.widget.Switch;
-import android.widget.TextView;
-
-import com.afollestad.materialdialogs.MaterialDialog;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import co.dift.ui.SwipeToAction;
-import io.syng.entities.Dapp;
-import io.syng.entities.DappAdapter;
-import io.syng.entities.Profile;
-
-
-/**
- * A simple {@link Fragment} subclass.
- * Activities that contain this fragment must implement the
- * {@link OnFragmentInteractionListener} interface
- * to handle interaction events.
- * Use the {@link AddProfileFragment#newInstance} factory method to
- * create an instance of this fragment.
- */
-public class AddProfileFragment extends Fragment {
- // TODO: Rename parameter arguments, choose names that match
- // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
- private static final String ARG_PARAM1 = "param1";
- private static final String ARG_PARAM2 = "param2";
-
- // TODO: Rename and change types of parameters
- private String mParam1;
- private String mParam2;
-
- private EditText profileName;
- private Switch profilePasswordProtected;
-
- private RecyclerView dappsList;
- private DappAdapter adapter;
- private RecyclerView.LayoutManager layoutManager;
- private SwipeToAction swipeToAction;
- private ArrayList dapps = 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");
-
- protected int dapEditPosition = -1;
-
- /**
- * Use this factory method to create a new instance of
- * this fragment using the provided parameters.
- *
- * @param param1 Parameter 1.
- * @param param2 Parameter 2.
- * @return A new instance of fragment AddProfileFragment.
- */
- public static AddProfileFragment newInstance(String param1, String param2) {
-
- AddProfileFragment fragment = new AddProfileFragment();
- Bundle args = new Bundle();
- args.putString(ARG_PARAM1, param1);
- args.putString(ARG_PARAM2, param2);
- fragment.setArguments(args);
- return fragment;
- }
-
- public AddProfileFragment() {
-
- // Required empty public constructor
- }
-
- 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()) {
- adapter.add(dapp);
- }
- }
- }
-
- protected void resetDapps() {
-
- adapter.clear();
- adapter.add(addDapp);
- }
-
- public Profile getProfile() {
-
- Profile profile = new Profile();
- profile.setName(profileName.getText().toString());
- profile.setPasswordProtectedProfile(profilePasswordProtected.isChecked());
- List dapps = adapter.getItems();
- dapps.remove(addDapp);
- profile.setDapps(dapps);
- return profile;
- }
-
- protected void editDapp(Dapp dapp) {
-
- dapEditPosition = adapter.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 void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
- if (getArguments() != null) {
- mParam1 = getArguments().getString(ARG_PARAM1);
- mParam2 = getArguments().getString(ARG_PARAM2);
- }
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
-
- // Inflate the layout for this fragment
- 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);
-
- dappsList = (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
- dappsList.setHasFixedSize(true);
-
- // use a linear layout manager
- layoutManager = new LinearLayoutManager(getActivity());
- dappsList.setLayoutManager(layoutManager);
-
- adapter = new DappAdapter(dapps);
- resetDapps();
- dappsList.setAdapter(adapter);
-
- swipeToAction = new SwipeToAction(dappsList, new SwipeToAction.SwipeListener() {
- @Override
- public boolean swipeLeft(final Dapp itemData) {
-
- adapter.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(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) {
- adapter.set(dapEditPosition, dapp);
- } else {
- adapter.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;
- }
-
-}
diff --git a/app/src/main/java/io/syng/BaseActivity.java b/app/src/main/java/io/syng/BaseActivity.java
deleted file mode 100644
index 1e0a03e..0000000
--- a/app/src/main/java/io/syng/BaseActivity.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package io.syng;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.graphics.Color;
-import android.os.Bundle;
-import android.support.v4.widget.DrawerLayout;
-import android.support.v7.app.ActionBarDrawerToggle;
-import android.support.v7.app.AppCompatActivity;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-import android.widget.ListView;
-import android.support.v7.widget.Toolbar;
-import android.widget.Spinner;
-import android.widget.TextView;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import io.syng.entities.PreferenceManager;
-import io.syng.entities.Profile;
-
-public class BaseActivity extends AppCompatActivity {
-
- Toolbar toolbar;
- protected ActionBarDrawerToggle drawerToggle;
- ArrayList menuItems = new ArrayList<>(Arrays.asList("Console", "DApps", "EtherEx", "TrustDavis", "Augur"));
- protected List profiles;
-
- Spinner spinner;
- EditText search;
- ListView drawerList;
-
- TextView settings;
- TextView profileManager;
-
- protected ArrayAdapter drawerListAdapter;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
- }
-
- @Override
- public void setContentView(final int layoutResID) {
-
- LayoutInflater inflater = getLayoutInflater();
- DrawerLayout fullLayout = (DrawerLayout) inflater.inflate(R.layout.drawer, null);
- LinearLayout actContent= (LinearLayout) fullLayout.findViewById(R.id.content);
-
- DrawerLayout drawerLayout = (DrawerLayout) fullLayout.findViewById(R.id.drawer_layout);
- drawerList = (ListView) drawerLayout.findViewById(R.id.drawer_list);
- initDrawer();
-
- toolbar = (Toolbar) inflater.inflate(layoutResID, actContent, true).findViewById(R.id.myToolbar);
- if (toolbar != null) {
- setSupportActionBar(toolbar);
- }
-
- drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close);
- drawerLayout.setDrawerListener(drawerToggle);
-
- spinner = (Spinner) drawerLayout.findViewById(R.id.nv_email);
- initSpinner();
-
- search = (EditText) drawerLayout.findViewById(R.id.search);
- initSearch();
-
- settings = (TextView) drawerLayout.findViewById(R.id.settings);
- settings.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
-
- startActivity(new Intent(BaseActivity.this, SettingsActivity.class));
- }
- });
-
- profileManager = (TextView) drawerLayout.findViewById(R.id.profileManager);
- profileManager.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
-
- startActivity(new Intent(BaseActivity.this, ProfileManagerActivity.class));
- }
- });
-
- super.setContentView(fullLayout);
- }
-
- private void initDrawer() {
-
- drawerListAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, (ArrayList)menuItems.clone());
- drawerList.setAdapter(drawerListAdapter);
- drawerListAdapter.notifyDataSetChanged();
-
- drawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
-
- String item = parent.getItemAtPosition(position).toString();
-
- switch (item) {
- case "Console":
- startActivity(new Intent(BaseActivity.this, MainActivity.class));
- break;
- case "DApps":
- break;
- case "EtherEx":
- break;
- case "TrustDavis":
- startActivity(new Intent(BaseActivity.this, webview.class));
- break;
- case "Augur":
- break;
- }
- }
- });
- }
-
- public void initSpinner() {
-
- profiles = ((Syng)getApplication()).preferenceManager.getProfiles();
- ArrayList spinnerItems = new ArrayList<>();
- for (Profile profile: profiles) {
- spinnerItems.add(profile.getName());
- }
- spinner.setAdapter(new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, spinnerItems.toArray(new String[spinnerItems.size()])));
- spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView> adapterView, View view, int i, long l) {
- //String item = (String) adapterView.getItemAtPosition(i);
- if (adapterView != null && adapterView.getChildAt(0) != null) {
- ((TextView) adapterView.getChildAt(0)).setTextColor(Color.parseColor("#ffffff"));
- }
- }
-
- @Override
- public void onNothingSelected(AdapterView> adapterView) {
-
- ((TextView) adapterView.getChildAt(0)).setTextColor(Color.parseColor("#ffffff"));
- }
-
- });
- }
-
- private void initSearch() {
-
- search.addTextChangedListener(new TextWatcher() {
-
- @Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
-
- }
-
- @Override
- public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
-
- }
-
- @Override
- public void afterTextChanged(Editable editable) {
-
- String searchValue = editable.toString();
- updateAppList(searchValue);
- }
- });
-
- search.setOnKeyListener(new View.OnKeyListener() {
-
- @Override
- public boolean onKey(View view, int i, KeyEvent keyEvent) {
-
- if (keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
- InputMethodManager imm = (InputMethodManager)getSystemService(
- Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(search.getWindowToken(), 0);
- return true;
- }
- return false;
- }
- });
- }
-
- protected void updateAppList(String filter) {
-
- drawerListAdapter.clear();
- int length = menuItems.size();
- for (int i = 0; i < length; i++) {
- String item = menuItems.get(i);
- if (item.toLowerCase().contains(filter.toLowerCase())) {
- drawerListAdapter.add(item);
- }
- }
- drawerListAdapter.notifyDataSetChanged();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- if (drawerToggle.onOptionsItemSelected(item)) {
- return true;
- }
- return super.onOptionsItemSelected(item);
-
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
-
- super.onPostCreate(savedInstanceState);
- drawerToggle.syncState();
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
-
- super.onConfigurationChanged(newConfig);
- drawerToggle.onConfigurationChanged(newConfig);
- }
-}
diff --git a/app/src/main/java/io/syng/MainActivity.java b/app/src/main/java/io/syng/MainActivity.java
deleted file mode 100644
index 4ed15ee..0000000
--- a/app/src/main/java/io/syng/MainActivity.java
+++ /dev/null
@@ -1,243 +0,0 @@
-package io.syng;
-
-import android.graphics.Color;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Message;
-import android.text.method.ScrollingMovementMethod;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.Window;
-import android.view.WindowManager;
-import android.widget.TextView;
-import org.ethereum.android.service.ConnectorHandler;
-import org.ethereum.android.service.EthereumClientMessage;
-import org.ethereum.android.service.EthereumConnector;
-import org.ethereum.android.service.events.BlockEventData;
-import org.ethereum.android.service.events.EventData;
-import org.ethereum.android.service.events.EventFlag;
-import org.ethereum.android.service.events.MessageEventData;
-import org.ethereum.android.service.events.PeerDisconnectEventData;
-import org.ethereum.android.service.events.PendingTransactionsEventData;
-import org.ethereum.android.service.events.TraceEventData;
-import org.ethereum.android.service.events.VMTraceCreatedEventData;
-import org.ethereum.config.SystemProperties;
-import org.ethereum.net.message.MessageFactory;
-import org.ethereum.net.p2p.HelloMessage;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.UUID;
-
-
-public class MainActivity extends BaseActivity implements ConnectorHandler {
-
- protected static String consoleLog = "";
-
- TextView consoleText;
-
- boolean isPaused = false;
-
- private Timer timer;
- private TimerTask timerTask;
-
- private static int CONSOLE_LENGTH = 10000;
- private static int CONSOLE_REFRESH = 1000;
-
- static EthereumConnector ethereum = null;
- protected String handlerIdentifier = UUID.randomUUID().toString();
-
- TextViewUpdater consoleUpdater = new TextViewUpdater();
-
- static DateFormat formatter = new SimpleDateFormat("HH:mm:ss:SSS");
-
- private class TextViewUpdater implements Runnable {
-
- private String txt;
- @Override
- public void run() {
-
- consoleText.setText(txt);
- }
- public void setText(String txt) {
-
- this.txt = txt;
- }
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- Window window = getWindow();
- window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- window.setStatusBarColor(Color.BLACK);
- }
-
- consoleText = (TextView) findViewById(R.id.console_log);
- consoleText.setText(MainActivity.consoleLog);
- consoleText.setMovementMethod(new ScrollingMovementMethod());
-
- if (ethereum == null) {
- ethereum = new EthereumConnector(this, EthereumService.class);
- ethereum.registerHandler(this);
- }
- }
-
- @Override
- protected void onPause() {
-
- super.onPause();
- isPaused = true;
- timer.cancel();
- ethereum.removeListener(handlerIdentifier);
- ethereum.unbindService();
- }
-
- @Override
- protected void onResume() {
-
- super.onResume();
- isPaused = false;
- try {
- timer = new Timer();
- timerTask = new TimerTask() {
- @Override
- public void run() {
- MainActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- int length = MainActivity.consoleLog.length();
- if (length > CONSOLE_LENGTH) {
- MainActivity.consoleLog = MainActivity.consoleLog.substring(CONSOLE_LENGTH * ((length/CONSOLE_LENGTH)-1) + length%CONSOLE_LENGTH);
- }
- consoleUpdater.setText(MainActivity.consoleLog);
- MainActivity.this.consoleText.post(consoleUpdater);
- }
- });
- }
- };
- timer.schedule(timerTask, 1000, CONSOLE_REFRESH);
- } catch (IllegalStateException e){
- android.util.Log.i("Damn", "resume error");
- }
- ethereum.bindService();
- }
-
- @Override
- protected void onDestroy() {
-
- super.onDestroy();
- ethereum.unbindService();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
-
- super.onPostCreate(savedInstanceState);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
-
- return super.onCreateOptionsMenu(menu);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public boolean handleMessage(Message message) {
-
- boolean isClaimed = true;
- switch(message.what) {
- case EthereumClientMessage.MSG_EVENT:
- Bundle data = message.getData();
- data.setClassLoader(EventFlag.class.getClassLoader());
- EventFlag event = (EventFlag)data.getSerializable("event");
- EventData eventData;
- MessageEventData messageEventData;
- switch(event) {
- case EVENT_BLOCK:
- BlockEventData blockEventData = data.getParcelable("data");
- addLogEntry(blockEventData.registeredTime, "Added block with " + blockEventData.receipts.size() + " transaction receipts.");
- break;
- case EVENT_HANDSHAKE_PEER:
- messageEventData = data.getParcelable("data");
- addLogEntry(messageEventData.registeredTime, "Peer " + new HelloMessage(messageEventData.message).getPeerId() + " said hello");
- break;
- case EVENT_NO_CONNECTIONS:
- eventData = data.getParcelable("data");
- addLogEntry(eventData.registeredTime, "No connections");
- break;
- case EVENT_PEER_DISCONNECT:
- PeerDisconnectEventData peerDisconnectEventData = data.getParcelable("data");
- addLogEntry(peerDisconnectEventData.registeredTime, "Peer " + peerDisconnectEventData.host + ":" + peerDisconnectEventData.port + " disconnected.");
- break;
- case EVENT_PENDING_TRANSACTIONS_RECEIVED:
- PendingTransactionsEventData pendingTransactionsEventData = data.getParcelable("data");
- addLogEntry(pendingTransactionsEventData.registeredTime, "Received " + pendingTransactionsEventData.transactions.size() + " pending transactions");
- break;
- case EVENT_RECEIVE_MESSAGE:
- messageEventData = data.getParcelable("data");
- addLogEntry(messageEventData.registeredTime, "Received message: " + messageEventData.messageClass.getName());
- break;
- case EVENT_SEND_MESSAGE:
- messageEventData = data.getParcelable("data");
- addLogEntry(messageEventData.registeredTime, "Sent message: " + messageEventData.messageClass.getName());
- break;
- case EVENT_SYNC_DONE:
- eventData = data.getParcelable("data");
- addLogEntry(eventData.registeredTime, "Sync done");
- break;
- case EVENT_VM_TRACE_CREATED:
- VMTraceCreatedEventData vmTraceCreatedEventData = data.getParcelable("data");
- addLogEntry(vmTraceCreatedEventData.registeredTime, "CM trace created: " + vmTraceCreatedEventData.transactionHash + " - " + vmTraceCreatedEventData.trace);
- break;
- case EVENT_TRACE:
- TraceEventData traceEventData = data.getParcelable("data");
- addLogEntry(traceEventData.registeredTime, traceEventData.message);
- break;
- }
- break;
- default:
- isClaimed = false;
- }
- return isClaimed;
- }
-
- protected void addLogEntry(long timestamp, String message) {
-
- Date date = new Date(timestamp);
-
- MainActivity.consoleLog += formatter.format(date) + " -> " + message + "\n";
- }
-
- @Override
- public String getID() {
-
- return handlerIdentifier;
- }
-
- @Override
- public void onConnectorConnected() {
-
- ethereum.addListener(handlerIdentifier, EnumSet.allOf(EventFlag.class));
- //ethereum.connect(SystemProperties.CONFIG.activePeerIP(), SystemProperties.CONFIG.activePeerPort(), SystemProperties.CONFIG.activePeerNodeid());
- }
-
- @Override
- public void onConnectorDisconnected() {
-
- }
-
-}
diff --git a/app/src/main/java/io/syng/SpashScreen.java b/app/src/main/java/io/syng/SpashScreen.java
deleted file mode 100644
index c4148b2..0000000
--- a/app/src/main/java/io/syng/SpashScreen.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package io.syng;
-
-//import io.syng.util.SystemUiHider;
-
-import android.annotation.TargetApi;
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Handler;
-import android.view.MotionEvent;
-import android.view.View;
-
-
-public class SpashScreen extends Activity {
-
- private final int SPLASH_DISPLAY_LENGTH = 1000;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_spash_screen);
-
- /* New Handler to start the Menu-Activity
- * and close this Splash-Screen after some seconds.*/
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- /* Create an Intent that will start the Menu-Activity. */
- Intent mainIntent = new Intent(SpashScreen.this, MainActivity.class);
- SpashScreen.this.startActivity(mainIntent);
- SpashScreen.this.finish();
- }
- }, SPLASH_DISPLAY_LENGTH);
-
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
-
-
- }
-
-}
diff --git a/app/src/main/java/io/syng/Syng.java b/app/src/main/java/io/syng/Syng.java
deleted file mode 100644
index 871d559..0000000
--- a/app/src/main/java/io/syng/Syng.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package io.syng;
-
-import android.content.res.Configuration;
-
-import io.syng.entities.PreferenceManager;
-
-
-public class Syng extends android.support.multidex.MultiDexApplication {
-
- public PreferenceManager preferenceManager;
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
-
- super.onConfigurationChanged(newConfig);
- }
-
-
- @Override public void onCreate() {
-
- super.onCreate();
- preferenceManager = new PreferenceManager(this);
- }
-
- @Override
- public void onTerminate() {
-
- super.onTerminate();
- preferenceManager.close();
- }
-}
diff --git a/app/src/main/java/io/syng/activity/BaseActivity.java b/app/src/main/java/io/syng/activity/BaseActivity.java
new file mode 100644
index 0000000..66bd8bb
--- /dev/null
+++ b/app/src/main/java/io/syng/activity/BaseActivity.java
@@ -0,0 +1,271 @@
+package io.syng.activity;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v4.view.GravityCompat;
+import android.support.v4.widget.DrawerLayout;
+import android.support.v7.app.ActionBarDrawerToggle;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+import com.bumptech.glide.Glide;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import io.syng.R;
+import io.syng.app.SyngApplication;
+import io.syng.entity.Profile;
+
+public abstract class BaseActivity extends AppCompatActivity implements OnItemClickListener,
+ OnClickListener {
+
+ private static final int DRAWER_CLOSE_DELAY_SHORT = 200;
+ private static final int DRAWER_CLOSE_DELAY_LONG = 400;
+
+ private static final String CONTRIBUTE_LINK = "https://github.com/syng-io";
+
+ private ArrayList mMenuItemsList = new ArrayList<>(Arrays.asList("Console", "DApps",
+ "EtherEx", "TrustDavis", "Augur"));
+
+ private ActionBarDrawerToggle mDrawerToggle;
+
+ private Spinner mAccountSpinner;
+ private EditText mSearchTextView;
+ private ListView mDrawerListView;
+ private DrawerLayout mDrawerLayout;
+
+ private ArrayAdapter mDrawerListAdapter;
+
+ private Handler mHandler = new Handler();
+
+ private Runnable mRunnable = new Runnable() {
+ @Override
+ public void run() {
+ mDrawerLayout.closeDrawer(GravityCompat.START);
+ }
+ };
+
+ protected abstract void onDAppClick(String item);
+
+ @SuppressLint("InflateParams")
+ @Override
+ public void setContentView(final int layoutResID) {
+ LayoutInflater inflater = getLayoutInflater();
+ mDrawerLayout = (DrawerLayout) inflater.inflate(R.layout.drawer, null, false);
+ FrameLayout content = (FrameLayout) mDrawerLayout.findViewById(R.id.content);
+
+ mDrawerListView = (ListView) mDrawerLayout.findViewById(R.id.drawer_list);
+ initDrawer();
+
+ Toolbar toolbar = (Toolbar) inflater.inflate(layoutResID, content, true).findViewById(R.id.myToolbar);
+ if (toolbar != null) {
+ setSupportActionBar(toolbar);
+ }
+
+ mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar,
+ R.string.drawer_open, R.string.drawer_close) {
+ @Override
+ public void onDrawerClosed(View drawerView) {
+ super.onDrawerClosed(drawerView);
+ hideKeyBoard(mSearchTextView);
+ }
+ };
+
+ mDrawerLayout.setDrawerListener(mDrawerToggle);
+
+ mAccountSpinner = (Spinner) mDrawerLayout.findViewById(R.id.nv_email);
+ initSpinner();
+
+ mSearchTextView = (EditText) mDrawerLayout.findViewById(R.id.search);
+ initSearch();
+
+ TextView settingsTextView = (TextView) mDrawerLayout.findViewById(R.id.settings);
+ settingsTextView.setOnClickListener(this);
+
+ TextView profileTextView = (TextView) mDrawerLayout.findViewById(R.id.profile_manager);
+ profileTextView.setOnClickListener(this);
+
+ TextView contributeTextView = (TextView) mDrawerLayout.findViewById(R.id.tv_contribute);
+ contributeTextView.setOnClickListener(this);
+
+ ImageView header = (ImageView) mDrawerLayout.findViewById(R.id.iv_header);
+ Glide.with(this).load(R.drawable.drawer).into(header);
+
+ super.setContentView(mDrawerLayout);
+ }
+
+
+ private void initDrawer() {
+ mDrawerListAdapter = new ArrayAdapter<>(this, R.layout.simple_list_item, new ArrayList<>(mMenuItemsList));
+ mDrawerListView.setAdapter(mDrawerListAdapter);
+ mDrawerListView.setOnItemClickListener(this);
+ }
+
+ private void closeDrawer(int delayMills) {
+ mHandler.postDelayed(mRunnable, delayMills);
+ }
+
+ public void initSpinner() {
+
+ List profilesList = ((SyngApplication) getApplication()).mPreferenceManager.getProfiles();
+ ArrayList spinnerItems = new ArrayList<>();
+ for (Profile profile : profilesList) {
+ 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() {
+ @Override
+ public void onItemSelected(AdapterView> adapterView, View view, int i, long l) {
+ //String item = (String) adapterView.getItemAtPosition(i);
+ if (adapterView != null && adapterView.getChildAt(0) != null) {
+ ((TextView) adapterView.getChildAt(0)).setTextColor(Color.parseColor("#ffffff"));
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> adapterView) {
+ ((TextView) adapterView.getChildAt(0)).setTextColor(Color.parseColor("#ffffff"));
+ }
+
+ });
+ }
+
+ private void initSearch() {
+
+ mSearchTextView.addTextChangedListener(new TextWatcher() {
+
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+ String searchValue = editable.toString();
+ updateAppList(searchValue);
+ }
+ });
+
+ mSearchTextView.setOnKeyListener(new View.OnKeyListener() {
+
+ @Override
+ public boolean onKey(View view, int i, KeyEvent keyEvent) {
+
+ if (keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
+ hideKeyBoard(mSearchTextView);
+ return true;
+ }
+ return false;
+ }
+ });
+ }
+
+ protected void updateAppList(String filter) {
+ mDrawerListAdapter.clear();
+ int length = mMenuItemsList.size();
+ for (int i = 0; i < length; i++) {
+ String item = mMenuItemsList.get(i);
+ if (item.toLowerCase().contains(filter.toLowerCase())) {
+ mDrawerListAdapter.add(item);
+ }
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ return mDrawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ mDrawerToggle.syncState();
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ mDrawerToggle.onConfigurationChanged(newConfig);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mHandler.removeCallbacksAndMessages(null);
+ }
+
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ String item = parent.getItemAtPosition(position).toString();
+ onDAppClick(item);
+ closeDrawer(DRAWER_CLOSE_DELAY_SHORT);
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.tv_contribute:
+ String url = CONTRIBUTE_LINK;
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setData(Uri.parse(url));
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+ break;
+ case R.id.settings:
+ startActivity(new Intent(BaseActivity.this, SettingsActivity.class));
+ break;
+ case R.id.profile_manager:
+ startActivity(new Intent(BaseActivity.this, ProfileManagerActivity.class));
+ break;
+ }
+ closeDrawer(DRAWER_CLOSE_DELAY_LONG);
+
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
+ mDrawerLayout.closeDrawer(GravityCompat.START);
+ } else {
+ super.onBackPressed();
+ }
+ }
+
+ private void hideKeyBoard(View view) {
+ if (view == null)
+ return;
+ InputMethodManager imm = (InputMethodManager)
+ getSystemService(Activity.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
+ }
+
+}
diff --git a/app/src/main/java/io/syng/activity/MainActivity.java b/app/src/main/java/io/syng/activity/MainActivity.java
new file mode 100644
index 0000000..a085f3a
--- /dev/null
+++ b/app/src/main/java/io/syng/activity/MainActivity.java
@@ -0,0 +1,51 @@
+package io.syng.activity;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+
+import io.syng.R;
+import io.syng.fragment.ConsoleFragment;
+import io.syng.fragment.WebViewFragment;
+
+
+public class MainActivity extends BaseActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.activity_main);
+
+ if (savedInstanceState == null) {
+ replaceFragment(new ConsoleFragment());
+ }
+
+ }
+
+ @Override
+ protected void onDAppClick(String item) {
+ switch (item) {
+ case "Console":
+ replaceFragment(new ConsoleFragment());
+ break;
+ case "DApps":
+ replaceFragment(new WebViewFragment());
+ break;
+ case "EtherEx":
+ replaceFragment(new WebViewFragment());
+ break;
+ case "TrustDavis":
+ replaceFragment(new WebViewFragment());
+ break;
+ case "Augur":
+ replaceFragment(new WebViewFragment());
+ break;
+ }
+ }
+
+ private void replaceFragment(Fragment fragment) {
+ getSupportFragmentManager().beginTransaction().
+ replace(R.id.container, fragment).commit();
+ }
+
+}
diff --git a/app/src/main/java/io/syng/ProfileManagerActivity.java b/app/src/main/java/io/syng/activity/ProfileManagerActivity.java
similarity index 69%
rename from app/src/main/java/io/syng/ProfileManagerActivity.java
rename to app/src/main/java/io/syng/activity/ProfileManagerActivity.java
index 086cf53..a2e6cc2 100644
--- a/app/src/main/java/io/syng/ProfileManagerActivity.java
+++ b/app/src/main/java/io/syng/activity/ProfileManagerActivity.java
@@ -1,22 +1,19 @@
-package io.syng;
+package io.syng.activity;
-import android.app.FragmentManager;
import android.net.Uri;
import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
-import io.syng.entities.Profile;
+import io.syng.R;
+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 FragmentManager fragmentManager;
-
private AddProfileFragment addProfileFragment;
private ProfileManagerFragment profileManagerFragment;
@@ -32,21 +29,19 @@ public class ProfileManagerActivity extends BaseActivity implements OnFragmentIn
super.onCreate(savedInstanceState);
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() {
@Override
public void onClick(View view) {
-
Profile profile = addProfileFragment.getProfile();
profileManagerFragment.addProfile(profile);
hideAddProfile();
}
});
- addProfileLink = (TextView)findViewById(R.id.add_profile_link);
+ addProfileLink = (TextView) findViewById(R.id.add_profile_link);
addProfileLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
-
profileManagerFragment.resetProfilePosition();
showAddProfile(null);
}
@@ -55,7 +50,7 @@ public class ProfileManagerActivity extends BaseActivity implements OnFragmentIn
if (savedInstanceState == null) {
addProfileFragment = new AddProfileFragment();
profileManagerFragment = new ProfileManagerFragment();
- getFragmentManager().beginTransaction()
+ getSupportFragmentManager().beginTransaction()
.add(R.id.profileManagerFragmentContainer, profileManagerFragment)
.add(R.id.addProfileFragmentContainer, addProfileFragment)
.commit();
@@ -64,16 +59,15 @@ public class ProfileManagerActivity extends BaseActivity implements OnFragmentIn
addProfileContainer = findViewById(R.id.addProfileFragmentContainer);
profileManagerContainer = findViewById(R.id.profileManagerFragmentContainer);
-
-
hideAddProfile();
}
public void showAddProfile(Profile profile) {
profileManagerContainer.setVisibility(View.INVISIBLE);
- addProfileContainer.setVisibility(View.VISIBLE);
addProfileLink.setVisibility(View.INVISIBLE);
+
+ addProfileContainer.setVisibility(View.VISIBLE);
saveProfileLink.setVisibility(View.VISIBLE);
addProfileFragment.setProfile(profile);
@@ -92,37 +86,17 @@ public class ProfileManagerActivity extends BaseActivity implements OnFragmentIn
}
public void addProfile(Profile profile) {
-
profileManagerFragment.addProfile(profile);
}
@Override
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;
+ protected void onDAppClick(String item) {
+
}
- @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);
- }
-
-
}
diff --git a/app/src/main/java/io/syng/SettingsActivity.java b/app/src/main/java/io/syng/activity/SettingsActivity.java
similarity index 87%
rename from app/src/main/java/io/syng/SettingsActivity.java
rename to app/src/main/java/io/syng/activity/SettingsActivity.java
index ff8461c..0144e85 100644
--- a/app/src/main/java/io/syng/SettingsActivity.java
+++ b/app/src/main/java/io/syng/activity/SettingsActivity.java
@@ -1,25 +1,20 @@
-package io.syng;
+package io.syng.activity;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Configuration;
-import android.media.Ringtone;
-import android.media.RingtoneManager;
-import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
-import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
-import android.preference.RingtonePreference;
-import android.text.TextUtils;
-
import java.util.List;
+import io.syng.R;
+
/**
* A {@link PreferenceActivity} that presents a set of application settings. On
* handset devices, settings are presented as a single list. On tablets,
@@ -31,6 +26,7 @@ import java.util.List;
* href="http://developer.android.com/guide/topics/ui/settings.html">Settings
* API Guide for more information on developing a Settings UI.
*/
+@SuppressWarnings("deprecation")
public class SettingsActivity extends PreferenceActivity {
/**
* Determines whether to always show the simplified settings UI, where
@@ -111,6 +107,7 @@ public class SettingsActivity extends PreferenceActivity {
* doesn't have an extra-large screen. In these cases, a single-pane
* "simplified" settings UI should be shown.
*/
+ @SuppressWarnings({"PointlessBooleanExpression", "ConstantConditions"})
private static boolean isSimplePreferences(Context context) {
return ALWAYS_SIMPLE_PREFS
|| Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
@@ -123,7 +120,6 @@ public class SettingsActivity extends PreferenceActivity {
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onBuildHeaders(List target) {
-
}
/**
@@ -176,22 +172,23 @@ public class SettingsActivity extends PreferenceActivity {
.getString(preference.getKey(), ""));
}
- /**
- * This fragment shows general preferences only. It is used when the
- * activity is showing a two-pane settings UI.
- */
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
- public static class GeneralPreferenceFragment extends PreferenceFragment {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.pref_general);
+// /**
+// * This fragment shows general preferences only. It is used when the
+// * activity is showing a two-pane settings UI.
+// */
+// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+// public static class GeneralPreferenceFragment extends PreferenceFragment {
+// @Override
+// public void onCreate(Bundle savedInstanceState) {
+// super.onCreate(savedInstanceState);
+// addPreferencesFromResource(R.xml.pref_general);
+//
+// // Bind the summaries of EditText/List/Dialog/Ringtone preferences
+// // to their values. When their values change, their summaries are
+// // updated to reflect the new value, per the Android Design
+// // guidelines.
+// bindPreferenceSummaryToValue(findPreference("runningMode"));
+// }
+// }
- // Bind the summaries of EditText/List/Dialog/Ringtone preferences
- // to their values. When their values change, their summaries are
- // updated to reflect the new value, per the Android Design
- // guidelines.
- bindPreferenceSummaryToValue(findPreference("runningMode"));
- }
- }
}
diff --git a/app/src/main/java/io/syng/entities/DappAdapter.java b/app/src/main/java/io/syng/adapter/DappAdapter.java
similarity index 65%
rename from app/src/main/java/io/syng/entities/DappAdapter.java
rename to app/src/main/java/io/syng/adapter/DappAdapter.java
index 79e19b5..09d8911 100644
--- a/app/src/main/java/io/syng/entities/DappAdapter.java
+++ b/app/src/main/java/io/syng/adapter/DappAdapter.java
@@ -1,4 +1,4 @@
-package io.syng.entities;
+package io.syng.adapter;
import android.support.v7.widget.RecyclerView;
@@ -11,13 +11,78 @@ import java.util.ArrayList;
import co.dift.ui.SwipeToAction;
import io.syng.R;
+import io.syng.entity.Dapp;
public class DappAdapter extends RecyclerView.Adapter {
- private ArrayList dataset;
+ private ArrayList mDataSet;
+ public void add(int position, Dapp item) {
+ mDataSet.add(position, item);
+ notifyItemInserted(position);
+ }
- public class DappViewHolder extends SwipeToAction.ViewHolder {
+ 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 getItems() {
+ return mDataSet;
+ }
+
+ public DappAdapter(ArrayList 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 {
public TextView txtHeader;
public TextView txtFooter;
@@ -30,83 +95,4 @@ public class DappAdapter extends RecyclerView.Adapter getItems() {
-
- return (ArrayList)dataset.clone();
- }
-
- public DappAdapter(ArrayList dataset) {
-
- this.dataset = dataset;
- }
-
- @Override
- public DappAdapter.DappViewHolder onCreateViewHolder(ViewGroup parent,
- int viewType) {
-
- // create a new view
- View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.dapp_item, parent, false);
- // set the view's size, margins, paddings and layout parameters
- DappViewHolder vh = new DappViewHolder(v);
- return vh;
- }
-
- // 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 = dataset.get(position);
- DappViewHolder viewHolder = (DappViewHolder) holder;
- viewHolder.data = dapp;
- holder.txtHeader.setText(dataset.get(position).getName());
- holder.txtFooter.setText("Footer: " + dataset.get(position).getName());
-
- }
-
- // Return the size of your dataset (invoked by the layout manager)
- @Override
- public int getItemCount() {
-
- return dataset.size();
- }
-
}
\ No newline at end of file
diff --git a/app/src/main/java/io/syng/entities/ProfileAdapter.java b/app/src/main/java/io/syng/adapter/ProfileAdapter.java
similarity index 71%
rename from app/src/main/java/io/syng/entities/ProfileAdapter.java
rename to app/src/main/java/io/syng/adapter/ProfileAdapter.java
index ddb195c..f9ceaf1 100644
--- a/app/src/main/java/io/syng/entities/ProfileAdapter.java
+++ b/app/src/main/java/io/syng/adapter/ProfileAdapter.java
@@ -1,4 +1,4 @@
-package io.syng.entities;
+package io.syng.adapter;
import android.support.v7.widget.RecyclerView;
@@ -11,75 +11,62 @@ import java.util.ArrayList;
import co.dift.ui.SwipeToAction;
import io.syng.R;
+import io.syng.entity.Profile;
public class ProfileAdapter extends RecyclerView.Adapter {
- private ArrayList dataset;
-
-
- public class ProfileViewHolder extends SwipeToAction.ViewHolder {
-
- 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);
- }
- }
+ private ArrayList mDataSet;
public void add(int position, Profile item) {
- dataset.add(position, item);
+ mDataSet.add(position, item);
notifyItemInserted(position);
}
public void set(int position, Profile item) {
- dataset.set(position, item);
+ mDataSet.set(position, item);
notifyItemChanged(position);
}
public void add(Profile item) {
- dataset.add(item);
- int position = dataset.indexOf(item);
+ mDataSet.add(item);
+ int position = mDataSet.indexOf(item);
notifyItemInserted(position);
}
public void remove(Profile item) {
- int position = dataset.indexOf(item);
- dataset.remove(position);
+ int position = mDataSet.indexOf(item);
+ mDataSet.remove(position);
notifyItemRemoved(position);
}
public void clear() {
- dataset.clear();
+ mDataSet.clear();
notifyDataSetChanged();
}
public int getPosition(Profile item) {
- return dataset.indexOf(item);
+ return mDataSet.indexOf(item);
}
public ArrayList getItems() {
- return (ArrayList)dataset.clone();
+ return (ArrayList) mDataSet.clone();
}
public ProfileAdapter(ArrayList dataset) {
- this.dataset = dataset;
+ this.mDataSet = dataset;
}
@Override
public ProfileAdapter.ProfileViewHolder onCreateViewHolder(ViewGroup parent,
- int viewType) {
+ int viewType) {
// create a new view
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.profile_item, parent, false);
@@ -94,11 +81,11 @@ public class ProfileAdapter extends RecyclerView.Adapter {
+
+ 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);
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/io/syng/app/SyngApplication.java b/app/src/main/java/io/syng/app/SyngApplication.java
new file mode 100644
index 0000000..32e82a8
--- /dev/null
+++ b/app/src/main/java/io/syng/app/SyngApplication.java
@@ -0,0 +1,39 @@
+package io.syng.app;
+
+import android.content.Context;
+import android.support.multidex.MultiDexApplication;
+
+import com.squareup.leakcanary.LeakCanary;
+import com.squareup.leakcanary.RefWatcher;
+
+import io.syng.util.PreferenceManager;
+
+
+public class SyngApplication extends MultiDexApplication {
+
+ public PreferenceManager mPreferenceManager;
+
+ private RefWatcher refWatcher;
+
+ @Override public void onCreate() {
+ super.onCreate();
+ mPreferenceManager = new PreferenceManager(this);
+ refWatcher = LeakCanary.install(this);
+// refWatcher = RefWatcher.DISABLED;
+ }
+
+ @Override
+ public void onTerminate() {
+ super.onTerminate();
+ mPreferenceManager.close();
+ }
+
+
+ public static RefWatcher getRefWatcher(Context context) {
+ SyngApplication application = (SyngApplication) context.getApplicationContext();
+ return application.refWatcher;
+ }
+
+
+
+}
diff --git a/app/src/main/java/io/syng/entities/RunningMode.java b/app/src/main/java/io/syng/entities/RunningMode.java
deleted file mode 100644
index ba67c87..0000000
--- a/app/src/main/java/io/syng/entities/RunningMode.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package io.syng.entities;
-
-
-public class RunningMode {
-
- public static int FULL_CLIENT = 1;
-
- public static int LIGHT_CLIENT = 2;
-
- public static int JSON_RPC_CLIENT = 3;
-}
diff --git a/app/src/main/java/io/syng/entities/Dapp.java b/app/src/main/java/io/syng/entity/Dapp.java
similarity index 95%
rename from app/src/main/java/io/syng/entities/Dapp.java
rename to app/src/main/java/io/syng/entity/Dapp.java
index 6f0fe3d..e9b5ae9 100644
--- a/app/src/main/java/io/syng/entities/Dapp.java
+++ b/app/src/main/java/io/syng/entity/Dapp.java
@@ -1,65 +1,54 @@
-package io.syng.entities;
+package io.syng.entity;
public class Dapp {
protected String name = "";
protected String version = "";
protected String url = "";
-
protected String id;
public Dapp(String id, String name) {
-
this.id = id;
this.name = name;
}
public Dapp(String name) {
-
this.name = name;
}
public Dapp() {
-
}
public String getName() {
-
return name;
}
public void setName(String name) {
-
this.name = name;
}
public String getVersion() {
-
return version;
}
public void setVersion(String version) {
-
this.version = version;
}
public String getUrl() {
-
return url;
}
public void setUrl(String url) {
-
this.url = url;
}
public String getId() {
-
return id;
}
public void setId(String id) {
-
this.id = id;
}
+
}
diff --git a/app/src/main/java/io/syng/entities/JsonRpcServer.java b/app/src/main/java/io/syng/entity/JsonRpcServer.java
similarity index 93%
rename from app/src/main/java/io/syng/entities/JsonRpcServer.java
rename to app/src/main/java/io/syng/entity/JsonRpcServer.java
index fecdec3..132e0a0 100644
--- a/app/src/main/java/io/syng/entities/JsonRpcServer.java
+++ b/app/src/main/java/io/syng/entity/JsonRpcServer.java
@@ -1,36 +1,31 @@
-package io.syng.entities;
+package io.syng.entity;
import java.io.Serializable;
public class JsonRpcServer implements Serializable {
protected String host;
-
protected int port;
private static final long serialVersionUID = 1L;
public JsonRpcServer() {
-
}
public String getHost() {
-
return host;
}
public void setHost(String host) {
-
this.host = host;
}
public int getPort() {
-
return port;
}
public void setPort(int port) {
-
this.port = port;
}
+
}
diff --git a/app/src/main/java/io/syng/entity/LogEntry.java b/app/src/main/java/io/syng/entity/LogEntry.java
new file mode 100644
index 0000000..e24c52a
--- /dev/null
+++ b/app/src/main/java/io/syng/entity/LogEntry.java
@@ -0,0 +1,20 @@
+package io.syng.entity;
+
+public class LogEntry {
+
+ private long timeStamp;
+ private String message;
+
+ public LogEntry(long timeStamp, String message) {
+ this.timeStamp = timeStamp;
+ this.message = message;
+ }
+
+ public long getTimeStamp() {
+ return timeStamp;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
diff --git a/app/src/main/java/io/syng/entities/ObjectSerializer.java b/app/src/main/java/io/syng/entity/ObjectSerializer.java
similarity index 88%
rename from app/src/main/java/io/syng/entities/ObjectSerializer.java
rename to app/src/main/java/io/syng/entity/ObjectSerializer.java
index e3ffa48..b1facca 100644
--- a/app/src/main/java/io/syng/entities/ObjectSerializer.java
+++ b/app/src/main/java/io/syng/entity/ObjectSerializer.java
@@ -1,4 +1,4 @@
-package io.syng.entities;
+package io.syng.entity;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -10,7 +10,6 @@ public class ObjectSerializer {
public static String serialize(Serializable obj) throws Exception {
-
if (obj == null) return "";
try {
ByteArrayOutputStream serialObj = new ByteArrayOutputStream();
@@ -23,8 +22,7 @@ public class ObjectSerializer {
}
}
- public static Object deserialize(String str) throws Exception{
-
+ public static Object deserialize(String str) throws Exception {
if (str == null || str.length() == 0) return null;
try {
ByteArrayInputStream serialObj = new ByteArrayInputStream(decodeBytes(str));
@@ -36,7 +34,6 @@ public class ObjectSerializer {
}
public static String encodeBytes(byte[] bytes) {
-
StringBuffer strBuf = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
strBuf.append((char) (((bytes[i] >> 4) & 0xF) + ((int) 'a')));
@@ -46,13 +43,12 @@ public class ObjectSerializer {
}
public static byte[] decodeBytes(String str) {
-
byte[] bytes = new byte[str.length() / 2];
- for (int i = 0; i < str.length(); i+=2) {
+ for (int i = 0; i < str.length(); i += 2) {
char c = str.charAt(i);
- bytes[i/2] = (byte) ((c - 'a') << 4);
- c = str.charAt(i+1);
- bytes[i/2] += (c - 'a');
+ bytes[i / 2] = (byte) ((c - 'a') << 4);
+ c = str.charAt(i + 1);
+ bytes[i / 2] += (c - 'a');
}
return bytes;
}
diff --git a/app/src/main/java/io/syng/entities/Profile.java b/app/src/main/java/io/syng/entity/Profile.java
similarity index 98%
rename from app/src/main/java/io/syng/entities/Profile.java
rename to app/src/main/java/io/syng/entity/Profile.java
index f5a59e8..14cccf8 100644
--- a/app/src/main/java/io/syng/entities/Profile.java
+++ b/app/src/main/java/io/syng/entity/Profile.java
@@ -1,4 +1,4 @@
-package io.syng.entities;
+package io.syng.entity;
import java.io.Serializable;
import java.util.List;
diff --git a/app/src/main/java/io/syng/entity/RunningMode.java b/app/src/main/java/io/syng/entity/RunningMode.java
new file mode 100644
index 0000000..34fccb6
--- /dev/null
+++ b/app/src/main/java/io/syng/entity/RunningMode.java
@@ -0,0 +1,10 @@
+package io.syng.entity;
+
+
+public final class RunningMode {
+
+ public final static int FULL_CLIENT = 1;
+ public final static int LIGHT_CLIENT = 2;
+ public final static int JSON_RPC_CLIENT = 3;
+
+}
diff --git a/app/src/main/java/io/syng/entities/Settings.java b/app/src/main/java/io/syng/entity/Settings.java
similarity index 98%
rename from app/src/main/java/io/syng/entities/Settings.java
rename to app/src/main/java/io/syng/entity/Settings.java
index 6afa31f..66f1b1c 100644
--- a/app/src/main/java/io/syng/entities/Settings.java
+++ b/app/src/main/java/io/syng/entity/Settings.java
@@ -1,4 +1,4 @@
-package io.syng.entities;
+package io.syng.entity;
import java.io.Serializable;
@@ -25,47 +25,38 @@ public class Settings implements Serializable {
}
public int getRunningMode() {
-
return runningMode;
}
public void setRunningMode(int runningMode) {
-
this.runningMode = runningMode;
}
public boolean getSyncInBackground() {
-
return syncInBackground;
}
public void setSyncInBackground(boolean syncInBackground) {
-
this.syncInBackground = syncInBackground;
}
public boolean getSyncOnlyWhenWifi() {
-
return syncOnlyWhenWifi;
}
public void setSyncOnlyWhenWifi(boolean syncOnlyWhenWifi) {
-
this.syncOnlyWhenWifi = syncOnlyWhenWifi;
}
public List getJsonRpcServers() {
-
return jsonRpcServers;
}
public void setJsonRpcServers(List jsonRpcServers) {
-
this.jsonRpcServers = jsonRpcServers;
}
public void addJsonRpcServer(String host, int port) {
-
JsonRpcServer server = new JsonRpcServer();
server.setHost(host);
server.setPort(port);
@@ -73,12 +64,11 @@ public class Settings implements Serializable {
}
public void addJsonRpcServer(JsonRpcServer jsonRpcServer) {
-
this.jsonRpcServers.add(jsonRpcServer);
}
public void removeJsonRpcServer(JsonRpcServer jsonRpcServer) {
-
this.jsonRpcServers.remove(jsonRpcServer);
}
+
}
diff --git a/app/src/main/java/io/syng/fragment/AddProfileFragment.java b/app/src/main/java/io/syng/fragment/AddProfileFragment.java
new file mode 100644
index 0000000..ddd7daa
--- /dev/null
+++ b/app/src/main/java/io/syng/fragment/AddProfileFragment.java
@@ -0,0 +1,213 @@
+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 android.widget.EditText;
+import android.widget.Switch;
+
+import com.afollestad.materialdialogs.MaterialDialog;
+
+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 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;
+
+ 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 = new Profile();
+ profile.setName(profileName.getText().toString());
+ profile.setPasswordProtectedProfile(profilePasswordProtected.isChecked());
+ List 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);
+
+ 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() {
+ @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;
+ }
+
+}
diff --git a/app/src/main/java/io/syng/fragment/ConsoleFragment.java b/app/src/main/java/io/syng/fragment/ConsoleFragment.java
new file mode 100644
index 0000000..2026a31
--- /dev/null
+++ b/app/src/main/java/io/syng/fragment/ConsoleFragment.java
@@ -0,0 +1,258 @@
+package io.syng.fragment;
+
+
+import android.annotation.SuppressLint;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.support.v4.app.Fragment;
+import android.text.method.ScrollingMovementMethod;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.bumptech.glide.Glide;
+import com.squareup.leakcanary.RefWatcher;
+
+import org.ethereum.android.service.ConnectorHandler;
+import org.ethereum.android.service.EthereumClientMessage;
+import org.ethereum.android.service.EthereumConnector;
+import org.ethereum.android.service.events.BlockEventData;
+import org.ethereum.android.service.events.EventData;
+import org.ethereum.android.service.events.EventFlag;
+import org.ethereum.android.service.events.MessageEventData;
+import org.ethereum.android.service.events.PeerDisconnectEventData;
+import org.ethereum.android.service.events.PendingTransactionsEventData;
+import org.ethereum.android.service.events.TraceEventData;
+import org.ethereum.android.service.events.VMTraceCreatedEventData;
+import org.ethereum.net.p2p.HelloMessage;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.UUID;
+
+import io.syng.R;
+import io.syng.app.SyngApplication;
+import io.syng.entity.LogEntry;
+import io.syng.service.EthereumService;
+
+
+public class ConsoleFragment extends Fragment implements ConnectorHandler {
+
+ private final static int CONSOLE_LENGTH = 10000;
+ private final static int CONSOLE_REFRESH_MILLS = 1000 * 5; //5 sec
+
+ private String mConsoleLog = "";
+
+ private static EthereumConnector sEthereumConnector;
+
+ private TextView mConsoleText;
+
+ private Handler mHandler = new Handler();
+
+ private String mHandlerIdentifier = UUID.randomUUID().toString();
+
+ @SuppressLint("SimpleDateFormat")
+ private DateFormat mDateFormatter = new SimpleDateFormat("HH:mm:ss:SSS");
+
+ private Runnable mRunnable = new Runnable() {
+ @Override
+ public void run() {
+
+ long startTime = System.currentTimeMillis();
+
+ int length = mConsoleLog.length();
+ if (length > CONSOLE_LENGTH) {
+ mConsoleLog = mConsoleLog.substring(CONSOLE_LENGTH * ((length / CONSOLE_LENGTH) - 1) + length % CONSOLE_LENGTH);
+ }
+ mConsoleText.setText(mConsoleLog);
+
+ long stopTime = System.currentTimeMillis();
+ long elapsedTime = stopTime - startTime;
+ Log.d("mRunnable", Long.toString(elapsedTime));
+
+ mHandler.postDelayed(mRunnable, CONSOLE_REFRESH_MILLS);
+ }
+ };
+
+ public ConsoleFragment() {
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_console, container, false);
+
+ mConsoleText = (TextView) view.findViewById(R.id.tv_console_log);
+ mConsoleText.setText(mConsoleLog);
+ mConsoleText.setMovementMethod(new ScrollingMovementMethod());
+
+ ImageView background = (ImageView) view.findViewById(R.id.iv_background);
+ Glide.with(this).load(R.drawable.bg1).into(background);
+
+ ImageView ethereumIcon = (ImageView) view.findViewById(R.id.iv_ethereum_icon);
+ 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_icon).into(ethereumIcon);
+
+ if (sEthereumConnector == null) {
+ sEthereumConnector = new EthereumConnector(getActivity(), EthereumService.class);
+ }
+ return view;
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mHandler.removeCallbacksAndMessages(null);
+ sEthereumConnector.removeHandler(this);
+ sEthereumConnector.removeListener(mHandlerIdentifier);
+ sEthereumConnector.unbindService();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mHandler.post(mRunnable);
+ sEthereumConnector.registerHandler(this);
+ sEthereumConnector.bindService();
+ }
+
+
+ @Override
+ public boolean handleMessage(Message message) {
+ new MyAsyncTask(message).execute();
+ return true;
+ }
+
+ private void addLogEntry(LogEntry logEntry) {
+
+ long startTime = System.currentTimeMillis();
+
+ Date date = new Date(logEntry.getTimeStamp());
+ mConsoleLog += mDateFormatter.format(date) + " -> " + logEntry.getMessage() + "\n";
+
+ long stopTime = System.currentTimeMillis();
+ long elapsedTime = stopTime - startTime;
+ Log.d("addLogEntry", Long.toString(elapsedTime));
+ }
+
+ @Override
+ public String getID() {
+ return mHandlerIdentifier;
+ }
+
+ @Override
+ public void onConnectorConnected() {
+ sEthereumConnector.addListener(mHandlerIdentifier, EnumSet.allOf(EventFlag.class));
+ }
+
+ @Override
+ public void onConnectorDisconnected() {
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ RefWatcher refWatcher = SyngApplication.getRefWatcher(getActivity());
+ refWatcher.watch(this);
+ if (getActivity().isFinishing()) {
+ sEthereumConnector = null;
+ }
+ }
+
+ private LogEntry myHandleMessage(Message message) {
+
+ switch (message.what) {
+ case EthereumClientMessage.MSG_EVENT:
+ Bundle data = message.getData();
+ data.setClassLoader(EventFlag.class.getClassLoader());
+ EventFlag event = (EventFlag) data.getSerializable("event");
+ EventData eventData;
+ MessageEventData messageEventData;
+ switch (event) {
+ case EVENT_BLOCK:
+ BlockEventData blockEventData = data.getParcelable("data");
+// addLogEntry(blockEventData.registeredTime, "Added block with " + blockEventData.receipts.size() + " transaction receipts.");
+ return new LogEntry(blockEventData.registeredTime, "Added block with " + blockEventData.receipts.size() + " transaction receipts.");
+ case EVENT_HANDSHAKE_PEER:
+ messageEventData = data.getParcelable("data");
+// addLogEntry(messageEventData.registeredTime, "Peer " + new HelloMessage(messageEventData.message).getPeerId() + " said hello");
+ return new LogEntry(messageEventData.registeredTime, "Peer " + new HelloMessage(messageEventData.message).getPeerId() + " said hello");
+ case EVENT_NO_CONNECTIONS:
+ eventData = data.getParcelable("data");
+// addLogEntry(eventData.registeredTime, "No connections");
+ return new LogEntry(eventData.registeredTime, "No connections");
+ case EVENT_PEER_DISCONNECT:
+ PeerDisconnectEventData peerDisconnectEventData = data.getParcelable("data");
+// addLogEntry(peerDisconnectEventData.registeredTime, "Peer " + peerDisconnectEventData.host + ":" + peerDisconnectEventData.port + " disconnected.");
+ return new LogEntry(peerDisconnectEventData.registeredTime, "Peer " + peerDisconnectEventData.host + ":" + peerDisconnectEventData.port + " disconnected.");
+ case EVENT_PENDING_TRANSACTIONS_RECEIVED:
+ PendingTransactionsEventData pendingTransactionsEventData = data.getParcelable("data");
+// addLogEntry(pendingTransactionsEventData.registeredTime, "Received " + pendingTransactionsEventData.transactions.size() + " pending transactions");
+ return new LogEntry(pendingTransactionsEventData.registeredTime, "Received " + pendingTransactionsEventData.transactions.size() + " pending transactions");
+ case EVENT_RECEIVE_MESSAGE:
+ messageEventData = data.getParcelable("data");
+// addLogEntry(messageEventData.registeredTime, "Received message: " + messageEventData.messageClass.getName());
+ return new LogEntry(messageEventData.registeredTime, "Received message: " + messageEventData.messageClass.getName());
+ case EVENT_SEND_MESSAGE:
+ messageEventData = data.getParcelable("data");
+// addLogEntry(messageEventData.registeredTime, "Sent message: " + messageEventData.messageClass.getName());
+ return new LogEntry(messageEventData.registeredTime, "Sent message: " + messageEventData.messageClass.getName());
+ case EVENT_SYNC_DONE:
+ eventData = data.getParcelable("data");
+// addLogEntry(eventData.registeredTime, "Sync done");
+ return new LogEntry(eventData.registeredTime, "Sync done");
+ case EVENT_VM_TRACE_CREATED:
+ VMTraceCreatedEventData vmTraceCreatedEventData = data.getParcelable("data");
+// addLogEntry(vmTraceCreatedEventData.registeredTime, "CM trace created: " + vmTraceCreatedEventData.transactionHash + " - " + vmTraceCreatedEventData.trace);
+ return new LogEntry(vmTraceCreatedEventData.registeredTime, "CM trace created: " + vmTraceCreatedEventData.transactionHash + " - " + vmTraceCreatedEventData.trace);
+ case EVENT_TRACE:
+ TraceEventData traceEventData = data.getParcelable("data");
+// addLogEntry(traceEventData.registeredTime, traceEventData.message);
+ return new LogEntry(traceEventData.registeredTime, traceEventData.message);
+ }
+ break;
+ }
+ return null;
+ }
+
+
+ private class MyAsyncTask extends AsyncTask {
+
+ private final Message mMessage;
+
+ public MyAsyncTask(final Message message) {
+ mMessage = Message.obtain(message);
+ }
+
+ @Override
+ protected LogEntry doInBackground(Void... params) {
+
+ long startTime = System.currentTimeMillis();
+
+ LogEntry logEntry = myHandleMessage(mMessage);
+
+ long stopTime = System.currentTimeMillis();
+ long elapsedTime = stopTime - startTime;
+ Log.d("doInBackground", Long.toString(elapsedTime));
+
+ return logEntry;
+ }
+
+ @Override
+ protected void onPostExecute(LogEntry logEntry) {
+ super.onPostExecute(logEntry);
+ if (logEntry != null) {
+ addLogEntry(logEntry);
+ }
+ }
+ }
+
+}
diff --git a/app/src/main/java/io/syng/ProfileManagerFragment.java b/app/src/main/java/io/syng/fragment/ProfileManagerFragment.java
similarity index 88%
rename from app/src/main/java/io/syng/ProfileManagerFragment.java
rename to app/src/main/java/io/syng/fragment/ProfileManagerFragment.java
index 7531b71..59ddfc9 100644
--- a/app/src/main/java/io/syng/ProfileManagerFragment.java
+++ b/app/src/main/java/io/syng/fragment/ProfileManagerFragment.java
@@ -1,21 +1,25 @@
-package io.syng;
+package io.syng.fragment;
import android.app.Activity;
import android.net.Uri;
-import android.app.Fragment;
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 android.widget.ImageButton;
import java.util.ArrayList;
import co.dift.ui.SwipeToAction;
-import io.syng.entities.Profile;
-import io.syng.entities.ProfileAdapter;
+import io.syng.R;
+import io.syng.activity.BaseActivity;
+import io.syng.activity.ProfileManagerActivity;
+import io.syng.adapter.ProfileAdapter;
+import io.syng.app.SyngApplication;
+import io.syng.entity.Profile;
+import io.syng.interfaces.OnFragmentInteractionListener;
/**
@@ -56,14 +60,13 @@ public class ProfileManagerFragment extends Fragment {
}
public void resetProfilePosition() {
-
profileEditPosition = -1;
}
public void updateProfiles() {
BaseActivity activity = (BaseActivity)getActivity();
- ((Syng) activity.getApplication()).preferenceManager.saveProfiles(adapter.getItems());
+ ((SyngApplication) activity.getApplication()).mPreferenceManager.saveProfiles(adapter.getItems());
activity.initSpinner();
}
@@ -91,7 +94,7 @@ public class ProfileManagerFragment extends Fragment {
// specify an adapter (see also next example)
- profiles = ((Syng)getActivity().getApplication()).preferenceManager.getProfiles();
+ profiles = ((SyngApplication)getActivity().getApplication()).mPreferenceManager.getProfiles();
adapter = new ProfileAdapter(profiles);
recyclerView.setAdapter(adapter);
diff --git a/app/src/main/java/io/syng/fragment/WebViewFragment.java b/app/src/main/java/io/syng/fragment/WebViewFragment.java
new file mode 100644
index 0000000..0160dad
--- /dev/null
+++ b/app/src/main/java/io/syng/fragment/WebViewFragment.java
@@ -0,0 +1,59 @@
+package io.syng.fragment;
+
+
+import android.annotation.SuppressLint;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebSettings;
+
+import com.github.ksoichiro.android.observablescrollview.ObservableWebView;
+import com.squareup.leakcanary.RefWatcher;
+
+import io.syng.R;
+import io.syng.app.SyngApplication;
+
+
+public class WebViewFragment extends Fragment {
+
+ private static final String HTTP_TRUSTDAVIS_METEOR_COM = "http://trustdavis.meteor.com";
+
+ public WebViewFragment() {
+ }
+
+ @SuppressLint("SetJavaScriptEnabled")
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_web_view, container, false);
+
+ ObservableWebView webView = (ObservableWebView) view.findViewById(R.id.web_view);
+ WebSettings webSettings = webView.getSettings();
+ webSettings.setJavaScriptEnabled(true);
+ webSettings.setDomStorageEnabled(true);
+//
+//// webView.setWebChromeClient(new WebChromeClient() {
+//// public boolean onConsoleMessage(@NonNull ConsoleMessage cm) {
+////
+//// String output = cm.message() + " -- From line "
+//// + cm.lineNumber() + " of "
+//// + cm.sourceId();
+//// MainActivity.CONSOLE_LOG += output;
+//// Log.d("SyngJs", output);
+//// return true;
+//// }
+//// });
+ webView.loadUrl(HTTP_TRUSTDAVIS_METEOR_COM);
+ return view;
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ RefWatcher refWatcher = SyngApplication.getRefWatcher(getActivity());
+ refWatcher.watch(this);
+ }
+
+}
diff --git a/app/src/main/java/io/syng/OnFragmentInteractionListener.java b/app/src/main/java/io/syng/interfaces/OnFragmentInteractionListener.java
similarity index 88%
rename from app/src/main/java/io/syng/OnFragmentInteractionListener.java
rename to app/src/main/java/io/syng/interfaces/OnFragmentInteractionListener.java
index 9dd5253..72776b6 100644
--- a/app/src/main/java/io/syng/OnFragmentInteractionListener.java
+++ b/app/src/main/java/io/syng/interfaces/OnFragmentInteractionListener.java
@@ -1,4 +1,4 @@
-package io.syng;
+package io.syng.interfaces;
import android.net.Uri;
@@ -15,5 +15,5 @@ import android.net.Uri;
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
- public void onFragmentInteraction(Uri uri);
+ void onFragmentInteraction(Uri uri);
}
diff --git a/app/src/main/java/io/syng/EthereumService.java b/app/src/main/java/io/syng/service/EthereumService.java
similarity index 78%
rename from app/src/main/java/io/syng/EthereumService.java
rename to app/src/main/java/io/syng/service/EthereumService.java
index 2ba2433..b82cc17 100644
--- a/app/src/main/java/io/syng/EthereumService.java
+++ b/app/src/main/java/io/syng/service/EthereumService.java
@@ -1,4 +1,4 @@
-package io.syng;
+package io.syng.service;
import android.content.Intent;
@@ -6,15 +6,9 @@ import org.ethereum.android.service.EthereumRemoteService;
public class EthereumService extends EthereumRemoteService {
- public EthereumService() {
-
- super();
- }
-
-
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
-
return START_STICKY;
}
+
}
diff --git a/app/src/main/java/io/syng/entities/PreferenceManager.java b/app/src/main/java/io/syng/util/PreferenceManager.java
similarity index 60%
rename from app/src/main/java/io/syng/entities/PreferenceManager.java
rename to app/src/main/java/io/syng/util/PreferenceManager.java
index c8d167f..bbde050 100644
--- a/app/src/main/java/io/syng/entities/PreferenceManager.java
+++ b/app/src/main/java/io/syng/util/PreferenceManager.java
@@ -1,40 +1,38 @@
-package io.syng.entities;
+package io.syng.util;
import android.content.Context;
import android.content.SharedPreferences;
-import java.io.IOException;
import java.util.ArrayList;
-import java.util.List;
+
+import io.syng.entity.ObjectSerializer;
+import io.syng.entity.Profile;
public class PreferenceManager {
- private SharedPreferences preferences;
+ private final static String SHARED_PREFERENCES_FILE = "test";
- private static String sharedPreferencesFile = "test";
+ private SharedPreferences mPreferences;
public PreferenceManager(Context context) {
-
- preferences = context.getSharedPreferences(sharedPreferencesFile, Context.MODE_PRIVATE);
+ mPreferences = context.getSharedPreferences(SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
}
public void saveProfiles(ArrayList profiles) {
-
- SharedPreferences.Editor editor = preferences.edit();
+ SharedPreferences.Editor editor = mPreferences.edit();
try {
editor.putString("profiles", ObjectSerializer.serialize(profiles));
} catch (Exception e) {
e.printStackTrace();
}
- editor.commit();
+ editor.apply();
}
public ArrayList getProfiles() {
-
ArrayList profiles = new ArrayList<>();
try {
- profiles = (ArrayList) ObjectSerializer.deserialize(preferences.getString("profiles", ObjectSerializer.serialize(profiles)));
+ profiles = (ArrayList) ObjectSerializer.deserialize(mPreferences.getString("profiles", ObjectSerializer.serialize(profiles)));
} catch (Exception e) {
e.printStackTrace();
}
@@ -42,7 +40,7 @@ public class PreferenceManager {
}
public void close() {
-
- preferences = null;
+ mPreferences = null;
}
+
}
diff --git a/app/src/main/java/io/syng/webview.java b/app/src/main/java/io/syng/webview.java
deleted file mode 100644
index 87afe2d..0000000
--- a/app/src/main/java/io/syng/webview.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package io.syng;
-
-import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.webkit.ConsoleMessage;
-import android.webkit.WebChromeClient;
-import android.webkit.WebSettings;
-import android.webkit.WebView;
-import android.webkit.WebViewClient;
-
-import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
-import com.github.ksoichiro.android.observablescrollview.ObservableWebView;
-import com.github.ksoichiro.android.observablescrollview.ScrollState;
-
-
-public class webview extends BaseActivity implements ObservableScrollViewCallbacks {
-
- ObservableWebView webView;
- int lastTop = 0;
- int previousToLastTop = 0;
- final int hideStep = 20;
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
- setContentView(R.layout.webview);
-
- webView = (ObservableWebView) findViewById(R.id.webView);
- WebSettings webSettings = webView.getSettings();
- webSettings.setJavaScriptEnabled(true);
- webSettings.setDomStorageEnabled(true);
- webView.setWebViewClient(new WebViewClient() {
- public boolean shouldOverrideUrlLoading(WebView view, String url) {
- view.loadUrl(url);
- return false;
- }
- });
- webView.setWebChromeClient(new WebChromeClient() {
- public boolean onConsoleMessage(ConsoleMessage cm) {
-
- String output = cm.message() + " -- From line "
- + cm.lineNumber() + " of "
- + cm.sourceId();
- MainActivity.consoleLog += output;
- Log.d("SyngJs", output);
- return true;
- }
- });
- webView.setScrollViewCallbacks(this);
- webView.loadUrl("http://trustdavis.meteor.com");
- }
-
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
-
- super.onPostCreate(savedInstanceState);
- }
-
-
- @Override
- public void onResume() {
-
- super.onResume();
- }
-
- @Override
- public void onScrollChanged(int i, boolean b, boolean b1) {
-
- }
-
- @Override
- public void onDownMotionEvent() {
-
- }
-
- @Override
- public void onUpOrCancelMotionEvent(ScrollState scrollState) {
-
- if (getSupportActionBar() == null) {
- Log.d("MyTag", "Null");
-
- return;
- }
- if (scrollState == ScrollState.UP) {
-
- if (getSupportActionBar().isShowing()) {
- Log.d("MyTag", "Hide");
- getSupportActionBar().hide();
-
- }
- } else if (scrollState == ScrollState.DOWN) {
- if (!getSupportActionBar().isShowing()) {
- Log.d("MyTag", "Show");
- getSupportActionBar().show();
- }
- }
-
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
-
- getMenuInflater().inflate(R.menu.webview_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- return super.onOptionsItemSelected(item);
- }
-}
diff --git a/app/src/main/res/drawable-hdpi/ic_add_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_add_black_24dp.png
new file mode 100644
index 0000000..c04b523
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_add_black_24dp.png differ
diff --git a/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png
new file mode 100644
index 0000000..694179b
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_add_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_add_black_24dp.png
new file mode 100644
index 0000000..23bf119
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_add_black_24dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png
new file mode 100644
index 0000000..3856041
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_add_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_add_black_24dp.png
new file mode 100644
index 0000000..3191d52
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_add_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png
new file mode 100644
index 0000000..67bb598
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_add_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_add_black_24dp.png
new file mode 100644
index 0000000..a84106b
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_add_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png
new file mode 100644
index 0000000..0fdced8
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_add_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_add_black_24dp.png
new file mode 100644
index 0000000..3cb1092
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_add_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png
new file mode 100644
index 0000000..d64c22e
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png differ
diff --git a/app/src/main/res/drawable/add.png b/app/src/main/res/drawable/add.png
deleted file mode 100644
index dae2e9e..0000000
Binary files a/app/src/main/res/drawable/add.png and /dev/null differ
diff --git a/app/src/main/res/drawable/bg1.jpg b/app/src/main/res/drawable/bg1.jpg
new file mode 100644
index 0000000..bea7212
Binary files /dev/null and b/app/src/main/res/drawable/bg1.jpg differ
diff --git a/app/src/main/res/drawable/ethereum_icon.png b/app/src/main/res/drawable/ethereum_icon.png
new file mode 100644
index 0000000..e35a348
Binary files /dev/null and b/app/src/main/res/drawable/ethereum_icon.png differ
diff --git a/app/src/main/res/drawable/syngeth_text.png b/app/src/main/res/drawable/ethereum_text.png
similarity index 100%
rename from app/src/main/res/drawable/syngeth_text.png
rename to app/src/main/res/drawable/ethereum_text.png
diff --git a/app/src/main/res/layout-v21/activity_profile_manager.xml b/app/src/main/res/layout-v21/activity_profile_manager.xml
deleted file mode 100644
index 24a2ef9..0000000
--- a/app/src/main/res/layout-v21/activity_profile_manager.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout-v21/drawer.xml b/app/src/main/res/layout-v21/drawer.xml
deleted file mode 100644
index 879fefb..0000000
--- a/app/src/main/res/layout-v21/drawer.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout-v21/drawer_contents.xml b/app/src/main/res/layout-v21/drawer_contents.xml
deleted file mode 100644
index 77a64dc..0000000
--- a/app/src/main/res/layout-v21/drawer_contents.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout-v21/fragment_add_profile.xml b/app/src/main/res/layout-v21/fragment_add_profile.xml
deleted file mode 100644
index 51eecf1..0000000
--- a/app/src/main/res/layout-v21/fragment_add_profile.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout-v21/fragment_profile_manager.xml b/app/src/main/res/layout-v21/fragment_profile_manager.xml
deleted file mode 100644
index 678cfa8..0000000
--- a/app/src/main/res/layout-v21/fragment_profile_manager.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
diff --git a/app/src/main/res/layout-v21/main.xml b/app/src/main/res/layout-v21/main.xml
deleted file mode 100644
index 8e512bf..0000000
--- a/app/src/main/res/layout-v21/main.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout-v21/profile_item.xml b/app/src/main/res/layout-v21/profile_item.xml
deleted file mode 100644
index 5bb0be1..0000000
--- a/app/src/main/res/layout-v21/profile_item.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout-v21/webview.xml b/app/src/main/res/layout-v21/webview.xml
deleted file mode 100644
index aad351b..0000000
--- a/app/src/main/res/layout-v21/webview.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..efc0174
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_profile_manager.xml b/app/src/main/res/layout/activity_profile_manager.xml
index 0b54422..761250e 100644
--- a/app/src/main/res/layout/activity_profile_manager.xml
+++ b/app/src/main/res/layout/activity_profile_manager.xml
@@ -1,37 +1,38 @@
-
+ tools:context="io.syng.activity.ProfileManagerActivity">
-
+
+
-
+ android:text="@string/add_profile"
+ android:textColor="@color/accent"/>
+
+
@@ -40,15 +41,17 @@
android:id="@+id/profileManagerFragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="visible"
- android:layout_below="@id/myToolbar">
+ android:layout_below="@id/myToolbar"
+ android:visibility="visible">
+
+ android:layout_below="@id/myToolbar"
+ android:visibility="invisible">
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_spash_screen.xml b/app/src/main/res/layout/activity_spash_screen.xml
index aa01d59..d412adb 100644
--- a/app/src/main/res/layout/activity_spash_screen.xml
+++ b/app/src/main/res/layout/activity_spash_screen.xml
@@ -1,18 +1,16 @@
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ tools:context="io.syng.activity.SplashScreenActivity">
-
-
-
+
diff --git a/app/src/main/res/layout/activity_test.xml b/app/src/main/res/layout/activity_test.xml
deleted file mode 100644
index 144a44b..0000000
--- a/app/src/main/res/layout/activity_test.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
diff --git a/app/src/main/res/layout/app_toolbar.xml b/app/src/main/res/layout/app_toolbar.xml
new file mode 100644
index 0000000..87eb14b
--- /dev/null
+++ b/app/src/main/res/layout/app_toolbar.xml
@@ -0,0 +1,9 @@
+
diff --git a/app/src/main/res/layout/dapp_item.xml b/app/src/main/res/layout/dapp_item.xml
index 806f861..01a7e5b 100644
--- a/app/src/main/res/layout/dapp_item.xml
+++ b/app/src/main/res/layout/dapp_item.xml
@@ -1,13 +1,12 @@
+ android:layout_width="match_parent"
+ android:layout_height="?android:attr/listPreferredItemHeight">
+ android:layout_height="match_parent"
+ android:background="@color/white"
+ android:tag="reveal-right">
+ android:layout_height="match_parent"
+ android:background="@color/red"
+ android:tag="reveal-left">
+ android:src="@drawable/ic_delete_black_24dp"
+ android:tint="@color/icons"/>
+ android:background="@color/primary_dark"
+ android:tag="front">
+ android:src="@drawable/ico_display"/>
+ android:textSize="12sp"/>
+ android:textSize="16sp"/>
diff --git a/app/src/main/res/layout/drawer.xml b/app/src/main/res/layout/drawer.xml
index 879fefb..90ef401 100644
--- a/app/src/main/res/layout/drawer.xml
+++ b/app/src/main/res/layout/drawer.xml
@@ -1,22 +1,23 @@
-
+ android:layout_height="match_parent">
-
-
+
-
+
-
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/drawer_contents.xml b/app/src/main/res/layout/drawer_contents.xml
index 77a64dc..a51bb9c 100644
--- a/app/src/main/res/layout/drawer_contents.xml
+++ b/app/src/main/res/layout/drawer_contents.xml
@@ -1,77 +1,141 @@
-
+ android:background="@android:color/white"
+ android:orientation="vertical">
-
-
-
-
-
+ android:layout_width="wrap_content"
+ android:layout_height="80dp">
+ android:id="@+id/iv_header"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop"/>
-
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp">
+ android:textColor="@android:color/black"
+ android:textColorHint="@android:color/black"
+ android:textSize="16sp"/>
-
+
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ tools:listitem="@layout/simple_list_item">
-
+
+ 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"/>
+ 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="Settings"
+ android:textAllCaps="true"/>
+ android:layout_width="match_parent"
+ android:layout_height="0.2dp"
+ android:layout_marginBottom="8dp"
+ android:layout_marginTop="8dp"
+ android:alpha="0.2"
+ android:background="@android:color/black"/>
-
+ android:id="@+id/tv_contribute"
+ 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="Contribute"
+ android:textAllCaps="true"/>
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_add_profile.xml b/app/src/main/res/layout/fragment_add_profile.xml
index 51eecf1..e9d6e4c 100644
--- a/app/src/main/res/layout/fragment_add_profile.xml
+++ b/app/src/main/res/layout/fragment_add_profile.xml
@@ -1,24 +1,27 @@
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="io.syng.fragment.AddProfileFragment">
+
+
+ android:hint="Name"
+ android:textColor="@color/accent"/>
+
+ android:layout_height="wrap_content"
+ android:text="@string/profile_password_protected"
+ android:textColor="@color/accent"/>
+
+ android:layout_below="@id/profile_settings"
+ android:scrollbars="vertical"/>
diff --git a/app/src/main/res/layout/fragment_console.xml b/app/src/main/res/layout/fragment_console.xml
new file mode 100644
index 0000000..5ddc454
--- /dev/null
+++ b/app/src/main/res/layout/fragment_console.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_profile_manager.xml b/app/src/main/res/layout/fragment_profile_manager.xml
index 678cfa8..97fc08f 100644
--- a/app/src/main/res/layout/fragment_profile_manager.xml
+++ b/app/src/main/res/layout/fragment_profile_manager.xml
@@ -6,7 +6,7 @@
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
- tools:context="io.syng.ProfileManagerFragment">
+ tools:context="io.syng.fragment.ProfileManagerFragment">
+
+
+
+
+
diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml
deleted file mode 100644
index 8e512bf..0000000
--- a/app/src/main/res/layout/main.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/menu.xml b/app/src/main/res/layout/menu.xml
deleted file mode 100644
index dc20c23..0000000
--- a/app/src/main/res/layout/menu.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/settings.xml b/app/src/main/res/layout/settings.xml
deleted file mode 100644
index 36e2c33..0000000
--- a/app/src/main/res/layout/settings.xml
+++ /dev/null
@@ -1,132 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/simple_list_item.xml b/app/src/main/res/layout/simple_list_item.xml
new file mode 100644
index 0000000..fa0c6d2
--- /dev/null
+++ b/app/src/main/res/layout/simple_list_item.xml
@@ -0,0 +1,9 @@
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/spinner_item.xml b/app/src/main/res/layout/spinner_item.xml
deleted file mode 100644
index 21d1b1f..0000000
--- a/app/src/main/res/layout/spinner_item.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/webview.xml b/app/src/main/res/layout/webview.xml
deleted file mode 100644
index aad351b..0000000
--- a/app/src/main/res/layout/webview.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
deleted file mode 100644
index fc90d3a..0000000
--- a/app/src/main/res/menu/menu_main.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
diff --git a/app/src/main/res/menu/menu_profile_manager.xml b/app/src/main/res/menu/menu_profile_manager.xml
deleted file mode 100644
index 2fc2d89..0000000
--- a/app/src/main/res/menu/menu_profile_manager.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
diff --git a/app/src/main/res/menu/menu_test.xml b/app/src/main/res/menu/menu_test.xml
deleted file mode 100644
index 412b782..0000000
--- a/app/src/main/res/menu/menu_test.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
diff --git a/app/src/main/res/menu/webview_menu.xml b/app/src/main/res/menu/webview_menu.xml
index ed03567..cb474b9 100644
--- a/app/src/main/res/menu/webview_menu.xml
+++ b/app/src/main/res/menu/webview_menu.xml
@@ -1,15 +1,14 @@
diff --git a/app/src/main/res/values-v14/styles.xml b/app/src/main/res/values-v14/styles.xml
new file mode 100644
index 0000000..8c92966
--- /dev/null
+++ b/app/src/main/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
index ec372b3..8268bbd 100644
--- a/app/src/main/res/values-v21/styles.xml
+++ b/app/src/main/res/values-v21/styles.xml
@@ -1,19 +1,9 @@
+
-
- -->
- - false
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 673584b..b87522e 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -6,8 +6,8 @@
#fafafa
#161c30
- #ffeeeeee
- #ff303030
+ #e7333333
+ #303030
#fafafa
#66000000
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9c9207e..f567be3 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,18 +1,10 @@
Syng
- Hello world!
- Settings
-
Open Navigation Drawer
Close Navigation Drawer
ProfileManagerActivity
-
- Hello blank fragment
- Test
-
-
Add Profile
Profiles
Save
@@ -26,4 +18,5 @@
Manage Profiles
Syng
+
diff --git a/app/src/main/res/values/style-test.xml b/app/src/main/res/values/style-test.xml
index 3c65f02..621785b 100644
--- a/app/src/main/res/values/style-test.xml
+++ b/app/src/main/res/values/style-test.xml
@@ -1,46 +1,22 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build.gradle b/build.gradle
index c6584d9..bb65c63 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,10 +5,8 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.1.0'
+ classpath 'com.android.tools.build:gradle:1.2.3'
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
}
}
diff --git a/settings.gradle b/settings.gradle
index e0e7542..d3c2853 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,5 +1,3 @@
+include ':app'
include ":ethereumj-core"
-project(':ethereumj-core').projectDir = new File('../ethereumj/ethereumj-core')
include ":ethereumj-core-android"
-project(':ethereumj-core-android').projectDir = new File('../ethereumj/ethereumj-core-android')
-include ':app'
\ No newline at end of file