1
0
mirror of https://github.com/tuskyapp/Tusky synced 2024-12-18 20:02:59 +01:00

Improved drawer look

This commit is contained in:
Eugen Rochko 2017-03-10 04:00:09 +01:00
parent ed262dfb2d
commit 44f777ebff
3 changed files with 47 additions and 52 deletions

View File

@ -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'
}

View File

@ -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,10 +246,12 @@ 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 {
if (id != null && username != null) {
loggedInAccountId = id;
loggedInAccountUsername = username;
}
mastodonAPI.accountVerifyCredentials().enqueue(new Callback<Account>() {
@Override
public void onResponse(Call<Account> call, retrofit2.Response<Account> response) {
@ -285,7 +280,6 @@ public class MainActivity extends BaseActivity {
onFetchUserInfoFailure((Exception) t);
}
});
//}
}
private void onFetchUserInfoSuccess(String id, String username) {

View File

@ -56,13 +56,13 @@
<item name="report_status_background_color">@color/report_status_background_dark</item>
<item name="report_status_divider_drawable">@drawable/report_status_divider_dark</item>
<item name="material_drawer_background">@color/color_primary_dark</item>
<item name="material_drawer_background">@color/window_background_dark</item>
<item name="material_drawer_primary_text">@color/text_color_primary_dark</item>
<item name="material_drawer_primary_icon">@color/toolbar_icon_dark</item>
<item name="material_drawer_secondary_text">@color/text_color_secondary_dark</item>
<item name="material_drawer_hint_text">@color/text_color_tertiary_dark</item>
<item name="material_drawer_divider">@color/color_primary_dark_dark</item>
<item name="material_drawer_selected">@color/window_background_dark</item>
<item name="material_drawer_selected">@color/color_primary_dark</item>
<item name="material_drawer_selected_text">@color/text_color_primary_dark</item>
<item name="material_drawer_header_selection_text">@color/text_color_primary_dark</item>
</style>