Changed to RemoteEthereumService.

Added Profiles UI.
Added Settings UI.
This commit is contained in:
Adrian Tiberius 2015-07-27 20:13:49 +02:00
parent b24f4c4717
commit ef0ccc2508
55 changed files with 2685 additions and 379 deletions

View File

@ -87,56 +87,51 @@
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="commons-io-2.4" level="project" /> <orderEntry type="library" exported="" name="commons-io-2.4" level="project" />
<orderEntry type="library" exported="" name="json-io-2.4.1" level="project" />
<orderEntry type="library" exported="" name="jackson-mapper-asl-1.9.13" level="project" />
<orderEntry type="library" exported="" name="floatingactionbutton-1.9.0" level="project" />
<orderEntry type="library" exported="" name="ormlite-android-4.48" level="project" />
<orderEntry type="library" exported="" name="dagger-producers-2.0-beta" level="project" />
<orderEntry type="library" exported="" name="antlr4-4.2.2" level="project" />
<orderEntry type="library" exported="" name="jackson-core-2.5.1" level="project" />
<orderEntry type="library" exported="" name="guava-18.0" level="project" />
<orderEntry type="library" exported="" name="commons-pool-1.5.4" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="jackson-databind-2.5.1" level="project" />
<orderEntry type="library" exported="" name="log4j-1.2.17" level="project" />
<orderEntry type="library" exported="" name="jsonrpc2-base-1.36" level="project" />
<orderEntry type="library" exported="" name="circleimageview-1.3.0" level="project" />
<orderEntry type="library" exported="" name="leveldb-0.7" level="project" />
<orderEntry type="library" exported="" name="dagger-2.1-SNAPSHOT" level="project" /> <orderEntry type="library" exported="" name="dagger-2.1-SNAPSHOT" level="project" />
<orderEntry type="library" exported="" name="json-io-2.4.1" level="project" />
<orderEntry type="library" exported="" name="javassist-3.15.0-GA" level="project" /> <orderEntry type="library" exported="" name="javassist-3.15.0-GA" level="project" />
<orderEntry type="library" exported="" name="commons-dbcp-1.4" level="project" /> <orderEntry type="library" exported="" name="commons-dbcp-1.4" level="project" />
<orderEntry type="library" exported="" name="mapdb-1.0.7" level="project" /> <orderEntry type="library" exported="" name="recyclerview-v7-22.2.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" /> <orderEntry type="library" exported="" name="support-annotations-22.2.1" level="project" />
<orderEntry type="library" exported="" name="floatingactionbutton-1.9.0" level="project" />
<orderEntry type="library" exported="" name="jsr305-3.0.0" level="project" /> <orderEntry type="library" exported="" name="jsr305-3.0.0" level="project" />
<orderEntry type="library" exported="" name="prov-1.51.0.0" level="project" /> <orderEntry type="library" exported="" name="prov-1.51.0.0" level="project" />
<orderEntry type="library" exported="" name="leveldb-api-0.7" level="project" /> <orderEntry type="library" exported="" name="leveldb-api-0.7" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="logback-android-core-1.1.1-3" level="project" /> <orderEntry type="library" exported="" name="logback-android-core-1.1.1-3" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.1" level="project" />
<orderEntry type="library" exported="" name="ormlite-android-4.48" level="project" />
<orderEntry type="library" exported="" name="dagger-producers-2.0-beta" level="project" />
<orderEntry type="library" exported="" name="java-util-1.8.0" level="project" /> <orderEntry type="library" exported="" name="java-util-1.8.0" level="project" />
<orderEntry type="library" exported="" name="jsonrpc2-client-1.15" level="project" />
<orderEntry type="library" exported="" name="javax.annotation-10.0-b28" level="project" /> <orderEntry type="library" exported="" name="javax.annotation-10.0-b28" level="project" />
<orderEntry type="library" exported="" name="json-smart-1.3.1" level="project" /> <orderEntry type="library" exported="" name="json-smart-1.3.1" level="project" />
<orderEntry type="library" exported="" name="antlr-runtime-3.5.2" level="project" />
<orderEntry type="library" exported="" name="jackson-annotations-2.5.0" level="project" /> <orderEntry type="library" exported="" name="jackson-annotations-2.5.0" level="project" />
<orderEntry type="library" exported="" name="core-1.51.0.0" level="project" /> <orderEntry type="library" exported="" name="core-1.51.0.0" level="project" />
<orderEntry type="library" exported="" name="dagger-compiler-2.0" level="project" /> <orderEntry type="library" exported="" name="dagger-compiler-2.0" level="project" />
<orderEntry type="library" exported="" name="commons-collections4-4.0" level="project" /> <orderEntry type="library" exported="" name="commons-collections4-4.0" level="project" />
<orderEntry type="library" exported="" name="antlr-denter-1.1" level="project" /> <orderEntry type="library" exported="" name="guava-18.0" level="project" />
<orderEntry type="library" exported="" name="jackson-core-2.5.1" level="project" />
<orderEntry type="library" exported="" name="netty-all-4.0.28.Final" level="project" /> <orderEntry type="library" exported="" name="netty-all-4.0.28.Final" level="project" />
<orderEntry type="library" exported="" name="jackson-core-asl-1.9.13" level="project" /> <orderEntry type="library" exported="" name="commons-pool-1.5.4" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.1" level="project" />
<orderEntry type="library" exported="" name="android-observablescrollview-1.5.2" level="project" /> <orderEntry type="library" exported="" name="android-observablescrollview-1.5.2" level="project" />
<orderEntry type="library" exported="" name="json-simple-1.1.1" level="project" /> <orderEntry type="library" exported="" name="json-simple-1.1.1" level="project" />
<orderEntry type="library" exported="" name="javax.inject-1" level="project" /> <orderEntry type="library" exported="" name="javax.inject-1" level="project" />
<orderEntry type="library" exported="" name="jackson-databind-2.5.1" level="project" />
<orderEntry type="library" exported="" name="apktool-lib-1.4.4-3" level="project" /> <orderEntry type="library" exported="" name="apktool-lib-1.4.4-3" level="project" />
<orderEntry type="library" exported="" name="jsonrpc2-server-1.11" level="project" />
<orderEntry type="library" exported="" name="ormlite-core-4.48" level="project" /> <orderEntry type="library" exported="" name="ormlite-core-4.48" level="project" />
<orderEntry type="library" exported="" name="ST4-4.0.8" level="project" /> <orderEntry type="library" exported="" name="jsonrpc2-base-1.36" level="project" />
<orderEntry type="library" exported="" name="log4j-1.2.17" level="project" />
<orderEntry type="library" exported="" name="jsonrpc2-server-1.11" level="project" />
<orderEntry type="library" exported="" name="circleimageview-1.3.0" level="project" />
<orderEntry type="library" exported="" name="library-1.1" level="project" />
<orderEntry type="library" exported="" name="multidex-1.0.0" level="project" /> <orderEntry type="library" exported="" name="multidex-1.0.0" level="project" />
<orderEntry type="library" exported="" name="antlr4-annotations-4.2.2" level="project" />
<orderEntry type="library" exported="" name="persistence-api-1.0.2" level="project" /> <orderEntry type="library" exported="" name="persistence-api-1.0.2" level="project" />
<orderEntry type="library" exported="" name="leveldb-0.7" level="project" />
<orderEntry type="library" exported="" name="logback-android-classic-1.1.1-3" level="project" /> <orderEntry type="library" exported="" name="logback-android-classic-1.1.1-3" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-21.0.0" level="project" /> <orderEntry type="library" exported="" name="design-22.2.1" level="project" />
<orderEntry type="library" exported="" name="h2-1.4.187" level="project" />
<orderEntry type="library" exported="" name="slf4j-api-1.7.12" level="project" /> <orderEntry type="library" exported="" name="slf4j-api-1.7.12" level="project" />
<orderEntry type="library" exported="" name="material-dialogs-0.7.7.0" level="project" />
<orderEntry type="module" module-name="ethereumj-core-android" exported="" /> <orderEntry type="module" module-name="ethereumj-core-android" exported="" />
<orderEntry type="module" module-name="ethereumj-core" exported="" /> <orderEntry type="module" module-name="ethereumj-core" exported="" />
</component> </component>

