From c8a0301402abafcc0a4556d066be1b7254c15a02 Mon Sep 17 00:00:00 2001
From: Christian Basler
Date: Fri, 16 Sep 2016 17:35:24 +0200
Subject: [PATCH] GUI, layout and style improvements, updated dependencies
---
app/build.gradle | 15 +-
.../apps/abit/AddressDetailActivity.java | 31 +-
.../ch/dissem/apps/abit/DetailActivity.java | 52 ++
.../ch/dissem/apps/abit/MainActivity.java | 474 +++++++++---------
.../apps/abit/MessageDetailActivity.java | 31 +-
.../ch/dissem/apps/abit/SettingsActivity.java | 12 +-
.../ch/dissem/apps/abit/StatusActivity.java | 9 +
.../apps/abit/listener/WifiReceiver.java | 19 +-
.../ch/dissem/apps/abit/util/Preferences.java | 2 +-
app/src/main/res/values-v21/styles.xml | 24 -
app/src/main/res/values/colors.xml | 53 +-
app/src/main/res/values/styles.xml | 18 +-
12 files changed, 370 insertions(+), 370 deletions(-)
create mode 100644 app/src/main/java/ch/dissem/apps/abit/DetailActivity.java
delete mode 100644 app/src/main/res/values-v21/styles.xml
diff --git a/app/build.gradle b/app/build.gradle
index 3ba3317..f2ecf7f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -44,20 +44,23 @@ dependencies {
compile 'org.slf4j:slf4j-android:1.7.12'
- compile('com.mikepenz:materialdrawer:3.1.0@aar') {
+ compile 'com.mikepenz:materialize:1.0.0@aar'
+ compile('com.mikepenz:materialdrawer:5.6.0@aar') {
transitive = true
}
- compile('com.mikepenz:aboutlibraries:5.3.4@aar') {
+ compile('com.mikepenz:aboutlibraries:5.8.1@aar') {
transitive = true
}
compile 'com.mikepenz:iconics:1.6.2@aar'
- compile 'com.mikepenz:community-material-typeface:1.1.71@aar'
+ compile 'com.mikepenz:community-material-typeface:1.5.54.2@aar'
compile 'com.journeyapps:zxing-android-embedded:3.1.0@aar'
compile 'com.google.zxing:core:3.2.0'
compile 'io.github.yavski:fab-speed-dial:1.0.2'
-
- compile 'com.github.amlcurran.showcaseview:library:5.4.0'
+ compile 'com.github.amlcurran.showcaseview:library:5.4.3'
+ compile ('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.9.3@aar'){
+ transitive=true
+ }
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
@@ -72,4 +75,4 @@ android {
lintOptions {
abortOnError false
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/ch/dissem/apps/abit/AddressDetailActivity.java b/app/src/main/java/ch/dissem/apps/abit/AddressDetailActivity.java
index 077a5d4..a00e613 100644
--- a/app/src/main/java/ch/dissem/apps/abit/AddressDetailActivity.java
+++ b/app/src/main/java/ch/dissem/apps/abit/AddressDetailActivity.java
@@ -16,12 +16,7 @@
package ch.dissem.apps.abit;
-import android.content.Intent;
import android.os.Bundle;
-import android.support.v4.app.NavUtils;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.view.MenuItem;
/**
@@ -33,18 +28,11 @@ import android.view.MenuItem;
* This activity is mostly just a 'shell' activity containing nothing
* more than a {@link AddressDetailFragment}.
*/
-public class AddressDetailActivity extends AppCompatActivity {
+public class AddressDetailActivity extends DetailActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.scrolling_toolbar_layout);
-
- final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- // Show the Up button in the action bar.
- //noinspection ConstantConditions
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// savedInstanceState is non-null when there is fragment state
// saved from previous configurations of this activity
@@ -68,21 +56,4 @@ public class AddressDetailActivity extends AppCompatActivity {
.commit();
}
}
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
- if (id == android.R.id.home) {
- // This ID represents the Home or Up button. In the case of this
- // activity, the Up button is shown. Use NavUtils to allow users
- // to navigate up one level in the application structure. For
- // more details, see the Navigation pattern on Android Design:
- //
- // http://developer.android.com/design/patterns/navigation.html#up-vs-back
- //
- NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
}
diff --git a/app/src/main/java/ch/dissem/apps/abit/DetailActivity.java b/app/src/main/java/ch/dissem/apps/abit/DetailActivity.java
new file mode 100644
index 0000000..fb94ef2
--- /dev/null
+++ b/app/src/main/java/ch/dissem/apps/abit/DetailActivity.java
@@ -0,0 +1,52 @@
+package ch.dissem.apps.abit;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.NavUtils;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.MenuItem;
+
+import com.mikepenz.materialize.MaterializeBuilder;
+
+/**
+ * @author Christian Basler
+ */
+public class DetailActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.scrolling_toolbar_layout);
+
+ final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ // Show the Up button in the action bar.
+ //noinspection ConstantConditions
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ new MaterializeBuilder()
+ .withActivity(this)
+ .withStatusBarColorRes(R.color.colorPrimaryDark)
+ .withTranslucentStatusBarProgrammatically(true)
+ .withStatusBarPadding(true)
+ .build();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ int id = item.getItemId();
+ if (id == android.R.id.home) {
+ // This ID represents the Home or Up button. In the case of this
+ // activity, the Up button is shown. Use NavUtils to allow users
+ // to navigate up one level in the application structure. For
+ // more details, see the Navigation pattern on Android Design:
+ //
+ // http://developer.android.com/design/patterns/navigation.html#up-vs-back
+ //
+ NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/app/src/main/java/ch/dissem/apps/abit/MainActivity.java b/app/src/main/java/ch/dissem/apps/abit/MainActivity.java
index b1e9ded..b8825c8 100644
--- a/app/src/main/java/ch/dissem/apps/abit/MainActivity.java
+++ b/app/src/main/java/ch/dissem/apps/abit/MainActivity.java
@@ -32,7 +32,6 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.AdapterView;
import android.widget.CompoundButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -43,10 +42,11 @@ import com.github.amlcurran.showcaseview.targets.Target;
import com.mikepenz.community_material_typeface_library.CommunityMaterial;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable;
+import com.mikepenz.materialdrawer.AccountHeader;
+import com.mikepenz.materialdrawer.AccountHeaderBuilder;
import com.mikepenz.materialdrawer.Drawer;
import com.mikepenz.materialdrawer.DrawerBuilder;
-import com.mikepenz.materialdrawer.accountswitcher.AccountHeader;
-import com.mikepenz.materialdrawer.accountswitcher.AccountHeaderBuilder;
+import com.mikepenz.materialdrawer.interfaces.OnCheckedChangeListener;
import com.mikepenz.materialdrawer.model.DividerDrawerItem;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
@@ -55,7 +55,6 @@ import com.mikepenz.materialdrawer.model.SwitchDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IProfile;
import com.mikepenz.materialdrawer.model.interfaces.Nameable;
-import com.mikepenz.materialdrawer.model.interfaces.OnCheckedChangeListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -100,7 +99,7 @@ import static ch.dissem.apps.abit.service.BitmessageService.isRunning;
*
*/
public class MainActivity extends AppCompatActivity
- implements ListSelectionListener, ActionBarListener {
+ implements ListSelectionListener, ActionBarListener {
public static final String EXTRA_SHOW_MESSAGE = "ch.dissem.abit.ShowMessage";
public static final String ACTION_SHOW_INBOX = "ch.dissem.abit.ShowInbox";
@@ -109,7 +108,7 @@ public class MainActivity extends AppCompatActivity
private static final int MANAGE_IDENTITY = 2;
private static final int ADD_CHAN = 3;
- public static WeakReference instance;
+ private static WeakReference instance;
/**
* Whether or not the activity is in two-pane mode, i.e. running on a tablet
@@ -157,7 +156,7 @@ public class MainActivity extends AppCompatActivity
MessageListFragment listFragment = new MessageListFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.item_list, listFragment)
- .commit();
+ .commit();
if (findViewById(R.id.message_detail_container) != null) {
// The detail container view will be present only in the
@@ -187,42 +186,42 @@ public class MainActivity extends AppCompatActivity
}
if (drawer.isDrawerOpen()) {
RelativeLayout.LayoutParams lps = new RelativeLayout.LayoutParams(ViewGroup
- .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
lps.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
int margin = ((Number) (getResources().getDisplayMetrics().density * 12)).intValue();
lps.setMargins(margin, margin, margin, margin);
showcaseView = new ShowcaseView.Builder(this)
- .withMaterialShowcase()
- .setStyle(R.style.CustomShowcaseTheme)
- .setContentTitle(R.string.full_node)
- .setContentText(R.string.full_node_description)
- .setTarget(new Target() {
- @Override
- public Point getPoint() {
- View view = drawer.getStickyFooter();
- int[] location = new int[2];
- view.getLocationInWindow(location);
- int x = location[0] + 7 * view.getWidth() / 8;
- int y = location[1] + view.getHeight() / 2;
- return new Point(x, y);
- }
+ .withMaterialShowcase()
+ .setStyle(R.style.CustomShowcaseTheme)
+ .setContentTitle(R.string.full_node)
+ .setContentText(R.string.full_node_description)
+ .setTarget(new Target() {
+ @Override
+ public Point getPoint() {
+ View view = drawer.getStickyFooter();
+ int[] location = new int[2];
+ view.getLocationInWindow(location);
+ int x = location[0] + 7 * view.getWidth() / 8;
+ int y = location[1] + view.getHeight() / 2;
+ return new Point(x, y);
}
- )
- .replaceEndButton(R.layout.showcase_button)
- .hideOnTouchOutside()
- .build();
+ }
+ )
+ .replaceEndButton(R.layout.showcase_button)
+ .hideOnTouchOutside()
+ .build();
showcaseView.setButtonPosition(lps);
}
}
private void changeList(AbstractItemListFragment> listFragment) {
getSupportFragmentManager()
- .beginTransaction()
- .replace(R.id.item_list, listFragment)
- .addToBackStack(null)
- .commit();
+ .beginTransaction()
+ .replace(R.id.item_list, listFragment)
+ .addToBackStack(null)
+ .commit();
if (twoPane) {
// In two-pane mode, list items should be given the
@@ -236,90 +235,91 @@ public class MainActivity extends AppCompatActivity
for (BitmessageAddress identity : bmc.addresses().getIdentities()) {
LOG.info("Adding identity " + identity.getAddress());
profiles.add(new ProfileDrawerItem()
- .withIcon(new Identicon(identity))
- .withName(identity.toString())
- .withNameShown(true)
- .withEmail(identity.getAddress())
- .withTag(identity)
+ .withIcon(new Identicon(identity))
+ .withName(identity.toString())
+ .withNameShown(true)
+ .withEmail(identity.getAddress())
+ .withTag(identity)
);
}
if (profiles.isEmpty()) {
// Create an initial identity
BitmessageAddress identity = Singleton.getIdentity(this);
profiles.add(new ProfileDrawerItem()
- .withIcon(new Identicon(identity))
- .withName(identity.toString())
- .withEmail(identity.getAddress())
- .withTag(identity)
+ .withIcon(new Identicon(identity))
+ .withName(identity.toString())
+ .withEmail(identity.getAddress())
+ .withTag(identity)
);
}
profiles.add(new ProfileSettingDrawerItem()
- .withName(getString(R.string.add_identity))
- .withDescription(getString(R.string.add_identity_summary))
- .withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_add)
- .actionBar()
- .paddingDp(5)
- .colorRes(R.color.icons))
- .withIdentifier(ADD_IDENTITY)
+ .withName(getString(R.string.add_identity))
+ .withDescription(getString(R.string.add_identity_summary))
+ .withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_add)
+ .actionBar()
+ .paddingDp(5)
+ .colorRes(R.color.icons))
+ .withIdentifier(ADD_IDENTITY)
);
profiles.add(new ProfileSettingDrawerItem()
- .withName(getString(R.string.add_chan))
- .withDescription(getString(R.string.add_chan_summary))
- .withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_add)
- .actionBar()
- .paddingDp(5)
- .colorRes(R.color.icons))
- .withIdentifier(ADD_CHAN)
+ .withName(getString(R.string.add_chan))
+ .withDescription(getString(R.string.add_chan_summary))
+ .withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_add)
+ .actionBar()
+ .paddingDp(5)
+ .colorRes(R.color.icons))
+ .withIdentifier(ADD_CHAN)
);
profiles.add(new ProfileSettingDrawerItem()
- .withName(getString(R.string.manage_identity))
- .withIcon(GoogleMaterial.Icon.gmd_settings)
- .withIdentifier(MANAGE_IDENTITY)
+ .withName(getString(R.string.manage_identity))
+ .withIcon(GoogleMaterial.Icon.gmd_settings)
+ .withIdentifier(MANAGE_IDENTITY)
);
// Create the AccountHeader
accountHeader = new AccountHeaderBuilder()
- .withActivity(this)
- .withHeaderBackground(R.drawable.header)
- .withProfiles(profiles)
- .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
- @Override
- public boolean onProfileChanged(View view, IProfile profile, boolean
- currentProfile) {
- switch (profile.getIdentifier()) {
- case ADD_IDENTITY:
- addIdentityDialog();
- break;
- case ADD_CHAN:
- addChanDialog();
- break;
- case MANAGE_IDENTITY:
- Intent show = new Intent(MainActivity.this,
- AddressDetailActivity.class);
- show.putExtra(AddressDetailFragment.ARG_ITEM,
- Singleton.getIdentity(getApplicationContext()));
- startActivity(show);
- break;
- default:
- if (profile instanceof ProfileDrawerItem) {
- Object tag = ((ProfileDrawerItem) profile).getTag();
- if (tag instanceof BitmessageAddress) {
- Singleton.setIdentity((BitmessageAddress) tag);
- }
+ .withActivity(this)
+ .withHeaderBackground(R.drawable.header)
+ .withProfiles(profiles)
+ .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
+ @Override
+ public boolean onProfileChanged(View view, IProfile profile, boolean
+ currentProfile) {
+ switch ((int) profile.getIdentifier()) {
+ case ADD_IDENTITY:
+ addIdentityDialog();
+ break;
+ case ADD_CHAN:
+ addChanDialog();
+ break;
+ case MANAGE_IDENTITY:
+ Intent show = new Intent(MainActivity.this,
+ AddressDetailActivity.class);
+ show.putExtra(AddressDetailFragment.ARG_ITEM,
+ Singleton.getIdentity(getApplicationContext()));
+ startActivity(show);
+ break;
+ default:
+ if (profile instanceof ProfileDrawerItem) {
+ Object tag = ((ProfileDrawerItem) profile).getTag();
+ if (tag instanceof BitmessageAddress) {
+ Singleton.setIdentity((BitmessageAddress) tag);
}
- }
- // false if it should close the drawer
- return false;
+ }
}
- })
- .build();
+ // false if it should close the drawer
+ return false;
+ }
+ })
+ .build();
if (profiles.size() > 2) { // There's always the add and manage identity items
accountHeader.setActiveProfile(profiles.get(0), true);
}
ArrayList drawerItems = new ArrayList<>();
for (Label label : labels) {
- PrimaryDrawerItem item = new PrimaryDrawerItem().withName(label.toString()).withTag
- (label);
+ PrimaryDrawerItem item = new PrimaryDrawerItem()
+ .withName(label.toString())
+ .withTag(label);
if (label.getType() == null) {
item.withIcon(CommunityMaterial.Icon.cmd_label);
} else {
@@ -349,146 +349,144 @@ public class MainActivity extends AppCompatActivity
drawerItems.add(item);
}
drawerItems.add(new PrimaryDrawerItem()
- .withName(R.string.archive)
- .withTag(null)
- .withIcon(CommunityMaterial.Icon.cmd_archive)
+ .withName(R.string.archive)
+ .withTag(null)
+ .withIcon(CommunityMaterial.Icon.cmd_archive)
);
drawerItems.add(new DividerDrawerItem());
drawerItems.add(new PrimaryDrawerItem()
- .withName(R.string.contacts_and_subscriptions)
- .withIcon(GoogleMaterial.Icon.gmd_contacts));
+ .withName(R.string.contacts_and_subscriptions)
+ .withIcon(GoogleMaterial.Icon.gmd_contacts));
drawerItems.add(new PrimaryDrawerItem()
- .withName(R.string.settings)
- .withIcon(GoogleMaterial.Icon.gmd_settings));
+ .withName(R.string.settings)
+ .withIcon(GoogleMaterial.Icon.gmd_settings));
drawer = new DrawerBuilder()
- .withActivity(this)
- .withToolbar(toolbar)
- .withAccountHeader(accountHeader)
- .withDrawerItems(drawerItems)
- .addStickyDrawerItems(
- new SwitchDrawerItem()
- .withName(R.string.full_node)
- .withIcon(CommunityMaterial.Icon.cmd_cloud_outline)
- .withChecked(isRunning())
- .withOnCheckedChangeListener(new OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(IDrawerItem drawerItem,
- CompoundButton buttonView,
- boolean isChecked) {
- if (isChecked) {
- checkAndStartNode(buttonView);
- } else {
- service.shutdownNode();
- }
- }
- })
- )
- .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
- @Override
- public boolean onItemClick(AdapterView> adapterView, View view, int i, long
- l, IDrawerItem item) {
- if (item.getTag() instanceof Label) {
- selectedLabel = (Label) item.getTag();
- showSelectedLabel();
- return false;
- } else if (item instanceof Nameable>) {
- Nameable> ni = (Nameable>) item;
- switch (ni.getNameRes()) {
- case R.string.contacts_and_subscriptions:
- if (!(getSupportFragmentManager().findFragmentById(R.id
- .item_list) instanceof AddressListFragment)) {
- changeList(new AddressListFragment());
- } else {
- ((AddressListFragment) getSupportFragmentManager()
- .findFragmentById(R.id.item_list)).updateList();
- }
-
- break;
- case R.string.settings:
- startActivity(new Intent(MainActivity.this, SettingsActivity
- .class));
- break;
- case R.string.archive:
- selectedLabel = null;
- showSelectedLabel();
- break;
- case R.string.full_node:
- return true;
+ .withActivity(this)
+ .withToolbar(toolbar)
+ .withAccountHeader(accountHeader)
+ .withDrawerItems(drawerItems)
+ .addStickyDrawerItems(
+ new SwitchDrawerItem()
+ .withName(R.string.full_node)
+ .withIcon(CommunityMaterial.Icon.cmd_cloud_outline)
+ .withChecked(isRunning())
+ .withOnCheckedChangeListener(new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(IDrawerItem drawerItem,
+ CompoundButton buttonView,
+ boolean isChecked) {
+ if (isChecked) {
+ checkAndStartNode(buttonView);
+ } else {
+ service.shutdownNode();
}
}
+ })
+ )
+ .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
+ @Override
+ public boolean onItemClick(View view, int position, IDrawerItem item) {
+ if (item.getTag() instanceof Label) {
+ selectedLabel = (Label) item.getTag();
+ showSelectedLabel();
return false;
+ } else if (item instanceof Nameable>) {
+ Nameable> ni = (Nameable>) item;
+ switch (ni.getName().getTextRes()) {
+ case R.string.contacts_and_subscriptions:
+ if (!(getSupportFragmentManager().findFragmentById(R.id
+ .item_list) instanceof AddressListFragment)) {
+ changeList(new AddressListFragment());
+ } else {
+ ((AddressListFragment) getSupportFragmentManager()
+ .findFragmentById(R.id.item_list)).updateList();
+ }
+ break;
+ case R.string.settings:
+ startActivity(new Intent(MainActivity.this, SettingsActivity
+ .class));
+ break;
+ case R.string.archive:
+ selectedLabel = null;
+ showSelectedLabel();
+ break;
+ case R.string.full_node:
+ return true;
+ }
}
- })
- .withShowDrawerOnFirstLaunch(true)
- .build();
+ return false;
+ }
+ })
+ .withShowDrawerOnFirstLaunch(true)
+ .build();
}
private void addIdentityDialog() {
new AlertDialog.Builder(MainActivity.this)
- .setMessage(R.string.add_identity_warning)
- .setPositiveButton(android.R.string.yes, new
- DialogInterface.OnClickListener() {
+ .setMessage(R.string.add_identity_warning)
+ .setPositiveButton(android.R.string.yes, new
+ DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+ Toast.makeText(MainActivity.this,
+ R.string.toast_long_running_operation,
+ Toast.LENGTH_SHORT).show();
+ new AsyncTask() {
@Override
- public void onClick(DialogInterface dialog,
- int which) {
- Toast.makeText(MainActivity.this,
- R.string.toast_long_running_operation,
- Toast.LENGTH_SHORT).show();
- new AsyncTask() {
- @Override
- protected BitmessageAddress doInBackground(Void... args) {
- return bmc.createIdentity(false, Pubkey.Feature.DOES_ACK);
- }
-
- @Override
- protected void onPostExecute(BitmessageAddress chan) {
- Toast.makeText(MainActivity.this,
- R.string.toast_identity_created,
- Toast.LENGTH_SHORT).show();
- addIdentityEntry(chan);
- }
- }.execute();
+ protected BitmessageAddress doInBackground(Void... args) {
+ return bmc.createIdentity(false, Pubkey.Feature.DOES_ACK);
}
- })
- .setNegativeButton(android.R.string.no, null)
- .show();
+
+ @Override
+ protected void onPostExecute(BitmessageAddress chan) {
+ Toast.makeText(MainActivity.this,
+ R.string.toast_identity_created,
+ Toast.LENGTH_SHORT).show();
+ addIdentityEntry(chan);
+ }
+ }.execute();
+ }
+ })
+ .setNegativeButton(android.R.string.no, null)
+ .show();
}
private void addChanDialog() {
@SuppressLint("InflateParams")
final View dialogView = getLayoutInflater().inflate(R.layout.dialog_input_passphrase, null);
new AlertDialog.Builder(MainActivity.this)
- .setMessage(R.string.add_chan)
- .setView(dialogView)
- .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- TextView passphrase = (TextView) dialogView.findViewById(R.id.passphrase);
- Toast.makeText(MainActivity.this, R.string.toast_long_running_operation,
- Toast.LENGTH_SHORT).show();
- new AsyncTask() {
- @Override
- protected BitmessageAddress doInBackground(String... args) {
- String pass = args[0];
- BitmessageAddress chan = bmc.createChan(pass);
- chan.setAlias(pass);
- bmc.addresses().save(chan);
- return chan;
- }
+ .setMessage(R.string.add_chan)
+ .setView(dialogView)
+ .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ TextView passphrase = (TextView) dialogView.findViewById(R.id.passphrase);
+ Toast.makeText(MainActivity.this, R.string.toast_long_running_operation,
+ Toast.LENGTH_SHORT).show();
+ new AsyncTask() {
+ @Override
+ protected BitmessageAddress doInBackground(String... args) {
+ String pass = args[0];
+ BitmessageAddress chan = bmc.createChan(pass);
+ chan.setAlias(pass);
+ bmc.addresses().save(chan);
+ return chan;
+ }
- @Override
- protected void onPostExecute(BitmessageAddress chan) {
- Toast.makeText(MainActivity.this,
- R.string.toast_chan_created,
- Toast.LENGTH_SHORT).show();
- addIdentityEntry(chan);
- }
- }.execute(passphrase.getText().toString());
- }
- })
- .setNegativeButton(R.string.cancel, null)
- .show();
+ @Override
+ protected void onPostExecute(BitmessageAddress chan) {
+ Toast.makeText(MainActivity.this,
+ R.string.toast_chan_created,
+ Toast.LENGTH_SHORT).show();
+ addIdentityEntry(chan);
+ }
+ }.execute(passphrase.getText().toString());
+ }
+ })
+ .setNegativeButton(R.string.cancel, null)
+ .show();
}
@Override
@@ -500,18 +498,18 @@ public class MainActivity extends AppCompatActivity
private void addIdentityEntry(BitmessageAddress identity) {
IProfile newProfile = new
- ProfileDrawerItem()
- .withName(identity.toString())
- .withEmail(identity.getAddress())
- .withTag(identity);
+ ProfileDrawerItem()
+ .withName(identity.toString())
+ .withEmail(identity.getAddress())
+ .withTag(identity);
if (accountHeader.getProfiles() != null) {
// we know that there are 3 setting
// elements.
// Set the new profile above them ;)
accountHeader.addProfile(
- newProfile, accountHeader
- .getProfiles().size()
- - 3);
+ newProfile, accountHeader
+ .getProfiles().size()
+ - 3);
} else {
accountHeader.addProfiles(newProfile);
}
@@ -530,20 +528,20 @@ public class MainActivity extends AppCompatActivity
service.startupNode();
} else {
new AlertDialog.Builder(MainActivity.this)
- .setMessage(R.string.full_node_warning)
- .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- service.startupNode();
- }
- })
- .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- buttonView.setChecked(false);
- }
- })
- .show();
+ .setMessage(R.string.full_node_warning)
+ .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ service.startupNode();
+ }
+ })
+ .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ buttonView.setChecked(false);
+ }
+ })
+ .show();
}
}
@@ -556,7 +554,7 @@ public class MainActivity extends AppCompatActivity
if (unread > 0) {
((PrimaryDrawerItem) item).withBadge(String.valueOf(unread));
} else {
- ((PrimaryDrawerItem) item).withBadge(null);
+ ((PrimaryDrawerItem) item).withBadge((String) null);
}
}
}
@@ -564,9 +562,9 @@ public class MainActivity extends AppCompatActivity
private void showSelectedLabel() {
if (getSupportFragmentManager().findFragmentById(R.id.item_list) instanceof
- MessageListFragment) {
+ MessageListFragment) {
((MessageListFragment) getSupportFragmentManager()
- .findFragmentById(R.id.item_list)).updateList(selectedLabel);
+ .findFragmentById(R.id.item_list)).updateList(selectedLabel);
} else {
MessageListFragment listFragment = new MessageListFragment();
changeList(listFragment);
@@ -593,12 +591,12 @@ public class MainActivity extends AppCompatActivity
fragment = new AddressDetailFragment();
else
throw new IllegalArgumentException("Plaintext or BitmessageAddress expected, but " +
- "was "
- + item.getClass().getSimpleName());
+ "was "
+ + item.getClass().getSimpleName());
fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction()
- .replace(R.id.message_detail_container, fragment)
- .commit();
+ .replace(R.id.message_detail_container, fragment)
+ .commit();
} else {
// In single-pane mode, simply start the detail activity
// for the selected item ID.
@@ -609,8 +607,8 @@ public class MainActivity extends AppCompatActivity
detailIntent = new Intent(this, AddressDetailActivity.class);
else
throw new IllegalArgumentException("Plaintext or BitmessageAddress expected, but " +
- "was "
- + item.getClass().getSimpleName());
+ "was "
+ + item.getClass().getSimpleName());
detailIntent.putExtra(MessageDetailFragment.ARG_ITEM, item);
startActivity(detailIntent);
@@ -632,7 +630,7 @@ public class MainActivity extends AppCompatActivity
protected void onStart() {
super.onStart();
bindService(new Intent(this, BitmessageService.class), connection, Context
- .BIND_AUTO_CREATE);
+ .BIND_AUTO_CREATE);
}
@Override
diff --git a/app/src/main/java/ch/dissem/apps/abit/MessageDetailActivity.java b/app/src/main/java/ch/dissem/apps/abit/MessageDetailActivity.java
index 7957185..dbad234 100644
--- a/app/src/main/java/ch/dissem/apps/abit/MessageDetailActivity.java
+++ b/app/src/main/java/ch/dissem/apps/abit/MessageDetailActivity.java
@@ -1,11 +1,6 @@
package ch.dissem.apps.abit;
-import android.content.Intent;
import android.os.Bundle;
-import android.support.v4.app.NavUtils;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.view.MenuItem;
/**
@@ -17,18 +12,11 @@ import android.view.MenuItem;
* This activity is mostly just a 'shell' activity containing nothing
* more than a {@link MessageDetailFragment}.
*/
-public class MessageDetailActivity extends AppCompatActivity {
+public class MessageDetailActivity extends DetailActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.scrolling_toolbar_layout);
-
- final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- // Show the Up button in the action bar.
- //noinspection ConstantConditions
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// savedInstanceState is non-null when there is fragment state
// saved from previous configurations of this activity
@@ -52,21 +40,4 @@ public class MessageDetailActivity extends AppCompatActivity {
.commit();
}
}
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
- if (id == android.R.id.home) {
- // This ID represents the Home or Up button. In the case of this
- // activity, the Up button is shown. Use NavUtils to allow users
- // to navigate up one level in the application structure. For
- // more details, see the Navigation pattern on Android Design:
- //
- // http://developer.android.com/design/patterns/navigation.html#up-vs-back
- //
- NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
}
diff --git a/app/src/main/java/ch/dissem/apps/abit/SettingsActivity.java b/app/src/main/java/ch/dissem/apps/abit/SettingsActivity.java
index 6a86ef2..07f4cc7 100644
--- a/app/src/main/java/ch/dissem/apps/abit/SettingsActivity.java
+++ b/app/src/main/java/ch/dissem/apps/abit/SettingsActivity.java
@@ -7,22 +7,14 @@ import android.support.v7.widget.Toolbar;
/**
* @author Christian Basler
*/
-public class SettingsActivity extends AppCompatActivity {
+public class SettingsActivity extends DetailActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.scrolling_toolbar_layout);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- //noinspection ConstantConditions
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- getSupportActionBar().setHomeButtonEnabled(false);
// Display the fragment as the main content.
getFragmentManager().beginTransaction()
.replace(R.id.content, new SettingsFragment())
.commit();
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/ch/dissem/apps/abit/StatusActivity.java b/app/src/main/java/ch/dissem/apps/abit/StatusActivity.java
index 1babcf6..cefd609 100644
--- a/app/src/main/java/ch/dissem/apps/abit/StatusActivity.java
+++ b/app/src/main/java/ch/dissem/apps/abit/StatusActivity.java
@@ -21,6 +21,8 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.TextView;
+import com.mikepenz.materialize.MaterializeBuilder;
+
import ch.dissem.apps.abit.service.Singleton;
import ch.dissem.bitmessage.BitmessageContext;
import ch.dissem.bitmessage.entity.BitmessageAddress;
@@ -39,6 +41,13 @@ public class StatusActivity extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
+ new MaterializeBuilder()
+ .withActivity(this)
+ .withStatusBarColorRes(R.color.colorPrimaryDark)
+ .withTranslucentStatusBarProgrammatically(true)
+ .withStatusBarPadding(true)
+ .build();
+
BitmessageContext bmc = Singleton.getBitmessageContext(this);
StringBuilder status = new StringBuilder();
for (BitmessageAddress address : bmc.addresses().getIdentities()) {
diff --git a/app/src/main/java/ch/dissem/apps/abit/listener/WifiReceiver.java b/app/src/main/java/ch/dissem/apps/abit/listener/WifiReceiver.java
index e4ea8e0..ccd81ac 100644
--- a/app/src/main/java/ch/dissem/apps/abit/listener/WifiReceiver.java
+++ b/app/src/main/java/ch/dissem/apps/abit/listener/WifiReceiver.java
@@ -32,20 +32,29 @@ public class WifiReceiver extends BroadcastReceiver {
if (Preferences.isWifiOnly(ctx)) {
BitmessageContext bmc = Singleton.getBitmessageContext(ctx);
- if (!isConnectedToWifi(ctx) && bmc.isRunning()) {
+ if (isConnectedToMeteredNetwork(ctx) && bmc.isRunning()) {
bmc.shutdown();
}
}
}
- public static boolean isConnectedToWifi(Context ctx) {
+ public static boolean isConnectedToMeteredNetwork(Context ctx) {
NetworkInfo netInfo = getNetworkInfo(ctx);
- return netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_WIFI;
+ if (netInfo == null || !netInfo.isConnectedOrConnecting()) {
+ return false;
+ }
+ switch (netInfo.getType()){
+ case ConnectivityManager.TYPE_ETHERNET:
+ case ConnectivityManager.TYPE_WIFI:
+ return false;
+ default:
+ return true;
+ }
}
private static NetworkInfo getNetworkInfo(Context ctx) {
ConnectivityManager conMan = (ConnectivityManager) ctx.getSystemService(Context
- .CONNECTIVITY_SERVICE);
+ .CONNECTIVITY_SERVICE);
return conMan.getActiveNetworkInfo();
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/ch/dissem/apps/abit/util/Preferences.java b/app/src/main/java/ch/dissem/apps/abit/util/Preferences.java
index a0cee3f..b7f3d97 100644
--- a/app/src/main/java/ch/dissem/apps/abit/util/Preferences.java
+++ b/app/src/main/java/ch/dissem/apps/abit/util/Preferences.java
@@ -101,7 +101,7 @@ public class Preferences {
}
public static boolean isConnectionAllowed(Context ctx) {
- return !isWifiOnly(ctx) || WifiReceiver.isConnectedToWifi(ctx);
+ return !isWifiOnly(ctx) || !WifiReceiver.isConnectedToMeteredNetwork(ctx);
}
public static boolean isWifiOnly(Context ctx) {
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
deleted file mode 100644
index 72150b4..0000000
--- a/app/src/main/res/values-v21/styles.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 8958204..6e7e100 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -1,13 +1,48 @@
- #FFC107
- #FFA000
- #DEFFFFFF
- #FFECB3
- #607D8B
- #212121
- #727272
- #212121
- #B6B6B6
+ #FFC107
+ #FFA000
+ #DEFFFFFF
+ #FFECB3
+ #607D8B
+ #212121
+ #727272
+ #212121
+ #B6B6B6
+
+
+ @color/colorPrimary
+ @color/colorPrimaryDark
+ @color/colorPrimaryLight
+ @color/colorAccent
+
+
+
+ @color/colorPrimaryDark
+
+ @color/colorPrimaryText
+ @color/icons
+ @color/colorSecondaryText
+ @color/colorSecondaryText
+ @color/divider
+
+ @color/primary
+ @color/colorPrimaryText
+ @color/colorPrimaryText
+
+
+
+ #303030
+
+ #DEFFFFFF
+ #8AFFFFFF
+ #8AFFFFFF
+ #42FFFFFF
+ #1FFFFFFF
+
+ #202020
+ @color/material_drawer_primary
+ #FFF
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 58f503e..a299e46 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,28 +1,12 @@
-
-
-