diff --git a/.idea/modules.xml b/.idea/modules.xml
index b43fa274a..ddab5125e 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/HabitAndroRPG/HabitAndroRPG.iml b/HabitAndroRPG/HabitAndroRPG.iml
index 0610a175e..04e3f9d74 100644
--- a/HabitAndroRPG/HabitAndroRPG.iml
+++ b/HabitAndroRPG/HabitAndroRPG.iml
@@ -1,5 +1,5 @@
-
+
@@ -9,6 +9,7 @@
+
@@ -21,6 +22,7 @@
+
diff --git a/HabitAndroRPG/res/layout/activity_main.xml b/HabitAndroRPG/res/layout/activity_main.xml
index 32bdf1cff..68a735bb5 100644
--- a/HabitAndroRPG/res/layout/activity_main.xml
+++ b/HabitAndroRPG/res/layout/activity_main.xml
@@ -47,7 +47,8 @@
android:layout_height="@dimen/bar_size"
android:gravity="center|right"
android:background="@drawable/border"
- android:text="HP" />
+ android:text="HP"
+ android:paddingRight="5dp" />
+ android:text="XP"
+ android:paddingRight="5dp" />
diff --git a/HabitAndroRPG/res/layout/simple_widget.xml b/HabitAndroRPG/res/layout/simple_widget.xml
index 81e717dd0..767138b26 100644
--- a/HabitAndroRPG/res/layout/simple_widget.xml
+++ b/HabitAndroRPG/res/layout/simple_widget.xml
@@ -28,7 +28,7 @@
android:layout_height="@dimen/avatar_height"
android:orientation="vertical"
android:gravity="center_vertical"
- android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/widget_bar_horizontal_margin"
>
@@ -69,6 +70,7 @@
android:layout_height="@dimen/bar_size"
android:gravity="center|right"
android:background="@drawable/border"
+ android:paddingRight="5dp"
android:text="XP" />
@@ -79,6 +81,7 @@
android:scaleType="fitStart"
android:src="@drawable/ic_menu_refresh"
android:layout_gravity="top|right"
+ android:layout_marginTop="5dp"
android:background="@color/transparent"
/>
diff --git a/HabitAndroRPG/res/values/dimens.xml b/HabitAndroRPG/res/values/dimens.xml
index cce768b6a..deb6e1c26 100644
--- a/HabitAndroRPG/res/values/dimens.xml
+++ b/HabitAndroRPG/res/values/dimens.xml
@@ -28,4 +28,7 @@
4dp
58dp
50dp
+
+
+ 20dp
\ No newline at end of file
diff --git a/HabitAndroRPG/src/com/magicmicky/habitrpgmobileapp/MainActivity.java b/HabitAndroRPG/src/com/magicmicky/habitrpgmobileapp/MainActivity.java
index 88d66b966..f8ad63fe5 100644
--- a/HabitAndroRPG/src/com/magicmicky/habitrpgmobileapp/MainActivity.java
+++ b/HabitAndroRPG/src/com/magicmicky/habitrpgmobileapp/MainActivity.java
@@ -14,6 +14,7 @@ import com.magicmicky.habitrpgmobileapp.callbacks.TaskDeletionCallback;
import com.magicmicky.habitrpgmobileapp.callbacks.TaskScoringCallback;
import com.magicmicky.habitrpgmobileapp.callbacks.TaskUpdateCallback;
import com.magicmicky.habitrpgmobileapp.prefs.PrefsActivity;
+import com.magicmicky.habitrpgmobileapp.userpicture.UserPicture;
import com.magicmicky.habitrpgwrapper.lib.api.HabitItemCallback;
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirectionData;
@@ -38,6 +39,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
+import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
@@ -289,10 +291,8 @@ public class MainActivity extends ActionBarActivity implements OnTaskCreationLis
((DailyFragment) mPagerAdapter.getItem(1)).setDayStart(user.getPreferences().getDayStart());
((RewardFragment) mPagerAdapter.getItem(3)).setGold(user.getStats().getGp());
-// this.username_TV.setText(user.getName());
-// if(user.getLook()!=null)
-// this.mUserPicture.setImageBitmap(this.dealWithUserPicture(user.getLook()));
- //this.mUserPicture.setImageBitmap(new UserPicture(1, this ).draw());
+ //this.username_TV.setText(user.getName());
+ this.mUserPicture.setImageBitmap(new UserPicture(user, this ).draw());
if(this.mDrawerList!=null) {
this.mTagAdapter.updateTags(user.getTags());
@@ -309,16 +309,6 @@ public class MainActivity extends ActionBarActivity implements OnTaskCreationLis
return user.getProfile().getName();
}
- /*private Bitmap dealWithUserPicture(UserLook look) {
- UserPicture up = new UserPicture(look, this);
- Resources r = getResources();
- int w = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, r.getDimension(R.dimen.avatar_width), r.getDisplayMetrics());
- int h = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, r.getDimension(R.dimen.avatar_height), r.getDisplayMetrics());
- Bitmap img = up.draw();
- Log.d(TAG + "_avatar", "width=" + w + " height =" + h);
- return Bitmap.createScaledBitmap(img, w,h,false);
-
- }*/
private void notifyUser(double xp, double hp, double gold,
double lvl, double delta) {
StringBuilder message = new StringBuilder();
diff --git a/HabitAndroRPG/src/com/magicmicky/habitrpgmobileapp/widget/UpdateWidgetService.java b/HabitAndroRPG/src/com/magicmicky/habitrpgmobileapp/widget/UpdateWidgetService.java
index a2d7e7704..2acee935b 100644
--- a/HabitAndroRPG/src/com/magicmicky/habitrpgmobileapp/widget/UpdateWidgetService.java
+++ b/HabitAndroRPG/src/com/magicmicky/habitrpgmobileapp/widget/UpdateWidgetService.java
@@ -4,9 +4,13 @@ import android.app.PendingIntent;
import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
+import android.content.Context;
import android.content.Intent;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
import android.os.IBinder;
import android.util.Log;
+import android.util.TypedValue;
import android.widget.RemoteViews;
import com.magicmicky.habitrpgmobileapp.APIHelper;
@@ -15,6 +19,7 @@ import com.magicmicky.habitrpgmobileapp.MainActivity;
import com.magicmicky.habitrpgmobileapp.R;
import com.magicmicky.habitrpgmobileapp.callbacks.HabitRPGUserCallback;
import com.magicmicky.habitrpgmobileapp.prefs.PrefsActivity;
+import com.magicmicky.habitrpgmobileapp.userpicture.UserPicture;
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
import retrofit.Callback;
@@ -83,27 +88,27 @@ public class UpdateWidgetService extends Service implements HabitRPGUserCallback
ComponentName thisWidget = new ComponentName(this,SimpleWidget.class);
int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
for (int widgetId : allWidgetIds) {
-// RemoteViews remoteViews = new RemoteViews(this.getPackageName(),R.layout.simple_widget);
-// remoteViews.setTextViewText(R.id.TV_HP, "" + (int) user.getHp() + "/" + (int) user.getMaxHp() + " " + this.getString(R.string.HP_default));
-// remoteViews.setTextViewText(R.id.TV_XP, "" + (int) user.getXp() + "/" + (int) user.getMaxXp() + " " + this.getString(R.string.XP_default));
-// remoteViews.setImageViewBitmap(R.id.IMG_ProfilePicture, dealWithUserPicture(user.getLook(),this));
-// remoteViews.setProgressBar(R.id.V_HPBar,(int)user.getMaxHp(),(int)user.getHp(),false);
-// remoteViews.setProgressBar(R.id.V_XPBar,(int)user.getMaxXp(),(int)user.getXp(),false);
-//
-// // If user click on refresh: refresh
-// Intent clickIntent = new Intent(this.getApplicationContext(),SimpleWidget.class);
-// clickIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
-// clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds);
-// PendingIntent updateIntent = PendingIntent.getBroadcast(this, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
-// remoteViews.setOnClickPendingIntent(R.id.BT_refresh, updateIntent);
-//
-// //If user click on life and xp: open the app
-// Intent openAppIntent = new Intent(this.getApplicationContext(), MainActivity.class);
-// PendingIntent openApp = PendingIntent.getActivity(this,0,openAppIntent,PendingIntent.FLAG_UPDATE_CURRENT);
-// remoteViews.setOnClickPendingIntent(R.id.LL_header, openApp);
-// remoteViews.setOnClickPendingIntent(R.id.IMG_ProfilePicture, openApp);
-//
-// appWidgetManager.updateAppWidget(widgetId, remoteViews);
+ RemoteViews remoteViews = new RemoteViews(this.getPackageName(),R.layout.simple_widget);
+ remoteViews.setTextViewText(R.id.TV_HP, "" + user.getStats().getHp().intValue() + "/" + (int) user.getStats().getMaxHealth() + " " + this.getString(R.string.HP_default));
+ remoteViews.setTextViewText(R.id.TV_XP, "" + user.getStats().getExp().intValue() + "/" + (int) user.getStats().getToNextLevel() + " " + this.getString(R.string.XP_default));
+ remoteViews.setImageViewBitmap(R.id.IMG_ProfilePicture, dealWithUserPicture(user,this));
+ remoteViews.setProgressBar(R.id.V_HPBar,(int)user.getStats().getMaxHealth(), user.getStats().getHp().intValue(), false);
+ remoteViews.setProgressBar(R.id.V_XPBar,(int)user.getStats().getToNextLevel(),user.getStats().getExp().intValue(), false);
+
+ // If user click on refresh: refresh
+ Intent clickIntent = new Intent(this.getApplicationContext(),SimpleWidget.class);
+ clickIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
+ clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds);
+ PendingIntent updateIntent = PendingIntent.getBroadcast(this, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ remoteViews.setOnClickPendingIntent(R.id.BT_refresh, updateIntent);
+
+ //If user click on life and xp: open the app
+ Intent openAppIntent = new Intent(this.getApplicationContext(), MainActivity.class);
+ PendingIntent openApp = PendingIntent.getActivity(this,0,openAppIntent,PendingIntent.FLAG_UPDATE_CURRENT);
+ remoteViews.setOnClickPendingIntent(R.id.LL_header, openApp);
+ remoteViews.setOnClickPendingIntent(R.id.IMG_ProfilePicture, openApp);
+
+ appWidgetManager.updateAppWidget(widgetId, remoteViews);
//If user click on the
@@ -128,15 +133,14 @@ public class UpdateWidgetService extends Service implements HabitRPGUserCallback
//TODO
}
-// private Bitmap dealWithUserPicture(UserLook look, Context c) {
-// UserPicture up = new UserPicture(look, this);
-// Resources r = getResources();
-// int w = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, r.getDimension(R.dimen.avatar_width), r.getDisplayMetrics());
-// int h = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, r.getDimension(R.dimen.avatar_height), r.getDisplayMetrics());
-// Bitmap img = up.draw();
-// return Bitmap.createScaledBitmap(img, w,h,false);
-//
-// }
+ private Bitmap dealWithUserPicture(HabitRPGUser look, Context c) {
+ UserPicture up = new UserPicture(look, this);
+ Resources r = getResources();
+ int w = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, r.getDimension(R.dimen.avatar_width), r.getDisplayMetrics());
+ int h = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, r.getDimension(R.dimen.avatar_height), r.getDisplayMetrics());
+ Bitmap img = up.draw();
+ return Bitmap.createScaledBitmap(img, w,h,false);
+ }
//
//
// @Override public void onNewUser(String s, String s2) {}
diff --git a/habitandrorpg.iml b/habitrpg-android.iml
similarity index 74%
rename from habitandrorpg.iml
rename to habitrpg-android.iml
index 2a0220140..0bb6048ae 100644
--- a/habitandrorpg.iml
+++ b/habitrpg-android.iml
@@ -1,5 +1,5 @@
-
+
@@ -7,9 +7,7 @@
-
-
-
+