GUI, layout and style improvements, updated dependencies

This commit is contained in:
Christian Basler 2016-09-16 17:35:24 +02:00
parent af2bfc796b
commit c8a0301402
12 changed files with 370 additions and 370 deletions

View File

@ -44,20 +44,23 @@ dependencies {
compile 'org.slf4j:slf4j-android:1.7.12' 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 transitive = true
} }
compile('com.mikepenz:aboutlibraries:5.3.4@aar') { compile('com.mikepenz:aboutlibraries:5.8.1@aar') {
transitive = true transitive = true
} }
compile 'com.mikepenz:iconics:1.6.2@aar' 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.journeyapps:zxing-android-embedded:3.1.0@aar'
compile 'com.google.zxing:core:3.2.0' compile 'com.google.zxing:core:3.2.0'
compile 'io.github.yavski:fab-speed-dial:1.0.2' compile 'io.github.yavski:fab-speed-dial:1.0.2'
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
compile 'com.github.amlcurran.showcaseview:library:5.4.0' compile ('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.9.3@aar'){
transitive=true
}
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19' testCompile 'org.mockito:mockito-core:1.10.19'

View File

@ -16,12 +16,7 @@
package ch.dissem.apps.abit; package ch.dissem.apps.abit;
import android.content.Intent;
import android.os.Bundle; 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 * This activity is mostly just a 'shell' activity containing nothing
* more than a {@link AddressDetailFragment}. * more than a {@link AddressDetailFragment}.
*/ */
public class AddressDetailActivity extends AppCompatActivity { public class AddressDetailActivity extends DetailActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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 // savedInstanceState is non-null when there is fragment state
// saved from previous configurations of this activity // saved from previous configurations of this activity
@ -68,21 +56,4 @@ public class AddressDetailActivity extends AppCompatActivity {
.commit(); .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);
}
} }

View File

@ -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);
}
}

View File

@ -32,7 +32,6 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; 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.community_material_typeface_library.CommunityMaterial;
import com.mikepenz.google_material_typeface_library.GoogleMaterial; import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable; import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.materialdrawer.AccountHeader;
import com.mikepenz.materialdrawer.AccountHeaderBuilder;
import com.mikepenz.materialdrawer.Drawer; import com.mikepenz.materialdrawer.Drawer;
import com.mikepenz.materialdrawer.DrawerBuilder; import com.mikepenz.materialdrawer.DrawerBuilder;
import com.mikepenz.materialdrawer.accountswitcher.AccountHeader; import com.mikepenz.materialdrawer.interfaces.OnCheckedChangeListener;
import com.mikepenz.materialdrawer.accountswitcher.AccountHeaderBuilder;
import com.mikepenz.materialdrawer.model.DividerDrawerItem; import com.mikepenz.materialdrawer.model.DividerDrawerItem;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; 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.IDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IProfile; import com.mikepenz.materialdrawer.model.interfaces.IProfile;
import com.mikepenz.materialdrawer.model.interfaces.Nameable; import com.mikepenz.materialdrawer.model.interfaces.Nameable;
import com.mikepenz.materialdrawer.model.interfaces.OnCheckedChangeListener;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -109,7 +108,7 @@ public class MainActivity extends AppCompatActivity
private static final int MANAGE_IDENTITY = 2; private static final int MANAGE_IDENTITY = 2;
private static final int ADD_CHAN = 3; private static final int ADD_CHAN = 3;
public static WeakReference<MainActivity> instance; private static WeakReference<MainActivity> instance;
/** /**
* Whether or not the activity is in two-pane mode, i.e. running on a tablet * Whether or not the activity is in two-pane mode, i.e. running on a tablet
@ -285,7 +284,7 @@ public class MainActivity extends AppCompatActivity
@Override @Override
public boolean onProfileChanged(View view, IProfile profile, boolean public boolean onProfileChanged(View view, IProfile profile, boolean
currentProfile) { currentProfile) {
switch (profile.getIdentifier()) { switch ((int) profile.getIdentifier()) {
case ADD_IDENTITY: case ADD_IDENTITY:
addIdentityDialog(); addIdentityDialog();
break; break;
@ -318,8 +317,9 @@ public class MainActivity extends AppCompatActivity
ArrayList<IDrawerItem> drawerItems = new ArrayList<>(); ArrayList<IDrawerItem> drawerItems = new ArrayList<>();
for (Label label : labels) { for (Label label : labels) {
PrimaryDrawerItem item = new PrimaryDrawerItem().withName(label.toString()).withTag PrimaryDrawerItem item = new PrimaryDrawerItem()
(label); .withName(label.toString())
.withTag(label);
if (label.getType() == null) { if (label.getType() == null) {
item.withIcon(CommunityMaterial.Icon.cmd_label); item.withIcon(CommunityMaterial.Icon.cmd_label);
} else { } else {
@ -386,15 +386,14 @@ public class MainActivity extends AppCompatActivity
) )
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override @Override
public boolean onItemClick(AdapterView<?> adapterView, View view, int i, long public boolean onItemClick(View view, int position, IDrawerItem item) {
l, IDrawerItem item) {
if (item.getTag() instanceof Label) { if (item.getTag() instanceof Label) {
selectedLabel = (Label) item.getTag(); selectedLabel = (Label) item.getTag();
showSelectedLabel(); showSelectedLabel();
return false; return false;
} else if (item instanceof Nameable<?>) { } else if (item instanceof Nameable<?>) {
Nameable<?> ni = (Nameable<?>) item; Nameable<?> ni = (Nameable<?>) item;
switch (ni.getNameRes()) { switch (ni.getName().getTextRes()) {
case R.string.contacts_and_subscriptions: case R.string.contacts_and_subscriptions:
if (!(getSupportFragmentManager().findFragmentById(R.id if (!(getSupportFragmentManager().findFragmentById(R.id
.item_list) instanceof AddressListFragment)) { .item_list) instanceof AddressListFragment)) {
@ -403,7 +402,6 @@ public class MainActivity extends AppCompatActivity
((AddressListFragment) getSupportFragmentManager() ((AddressListFragment) getSupportFragmentManager()
.findFragmentById(R.id.item_list)).updateList(); .findFragmentById(R.id.item_list)).updateList();
} }
break; break;
case R.string.settings: case R.string.settings:
startActivity(new Intent(MainActivity.this, SettingsActivity startActivity(new Intent(MainActivity.this, SettingsActivity
@ -556,7 +554,7 @@ public class MainActivity extends AppCompatActivity
if (unread > 0) { if (unread > 0) {
((PrimaryDrawerItem) item).withBadge(String.valueOf(unread)); ((PrimaryDrawerItem) item).withBadge(String.valueOf(unread));
} else { } else {
((PrimaryDrawerItem) item).withBadge(null); ((PrimaryDrawerItem) item).withBadge((String) null);
} }
} }
} }

View File

@ -1,11 +1,6 @@
package ch.dissem.apps.abit; package ch.dissem.apps.abit;
import android.content.Intent;
import android.os.Bundle; 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 * This activity is mostly just a 'shell' activity containing nothing
* more than a {@link MessageDetailFragment}. * more than a {@link MessageDetailFragment}.
*/ */
public class MessageDetailActivity extends AppCompatActivity { public class MessageDetailActivity extends DetailActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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 // savedInstanceState is non-null when there is fragment state
// saved from previous configurations of this activity // saved from previous configurations of this activity
@ -52,21 +40,4 @@ public class MessageDetailActivity extends AppCompatActivity {
.commit(); .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);
}
} }

