mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-24 14:45:46 +00:00
re-enable avatar drawing / re-enable widget / add some margins
This commit is contained in:
parent
e1f89724c5
commit
0593879335
8 changed files with 55 additions and 53 deletions
|
|
@ -3,7 +3,7 @@
|
|||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/HabitAndroRPG/HabitAndroRPG.iml" filepath="$PROJECT_DIR$/HabitAndroRPG/HabitAndroRPG.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/habitandrorpg.iml" filepath="$PROJECT_DIR$/habitandrorpg.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/habitrpg-android.iml" filepath="$PROJECT_DIR$/habitrpg-android.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
||||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="habitrpg-android" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="android-gradle" name="Android-Gradle">
|
||||
<configuration>
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
<facet type="android" name="Android">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
|
||||
|
|
@ -21,6 +22,7 @@
|
|||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
||||
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||
|
|
|
|||
|
|
@ -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" />
|
||||
</FrameLayout>
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -65,7 +66,8 @@
|
|||
android:layout_height="@dimen/bar_size"
|
||||
android:gravity="center|right"
|
||||
android:background="@drawable/border"
|
||||
android:text="XP" />
|
||||
android:text="XP"
|
||||
android:paddingRight="5dp" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
>
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -48,6 +48,7 @@
|
|||
android:layout_height="@dimen/bar_size"
|
||||
android:gravity="center|right"
|
||||
android:background="@drawable/border"
|
||||
android:paddingRight="5dp"
|
||||
android:text="HP" />
|
||||
|
||||
</FrameLayout>
|
||||
|
|
@ -69,6 +70,7 @@
|
|||
android:layout_height="@dimen/bar_size"
|
||||
android:gravity="center|right"
|
||||
android:background="@drawable/border"
|
||||
android:paddingRight="5dp"
|
||||
android:text="XP" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
|
@ -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"
|
||||
/>
|
||||
</FrameLayout>
|
||||
|
|
|
|||
|
|
@ -28,4 +28,7 @@
|
|||
<dimen name="view_layout_margin">4dp</dimen>
|
||||
<dimen name="row_size">58dp</dimen>
|
||||
<dimen name="btn_height_reward">50dp</dimen>
|
||||
|
||||
<!-- Widget -->
|
||||
<dimen name="widget_bar_horizontal_margin">20dp</dimen>
|
||||
</resources>
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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) {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
||||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="java-gradle" name="Java-Gradle">
|
||||
<configuration>
|
||||
|
|
@ -7,9 +7,7 @@
|
|||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/build/classes/main" />
|
||||
<output-test url="file://$MODULE_DIR$/build/classes/test" />
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
Loading…
Reference in a new issue