View File

@ -39,10 +39,19 @@ android {
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':ethereumj-core-android') compile(project(':ethereumj-core-android')) {
exclude group: "org.hibernate", module: "hibernate-core"
exclude group: "com.h2database", module: "h2"
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.0'
compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:appcompat-v7:22.2.+'
compile 'com.android.support:recyclerview-v7:22.2.+'
compile 'com.android.support:design:22.2.+'
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.getbase:floatingactionbutton:1.9.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.2' compile 'com.github.ksoichiro:android-observablescrollview:1.5.2'
compile 'com.afollestad:material-dialogs:0.7.7.0'
} }

View File

@ -8,8 +8,9 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application <application
android:name="android.support.multidex.MultiDexApplication" android:name=".Syng"
android:allowBackup="true" android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:largeHeap="true" android:largeHeap="true"
@ -24,16 +25,22 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".webview" /> <activity android:name=".webview" />
<service <service
android:name="io.blockchainsociety.syng.EthereumService" android:name=".EthereumService"
android:enabled="true" android:enabled="true"
android:exported="true" android:exported="true"
android:process=":ethereum_process" > android:process=":ethereum_process" >
<intent-filter>
<action android:name="io.blockchainsociety.syng.EthereumService" />
</intent-filter>
</service> </service>
<activity
android:name=".SettingsActivity"
android:label="@string/title_activity_settings" >
</activity>
<activity
android:name=".ProfileManagerActivity"
android:label="@string/title_activity_profile_manager" >
</activity>
</application> </application>
</manifest> </manifest>

View File

@ -0,0 +1,266 @@
package io.blockchainsociety.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.blockchainsociety.syng.entities.Dapp;
import io.blockchainsociety.syng.entities.DappAdapter;
import io.blockchainsociety.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<Dapp> 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<Dapp> 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<Dapp>() {
@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;
}
}

View File

@ -11,6 +11,7 @@ import android.support.v7.app.AppCompatActivity;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
@ -27,18 +28,23 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import io.blockchainsociety.syng.entities.PreferenceManager;
import io.blockchainsociety.syng.entities.Profile;
public class BaseActivity extends AppCompatActivity { public class BaseActivity extends AppCompatActivity {
Toolbar toolbar; Toolbar toolbar;
public String[] layers;
protected ActionBarDrawerToggle drawerToggle; protected ActionBarDrawerToggle drawerToggle;
ArrayList<String> menuItems = new ArrayList<>(Arrays.asList("Console", "DApps", "EtherEx", "TrustDavis", "Augur")); ArrayList<String> menuItems = new ArrayList<>(Arrays.asList("Console", "DApps", "EtherEx", "TrustDavis", "Augur"));
String[] spinnerItems = {"3WMn9M3uk2CxdGcwp", "L8a9KzyWyfDRnRMCA", "userID3", "userID4"}; protected List<Profile> profiles;
Spinner spinner; Spinner spinner;
EditText search; EditText search;
ListView drawerList; ListView drawerList;
TextView settings;
TextView profileManager;
protected ArrayAdapter<String> drawerListAdapter; protected ArrayAdapter<String> drawerListAdapter;
@Override @Override
@ -50,14 +56,15 @@ public class BaseActivity extends AppCompatActivity {
@Override @Override
public void setContentView(final int layoutResID) { public void setContentView(final int layoutResID) {
DrawerLayout fullLayout = (DrawerLayout) getLayoutInflater().inflate(R.layout.drawer, null); LayoutInflater inflater = getLayoutInflater();
DrawerLayout fullLayout = (DrawerLayout) inflater.inflate(R.layout.drawer, null);
LinearLayout actContent= (LinearLayout) fullLayout.findViewById(R.id.content); LinearLayout actContent= (LinearLayout) fullLayout.findViewById(R.id.content);
DrawerLayout drawerLayout = (DrawerLayout) fullLayout.findViewById(R.id.drawer_layout); DrawerLayout drawerLayout = (DrawerLayout) fullLayout.findViewById(R.id.drawer_layout);
drawerList = (ListView) fullLayout.findViewById(R.id.drawer_list); drawerList = (ListView) drawerLayout.findViewById(R.id.drawer_list);
initDrawer(); initDrawer();
toolbar = (Toolbar) getLayoutInflater().inflate(layoutResID, actContent, true).findViewById(R.id.myToolbar); toolbar = (Toolbar) inflater.inflate(layoutResID, actContent, true).findViewById(R.id.myToolbar);
if (toolbar != null) { if (toolbar != null) {
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
} }
@ -71,6 +78,24 @@ public class BaseActivity extends AppCompatActivity {
search = (EditText) drawerLayout.findViewById(R.id.search); search = (EditText) drawerLayout.findViewById(R.id.search);
initSearch(); 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); super.setContentView(fullLayout);
} }
@ -105,9 +130,14 @@ public class BaseActivity extends AppCompatActivity {
}); });
} }
private void initSpinner() { public void initSpinner() {
spinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, spinnerItems)); profiles = ((Syng)getApplication()).preferenceManager.getProfiles();
ArrayList<String> spinnerItems = new ArrayList<>();
for (Profile profile: profiles) {
spinnerItems.add(profile.getName());
}
spinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, spinnerItems.toArray(new String[spinnerItems.size()])));
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

