diff --git a/app/build.gradle b/app/build.gradle index da954005..a6ed973f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -47,7 +47,6 @@ dependencies { compile 'com.github.varunest:sparkbutton:1.0.5' compile 'com.github.chrisbanes:PhotoView:2.0.0' compile 'com.mikepenz:google-material-typeface:3.0.1.0.original@aar' - compile 'com.github.arimorty:floatingsearchview:2.0.4' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.3' compile 'com.jakewharton:butterknife:8.5.1' compile 'org.jsoup:jsoup:1.10.2' diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index a4a200bd..2c3936dd 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -19,7 +19,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; -import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; @@ -31,18 +30,11 @@ import android.support.v4.content.ContextCompat; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.view.ViewPager; import android.support.v7.app.AlertDialog; -import android.text.SpannableStringBuilder; -import android.text.Spanned; -import android.text.TextUtils; -import android.text.style.StyleSpan; import android.util.Log; import android.view.View; +import android.widget.ImageButton; import android.widget.ImageView; -import android.widget.TextView; -import com.arlib.floatingsearchview.FloatingSearchView; -import com.arlib.floatingsearchview.suggestions.SearchSuggestionsAdapter; -import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion; import com.keylesspalace.tusky.entity.Account; import com.keylesspalace.tusky.pager.TimelinePagerAdapter; import com.keylesspalace.tusky.receiver.TimelineReceiver; @@ -91,8 +83,8 @@ public class MainActivity extends BaseActivity { private AccountHeader headerResult; private Drawer drawer; - @BindView(R.id.floating_search_view) FloatingSearchView searchView; @BindView(R.id.floating_btn) FloatingActionButton floatingBtn; + @BindView(R.id.drawer_toggle) ImageButton drawerToggle; @BindView(R.id.tab_layout) TabLayout tabLayout; @BindView(R.id.pager) ViewPager viewPager; @@ -122,7 +114,15 @@ public class MainActivity extends BaseActivity { }); setupDrawer(); - setupSearchView(); + + // Setup the navigation drawer toggle button. + ThemeUtils.setDrawableTint(this, drawerToggle.getDrawable(), R.attr.toolbar_icon_tint); + drawerToggle.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + drawer.openDrawer(); + } + }); /* Fetch user info while we're doing other things. This has to be after setting up the * drawer, though, because its callback touches the header in the drawer. */ @@ -376,93 +376,6 @@ public class MainActivity extends BaseActivity { .show(); } - private void setupSearchView() { - searchView.attachNavigationDrawerToMenuButton(drawer.getDrawerLayout()); - - // Setup content descriptions for the different elements in the search view. - final View leftAction = searchView.findViewById(R.id.left_action); - leftAction.setContentDescription(getString(R.string.action_open_drawer)); - searchView.setOnFocusChangeListener(new FloatingSearchView.OnFocusChangeListener() { - @Override - public void onFocus() { - leftAction.setContentDescription(getString(R.string.action_close)); - } - - @Override - public void onFocusCleared() { - leftAction.setContentDescription(getString(R.string.action_open_drawer)); - } - }); - View clearButton = searchView.findViewById(R.id.clear_btn); - clearButton.setContentDescription(getString(R.string.action_clear)); - - searchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() { - @Override - public void onSearchTextChanged(String oldQuery, String newQuery) { - if (!oldQuery.equals("") && newQuery.equals("")) { - searchView.clearSuggestions(); - return; - } - - if (newQuery.length() < 3) { - return; - } - - searchView.showProgress(); - - mastodonAPI.searchAccounts(newQuery, false, 5).enqueue(new Callback>() { - @Override - public void onResponse(Call> call, Response> response) { - if (response.isSuccessful()) { - searchView.swapSuggestions(response.body()); - searchView.hideProgress(); - } else { - searchView.hideProgress(); - } - } - - @Override - public void onFailure(Call> call, Throwable t) { - searchView.hideProgress(); - } - }); - } - }); - - searchView.setOnSearchListener(new FloatingSearchView.OnSearchListener() { - @Override - public void onSuggestionClicked(SearchSuggestion searchSuggestion) { - Account accountSuggestion = (Account) searchSuggestion; - Intent intent = new Intent(MainActivity.this, AccountActivity.class); - intent.putExtra("id", accountSuggestion.id); - startActivity(intent); - } - - @Override - public void onSearchAction(String currentQuery) {} - }); - - searchView.setOnBindSuggestionCallback(new SearchSuggestionsAdapter.OnBindSuggestionCallback() { - @Override - public void onBindSuggestion(View suggestionView, ImageView leftIcon, TextView textView, SearchSuggestion item, int itemPosition) { - Account accountSuggestion = ((Account) item); - - Picasso.with(MainActivity.this) - .load(accountSuggestion.avatar) - .placeholder(R.drawable.avatar_default) - .into(leftIcon); - - String searchStr = accountSuggestion.getDisplayName() + " " + accountSuggestion.username; - final SpannableStringBuilder str = new SpannableStringBuilder(searchStr); - - str.setSpan(new StyleSpan(Typeface.BOLD), 0, accountSuggestion.getDisplayName().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - textView.setText(str); - textView.setMaxLines(1); - textView.setEllipsize(TextUtils.TruncateAt.END); - } - }); - } - private void fetchUserInfo() { SharedPreferences preferences = getPrivatePreferences(); final String domain = preferences.getString("domain", null); 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 c802bd4a..66f336af 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Account.java +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Account.java @@ -16,14 +16,14 @@ package com.keylesspalace.tusky.entity; import android.os.Parcel; +import android.os.Parcelable; import android.text.Spanned; -import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion; import com.google.gson.annotations.SerializedName; import com.keylesspalace.tusky.util.HtmlUtils; import com.keylesspalace.tusky.json.StringWithEmoji; -public class Account implements SearchSuggestion { +public class Account implements Parcelable { public String id; @SerializedName("username") @@ -77,11 +77,6 @@ public class Account implements SearchSuggestion { return displayName.value; } - @Override - public String getBody() { - return username; - } - @Override public int describeContents() { return 0; @@ -103,9 +98,7 @@ public class Account implements SearchSuggestion { dest.writeString(statusesCount); } - public Account() { - - } + public Account() {} protected Account(Parcel in) { id = in.readString(); diff --git a/app/src/main/res/drawable/ic_menu_24dp.xml b/app/src/main/res/drawable/ic_menu_24dp.xml new file mode 100644 index 00000000..8ec2ddf7 --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_24dp.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ec98ae77..1e059440 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,77 +1,75 @@ - - + android:layout_height="match_parent"> - + + + - + android:text="@string/title_home" /> - - - - - + - + - + - + - + - + #000000 #8f000000 + #33000000 #4c5368 #363c4b diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index c2babd78..a2aab0df 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,6 +1,4 @@ - 0dp - 0dp 4dp 4dp 8dp @@ -21,4 +19,5 @@ 8dp 8dp 38dp + 16dp diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 91a842e9..853d6291 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -80,16 +80,6 @@ @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