Browse Source

Merge branch 'master' of https://git.tk.informatik.tu-darmstadt.de/scm-ssi-student-hostagev2

Daniel Lazar 10 years ago
parent
commit
f4d0a78cc7

+ 18 - 16
res/layout/fragment_record_detail.xml

@@ -4,7 +4,7 @@
 			  android:layout_width="match_parent"
 			  android:layout_height="match_parent"
 			  android:orientation="vertical"
-			  android:padding="8dp">
+			  android:padding="16dp" android:background="@android:color/transparent">
 
 	<TableLayout
 			android:layout_width="match_parent"
@@ -24,7 +24,7 @@
 					android:textAppearance="?android:attr/textAppearanceMedium"
 					android:text="undefined"
 					android:id="@+id/record_detail_ssid_value" android:layout_column="1"
-					android:gravity="right"/>
+					/>
 		</TableRow>
 		<TableRow
 				android:layout_width="match_parent"
@@ -41,7 +41,7 @@
 					android:textAppearance="?android:attr/textAppearanceMedium"
 					android:text="undefined"
 					android:id="@+id/record_detail_bssid_value"
-					android:gravity="right"/>
+					/>
 		</TableRow>
 		<TableRow
 				android:layout_width="match_parent"
@@ -58,7 +58,7 @@
 					android:textAppearance="?android:attr/textAppearanceMedium"
 					android:text="undefined"
 					android:id="@+id/record_detail_protocol_value"
-					android:gravity="right"/>
+					/>
 		</TableRow>
 		<TableRow
 				android:layout_width="match_parent"
@@ -75,7 +75,7 @@
 					android:textAppearance="?android:attr/textAppearanceMedium"
 					android:text="undefined"
 					android:id="@+id/record_detail_timestamp_value"
-					android:gravity="right"/>
+					/>
 		</TableRow>
 		<TableRow
 				android:layout_width="match_parent"
@@ -92,7 +92,7 @@
 					android:textAppearance="?android:attr/textAppearanceMedium"
 					android:text="undefined"
 					android:id="@+id/record_detail_location_value"
-					android:gravity="right"/>
+					/>
 		</TableRow>
 		<TableRow
 				android:layout_width="match_parent"
@@ -109,7 +109,7 @@
 					android:textAppearance="?android:attr/textAppearanceMedium"
 					android:text="undefined"
 					android:id="@+id/record_detail_internalip_value"
-					android:gravity="right"/>
+					/>
 		</TableRow>
 		<TableRow
 				android:layout_width="match_parent"
@@ -126,7 +126,7 @@
 					android:textAppearance="?android:attr/textAppearanceMedium"
 					android:text="undefined"
 					android:id="@+id/record_detail_externalip_value"
-					android:gravity="right"/>
+					/>
 		</TableRow>
 		<TableRow
 				android:layout_width="match_parent"
@@ -143,7 +143,7 @@
 					android:textAppearance="?android:attr/textAppearanceMedium"
 					android:text="undefined"
 					android:id="@+id/record_detail_remoteip_value"
-					android:gravity="right"/>
+					/>
 		</TableRow>
 		<TableRow
 				android:layout_width="match_parent"
@@ -160,7 +160,7 @@
 					android:textAppearance="?android:attr/textAppearanceMedium"
 					android:text="undefined"
 					android:id="@+id/record_detail_packettype_value"
-					android:gravity="right"/>
+					/>
 		</TableRow>
 	</TableLayout>
 	<TextView
@@ -173,19 +173,19 @@
 			android:layout_width="match_parent"
 			android:layout_height="wrap_content"
 			android:id="@+id/scrollView"
-			android:layout_gravity="bottom"
-			android:layout_weight="1">
+			android:layout_weight="1" android:fillViewport="true"
+			android:background="@drawable/panel_bg">
 		<TextView
-				android:layout_width="wrap_content"
+				android:layout_width="match_parent"
 				android:layout_height="wrap_content"
 				android:padding="8dp"
 				android:textAppearance="?android:attr/textAppearanceMedium"
