From 44f777ebff6dd588a5f9ecac85a855b96f974dab Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 10 Mar 2017 04:00:09 +0100 Subject: [PATCH 1/2] Improved drawer look --- app/build.gradle | 1 + .../com/keylesspalace/tusky/MainActivity.java | 100 ++++++++---------- app/src/main/res/values/styles.xml | 4 +- 3 files changed, 50 insertions(+), 55 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index cad0b874..d606f1ce 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,4 +41,5 @@ dependencies { transitive = true } compile 'com.github.chrisbanes:PhotoView:1.3.1' + compile 'com.mikepenz:google-material-typeface:3.0.1.0.original@aar' } diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index d027952f..14d4d950 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -44,10 +44,12 @@ import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.keylesspalace.tusky.entity.Account; +import com.mikepenz.google_material_typeface_library.GoogleMaterial; import com.mikepenz.materialdrawer.AccountHeader; import com.mikepenz.materialdrawer.AccountHeaderBuilder; import com.mikepenz.materialdrawer.Drawer; import com.mikepenz.materialdrawer.DrawerBuilder; +import com.mikepenz.materialdrawer.model.DividerDrawerItem; import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; import com.mikepenz.materialdrawer.model.ProfileDrawerItem; import com.mikepenz.materialdrawer.model.SecondaryDrawerItem; @@ -103,22 +105,8 @@ public class MainActivity extends BaseActivity { headerResult = new AccountHeaderBuilder() .withActivity(this) .withSelectionListEnabledForSingleProfile(false) - .withTranslucentStatusBar(true) + .withDividerBelowHeader(false) .withCompactStyle(true) - .withOnAccountHeaderProfileImageListener(new AccountHeader.OnAccountHeaderProfileImageListener() { - @Override - public boolean onProfileImageClick(View view, IProfile profile, boolean current) { - Intent intent = new Intent(MainActivity.this, AccountActivity.class); - intent.putExtra("id", loggedInAccountId); - startActivity(intent); - return false; - } - - @Override - public boolean onProfileImageLongClick(View view, IProfile profile, boolean current) { - return false; - } - }) .build(); DrawerImageLoader.init(new AbstractDrawerImageLoader() { @@ -136,15 +124,16 @@ public class MainActivity extends BaseActivity { drawer = new DrawerBuilder() .withActivity(this) .withToolbar(toolbar) - .withTranslucentStatusBar(true) .withAccountHeader(headerResult) .withHasStableIds(true) .withSelectedItem(-1) .addDrawerItems( - new PrimaryDrawerItem().withIdentifier(1).withName(getString(R.string.action_view_favourites)).withSelectable(false), - new PrimaryDrawerItem().withIdentifier(2).withName(getString(R.string.action_view_blocks)).withSelectable(false), - new PrimaryDrawerItem().withIdentifier(3).withName(getString(R.string.action_view_preferences)).withSelectable(false), - new PrimaryDrawerItem().withIdentifier(4).withName(getString(R.string.action_logout)).withSelectable(false) + new PrimaryDrawerItem().withIdentifier(0).withName(R.string.action_view_profile).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_person), + new PrimaryDrawerItem().withIdentifier(1).withName(getString(R.string.action_view_favourites)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_star), + new PrimaryDrawerItem().withIdentifier(2).withName(getString(R.string.action_view_blocks)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_block), + new DividerDrawerItem(), + new SecondaryDrawerItem().withIdentifier(3).withName(getString(R.string.action_view_preferences)).withSelectable(false), + new SecondaryDrawerItem().withIdentifier(4).withName(getString(R.string.action_logout)).withSelectable(false) ) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override @@ -152,7 +141,11 @@ public class MainActivity extends BaseActivity { if (drawerItem != null) { long drawerItemIdentifier = drawerItem.getIdentifier(); - if (drawerItemIdentifier == 1) { + if (drawerItemIdentifier == 0) { + Intent intent = new Intent(MainActivity.this, AccountActivity.class); + intent.putExtra("id", loggedInAccountId); + startActivity(intent); + } else if (drawerItemIdentifier == 1) { Intent intent = new Intent(MainActivity.this, FavouritesActivity.class); startActivity(intent); } else if (drawerItemIdentifier == 2) { @@ -253,39 +246,40 @@ public class MainActivity extends BaseActivity { final String domain = preferences.getString("domain", null); String id = preferences.getString("loggedInAccountId", null); String username = preferences.getString("loggedInAccountUsername", null); - //if (id != null && username != null) { - // loggedInAccountId = id; - // loggedInAccountUsername = username; - //} else { - mastodonAPI.accountVerifyCredentials().enqueue(new Callback() { - @Override - public void onResponse(Call call, retrofit2.Response response) { - Account me = response.body(); - ImageView background = headerResult.getHeaderBackgroundView(); - - Picasso.with(MainActivity.this) - .load(me.header) - .placeholder(R.drawable.account_header_missing) - .resize(background.getWidth(), background.getHeight()) - .centerCrop() - .into(background); - - headerResult.addProfiles( - new ProfileDrawerItem() - .withName(me.displayName) - .withEmail(String.format("%s@%s", me.username, domain)) - .withIcon(me.avatar) - ); - - //onFetchUserInfoSuccess(response.body().id, response.body().username); - } - @Override - public void onFailure(Call call, Throwable t) { - onFetchUserInfoFailure((Exception) t); - } - }); - //} + if (id != null && username != null) { + loggedInAccountId = id; + loggedInAccountUsername = username; + } + + mastodonAPI.accountVerifyCredentials().enqueue(new Callback() { + @Override + public void onResponse(Call call, retrofit2.Response response) { + Account me = response.body(); + ImageView background = headerResult.getHeaderBackgroundView(); + + Picasso.with(MainActivity.this) + .load(me.header) + .placeholder(R.drawable.account_header_missing) + .resize(background.getWidth(), background.getHeight()) + .centerCrop() + .into(background); + + headerResult.addProfiles( + new ProfileDrawerItem() + .withName(me.displayName) + .withEmail(String.format("%s@%s", me.username, domain)) + .withIcon(me.avatar) + ); + + //onFetchUserInfoSuccess(response.body().id, response.body().username); + } + + @Override + public void onFailure(Call call, Throwable t) { + onFetchUserInfoFailure((Exception) t); + } + }); } private void onFetchUserInfoSuccess(String id, String username) { diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ac08ab61..37cb2999 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -56,13 +56,13 @@ @color/report_status_background_dark @drawable/report_status_divider_dark - @color/color_primary_dark + @color/window_background_dark @color/text_color_primary_dark @color/toolbar_icon_dark @color/text_color_secondary_dark @color/text_color_tertiary_dark @color/color_primary_dark_dark - @color/window_background_dark + @color/color_primary_dark @color/text_color_primary_dark @color/text_color_primary_dark From 68e10f77f4cf999da07e3f81e5840d3e0e89538a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 10 Mar 2017 04:35:08 +0100 Subject: [PATCH 2/2] Integrate floating search bar --- app/build.gradle | 3 +++ .../com/keylesspalace/tusky/MainActivity.java | 12 ++++++++--- .../keylesspalace/tusky/entity/Account.java | 4 ++++ app/src/main/res/layout/activity_main.xml | 21 ++++++++++++++++--- app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 10 +++++++++ 6 files changed, 45 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d606f1ce..3f6b5633 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,4 +42,7 @@ dependencies { } compile 'com.github.chrisbanes:PhotoView:1.3.1' compile 'com.mikepenz:google-material-typeface:3.0.1.0.original@aar' + compile 'com.github.arimorty:floatingsearchview:2.0.3' + compile 'org.parceler:parceler-api:1.1.6' + annotationProcessor 'org.parceler:parceler:1.1.6' } diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index 14d4d950..22c1590e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -43,6 +43,7 @@ import com.android.volley.Request; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; +import com.arlib.floatingsearchview.FloatingSearchView; import com.keylesspalace.tusky.entity.Account; import com.mikepenz.google_material_typeface_library.GoogleMaterial; import com.mikepenz.materialdrawer.AccountHeader; @@ -63,6 +64,7 @@ import org.json.JSONException; import org.json.JSONObject; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Stack; @@ -90,8 +92,8 @@ public class MainActivity extends BaseActivity { // Fetch user info while we're doing other things. fetchUserInfo(); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); + //Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + //setSupportActionBar(toolbar); FloatingActionButton floatingBtn = (FloatingActionButton) findViewById(R.id.floating_btn); floatingBtn.setOnClickListener(new View.OnClickListener() { @@ -102,6 +104,8 @@ public class MainActivity extends BaseActivity { } }); + final FloatingSearchView searchView = (FloatingSearchView) findViewById(R.id.floating_search_view); + headerResult = new AccountHeaderBuilder() .withActivity(this) .withSelectionListEnabledForSingleProfile(false) @@ -123,7 +127,7 @@ public class MainActivity extends BaseActivity { drawer = new DrawerBuilder() .withActivity(this) - .withToolbar(toolbar) + //.withToolbar(toolbar) .withAccountHeader(headerResult) .withHasStableIds(true) .withSelectedItem(-1) @@ -175,6 +179,8 @@ public class MainActivity extends BaseActivity { }) .build(); + searchView.attachNavigationDrawerToMenuButton(drawer.getDrawerLayout()); + // Setup the tabs and timeline pager. TimelinePagerAdapter adapter = new TimelinePagerAdapter(getSupportFragmentManager()); String[] pageTitles = { diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Account.java b/app/src/main/java/com/keylesspalace/tusky/entity/Account.java index d091512e..486dc6f6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Account.java +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Account.java @@ -15,10 +15,14 @@ package com.keylesspalace.tusky.entity; +import android.os.Parcel; import android.text.Spanned; +import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion; import com.google.gson.annotations.SerializedName; +import org.parceler.Parcels; + public class Account { public String id; diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 004527b6..64251fad 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -16,14 +16,14 @@ android:layout_height="match_parent" android:orientation="vertical"> - + android:background="?attr/toolbar_background_color" />--> + + Unmute That user wasn\'t unmuted. That user wasn\'t muted. + Search accounts... diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 37cb2999..41ce0b58 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -65,6 +65,16 @@ @color/color_primary_dark @color/text_color_primary_dark @color/text_color_primary_dark + + @color/toolbar_background_dark + @color/text_color_secondary_dark + @color/text_color_tertiary_dark + @color/status_divider_dark + @color/toolbar_icon_dark + @color/toolbar_icon_dark + @color/toolbar_icon_dark + @color/toolbar_icon_dark + @color/toolbar_icon_dark-->