add email to sidebar

This commit is contained in:
Phillip Thelen 2015-11-18 16:08:59 +01:00
parent d56237e726
commit 012278e4b9
11 changed files with 91 additions and 41 deletions

View file

@ -0,0 +1 @@
ALTER TABLE HabitRPGUser ADD COLUMN authentication_id varchar(255);

View file

@ -83,20 +83,6 @@
<color name="new_task_bar_color">#555555</color>
<color name="white">#FFFFFFFF</color>
<!-- MaterialDrawer DEFAULT DARK colors -->
<color name="material_drawer_dark_background">#303030</color>
<!-- MaterialDrawer DEFAULT DARK text / items colors -->
<color name="material_drawer_dark_icons">#000</color>
<color name="material_drawer_dark_primary_text">#de9a9a9a</color>
<color name="material_drawer_dark_primary_icon">#8AFFFFFF</color>
<color name="material_drawer_dark_secondary_text">#de9a9a9a</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/brand</color>
<color name="material_drawer_dark_header_selection_text">#FFF</color>
<color name="checkbox_tint_color">#ffd8dcdd</color>
<color name="cell_separator">#c3c2c6</color>

View file

@ -30,7 +30,7 @@
<item name="material_drawer_hint_text">@color/material_drawer_hint_text</item>
<item name="material_drawer_divider">@color/material_drawer_divider</item>
<item name="material_drawer_selected">@color/material_drawer_selected</item>
<item name="material_drawer_selected_text">@color/brand</item>
<item name="material_drawer_selected_text">@color/brand_200</item>
<item name="material_drawer_header_selection_text">@color/material_drawer_header_selection_text</item>
<item name="popupMenuStyle">@style/PopupTheme</item>

View file