View File

@ -1,40 +1,20 @@
package io.blockchainsociety.syng; package io.blockchainsociety.syng;
import org.ethereum.android.EthereumAidlService; import android.content.Intent;
import org.ethereum.android.interop.IListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EthereumService extends EthereumAidlService { import org.ethereum.android.service.EthereumRemoteService;
public class EthereumService extends EthereumRemoteService {
private static final Logger logger = LoggerFactory.getLogger("EthereumService");
public EthereumService() { public EthereumService() {
super();
} }
@Override @Override
protected void broadcastMessage(String message) { public int onStartCommand(Intent intent, int flags, int startId) {
//updateLog(message); return START_STICKY;
for (IListener listener: clientListeners) {
try {
listener.trace(message);
} catch (Exception e) {
// Remove listener
clientListeners.remove(listener);
} }
} }
}
private void updateLog(String message) {
EthereumService.log += message;
int logLength = EthereumService.log.length();
if (logLength > 5000) {
EthereumService.log = EthereumService.log.substring(2000);
}
}
}

View File

@ -1,41 +1,43 @@
package io.blockchainsociety.syng; package io.blockchainsociety.syng;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.Color; import android.graphics.Color;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.Message;
import android.os.RemoteException;
import android.text.method.ScrollingMovementMethod; import android.text.method.ScrollingMovementMethod;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import org.ethereum.android.service.ConnectorHandler;
import org.ethereum.android.service.EthereumClientMessage;
import org.ethereum.android.interop.IAsyncCallback; import org.ethereum.android.service.EthereumConnector;
import org.ethereum.android.interop.IEthereumService; import org.ethereum.android.service.events.BlockEventData;
import org.ethereum.android.interop.IListener; 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.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.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.UUID;
public class MainActivity extends BaseActivity { public class MainActivity extends BaseActivity implements ConnectorHandler {
protected static String consoleLog = ""; protected static String consoleLog = "";
/** Ethereum Aidl Service. */
IEthereumService ethereumService = null;
/** Flag indicating whether we have called bind on the service. */
boolean isBound;
TextView consoleText; TextView consoleText;
boolean isPaused = false; boolean isPaused = false;
@ -46,8 +48,13 @@ public class MainActivity extends BaseActivity {
private static int CONSOLE_LENGTH = 10000; private static int CONSOLE_LENGTH = 10000;
private static int CONSOLE_REFRESH = 1000; private static int CONSOLE_REFRESH = 1000;
static EthereumConnector ethereum = null;
protected String handlerIdentifier = UUID.randomUUID().toString();
TextViewUpdater consoleUpdater = new TextViewUpdater(); TextViewUpdater consoleUpdater = new TextViewUpdater();
static DateFormat formatter = new SimpleDateFormat("HH:mm:ss:SSS");
private class TextViewUpdater implements Runnable { private class TextViewUpdater implements Runnable {
private String txt; private String txt;
@ -60,73 +67,6 @@ public class MainActivity extends BaseActivity {
this.txt = txt; this.txt = txt;
} }
}
IAsyncCallback.Stub getLogCallback = new IAsyncCallback.Stub() {
public void handleResponse(String log) throws RemoteException {
MainActivity.consoleLog = log;
logMessage("");
}
};
/**
* Class for interacting with the main interface of the service.
*/
protected ServiceConnection serviceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
// This is called when the connection with the service has been
// established, giving us the service object we can use to
// interact with the service. We are communicating with our
// service through an IDL interface, so get a client-side
// representation of that from the raw service object.
ethereumService = IEthereumService.Stub.asInterface(service);
Toast.makeText(MainActivity.this, "service attached", Toast.LENGTH_SHORT).show();
// We want to monitor the service for as long as we are
// connected to it.
try {
ethereumService.addListener(ethereumListener);
ethereumService.connect(SystemProperties.CONFIG.activePeerIP(),
SystemProperties.CONFIG.activePeerPort(),
SystemProperties.CONFIG.activePeerNodeid());
Toast.makeText(MainActivity.this, "connected to service", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
logMessage("Error adding listener: " + e.getMessage());
}
}
public void onServiceDisconnected(ComponentName className) {
// This is called when the connection with the service has been
// unexpectedly disconnected -- that is, its process crashed.
ethereumService = null;
Toast.makeText(MainActivity.this, "service disconnected", Toast.LENGTH_SHORT).show();
}
};
IListener.Stub ethereumListener = new IListener.Stub() {
public void trace(String message) throws RemoteException {
MainActivity.consoleLog += message + "\n" + "\n";
}
};
protected void logMessage(String message) {
MainActivity.consoleLog += message + "\n";
int consoleLength = MainActivity.consoleLog.length();
if (consoleLength > 5000) {
MainActivity.consoleLog = MainActivity.consoleLog.substring(2000);
}
consoleUpdater.setText(MainActivity.consoleLog);
MainActivity.this.consoleText.post(consoleUpdater);
} }
@Override @Override
@ -144,38 +84,10 @@ public class MainActivity extends BaseActivity {
consoleText = (TextView) findViewById(R.id.console_log); consoleText = (TextView) findViewById(R.id.console_log);
consoleText.setText(MainActivity.consoleLog); consoleText.setText(MainActivity.consoleLog);
consoleText.setMovementMethod(new ScrollingMovementMethod()); consoleText.setMovementMethod(new ScrollingMovementMethod());
ComponentName myService = startService(new Intent(MainActivity.this, EthereumService.class));
doBindService();
}
void doBindService() { if (ethereum == null) {
ethereum = new EthereumConnector(this, EthereumService.class);
// Establish a connection with the service. We use an explicit ethereum.registerHandler(this);
// class name because there is no reason to be able to let other
// applications replace our component.
bindService(new Intent(MainActivity.this, EthereumService.class), serviceConnection, Context.BIND_AUTO_CREATE);
isBound = true;
Toast.makeText(MainActivity.this, "binding to service", Toast.LENGTH_SHORT).show();
}
void doUnbindService() {
if (isBound) {
// If we have received the service, and hence registered with
// it, then now is the time to unregister.
if (ethereumService != null) {
try {
ethereumService.removeListener(ethereumListener);
} catch (RemoteException e) {
// There is nothing special we need to do if the service
// has crashed.
}
}
// Detach our existing connection.
unbindService(serviceConnection);
isBound = false;
Toast.makeText(MainActivity.this, "unbinding from service", Toast.LENGTH_SHORT).show();
} }
} }
@ -185,6 +97,8 @@ public class MainActivity extends BaseActivity {
super.onPause(); super.onPause();
isPaused = true; isPaused = true;
timer.cancel(); timer.cancel();
ethereum.removeListener(handlerIdentifier);
ethereum.unbindService();
} }
@Override @Override
@ -213,13 +127,14 @@ public class MainActivity extends BaseActivity {
} catch (IllegalStateException e){ } catch (IllegalStateException e){
android.util.Log.i("Damn", "resume error"); android.util.Log.i("Damn", "resume error");
} }
ethereum.bindService();
} }
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
doUnbindService(); ethereum.unbindService();
} }
@Override @Override
@ -239,4 +154,90 @@ public class MainActivity extends BaseActivity {
return super.onOptionsItemSelected(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() {
}
} }

