Browse Source

some changes

Alexander Brakowski 10 years ago
parent
commit
f740cd12fb

+ 10 - 11
src/de/tudarmstadt/informatik/hostage/dao/ProfileManager.java

@@ -11,7 +11,6 @@ import de.tudarmstadt.informatik.hostage.logging.UglyDbHelper;
 import de.tudarmstadt.informatik.hostage.model.Profile;
 import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
 import de.tudarmstadt.informatik.hostage.ui2.adapter.ProfileManagerListAdapter;
-import de.tudarmstadt.informatik.hostage.ui2.model.ProfileListItem;
 
 /**
  * @author Alexander Brakowski
@@ -52,9 +51,9 @@ public class ProfileManager {
 		this.mProfiles.clear();
 
 		for(Profile p: profiles){
-			this.mProfiles.put(p.id, p);
+			this.mProfiles.put(p.mId, p);
 
-			if(p.activated){
+			if(p.mActivated){
 				this.mCurrentActivatedProfile = p;
 			}
 		}
@@ -79,8 +78,8 @@ public class ProfileManager {
 	public long persistProfile(Profile profile){
 		int id = (int) this.dbh.persistProfile(profile);
 
-		if(profile.id != id){
-			profile.id = id;
+		if(profile.mId != id){
+			profile.mId = id;
 		}
 
 		this.mProfiles.put(id, profile);
@@ -101,7 +100,7 @@ public class ProfileManager {
 
 	public void addProfile(Profile profile){
 		int id = (int) this.dbh.persistProfile(profile);
-		profile.id = id;
+		profile.mId = id;
 
 		this.mProfiles.put(id, profile);
 		if(this.mProfileListAdapter != null){
@@ -111,9 +110,9 @@ public class ProfileManager {
 	}
 
 	public void deleteProfile(Profile profile){
-		if(this.mProfiles.containsKey(profile.id)){
-			this.mProfiles.remove(profile.id);
-			this.dbh.deleteProfile(profile.id);
+		if(this.mProfiles.containsKey(profile.mId)){
+			this.mProfiles.remove(profile.mId);
+			this.dbh.deleteProfile(profile.mId);
 
 			if(this.mProfileListAdapter != null){
 				this.mProfileListAdapter.remove(profile);
@@ -126,11 +125,11 @@ public class ProfileManager {
 		if(profile.equals(this.mCurrentActivatedProfile)) return;
 
 		if(this.mCurrentActivatedProfile != null){
-			this.mCurrentActivatedProfile.activated = false;
+			this.mCurrentActivatedProfile.mActivated = false;
 			this.persistProfile(this.mCurrentActivatedProfile);
 		}
 
-		profile.activated = true;
+		profile.mActivated = true;
 		this.mCurrentActivatedProfile = profile;
 
 		this.dbh.persistProfile(profile);

+ 9 - 9
src/de/tudarmstadt/informatik/hostage/logging/UglyDbHelper.java

@@ -764,7 +764,7 @@ public class UglyDbHelper extends SQLiteOpenHelper {
 				Profile profile = new Profile(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getInt(4) == 1);
 
 				if(cursor.getInt(5) == 1){
-					profile.activated = true;
+					profile.mActivated = true;
 				}
 
 				// Adding record to list
@@ -789,15 +789,15 @@ public class UglyDbHelper extends SQLiteOpenHelper {
 
 		ContentValues values = new ContentValues();
 
-		if(profile.id != -1){
-			values.put(KEY_PROFILE_ID, profile.id);
+		if(profile.mId != -1){
+			values.put(KEY_PROFILE_ID, profile.mId);
 		}
 
-		values.put(KEY_PROFILE_NAME, profile.label);
-		values.put(KEY_PROFILE_DESCRIPTION, profile.text);
-		values.put(KEY_PROFILE_ICON, profile.iconPath);
-		values.put(KEY_PROFILE_ACTIVE, profile.activated);
-		values.put(KEY_PROFILE_EDITABLE, profile.editable);
+		values.put(KEY_PROFILE_NAME, profile.mLabel);
+		values.put(KEY_PROFILE_DESCRIPTION, profile.mText);
+		values.put(KEY_PROFILE_ICON, profile.mIconPath);
+		values.put(KEY_PROFILE_ACTIVE, profile.mActivated);
+		values.put(KEY_PROFILE_EDITABLE, profile.mEditable);
 
 		return db.replace(TABLE_PROFILES, null, values);
 	}
@@ -814,7 +814,7 @@ public class UglyDbHelper extends SQLiteOpenHelper {
 			profile = new Profile(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getInt(4) == 1);
 
 			if(cursor.getInt(5) == 1){
-				profile.activated = true;
+				profile.mActivated = true;
 			}
 		}
 

+ 27 - 27
src/de/tudarmstadt/informatik/hostage/model/Profile.java

@@ -12,23 +12,23 @@ import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
  * @created 14.01.14 18:04
  */
 public class Profile {
-	public String text;
-	public String label;
-	public int id;
-	public boolean activated;
-	public Bitmap icon;
-	public String iconPath;
+	public String mText;
+	public String mLabel;
+	public int mId;
+	public boolean mActivated;
+	public Bitmap mIcon;
+	public String mIconPath;
 
-	public boolean isBackVisible = false;
-	public boolean editable = false;
+	public boolean mIsBackVisible = false;
+	public boolean mEditable = false;
 
 	public Profile(int id, String label, String text, Bitmap icon, boolean editable){
-		this.id = id;
-		this.label = text;
-		this.text = label;
-		this.activated = false;
-		this.icon = icon;
-		this.editable = editable;
+		this.mId = id;
+		this.mLabel = text;
+		this.mText = label;
+		this.mActivated = false;
+		this.mIcon = icon;
+		this.mEditable = editable;
 	}
 
 	public Profile(int id, String label, String text, int icon, boolean editable){
@@ -36,29 +36,29 @@ public class Profile {
 	}
 
 	public Profile(int id, String label, String text, String iconPath, boolean editable){
-		this.id = id;
-		this.label = label;
-		this.text = text;
-		this.activated = false;
-		this.iconPath = iconPath;
-		this.editable = editable;
+		this.mId = id;
+		this.mLabel = label;
+		this.mText = text;
+		this.mActivated = false;
+		this.mIconPath = iconPath;
+		this.mEditable = editable;
 	}
 
 	public void setIcon(Bitmap bitmap){
-		this.icon = bitmap;
+		this.mIcon = bitmap;
 	}
 
 	public void setIcon(int icon){
-		this.icon = BitmapFactory.decodeResource(MainActivity.context.getResources(), icon);
+		this.mIcon = BitmapFactory.decodeResource(MainActivity.context.getResources(), icon);
 	}
 
 	public Bitmap getIconBitmap(){
-		if(this.icon != null) return icon;
+		if(this.mIcon != null) return mIcon;
 
-		if(this.iconPath != null){
+		if(this.mIconPath != null){
 			BitmapFactory.Options options = new BitmapFactory.Options();
 			options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-			Bitmap bitmap = BitmapFactory.decodeFile(this.iconPath, options);
+			Bitmap bitmap = BitmapFactory.decodeFile(this.mIconPath, options);
 
 			return bitmap;
 		}
@@ -71,10 +71,10 @@ public class Profile {
 	}
 
 	public boolean isEditable(){
-		return this.editable;
+		return this.mEditable;
 	}
 
 	public Profile cloneProfile(){
-		return new Profile(id, label, text, icon, editable);
+		return new Profile(mId, mLabel, mText, mIcon, mEditable);
 	}
 }

+ 4 - 5
src/de/tudarmstadt/informatik/hostage/ui2/adapter/ProfileManagerListAdapter.java

@@ -4,7 +4,6 @@ import android.app.AlertDialog;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
-import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -79,8 +78,8 @@ public class ProfileManagerListAdapter extends ArrayAdapter<Profile> {
 
 	    ((SwipeListView)parent).recycle(rowView, position);
 
-	    holder.textView.setText(item.text);
-	    holder.labelView.setText(item.label);
+	    holder.textView.setText(item.mText);
+	    holder.labelView.setText(item.mLabel);
 
 	    if(item.getIconBitmap() != null){
 	        //Bitmap bitmap = Bitmap.createScaledBitmap(item.getIconBitmap(), 32, 32, true);
@@ -94,7 +93,7 @@ public class ProfileManagerListAdapter extends ArrayAdapter<Profile> {
 			public void onClick(View v) {
 				Intent intent = new Intent(context, ProfileEditActivity.class);
 				intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-				intent.putExtra("profile_id", item.id);
+				intent.putExtra("profile_id", item.mId);
 				context.startActivity(intent);
 			}
 		});
@@ -127,7 +126,7 @@ public class ProfileManagerListAdapter extends ArrayAdapter<Profile> {
 
 		RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) holder.textView.getLayoutParams();
 
-        if(!item.activated){
+        if(!item.mActivated){
             lp.setMargins(0, 0, 0, 0);
 
 	        holder.textView.setLayoutParams(lp);

+ 10 - 10
src/de/tudarmstadt/informatik/hostage/ui2/fragment/ProfileEditFragment.java

@@ -58,16 +58,16 @@ public class ProfileEditFragment extends PreferenceFragment implements
 
 				if(!profile.isEditable()){
 					profile = profile.cloneProfile();
-					profile.editable = true;
+					profile.mEditable = true;
 					createNew = true;
 				}
 
-				profile.label = prefs.getString("pref_profile_general_name", profile.label);
-				profile.iconPath = prefs.getString("pref_profile_general_image", profile.iconPath);
-				profile.text = prefs.getString("pref_profile_general_description", profile.text);
+				profile.mLabel = prefs.getString("pref_profile_general_name", profile.mLabel);
+				profile.mIconPath = prefs.getString("pref_profile_general_image", profile.mIconPath);
+				profile.mText = prefs.getString("pref_profile_general_description", profile.mText);
 
 				if(createNew){
-					profile.id = -1;
+					profile.mId = -1;
 					pmanager.addProfile(profile);
 				} else {
 					pmanager.persistProfile(profile);
@@ -88,9 +88,9 @@ public class ProfileEditFragment extends PreferenceFragment implements
 		prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()).edit();
 
 		if(profile != null){
-			prefs.putString("pref_profile_general_name", profile.label);
-			prefs.putString("pref_profile_general_image", profile.iconPath);
-			prefs.putString("pref_profile_general_description", profile.text);
+			prefs.putString("pref_profile_general_name", profile.mLabel);
+			prefs.putString("pref_profile_general_image", profile.mIconPath);
+			prefs.putString("pref_profile_general_description", profile.mText);
 
 			prefs.commit();
 		}
@@ -119,8 +119,8 @@ public class ProfileEditFragment extends PreferenceFragment implements
 				}
 		);
 
-		findPreference("pref_profile_general_name").setSummary(profile.label);
-		findPreference("pref_profile_general_description").setSummary(profile.text);
+		findPreference("pref_profile_general_name").setSummary(profile.mLabel);
+		findPreference("pref_profile_general_description").setSummary(profile.mText);
 	}
 
 	public Profile getProfile(){