View File

@ -7,18 +7,10 @@ import android.support.v7.widget.Toolbar;
/** /**
* @author Christian Basler * @author Christian Basler
*/ */
public class SettingsActivity extends AppCompatActivity { public class SettingsActivity extends DetailActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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. // Display the fragment as the main content.
getFragmentManager().beginTransaction() getFragmentManager().beginTransaction()

View File

@ -21,6 +21,8 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.widget.TextView; import android.widget.TextView;
import com.mikepenz.materialize.MaterializeBuilder;
import ch.dissem.apps.abit.service.Singleton; import ch.dissem.apps.abit.service.Singleton;
import ch.dissem.bitmessage.BitmessageContext; import ch.dissem.bitmessage.BitmessageContext;
import ch.dissem.bitmessage.entity.BitmessageAddress; import ch.dissem.bitmessage.entity.BitmessageAddress;
@ -39,6 +41,13 @@ public class StatusActivity extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false); getSupportActionBar().setHomeButtonEnabled(false);
new MaterializeBuilder()
.withActivity(this)
.withStatusBarColorRes(R.color.colorPrimaryDark)
.withTranslucentStatusBarProgrammatically(true)
.withStatusBarPadding(true)
.build();
BitmessageContext bmc = Singleton.getBitmessageContext(this); BitmessageContext bmc = Singleton.getBitmessageContext(this);
StringBuilder status = new StringBuilder(); StringBuilder status = new StringBuilder();
for (BitmessageAddress address : bmc.addresses().getIdentities()) { for (BitmessageAddress address : bmc.addresses().getIdentities()) {

View File

@ -32,15 +32,24 @@ public class WifiReceiver extends BroadcastReceiver {
if (Preferences.isWifiOnly(ctx)) { if (Preferences.isWifiOnly(ctx)) {
BitmessageContext bmc = Singleton.getBitmessageContext(ctx); BitmessageContext bmc = Singleton.getBitmessageContext(ctx);
if (!isConnectedToWifi(ctx) && bmc.isRunning()) { if (isConnectedToMeteredNetwork(ctx) && bmc.isRunning()) {
bmc.shutdown(); bmc.shutdown();
} }
} }
} }
public static boolean isConnectedToWifi(Context ctx) { public static boolean isConnectedToMeteredNetwork(Context ctx) {
NetworkInfo netInfo = getNetworkInfo(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) { private static NetworkInfo getNetworkInfo(Context ctx) {

View File

@ -101,7 +101,7 @@ public class Preferences {
} }
public static boolean isConnectionAllowed(Context ctx) { public static boolean isConnectionAllowed(Context ctx) {
return !isWifiOnly(ctx) || WifiReceiver.isConnectedToWifi(ctx); return !isWifiOnly(ctx) || !WifiReceiver.isConnectedToMeteredNetwork(ctx);
} }
public static boolean isWifiOnly(Context ctx) { public static boolean isWifiOnly(Context ctx) {

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="AppTheme.Base">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/colorPrimary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/colorAccent</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<!--<item name="android:statusBarColor">@android:color/transparent</item>-->
</style>
</resources>

View File

@ -10,4 +10,39 @@
<color name="colorSecondaryText">#727272</color> <color name="colorSecondaryText">#727272</color>
<color name="icons">#212121</color> <color name="icons">#212121</color>
<color name="divider">#B6B6B6</color> <color name="divider">#B6B6B6</color>
<!-- Material DEFAULT colors -->
<color name="material_drawer_primary">@color/colorPrimary</color>
<color name="material_drawer_primary_dark">@color/colorPrimaryDark</color>
<color name="material_drawer_primary_light">@color/colorPrimaryLight</color>
<color name="material_drawer_accent">@color/colorAccent</color>
<!-- OVERWRITE THESE COLORS FOR A LIGHT THEME -->
<!-- MaterialDrawer DEFAULT colors -->
<color name="material_drawer_background">@color/colorPrimaryDark</color>
<!-- Material DEFAULT text / items colors -->
<color name="material_drawer_primary_text">@color/colorPrimaryText</color>
<color name="material_drawer_primary_icon">@color/icons</color>
<color name="material_drawer_secondary_text">@color/colorSecondaryText</color>
<color name="material_drawer_hint_text">@color/colorSecondaryText</color>
<color name="material_drawer_divider">@color/divider</color>
<!-- Material DEFAULT drawer colors -->
<color name="material_drawer_selected">@color/primary</color>
<color name="material_drawer_selected_text">@color/colorPrimaryText</color>
<color name="material_drawer_header_selection_text">@color/colorPrimaryText</color>
<!-- OVERWRITE THESE COLORS FOR A DARK THEME -->
<!-- MaterialDrawer DEFAULT DARK colors -->
<color name="material_drawer_dark_background">#303030</color>
<!-- MaterialDrawer DEFAULT DARK text / items colors -->
<color name="material_drawer_dark_primary_text">#DEFFFFFF</color>
<color name="material_drawer_dark_primary_icon">#8AFFFFFF</color>
<color name="material_drawer_dark_secondary_text">#8AFFFFFF</color>
<color name="material_drawer_dark_hint_text">#42FFFFFF</color>
<color name="material_drawer_dark_divider">#1FFFFFFF</color>
<!-- MaterialDrawer DEFAULT DARK drawer colors -->
<color name="material_drawer_dark_selected">#202020</color>
<color name="material_drawer_dark_selected_text">@color/material_drawer_primary</color>
<color name="material_drawer_dark_header_selection_text">#FFF</color>
</resources> </resources>

View File

@ -1,28 +1,12 @@
<resources> <resources>
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme.Base" parent="MaterialDrawerTheme.Light.DarkToolbar.TranslucentStatus"> <style name="AppTheme" parent="MaterialDrawerTheme.Light.DarkToolbar.TranslucentStatus">
<item name="android:activatedBackgroundIndicator">@color/colorPrimaryLight</item> <item name="android:activatedBackgroundIndicator">@color/colorPrimaryLight</item>
<item name="android:textColor">@color/colorPrimaryText</item> <item name="android:textColor">@color/colorPrimaryText</item>
<item name="android:textColorSecondary">@color/colorSecondaryText</item> <item name="android:textColorSecondary">@color/colorSecondaryText</item>
<!-- MaterialDrawer specific values -->
<item name="material_drawer_background">@color/colorPrimaryDark</item>
<item name="material_drawer_icons">@color/colorPrimaryText</item>
<item name="material_drawer_primary_icon">@color/icons</item>
<item name="material_drawer_primary_text">@color/colorPrimaryText</item>
<item name="material_drawer_secondary_text">@color/colorSecondaryText</item>
<item name="material_drawer_hint_text">@color/colorSecondaryText</item>
<item name="material_drawer_divider">@color/divider</item>
<item name="material_drawer_selected">@color/primary</item>
<item name="material_drawer_selected_text">@color/colorPrimaryText</item>
<item name="material_drawer_header_selection_text">@color/colorPrimaryText</item>
</style> </style>
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="CustomShowcaseTheme" parent="ShowcaseView"> <style name="CustomShowcaseTheme" parent="ShowcaseView">
<item name="sv_backgroundColor">#eeffc107</item> <item name="sv_backgroundColor">#eeffc107</item>
<item name="sv_showcaseColor">#ffc107</item> <item name="sv_showcaseColor">#ffc107</item>