-				android:text="undefinedsajdsdbjkfhjkashjf kljsdlfkaskldfdsaklhfhl klhkl fdslkhkfls dhklfads hklf hklsdfklh salkhflkhsadklfkhlsad klf asklfhkl safklaslhkdf klsad klhf sdklfdlkhö klsdlfkhö sklflhkslhkdf dklsfklh s dfklhöds kdklshf kdsklhflhksdfhkldkls klhf sdkl dkfhldsjfhj sdhflhjksd fjkldsklj fsljkf ljksd fljksdjklfdskljfjksd klj dklsfklösadjklfjkeifjih klds f"
+				android:text="undefined"
 				android:id="@+id/record_detail_packetcontent_value" android:autoText="false"
 				android:typeface="monospace"
 				android:singleLine="false"
 				android:textIsSelectable="true"
-				android:background="@color/holo_yellow"/>
+				/>
 	</ScrollView>
 
 	<Button
@@ -194,5 +194,7 @@
 			android:text="@string/delete"
 			android:id="@+id/button"
 			android:layout_gravity="center_horizontal|bottom"
-			android:layout_weight="0"/>
+			android:layout_weight="0" android:layout_marginTop="8dp"
+			android:background="@color/holo_red"
+			android:textColor="@android:color/white"/>
 </LinearLayout>

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