View File

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

View File

@ -0,0 +1,128 @@
package io.blockchainsociety.syng;
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.blockchainsociety.syng.entities.Profile;
public class ProfileManagerActivity extends BaseActivity implements OnFragmentInteractionListener {
private FragmentManager fragmentManager;
private AddProfileFragment addProfileFragment;
private ProfileManagerFragment profileManagerFragment;
private TextView saveProfileLink;
private TextView addProfileLink;
private View profileManagerContainer;
private View addProfileContainer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile_manager);
saveProfileLink = (TextView)findViewById(R.id.save_profile_link);
saveProfileLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Profile profile = addProfileFragment.getProfile();
profileManagerFragment.addProfile(profile);
hideAddProfile();
}
});
addProfileLink = (TextView)findViewById(R.id.add_profile_link);
addProfileLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
profileManagerFragment.resetProfilePosition();
showAddProfile(null);
}
});
if (savedInstanceState == null) {
addProfileFragment = new AddProfileFragment();
profileManagerFragment = new ProfileManagerFragment();
getFragmentManager().beginTransaction()
.add(R.id.profileManagerFragmentContainer, profileManagerFragment)
.add(R.id.addProfileFragmentContainer, addProfileFragment)
.commit();
}
addProfileContainer = findViewById(R.id.addProfileFragmentContainer);
profileManagerContainer = findViewById(R.id.profileManagerFragmentContainer);
hideAddProfile();
}
public void showAddProfile(Profile profile) {
profileManagerContainer.setVisibility(View.INVISIBLE);
addProfileContainer.setVisibility(View.VISIBLE);
addProfileLink.setVisibility(View.INVISIBLE);
saveProfileLink.setVisibility(View.VISIBLE);
addProfileFragment.setProfile(profile);
getSupportActionBar().setTitle(R.string.add_profile);
}
public void hideAddProfile() {
addProfileContainer.setVisibility(View.INVISIBLE);
profileManagerContainer.setVisibility(View.VISIBLE);
addProfileLink.setVisibility(View.VISIBLE);
saveProfileLink.setVisibility(View.INVISIBLE);
getSupportActionBar().setTitle(R.string.profile_manager_title);
}
public void addProfile(Profile profile) {
profileManagerFragment.addProfile(profile);
}
@Override
public void onFragmentInteraction(Uri uri) {
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_profile_manager, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}

View File

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

View File