@ -109,6 +109,11 @@ public abstract class AvatarActivityBase extends InstabugAppCompatActivity {
public void updateSidebar() {
final IProfile profile = accountHeader.getProfiles().get(0);
if (User.getAuthentication() != null) {
if (User.getAuthentication().getLocalAuthentication() != null) {
profile.withEmail(User.getAuthentication().getLocalAuthentication().getEmail());
}
}
profile.withName(User.getProfile().getName());
new UserPicture(User, this, true, false).setPictureWithRunnable(new UserPictureRunnable() {
public void run(Bitmap avatar) {

View file

@ -82,7 +82,11 @@ public class GemPurchaseActivity extends AppCompatActivity {
HabitRPGUser user = new Select().from(HabitRPGUser.class).where(Condition.column("id").eq(hostConfig.getUser())).querySingle();
final IProfile profile = accountHeader.getProfiles().get(0);
profile.withName(user.getProfile().getName());
if (user.getAuthentication() != null) {
if (user.getAuthentication().getLocalAuthentication() != null) {
profile.withEmail(user.getAuthentication().getLocalAuthentication().getEmail());
}
} profile.withName(user.getProfile().getName());
new UserPicture(user, this, true, false).setPictureWithRunnable(new UserPictureRunnable() {
public void run(Bitmap avatar) {
profile.withIcon(avatar);

View file

@ -10,5 +10,5 @@ public class HabitDatabase {
public static final String NAME = "Habitica";
public static final int VERSION = 1;
public static final int VERSION = 2;
}

View file

@ -88,7 +88,11 @@ public class TavernActivity extends AppCompatActivity {
private void updateSidebar() {
final IProfile profile = accountHeader.getProfiles().get(0);
profile.withName(User.getProfile().getName());
if (User.getAuthentication() != null) {
if (User.getAuthentication().getLocalAuthentication() != null) {
profile.withEmail(User.getAuthentication().getLocalAuthentication().getEmail());
}
} profile.withName(User.getProfile().getName());
new UserPicture(User, this, true, false).setPictureWithRunnable(new UserPictureRunnable() {
public void run(Bitmap avatar) {
profile.withIcon(avatar);

View file

@ -155,18 +155,8 @@ public class UserPicture {
currentCacheFileName = layersHash.concat(".png");
// does it already exist?
<<<<<<< HEAD
return BitmapUtils.loadFromFile(currentCacheFileName);
}
=======
Bitmap cache = BitmapUtils.loadFromFile(currentCacheFileName);
// yes => load image to bitmap
if (cache != null) {
imageView.setImageBitmap(cache);
return;
}
>>>>>>> d0ae3a5b4a54a09409b3701d256c7715181ae781
private void generateImage(List<String> layerNames) {
Integer layerNumber = 0;
@ -219,26 +209,15 @@ public class UserPicture {
yOffset = 0;
}
<<<<<<< HEAD
if (this.hasPetMount && !((this.hasBackground && layerNumber == 1) ||
(!this.hasBackground && layerNumber == 0) ||
(this.hasPetMount && layerNumber == this.layers.size()-2) ||
(!this.hasPetMount && layerNumber == this.layers.size()-1)
=======
if (this.hasMount && !((this.hasBackground && layerNumber == 1) ||
(!this.hasBackground && layerNumber == 0) ||
(this.hasPet && layerNumber == this.layers.size() - 2) ||
(!this.hasPet && layerNumber == this.layers.size() - 1)
>>>>>>> d0ae3a5b4a54a09409b3701d256c7715181ae781
)) {
yOffset = 0;
}
<<<<<<< HEAD
if (this.hasPetMount && layerNumber == this.layers.size()-1) {
=======
if (this.hasPet && layerNumber == this.layers.size() - 1) {
>>>>>>> d0ae3a5b4a54a09409b3701d256c7715181ae781
xOffset = 0;
yOffset = 43;
}

View file

@ -1,7 +1,43 @@
package com.magicmicky.habitrpgwrapper.lib.models;
import com.google.gson.annotations.SerializedName;
import com.habitrpg.android.habitica.HabitDatabase;
import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.ForeignKey;
import com.raizlabs.android.dbflow.annotation.ForeignKeyReference;
import com.raizlabs.android.dbflow.annotation.NotNull;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.structure.BaseModel;
/**
* Created by admin on 18/11/15.
*/
public class Authentication {
@Table(databaseName = HabitDatabase.NAME)
public class Authentication extends BaseModel {
@Column
@PrimaryKey
@NotNull
String user_id;
@SerializedName("local")
@Column
@ForeignKey(references = {@ForeignKeyReference(columnName = "localauthentication_user_id",
columnType = String.class,
foreignColumnName = "user_id")})
public LocalAuthentication localAuthentication;
public LocalAuthentication getLocalAuthentication() { return localAuthentication; }
public void setLocalAuthentication(LocalAuthentication LocalAuthentication) {this.localAuthentication = LocalAuthentication; }
@Override
public void save() {
if (localAuthentication != null)
localAuthentication.user_id = user_id;
super.save();
}
}

View file

@ -1,5 +1,6 @@
package com.magicmicky.habitrpgwrapper.lib.models;
import com.google.gson.annotations.SerializedName;
import com.habitrpg.android.habitica.HabitDatabase;
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
import com.raizlabs.android.dbflow.annotation.Column;
@ -65,6 +66,13 @@ public class HabitRPGUser extends BaseModel {
foreignColumnName = "user_id")})
private Items items;
@Column
@ForeignKey(references = {@ForeignKeyReference(columnName = "authentication_id",
columnType = String.class,
foreignColumnName = "user_id")})
@SerializedName("auth")
private Authentication authentication;
public Preferences getPreferences() {
return preferences;
}
@ -141,6 +149,10 @@ public class HabitRPGUser extends BaseModel {
return this.balance;
}
public Authentication getAuthentication() { return authentication; }
public void setAuthentication(Authentication authentication) {this.authentication = authentication; }
@OneToMany(methods = {OneToMany.Method.SAVE, OneToMany.Method.DELETE}, variableName = "habits")
public List<Task> getHabits() {
if(habits == null) {
@ -207,6 +219,7 @@ public class HabitRPGUser extends BaseModel {
stats.id = id;
profile.user_Id = id;
items.user_id = id;
authentication.user_id = id;
ArrayList<Task> allTasks = new ArrayList<Task>();

View file

@ -1,7 +1,29 @@
package com.magicmicky.habitrpgwrapper.lib.models;
import com.habitrpg.android.habitica.HabitDatabase;
import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.NotNull;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.structure.BaseModel;
/**
* Created by admin on 18/11/15.
*/
public class LocalAuthentication {
@Table(databaseName = HabitDatabase.NAME)
public class LocalAuthentication extends BaseModel {
@Column
@PrimaryKey
@NotNull
String user_id;
@Column
String email, username;
public String getEmail() { return email; }
public String getUsername() { return username; }
public void setEmail(String email) {this.email = email; }
public void setUsername(String username) {this.username = username; }
}