@@ -33,7 +33,7 @@ public class UglyDbHelper extends SQLiteOpenHelper {
 
 	// All Static variables
 	// Database Version
-	private static final int DATABASE_VERSION = 7;
+	private static final int DATABASE_VERSION = 9;
 
 	// Database Name
 	private static final String DATABASE_NAME = "recordManager";
@@ -70,6 +70,7 @@ public class UglyDbHelper extends SQLiteOpenHelper {
 	public static final String KEY_PROFILE_ICON = "profile_icon";
 	public static final String KEY_PROFILE_EDITABLE = "profile_editable";
 	public static final String KEY_PROFILE_ACTIVE = "profile_active";
+	public static final String KEY_PROFILE_ICON_NAME = "profile_icon_name";
 
 	// Database sql create statements
 	private static final String CREATE_PROFILE_TABLE = "CREATE TABLE "
@@ -78,6 +79,7 @@ public class UglyDbHelper extends SQLiteOpenHelper {
 			+ KEY_PROFILE_NAME + " TEXT,"
 			+ KEY_PROFILE_DESCRIPTION + " TEXT,"
 			+ KEY_PROFILE_ICON + " TEXT,"
+			+ KEY_PROFILE_ICON_NAME + " TEXT,"
 			+ KEY_PROFILE_EDITABLE + " INTEGER,"
 			+ KEY_PROFILE_ACTIVE + " INTEGER"
 			+ ")";
@@ -821,12 +823,14 @@ public class UglyDbHelper extends SQLiteOpenHelper {
 		// looping through all rows and adding to list
 		if (cursor.moveToFirst()) {
 			do {
-				Profile profile = new Profile(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getInt(4) == 1);
+				Profile profile = new Profile(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getInt(5) == 1);
 
-				if(cursor.getInt(5) == 1){
+				if(cursor.getInt(6) == 1){
 					profile.mActivated = true;
 				}
 
+				profile.mIconName = cursor.getString(4);
+
 				// Adding record to list
 				profiles.add(profile);
 			} while (cursor.moveToNext());
@@ -856,6 +860,7 @@ public class UglyDbHelper extends SQLiteOpenHelper {
 		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_ICON_NAME, profile.mIconName);
 		values.put(KEY_PROFILE_ACTIVE, profile.mActivated);
 		values.put(KEY_PROFILE_EDITABLE, profile.mEditable);
 
@@ -863,6 +868,18 @@ public class UglyDbHelper extends SQLiteOpenHelper {
 	}
 
 
+	/**
+	 * private static final String CREATE_PROFILE_TABLE = "CREATE TABLE "
+	 + TABLE_PROFILES + "("
+	 + KEY_PROFILE_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+	 + KEY_PROFILE_NAME + " TEXT,"
+	 + KEY_PROFILE_DESCRIPTION + " TEXT,"
+	 + KEY_PROFILE_ICON + " TEXT,"
+	 + KEY_PROFILE_ICON_ID + " INTEGER,"
+	 + KEY_PROFILE_EDITABLE + " INTEGER,"
+	 + KEY_PROFILE_ACTIVE + " INTEGER"
+	 + ")";
+	 */
 	public Profile getProfile(int id) {
 		String selectQuery = "SELECT  * FROM " + TABLE_PROFILES + " WHERE " + TABLE_PROFILES + "." + KEY_PROFILE_ID + " = " + id;
 		SQLiteDatabase db = this.getReadableDatabase();
@@ -871,11 +888,13 @@ public class UglyDbHelper extends SQLiteOpenHelper {
 		Profile profile = null;
 
 		if (cursor.moveToFirst()) {
-			profile = new Profile(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getInt(4) == 1);
+			profile = new Profile(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getInt(5) == 1);
 
-			if(cursor.getInt(5) == 1){
+			if(cursor.getInt(6) == 1){
 				profile.mActivated = true;
 			}
+
+			profile.mIconName = cursor.getString(5);
 		}
 
 		cursor.close();

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

@@ -17,6 +17,9 @@ public class Profile {
 	public int mId;
 	public boolean mActivated;
 	public Bitmap mIcon;
+	public int mIconId;
+	public String mIconName;
+
 	public String mIconPath;
 
 	public boolean mIsBackVisible = false;
@@ -39,6 +42,8 @@ public class Profile {
 
 	public Profile(int id, String label, String text, int icon, boolean editable){
 		this(id, text, label, BitmapFactory.decodeResource(MainActivity.context.getResources(), icon), editable);
+		mIconId = icon;
+		mIconName = MainActivity.context.getResources().getResourceName(icon);
 	}
 
 	public Profile(int id, String label, String text, String iconPath, boolean editable){
@@ -61,6 +66,19 @@ public class Profile {
 	public Bitmap getIconBitmap(){
 		if(this.mIcon != null) return mIcon;
 
+		if(this.mIconId != 0){
+			this.mIcon = BitmapFactory.decodeResource(MainActivity.context.getResources(), mIconId);
+			return this.mIcon;
+		}
+
+		if(!this.mIconName.isEmpty()){
+			this.mIconId = MainActivity.context.getResources().getIdentifier(this.mIconName,
+					"drawable", "de.tudarmstadt.informatik.hostage");
+			this.mIcon = BitmapFactory.decodeResource(MainActivity.context.getResources(), this.mIconId);
+
+			return this.mIcon;
+		}
+
 		if(this.mIconPath != null){
 			BitmapFactory.Options options = new BitmapFactory.Options();
 			options.inPreferredConfig = Bitmap.Config.ARGB_8888;

+ 2 - 2
src/de/tudarmstadt/informatik/hostage/ui2/activity/MainActivity.java

@@ -410,7 +410,7 @@ public class MainActivity extends Activity {
 
 	private void injectFragment(Fragment fragment, boolean enableBack, Object tagObj){
 		if(enableBack){
-			mDrawerToggle.setDrawerIndicatorEnabled(false);
+			//mDrawerToggle.setDrawerIndicatorEnabled(false);
 		}
 
 		String tag = (tagObj == null ? null : tagObj.toString());
@@ -434,7 +434,7 @@ public class MainActivity extends Activity {
 	@Override
 	public void onBackPressed() {
 		super.onBackPressed();
-		if(getCurrentFragment().getTag() != null) mDrawerToggle.setDrawerIndicatorEnabled(true);
+		//if(getCurrentFragment().getTag() != null) mDrawerToggle.setDrawerIndicatorEnabled(true);
 	}
 
 	public static void displayBackStack(FragmentManager fm) {

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

@@ -74,6 +74,8 @@ public class ProfileEditFragment extends PreferenceFragment implements
 
 				if(createNew){
 					profile.mId = -1;
+					profile.mIconId = 0;
+					profile.mIconName = "";
 					pmanager.addProfile(profile);
 				} else {
 					pmanager.persistProfile(profile);