@ -0,0 +1,197 @@
package io.blockchainsociety.syng;
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;
/**
* A {@link PreferenceActivity} that presents a set of application settings. On
* handset devices, settings are presented as a single list. On tablets,
* settings are split by category, with category headers shown to the left of
* the list of settings.
* <p/>
* See <a href="http://developer.android.com/design/patterns/settings.html">
* Android Design: Settings</a> for design guidelines and the <a
* href="http://developer.android.com/guide/topics/ui/settings.html">Settings
* API Guide</a> for more information on developing a Settings UI.
*/
public class SettingsActivity extends PreferenceActivity {
/**
* Determines whether to always show the simplified settings UI, where
* settings are presented in a single list. When false, settings are shown
* as a master/detail two-pane view on tablets. When true, a single pane is
* shown on tablets.
*/
private static final boolean ALWAYS_SIMPLE_PREFS = false;
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
setupSimplePreferencesScreen();
}
/**
* Shows the simplified settings UI if the device configuration if the
* device configuration dictates that a simplified, single-pane UI should be
* shown.
*/
private void setupSimplePreferencesScreen() {
if (!isSimplePreferences(this)) {
return;
}
// In the simplified UI, fragments are not used at all and we instead
// use the older PreferenceActivity APIs.
// Add 'general' preferences.
addPreferencesFromResource(R.xml.pref_general);
bindPreferenceSummaryToValue(findPreference("runningMode"));
/*
// Add 'notifications' preferences, and a corresponding header.
PreferenceCategory fakeHeader = new PreferenceCategory(this);
fakeHeader.setTitle(R.string.pref_header_notifications);
getPreferenceScreen().addPreference(fakeHeader);
addPreferencesFromResource(R.xml.pref_notification);
// Add 'data and sync' preferences, and a corresponding header.
fakeHeader = new PreferenceCategory(this);
fakeHeader.setTitle(R.string.pref_header_data_sync);
getPreferenceScreen().addPreference(fakeHeader);
addPreferencesFromResource(R.xml.pref_data_sync);
// 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("example_text"));
bindPreferenceSummaryToValue(findPreference("example_list"));
bindPreferenceSummaryToValue(findPreference("notifications_new_message_ringtone"));
bindPreferenceSummaryToValue(findPreference("sync_frequency"));
*/
}
/**
* {@inheritDoc}
*/
@Override
public boolean onIsMultiPane() {
return isXLargeTablet(this) && !isSimplePreferences(this);
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* Determines whether the simplified settings UI should be shown. This is
* true if this is forced via {@link #ALWAYS_SIMPLE_PREFS}, or the device
* doesn't have newer APIs like {@link PreferenceFragment}, or the device
* doesn't have an extra-large screen. In these cases, a single-pane
* "simplified" settings UI should be shown.
*/
private static boolean isSimplePreferences(Context context) {
return ALWAYS_SIMPLE_PREFS
|| Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
|| !isXLargeTablet(context);
}
/**
* {@inheritDoc}
*/
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onBuildHeaders(List<Header> target) {
}
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(
index >= 0
? listPreference.getEntries()[index]
: null);
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
return true;
}
};
/**
* Binds a preference's summary to its value. More specifically, when the
* preference's value is changed, its summary (line of text below the
* preference title) is updated to reflect the value. The summary is also
* immediately updated upon calling this method. The exact display format is
* dependent on the type of preference.
*
* @see #sBindPreferenceSummaryToValueListener
*/
private static void bindPreferenceSummaryToValue(Preference preference) {
// Set the listener to watch for value changes.
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
// Trigger the listener immediately with the preference's
// current value.
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.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);
// 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"));
}
}
}

View File

@ -0,0 +1,31 @@
package io.blockchainsociety.syng;
import android.content.res.Configuration;
import io.blockchainsociety.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();
}
}

View File

@ -0,0 +1,65 @@
package io.blockchainsociety.syng.entities;
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;
}
}

View File

@ -0,0 +1,112 @@
package io.blockchainsociety.syng.entities;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import co.dift.ui.SwipeToAction;
import io.blockchainsociety.syng.R;
public class DappAdapter extends RecyclerView.Adapter<DappAdapter.DappViewHolder> {
private ArrayList<Dapp> dataset;
public class DappViewHolder extends SwipeToAction.ViewHolder<Dapp> {
public TextView txtHeader;
public TextView txtFooter;
public DappViewHolder(View v) {
super(v);
txtHeader = (TextView) v.findViewById(R.id.firstLine);
txtFooter = (TextView) v.findViewById(R.id.secondLine);
}
}
public void add(int position, Dapp item) {
dataset.add(position, item);
notifyItemInserted(position);
}
public void set(int position, Dapp item) {
dataset.set(position, item);
notifyItemChanged(position);
}
public void add(Dapp item) {
dataset.add(item);
int position = dataset.indexOf(item);
notifyItemInserted(position);
}
public void remove(Dapp item) {
int position = dataset.indexOf(item);
dataset.remove(position);
notifyItemRemoved(position);
}
public void clear() {
dataset.clear();
notifyDataSetChanged();
}
public int getPosition(Dapp dapp) {
return dataset.indexOf(dapp);
}
public ArrayList<Dapp> getItems() {
return (ArrayList<Dapp>)dataset.clone();
}
public DappAdapter(ArrayList<Dapp> 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();
}
}

View File

@ -0,0 +1,36 @@
package io.blockchainsociety.syng.entities;
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;
}
}

View File

@ -0,0 +1,61 @@
package io.blockchainsociety.syng.entities;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class ObjectSerializer {
public static String serialize(Serializable obj) throws Exception {
if (obj == null) return "";
try {
ByteArrayOutputStream serialObj = new ByteArrayOutputStream();
ObjectOutputStream objStream = new ObjectOutputStream(serialObj);
objStream.writeObject(obj);
objStream.close();
return encodeBytes(serialObj.toByteArray());
} catch (Exception e) {
throw e;
}
}
public static Object deserialize(String str) throws Exception{
if (str == null || str.length() == 0) return null;
try {
ByteArrayInputStream serialObj = new ByteArrayInputStream(decodeBytes(str));
ObjectInputStream objStream = new ObjectInputStream(serialObj);
return objStream.readObject();
} catch (Exception e) {
throw e;
}
}
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')));
strBuf.append((char) (((bytes[i]) & 0xF) + ((int) 'a')));
}
return strBuf.toString();
}
public static byte[] decodeBytes(String str) {
byte[] bytes = new byte[str.length() / 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');
}
return bytes;
}
}

View File

@ -0,0 +1,48 @@
package io.blockchainsociety.syng.entities;
import android.content.Context;
import android.content.SharedPreferences;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class PreferenceManager {
private SharedPreferences preferences;
private static String sharedPreferencesFile = "test";
public PreferenceManager(Context context) {
preferences = context.getSharedPreferences(sharedPreferencesFile, Context.MODE_PRIVATE);
}
public void saveProfiles(ArrayList<Profile> profiles) {
SharedPreferences.Editor editor = preferences.edit();
try {
editor.putString("profiles", ObjectSerializer.serialize(profiles));
} catch (Exception e) {
e.printStackTrace();
}
editor.commit();
}
public ArrayList<Profile> getProfiles() {
ArrayList<Profile> profiles = new ArrayList<>();
try {
profiles = (ArrayList<Profile>) ObjectSerializer.deserialize(preferences.getString("profiles", ObjectSerializer.serialize(profiles)));
} catch (Exception e) {
e.printStackTrace();
}
return profiles;
}
public void close() {
preferences = null;
}
}

