From a52b4e8dedd5f8a0a0537b56235ddf98272674c9 Mon Sep 17 00:00:00 2001 From: Yaroslav Berezanskyi Date: Wed, 19 Aug 2015 18:24:29 +0300 Subject: [PATCH] All Dialogs code from BaseActivity moved to GeneralUtil --- app/src/main/AndroidManifest.xml | 39 ++- .../java/io/syng/activity/BaseActivity.java | 220 +---------------- .../java/io/syng/activity/LoginActivity.java | 16 ++ .../main/java/io/syng/util/GeneralUtil.java | 230 ++++++++++++++++++ .../java/io/syng/util/ProfileManager.java | 12 + app/src/main/res/layout/activity_login.xml | 12 + app/src/main/res/values/strings.xml | 4 + 7 files changed, 301 insertions(+), 232 deletions(-) create mode 100644 app/src/main/java/io/syng/activity/LoginActivity.java create mode 100644 app/src/main/res/layout/activity_login.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d9a978f..f5b1ad7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,25 +1,19 @@ - + - - - - - + android:theme="@style/AppTheme" > - - + + + android:launchMode="singleTop" + android:windowSoftInputMode="adjustNothing" > - + - + + + - + tools:ignore="UnusedAttribute" > + android:value=".activity.MainActivity" /> + android:process=":ethereum_process" /> + + diff --git a/app/src/main/java/io/syng/activity/BaseActivity.java b/app/src/main/java/io/syng/activity/BaseActivity.java index f2a0c2a..52532f8 100644 --- a/app/src/main/java/io/syng/activity/BaseActivity.java +++ b/app/src/main/java/io/syng/activity/BaseActivity.java @@ -15,9 +15,7 @@ import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.text.Editable; -import android.text.TextUtils; import android.text.TextWatcher; -import android.util.Patterns; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MenuItem; @@ -25,30 +23,19 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.view.ViewGroup; -import android.widget.CheckBox; import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.RadioButton; import android.widget.TextView; import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; import com.bumptech.glide.Glide; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.FileInputStream; -import java.nio.MappedByteBuffer; -import java.nio.channels.FileChannel; -import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; import io.syng.R; -import io.syng.adapter.BackgroundArrayAdapter; import io.syng.adapter.DAppDrawerAdapter; import io.syng.adapter.DAppDrawerAdapter.OnDAppClickListener; import io.syng.adapter.ProfileDrawerAdapter; @@ -57,7 +44,6 @@ import io.syng.entity.Dapp; import io.syng.entity.Profile; import io.syng.fragment.profile.ProfileDialogFragment; import io.syng.util.GeneralUtil; -import io.syng.util.PrefsUtil; import io.syng.util.ProfileManager; import io.syng.util.ProfileManager.ProfilesChangeListener; @@ -66,7 +52,7 @@ import static android.view.View.VISIBLE; public abstract class BaseActivity extends AppCompatActivity implements OnClickListener, OnDAppClickListener, OnProfileClickListener, OnLongClickListener, ProfilesChangeListener { - private static final Logger logger = LoggerFactory.getLogger("SyngApplication"); +// private static final Logger logger = LoggerFactory.getLogger("SyngApplication"); private static final int DRAWER_CLOSE_DELAY_SHORT = 200; private static final int DRAWER_CLOSE_DELAY_LONG = 400; @@ -156,8 +142,7 @@ public abstract class BaseActivity extends AppCompatActivity implements populateDApps(); mHeaderImageView = (ImageView) findViewById(R.id.iv_header); - String currentProfileId = ProfileManager.getCurrentProfile().getId(); - Glide.with(this).load(PrefsUtil.getBackgroundResourceId(currentProfileId)).into(mHeaderImageView); + Glide.with(this).load(ProfileManager.getCurrentProfileBackgroundResourceId()).into(mHeaderImageView); GeneralUtil.showWarningDialogIfNeed(this); ProfileManager.setProfilesChangeListener(this); @@ -301,55 +286,7 @@ public abstract class BaseActivity extends AppCompatActivity implements } @SuppressWarnings("ConstantConditions") - private void showProfileCreateDialog() { - MaterialDialog dialog = new MaterialDialog.Builder(this) - .title("New profile") - .positiveText(R.string.dialog_button_create) - .negativeText(R.string.dialog_button_cancel) - .customView(R.layout.profile_create_dialog, true) - .autoDismiss(false) - .callback(new MaterialDialog.ButtonCallback() { - @Override - public void onPositive(MaterialDialog dialog) { - EditText name = (EditText) dialog.findViewById(R.id.et_profile_name); - EditText pass1 = (EditText) dialog.findViewById(R.id.et_profile_pass_1); - EditText pass2 = (EditText) dialog.findViewById(R.id.et_profile_pass_2); - String nameString = name.getText().toString(); - String pass1String = pass1.getText().toString(); - String pass2String = pass2.getText().toString(); - - if (TextUtils.isEmpty(nameString)) { - Toast.makeText(BaseActivity.this, "Profile name can't be empty", Toast.LENGTH_SHORT).show(); - return; - } - if (TextUtils.isEmpty(pass1String) || TextUtils.isEmpty(pass2String)) { - Toast.makeText(BaseActivity.this, "Password name can't be empty", Toast.LENGTH_SHORT).show(); - return; - } - - if (!pass1.getText().toString().equals(pass2.getText().toString())) { - Toast.makeText(BaseActivity.this, "Passwords should be the same!", Toast.LENGTH_SHORT).show(); - } else { - Profile profile = new Profile(); - profile.setName(name.getText().toString()); - profile.setPassword(pass1String); - ProfileManager.addProfile(profile); - GeneralUtil.hideKeyBoard(name, BaseActivity.this); - GeneralUtil.hideKeyBoard(pass1, BaseActivity.this); - GeneralUtil.hideKeyBoard(pass2, BaseActivity.this); - dialog.dismiss(); - } - } - - @Override - public void onNegative(MaterialDialog dialog) { - dialog.dismiss(); - } - }).show(); - EditText name = (EditText) dialog.findViewById(R.id.et_profile_name); - GeneralUtil.showKeyBoard(name, this); - } private void flipDrawer() { ImageView imageView = (ImageView) findViewById(R.id.drawer_indicator); @@ -393,105 +330,12 @@ public abstract class BaseActivity extends AppCompatActivity implements @Override public void onProfileImport() { - new MaterialDialog.Builder(this) - .title(R.string.wallet_title) - .customView(R.layout.wallet_import, true) - .positiveText(R.string.sImport) - .negativeText(R.string.cancel) - .callback(new MaterialDialog.ButtonCallback() { - @Override - public void onPositive(MaterialDialog dialog) { - RadioButton importJsonRadio = (RadioButton) dialog.findViewById(R.id.radio_import_json); - EditText importPathEdit = (EditText) dialog.findViewById(R.id.wallet_import_path); - EditText walletPasswordEdit = (EditText) dialog.findViewById(R.id.wallet_password); - String importPath = importPathEdit.getText().toString(); - String password = walletPasswordEdit.getText().toString(); - String fileContents = null; - try { - File walletFile = new File(importPath); - if (walletFile.exists()) { - FileInputStream stream = new FileInputStream(walletFile); - try { - FileChannel fileChannel = stream.getChannel(); - MappedByteBuffer buffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileChannel.size()); - fileContents = Charset.defaultCharset().decode(buffer).toString(); - } finally { - stream.close(); - } - } else { - Toast.makeText(BaseActivity.this, R.string.file_not_found, Toast.LENGTH_SHORT).show(); - logger.warn("Wallet file not found: " + importPath); - return; - } - } catch (Exception e) { - Toast.makeText(BaseActivity.this, R.string.error_reading_file, Toast.LENGTH_SHORT).show(); - logger.error("Error reading wallet file", e); - } - if (importJsonRadio.isChecked()) { - Profile profile = ProfileManager.getCurrentProfile(); - if (profile.importWallet(fileContents, password)) { - ProfileManager.updateProfile(profile); - ProfileManager.setCurrentProfile(profile); - } else { - Toast.makeText(BaseActivity.this, R.string.invalid_wallet_password, Toast.LENGTH_SHORT).show(); - } - } else { - Profile profile = ProfileManager.getCurrentProfile(); - profile.importPrivateKey(fileContents, password); - ProfileManager.updateProfile(profile); - } - } - - @Override - public void onNegative(MaterialDialog dialog) { - dialog.hide(); - } - }) - .build().show(); + GeneralUtil.showProfileImportDialog(this); } @Override public void onDAppPress(final Dapp dapp) { - MaterialDialog dialog = new MaterialDialog.Builder(this) - .title("Edit") - .customView(R.layout.dapp_form, true) - .positiveText(R.string.save) - .negativeText(R.string.cancel) - .callback(new MaterialDialog.ButtonCallback() { - @Override - public void onPositive(MaterialDialog dialog) { - EditText dappNameEdit = (EditText) dialog.findViewById(R.id.dapp_name); - EditText dappUrlEdit = (EditText) dialog.findViewById(R.id.dapp_url); - CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.dapp_home_icon); - boolean homeScreenIcon = checkBox.isChecked(); - String url = dappUrlEdit.getText().toString(); - String name = dappNameEdit.getText().toString(); - if (Patterns.WEB_URL.matcher(url.replace("dapp://", "http://")).matches()) { - dapp.setName(name); - dapp.setUrl(url); - System.out.println(url); - ProfileManager.updateDAppInProfile(ProfileManager.getCurrentProfile(), dapp); - if (homeScreenIcon) { - GeneralUtil.createHomeScreenIcon(BaseActivity.this, name, url); - } - dialog.hide(); - } else { - Toast.makeText(BaseActivity.this, R.string.invalid_url, Toast.LENGTH_SHORT).show(); - } - } - - @Override - public void onNegative(MaterialDialog dialog) { - dialog.hide(); - } - }) - .autoDismiss(false) - .build(); - EditText dappNameEdit = (EditText) dialog.findViewById(R.id.dapp_name); - dappNameEdit.setText(dapp.getName()); - EditText dappUrlEdit = (EditText) dialog.findViewById(R.id.dapp_url); - dappUrlEdit.setText(dapp.getUrl()); - dialog.show(); + GeneralUtil.showDAppEditDialog(dapp, this); } @SuppressWarnings("ConstantConditions") @@ -503,42 +347,7 @@ public abstract class BaseActivity extends AppCompatActivity implements @Override public void onDAppAdd() { - Dialog dialog = new MaterialDialog.Builder(this) - .title("Add new DApp") - .customView(R.layout.dapp_form, true) - .positiveText(R.string.save) - .negativeText(R.string.cancel) - .callback(new MaterialDialog.ButtonCallback() { - @Override - public void onPositive(MaterialDialog dialog) { - EditText dappNameEdit = (EditText) dialog.findViewById(R.id.dapp_name); - EditText dappUrlEdit = (EditText) dialog.findViewById(R.id.dapp_url); - CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.dapp_home_icon); - boolean homeScreenIcon = checkBox.isChecked(); - String url = dappUrlEdit.getText().toString(); - String name = dappNameEdit.getText().toString(); - if (Patterns.WEB_URL.matcher(url.replace("dapp://", "http://")).matches()) { - Dapp dapp = new Dapp(name); - dapp.setUrl(url); - ProfileManager.addDAppToProfile(ProfileManager.getCurrentProfile(), dapp); - if (homeScreenIcon) { - GeneralUtil.createHomeScreenIcon(BaseActivity.this, name, url); - } - dialog.hide(); - } else { - Toast.makeText(BaseActivity.this, R.string.invalid_url, Toast.LENGTH_SHORT).show(); - } - } - - @Override - public void onNegative(MaterialDialog dialog) { - dialog.hide(); - } - }) - .autoDismiss(false) - .show(); - EditText dappNameEdit = (EditText) dialog.findViewById(R.id.dapp_name); - GeneralUtil.showKeyBoard(dappNameEdit, this); + GeneralUtil.showDAppCreateDialog(this); } @Override @@ -555,26 +364,13 @@ public abstract class BaseActivity extends AppCompatActivity implements @Override public void onNewProfile() { - showProfileCreateDialog(); + GeneralUtil.showProfileCreateDialog(this); } @Override public boolean onLongClick(View v) { if (v.getId() == R.id.drawer_header_item) { - new MaterialDialog.Builder(this) - .adapter(new BackgroundArrayAdapter(this), - new MaterialDialog.ListCallback() { - @SuppressWarnings("ConstantConditions") - @Override - public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) { - BackgroundArrayAdapter adapter = (BackgroundArrayAdapter) dialog.getListView().getAdapter(); - int imageResourceId = adapter.getImageResourceIdByPosition(which); - Glide.with(BaseActivity.this).load(imageResourceId).into(mHeaderImageView); - PrefsUtil.setBackgroundResourceId(ProfileManager.getCurrentProfile().getId(), imageResourceId); - dialog.dismiss(); - } - }) - .show(); + GeneralUtil.showHeaderBackgroundDialog(this); } return true; } @@ -584,7 +380,7 @@ public abstract class BaseActivity extends AppCompatActivity implements updateCurrentProfileName(); populateDApps(); populateProfiles(); - Glide.with(this).load(PrefsUtil.getBackgroundResourceId(ProfileManager.getCurrentProfile().getId())).into(mHeaderImageView); + Glide.with(this).load(ProfileManager.getCurrentProfileBackgroundResourceId()).into(mHeaderImageView); } } \ No newline at end of file diff --git a/app/src/main/java/io/syng/activity/LoginActivity.java b/app/src/main/java/io/syng/activity/LoginActivity.java new file mode 100644 index 0000000..8013b3d --- /dev/null +++ b/app/src/main/java/io/syng/activity/LoginActivity.java @@ -0,0 +1,16 @@ +package io.syng.activity; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; + +import io.syng.R; + +public class LoginActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_login); + } + +} diff --git a/app/src/main/java/io/syng/util/GeneralUtil.java b/app/src/main/java/io/syng/util/GeneralUtil.java index 52615f2..09af9f4 100644 --- a/app/src/main/java/io/syng/util/GeneralUtil.java +++ b/app/src/main/java/io/syng/util/GeneralUtil.java @@ -1,16 +1,36 @@ package io.syng.util; import android.app.Activity; +import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; +import android.text.TextUtils; +import android.util.Patterns; import android.view.View; import android.view.inputmethod.InputMethodManager; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.RadioButton; +import android.widget.Toast; import com.afollestad.materialdialogs.AlertDialogWrapper; +import com.afollestad.materialdialogs.MaterialDialog; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.FileInputStream; +import java.nio.MappedByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.charset.Charset; import io.syng.R; +import io.syng.adapter.BackgroundArrayAdapter; +import io.syng.entity.Dapp; +import io.syng.entity.Profile; public final class GeneralUtil { @@ -58,4 +78,214 @@ public final class GeneralUtil { }).show(); } } + + public static void showProfileCreateDialog(final Context context) { + MaterialDialog dialog = new MaterialDialog.Builder(context) + .title("New profile") + .positiveText(R.string.dialog_button_create) + .negativeText(R.string.dialog_button_cancel) + .customView(R.layout.profile_create_dialog, true) + .autoDismiss(false) + .callback(new MaterialDialog.ButtonCallback() { + @Override + public void onPositive(MaterialDialog dialog) { + EditText name = (EditText) dialog.findViewById(R.id.et_profile_name); + EditText pass1 = (EditText) dialog.findViewById(R.id.et_profile_pass_1); + EditText pass2 = (EditText) dialog.findViewById(R.id.et_profile_pass_2); + + String nameString = name.getText().toString(); + String pass1String = pass1.getText().toString(); + String pass2String = pass2.getText().toString(); + + if (TextUtils.isEmpty(nameString)) { + Toast.makeText(context, "Profile name can't be empty", Toast.LENGTH_SHORT).show(); + return; + } + if (TextUtils.isEmpty(pass1String) || TextUtils.isEmpty(pass2String)) { + Toast.makeText(context, "Password name can't be empty", Toast.LENGTH_SHORT).show(); + return; + } + + if (!pass1.getText().toString().equals(pass2.getText().toString())) { + Toast.makeText(context, "Passwords should be the same!", Toast.LENGTH_SHORT).show(); + } else { + Profile profile = new Profile(); + profile.setName(name.getText().toString()); + profile.setPassword(pass1String); + ProfileManager.addProfile(profile); + GeneralUtil.hideKeyBoard(name, context); + GeneralUtil.hideKeyBoard(pass1, context); + GeneralUtil.hideKeyBoard(pass2, context); + dialog.dismiss(); + } + } + + @Override + public void onNegative(MaterialDialog dialog) { + dialog.dismiss(); + } + }).show(); + EditText name = (EditText) dialog.findViewById(R.id.et_profile_name); + GeneralUtil.showKeyBoard(name, context); + } + + public static void showDAppEditDialog(final Dapp dapp, final Context context) { + MaterialDialog dialog = new MaterialDialog.Builder(context) + .title("Edit") + .customView(R.layout.dapp_form, true) + .positiveText(R.string.save) + .negativeText(R.string.cancel) + .callback(new MaterialDialog.ButtonCallback() { + @Override + public void onPositive(MaterialDialog dialog) { + EditText dappNameEdit = (EditText) dialog.findViewById(R.id.dapp_name); + EditText dappUrlEdit = (EditText) dialog.findViewById(R.id.dapp_url); + CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.dapp_home_icon); + boolean homeScreenIcon = checkBox.isChecked(); + String url = dappUrlEdit.getText().toString(); + String name = dappNameEdit.getText().toString(); + if (Patterns.WEB_URL.matcher(url.replace("dapp://", "http://")).matches()) { + dapp.setName(name); + dapp.setUrl(url); + System.out.println(url); + ProfileManager.updateDAppInProfile(ProfileManager.getCurrentProfile(), dapp); + if (homeScreenIcon) { + GeneralUtil.createHomeScreenIcon(context, name, url); + } + dialog.hide(); + } else { + Toast.makeText(context, R.string.invalid_url, Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onNegative(MaterialDialog dialog) { + dialog.hide(); + } + }) + .autoDismiss(false) + .build(); + EditText dappNameEdit = (EditText) dialog.findViewById(R.id.dapp_name); + dappNameEdit.setText(dapp.getName()); + EditText dappUrlEdit = (EditText) dialog.findViewById(R.id.dapp_url); + dappUrlEdit.setText(dapp.getUrl()); + dialog.show(); + } + + public static void showDAppCreateDialog(final Context context) { + Dialog dialog = new MaterialDialog.Builder(context) + .title("Add new DApp") + .customView(R.layout.dapp_form, true) + .positiveText(R.string.save) + .negativeText(R.string.cancel) + .callback(new MaterialDialog.ButtonCallback() { + @Override + public void onPositive(MaterialDialog dialog) { + EditText dappNameEdit = (EditText) dialog.findViewById(R.id.dapp_name); + EditText dappUrlEdit = (EditText) dialog.findViewById(R.id.dapp_url); + CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.dapp_home_icon); + boolean homeScreenIcon = checkBox.isChecked(); + String url = dappUrlEdit.getText().toString(); + String name = dappNameEdit.getText().toString(); + if (Patterns.WEB_URL.matcher(url.replace("dapp://", "http://")).matches()) { + Dapp dapp = new Dapp(name); + dapp.setUrl(url); + ProfileManager.addDAppToProfile(ProfileManager.getCurrentProfile(), dapp); + if (homeScreenIcon) { + GeneralUtil.createHomeScreenIcon(context, name, url); + } + dialog.hide(); + } else { + Toast.makeText(context, R.string.invalid_url, Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onNegative(MaterialDialog dialog) { + dialog.hide(); + } + }) + .autoDismiss(false) + .show(); + EditText dappNameEdit = (EditText) dialog.findViewById(R.id.dapp_name); + GeneralUtil.showKeyBoard(dappNameEdit, context); + } + + public static void showProfileImportDialog(final Context context) { + new MaterialDialog.Builder(context) + .title(R.string.wallet_title) + .customView(R.layout.wallet_import, true) + .positiveText(R.string.sImport) + .negativeText(R.string.cancel) + .callback(new MaterialDialog.ButtonCallback() { + @Override + public void onPositive(MaterialDialog dialog) { + + Logger logger = LoggerFactory.getLogger("SyngApplication"); + + RadioButton importJsonRadio = (RadioButton) dialog.findViewById(R.id.radio_import_json); + EditText importPathEdit = (EditText) dialog.findViewById(R.id.wallet_import_path); + EditText walletPasswordEdit = (EditText) dialog.findViewById(R.id.wallet_password); + String importPath = importPathEdit.getText().toString(); + String password = walletPasswordEdit.getText().toString(); + String fileContents = null; + try { + File walletFile = new File(importPath); + if (walletFile.exists()) { + FileInputStream stream = new FileInputStream(walletFile); + try { + FileChannel fileChannel = stream.getChannel(); + MappedByteBuffer buffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileChannel.size()); + fileContents = Charset.defaultCharset().decode(buffer).toString(); + } finally { + stream.close(); + } + } else { + Toast.makeText(context, R.string.file_not_found, Toast.LENGTH_SHORT).show(); + logger.warn("Wallet file not found: " + importPath); + return; + } + } catch (Exception e) { + Toast.makeText(context, R.string.error_reading_file, Toast.LENGTH_SHORT).show(); + logger.error("Error reading wallet file", e); + } + if (importJsonRadio.isChecked()) { + Profile profile = ProfileManager.getCurrentProfile(); + if (profile.importWallet(fileContents, password)) { + ProfileManager.updateProfile(profile); + ProfileManager.setCurrentProfile(profile); + } else { + Toast.makeText(context, R.string.invalid_wallet_password, Toast.LENGTH_SHORT).show(); + } + } else { + Profile profile = ProfileManager.getCurrentProfile(); + profile.importPrivateKey(fileContents, password); + ProfileManager.updateProfile(profile); + } + } + + @Override + public void onNegative(MaterialDialog dialog) { + dialog.hide(); + } + }) + .build().show(); + } + + public static void showHeaderBackgroundDialog(final Context context) { + new MaterialDialog.Builder(context) + .adapter(new BackgroundArrayAdapter(context), + new MaterialDialog.ListCallback() { + @SuppressWarnings("ConstantConditions") + @Override + public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) { + BackgroundArrayAdapter adapter = (BackgroundArrayAdapter) dialog.getListView().getAdapter(); + int imageResourceId = adapter.getImageResourceIdByPosition(which); + ProfileManager.setCurrentProfileBackgroundResourceId(imageResourceId); + dialog.dismiss(); + } + }) + .show(); + } + } diff --git a/app/src/main/java/io/syng/util/ProfileManager.java b/app/src/main/java/io/syng/util/ProfileManager.java index e9712f9..e8a9f6e 100644 --- a/app/src/main/java/io/syng/util/ProfileManager.java +++ b/app/src/main/java/io/syng/util/ProfileManager.java @@ -1,5 +1,6 @@ package io.syng.util; +import android.support.annotation.DrawableRes; import android.support.annotation.Nullable; import org.ethereum.crypto.HashUtil; @@ -81,6 +82,7 @@ public final class ProfileManager { } } + return new Profile(); } @@ -115,6 +117,15 @@ public final class ProfileManager { return null; } + public static void setCurrentProfileBackgroundResourceId(@DrawableRes int resourceId) { + PrefsUtil.setBackgroundResourceId(ProfileManager.getCurrentProfile().getId(), resourceId); + notifyListener(); + } + + public static int getCurrentProfileBackgroundResourceId() { + return PrefsUtil.getBackgroundResourceId(ProfileManager.getCurrentProfile().getId()); + } + public static void setProfilesChangeListener(ProfilesChangeListener listener) { getInstance().mProfilesChangeListener = listener; } @@ -128,4 +139,5 @@ public final class ProfileManager { getInstance().mProfilesChangeListener.onProfilesChange(); } } + } diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..0859fd7 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 746d0fa..8ab56f1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -37,5 +37,9 @@ Cancel Import Export + LoginActivity + + Hello world! + Settings