View File

@ -0,0 +1,96 @@
package io.blockchainsociety.syng.entities;
import java.io.Serializable;
import java.util.List;
public class Profile implements Serializable {
protected String name;
protected String privateKey;
/* "password protect profile" (encrypt the private keys) */
protected boolean passwordProtectedProfile = false;
protected List<Dapp> dapps;
private static final long serialVersionUID = 1L;
public Profile() {
this.privateKey = "new key";
}
public String getPrivateKey() {
if (passwordProtectedProfile) {
return decryptPrivateKey(privateKey, null);
} else {
return privateKey;
}
}
public void setPrivateKey(String privateKey) {
if (passwordProtectedProfile) {
this.privateKey = encryptPrivateKey(privateKey, null);
} else {
this.privateKey = privateKey;
}
}
public List<Dapp> getDapps() {
return dapps;
}
public void setDapps(List<Dapp> dapps) {
this.dapps = dapps;
}
public void addDapp(Dapp dapp) {
this.dapps.add(dapp);
}
public void removeDapp(Dapp dapp) {
this.dapps.remove(dapp);
}
public boolean getPasswordProtectedProfile() {
return passwordProtectedProfile;
}
public void setPasswordProtectedProfile(boolean passwordProtectedProfile) {
this.passwordProtectedProfile = passwordProtectedProfile;
if (passwordProtectedProfile) {
this.privateKey = encryptPrivateKey(privateKey, null);
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
protected String encryptPrivateKey(String privateKey, String password) {
// TODO: Encrypt private key
return privateKey;
}
protected String decryptPrivateKey(String privateKey, String password) {
// TODO: Decrypt private key
return privateKey;
}
}

View File

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

View File

@ -0,0 +1,11 @@
package io.blockchainsociety.syng.entities;
public class RunningMode {
public static int FULL_CLIENT = 1;
public static int LIGHT_CLIENT = 2;
public static int JSON_RPC_CLIENT = 3;
}

View File

@ -0,0 +1,84 @@
package io.blockchainsociety.syng.entities;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class Settings implements Serializable {
protected int runningMode = RunningMode.JSON_RPC_CLIENT;
/* "sync in background" option */
protected boolean syncInBackground = false;
/* "sync only when connected to wifi" */
protected boolean syncOnlyWhenWifi = true;
/* "setting json-rpc servers (address and port)" */
protected List<JsonRpcServer> jsonRpcServers = new ArrayList<>();
private static final long serialVersionUID = 1L;
public Settings() {
}
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<JsonRpcServer> getJsonRpcServers() {
return jsonRpcServers;
}
public void setJsonRpcServers(List<JsonRpcServer> jsonRpcServers) {
this.jsonRpcServers = jsonRpcServers;
}
public void addJsonRpcServer(String host, int port) {
JsonRpcServer server = new JsonRpcServer();
server.setHost(host);
server.setPort(port);
jsonRpcServers.add(server);
}
public void addJsonRpcServer(JsonRpcServer jsonRpcServer) {
this.jsonRpcServers.add(jsonRpcServer);
}
public void removeJsonRpcServer(JsonRpcServer jsonRpcServer) {
this.jsonRpcServers.remove(jsonRpcServer);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

View File

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

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
<LinearLayout
style="@style/Container320">
<include layout="@layout/drawer_contents" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/addrel"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:id="@+id/drawer_bg"
style="@style/Drawer320">
<TextView
android:id="@+id/nv_name"
style="@style/TextDrawer320" />
<Spinner
android:id="@+id/nv_email"
style="@style/SpinnertDrawer320" />
<ImageView
android:id="@+id/imageView"
style="@style/ViewDrawer320" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/search_ll"
style="@style/Search320">
<EditText
android:id="@+id/search"
android:inputType="text"
style="@style/TextSearch320" />
<ImageView style="@style/ViewSearch320" />
</RelativeLayout>
<ListView
android:id="@+id/drawer_list"
style="@style/List320"
tools:listitem="@android:layout/simple_list_item_1"
android:layout_alignParentEnd="true"
android:layout_width="match_parent"
android:layout_height="250dp">
</ListView>
<RelativeLayout style="@style/BottomLinks320" android:layout_below="@+id/drawer_list"
android:layout_height="wrap_content">
<TextView
android:id="@+id/profileManager"
style="@style/TextBottomLinks320"
android:text="Profile Manager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/settings"
style="@style/TextBottomLinks320"
android:layout_below="@+id/profileManager"
android:text="Settings" />
<View
android:id="@+id/seperator"
style="@style/SeparatorBottomLinks320" />
<TextView
android:id="@+id/help"
style="@style/TextBottomLinks320"
android:layout_below="@+id/seperator"
android:text="Help" />
</RelativeLayout>
</RelativeLayout>

View File

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

View File

@ -0,0 +1,16 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="io.blockchainsociety.syng.ProfileManagerFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/profile_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
</RelativeLayout>

View File

@ -0,0 +1,91 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/ContainerNet"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="io.blockchainsociety.syng.MainActivity">
<RelativeLayout
android:id="@+id/rella_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg">
<TextView
android:id="@+id/console_log"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:alpha="0.8"
android:gravity="bottom"
android:paddingTop="51dp"
android:scrollbarFadeDuration="0"
android:scrollbarSize="25dip"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:text=" "
android:textColor="#ffffff"
android:textSize="12sp" />
<android.support.v7.widget.Toolbar
android:id="@+id/myToolbar"
android:layout_width="match_parent"
android:layout_height="51dp"
android:background="@drawable/fill"
android:theme="@style/MyToolbar">
</android.support.v7.widget.Toolbar>
<ImageButton style="@style/ToolbarButtonWhite" />
<RelativeLayout
android:id="@+id/dynamic_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/myToolbar">
<LinearLayout
android:id="@+id/dynamicContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="60dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="1.3"
android:src="@drawable/etherum_icon" />
<View
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.1" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="0.4"
android:src="@drawable/syngeth_text" />
</LinearLayout>
<com.getbase.floatingactionbutton.FloatingActionButton xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/pink_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="7dp"
android:layout_marginEnd="7dp"
android:layout_marginRight="7dp"
fab:fab_colorNormal="#ffffff"
fab:fab_colorPressed="#e9e9e9"
fab:fab_icon="@drawable/add" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

View File

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

View File

@ -0,0 +1,27 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="io.blockchainsociety.syng.webview">
<android.support.v7.widget.Toolbar
android:id="@+id/myToolbar"
style="@style/ToolbarCointainer"
android:layout_width="fill_parent"
android:background="@color/toolbar"
app:title="Trust Davis">
<ImageButton
style="@style/ToolbarIcon"
android:src="@drawable/fav" />
</android.support.v7.widget.Toolbar>
<com.github.ksoichiro.android.observablescrollview.ObservableWebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/myToolbar" />
</RelativeLayout>

View File

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

View File

@ -0,0 +1,4 @@
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/fragment"
android:name="io.blockchainsociety.syng.TestFragment" tools:layout="@layout/fragment_test"
android:layout_width="match_parent" android:layout_height="match_parent" />

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/primary_dark">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/dapp_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/accent"
android:textColorHint="@color/accent"
android:hint="@string/name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/dapp_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/accent"
android:textColorHint="@color/accent"
android:hint="@string/url" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>

View File

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

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -17,70 +16,7 @@
<LinearLayout <LinearLayout
style="@style/Container320"> style="@style/Container320">
<RelativeLayout <include layout="@layout/drawer_contents" />
android:id="@+id/addrel"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/drawer_bg"
style="@style/Drawer320">
<TextView
android:id="@+id/nv_name"
style="@style/TextDrawer320" />
<Spinner
android:id="@+id/nv_email"
style="@style/SpinnertDrawer320" />
<ImageView
android:id="@+id/imageView"
style="@style/ViewDrawer320" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/search_ll"
style="@style/Search320">
<EditText
android:id="@+id/search"
android:inputType="text"
style="@style/TextSearch320"/>
<ImageView
style="@style/ViewSearch320"/>
</RelativeLayout>
<ListView
android:id="@+id/drawer_list"
style="@style/List320"
tools:listitem="@android:layout/simple_list_item_1">
</ListView>
<RelativeLayout
style="@style/BottomLinks320">
<TextView
android:id="@+id/settings"
style="@style/TextBottomLinks320"
android:text="SETTINGS" />
<View
android:id="@+id/seperator"
style="@style/SeparatorBottomLinks320" />
<TextView
android:id="@+id/help"
style="@style/TextBottomLinks320"
android:layout_below="@+id/seperator"
android:text="HELP" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout> </LinearLayout>
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/addrel"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:id="@+id/drawer_bg"
style="@style/Drawer320">
<TextView
android:id="@+id/nv_name"
style="@style/TextDrawer320" />
<Spinner
android:id="@+id/nv_email"
style="@style/SpinnertDrawer320" />
<ImageView
android:id="@+id/imageView"
style="@style/ViewDrawer320" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/search_ll"
style="@style/Search320">
<EditText
android:id="@+id/search"
android:inputType="text"
style="@style/TextSearch320" />
<ImageView style="@style/ViewSearch320" />
</RelativeLayout>
<ListView
android:id="@+id/drawer_list"
style="@style/List320"
tools:listitem="@android:layout/simple_list_item_1"
android:layout_alignParentEnd="true"
android:layout_width="match_parent"
android:layout_height="250dp">
</ListView>
<RelativeLayout style="@style/BottomLinks320" android:layout_below="@+id/drawer_list"
android:layout_height="wrap_content">
<TextView
android:id="@+id/profileManager"
style="@style/TextBottomLinks320"
android:text="Profile Manager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/settings"
style="@style/TextBottomLinks320"
android:layout_below="@+id/profileManager"
android:text="Settings" />
<View
android:id="@+id/seperator"
style="@style/SeparatorBottomLinks320" />
<TextView
android:id="@+id/help"
style="@style/TextBottomLinks320"
android:layout_below="@+id/seperator"
android:text="Help" />
</RelativeLayout>
</RelativeLayout>

View File

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

View File

@ -0,0 +1,16 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="io.blockchainsociety.syng.ProfileManagerFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/profile_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
</RelativeLayout>

View File

@ -1,39 +1,30 @@
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/NvDrawer" style="@style/ContainerNet"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="io.blockchainsociety.syng.MainActivity"> tools:context="io.blockchainsociety.syng.MainActivity">
<FrameLayout <RelativeLayout
android:id="@+id/MainContent" android:id="@+id/rella_lay"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/bg"> android:background="@drawable/bg">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/ContainerNet">
<RelativeLayout
android:id="@+id/rella_lay"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView <TextView
android:id="@+id/console_log" android:id="@+id/console_log"
android:paddingTop="51dp"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:text=" "
android:alpha="0.8" android:alpha="0.8"
android:textColor="#ffffff"
android:textSize="12sp"
android:gravity="bottom" android:gravity="bottom"
android:scrollbars="vertical" android:paddingTop="51dp"
android:scrollbarStyle="insideOverlay" android:scrollbarFadeDuration="0"
android:scrollbarSize="25dip" android:scrollbarSize="25dip"
android:scrollbarFadeDuration="0"/> android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:text=" "
android:textColor="#ffffff"
android:textSize="12sp" />
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/myToolbar" android:id="@+id/myToolbar"
@ -44,8 +35,7 @@
</android.support.v7.widget.Toolbar> </android.support.v7.widget.Toolbar>
<ImageButton <ImageButton style="@style/ToolbarButtonWhite" />
style="@style/ToolbarButtonWhite" />
<RelativeLayout <RelativeLayout
android:id="@+id/dynamic_content" android:id="@+id/dynamic_content"
@ -99,7 +89,3 @@
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
</FrameLayout>
</android.support.v4.widget.DrawerLayout>

View File

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

View File

@ -43,7 +43,8 @@
<Switch <Switch
style="@style/ListSwitch" style="@style/ListSwitch"
android:text="EthereumJ" /> android:text="Running Mode"
android:layout_height="match_parent" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -55,7 +56,8 @@
<Switch <Switch
style="@style/ListSwitch" style="@style/ListSwitch"
android:text="127.0.0.1:8080" /> android:text="Sync in background"
android:layout_height="match_parent" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -67,7 +69,8 @@
<Switch <Switch
style="@style/ListSwitch" style="@style/ListSwitch"
android:text="Switch on WiFi" /> android:text="Sync only on wifi"
android:layout_height="match_parent" />
</LinearLayout> </LinearLayout>
<View <View
@ -76,7 +79,7 @@
<TextView <TextView
style="@style/ListTitle" style="@style/ListTitle"
android:text="Profile" /> android:text="Servers" />
<LinearLayout <LinearLayout
style="@style/ListItem"> style="@style/ListItem">

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:textColor="#FFFFFF" style="@style/SpinnertDrawer320">
</TextView>

View File

@ -1,23 +1,16 @@
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/NvDrawer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="io.blockchainsociety.syng.webview"> tools:context="io.blockchainsociety.syng.webview">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/myToolbar"
style="@style/ToolbarCointainer" style="@style/ToolbarCointainer"
app:title="Trust Davis"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:background="@color/toolbar" android:background="@color/toolbar"
android:id="@+id/myToolbar"> app:title="Trust Davis">
<ImageButton <ImageButton
style="@style/ToolbarIcon" style="@style/ToolbarIcon"
@ -32,13 +25,3 @@
android:layout_below="@+id/myToolbar" /> android:layout_below="@+id/myToolbar" />
</RelativeLayout> </RelativeLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#eceff1"
android:orientation="vertical">
</LinearLayout>
</android.support.v4.widget.DrawerLayout>

View File

@ -0,0 +1,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="io.blockchainsociety.syng.ProfileManagerActivity">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
</menu>

View File

@ -0,0 +1,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context="io.blockchainsociety.syng.Test">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
</menu>

View File

@ -0,0 +1,19 @@
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/accent</item>
<!--
<item name="android:textColorPrimary">@color/accent</item>
-->
<item name="windowActionBar">false</item>
</style>
</resources>

View File

@ -1,5 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="white">#ffffff</color> <color name="white">#ffffff</color>
<color name="red">#fa0000</color>
<color name="toolbar">#fafafa</color> <color name="toolbar">#fafafa</color>
<color name="icons">#fafafa</color>
<color name="profile">#161c30</color>
<color name="primary">#ffeeeeee</color>
<color name="primary_dark">#ff303030</color>
<color name="accent">#fafafa</color>
</resources> </resources>

View File

@ -6,4 +6,22 @@
<string name="drawer_open">Open Navigation Drawer</string> <string name="drawer_open">Open Navigation Drawer</string>
<string name="drawer_close">Close Navigation Drawer</string> <string name="drawer_close">Close Navigation Drawer</string>
<string name="title_activity_profile_manager">ProfileManagerActivity</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="title_activity_test">Test</string>
<string name="add_profile">Add Profile</string>
<string name="profile_manager_title">Profiles</string>
<string name="profile_save">Save</string>
<string name="profile_password_protected">Password Protected</string>
<string name="dapp_dialog_title">Add Dapp</string>
<string name="name">Name</string>
<string name="url">Url</string>
<string name="save">Save</string>
<string name="cancel">Cancel</string>
<string name="manage_profiles">Manage Profiles</string>
</resources> </resources>

View File

@ -0,0 +1,52 @@
<resources>
<string name="title_activity_settings">Settings</string>
<!-- Strings related to Settings -->
<!-- Example General settings -->
<string name="pref_header_general">General</string>
<string name="pref_title_sync_in_background">Sync in background</string>
<string name="pref_description_sync_in_background">Enable syncing blockchain in background
</string>
<string name="pref_title_sync_only_on_wifi">Sync only on wifi</string>
<string name="pref_description_sync_only_on_wifi">Sync blockchain only on wifi
</string>
<string name="pref_title_display_name">Display name</string>
<string name="pref_default_display_name">John Smith</string>
<string name="pref_title_running_mode">Running Mode</string>
<string-array name="pref_running_modes_titles">
<item>Full Client</item>
<item>Light Client</item>
<item>Json RPC Client</item>
</string-array>
<string-array name="pref_running_modes_values">
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>
<!-- Example settings for Data & Sync -->
<string name="pref_header_data_sync">Data &amp; sync</string>
<string name="pref_title_sync_frequency">Sync frequency</string>
<string-array name="pref_sync_frequency_titles">
<item>15 minutes</item>
<item>30 minutes</item>
<item>1 hour</item>
<item>3 hours</item>
<item>6 hours</item>
<item>Never</item>
</string-array>
<string-array name="pref_sync_frequency_values">
<item>15</item>
<item>30</item>
<item>60</item>
<item>180</item>
<item>360</item>
<item>-1</item>
</string-array>
</resources>

View File

@ -1,7 +1,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <style name="AppTheme1" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
</style> </style>

View File

@ -1,9 +1,15 @@
<resources> <resources>
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme1" parent="Theme.AppCompat.Light.NoActionBar"> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="colorAccent">@color/accent</item>
<item name="actionBarStyle">@style/MyToolbar</item>
</style> </style>
<style name="MyTheme" parent="Theme.AppCompat"> <style name="MyTheme" parent="Theme.AppCompat">

View File

@ -0,0 +1,24 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference
android:key="runningMode"
android:title="@string/pref_title_running_mode"
android:defaultValue="3"
android:entries="@array/pref_running_modes_titles"
android:entryValues="@array/pref_running_modes_values"
android:negativeButtonText="@null"
android:positiveButtonText="@null" />
<CheckBoxPreference
android:key="syncInBackground"
android:title="@string/pref_title_sync_in_background"
android:summary="@string/pref_description_sync_in_background"
android:defaultValue="true" />
<CheckBoxPreference
android:key="syncOnlyWhenWifi"
android:title="@string/pref_title_sync_only_on_wifi"
android:summary="@string/pref_description_sync_only_on_wifi"
android:defaultValue="true" />
</PreferenceScreen>