Skip to content

Commit

Permalink
Bugs Fixed, Updated UI, Updated Info Page, Manifest Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Porvil committed Dec 12, 2020
1 parent dd1fc4c commit 67e86e2
Show file tree
Hide file tree
Showing 19 changed files with 555 additions and 281 deletions.
87 changes: 37 additions & 50 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,86 +12,73 @@
android:theme="@style/AppTheme">

<activity
android:name=".runapp.activities.HomeActivity"
android:name=".runapp.activities.SplashActivity"
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".runapp.activities.AboutActivity"
<activity
android:name=".runapp.activities.HomeActivity"
android:screenOrientation="sensorLandscape">

<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>

<activity
android:name=".runapp.activities.AlgorithmActivity"
android:screenOrientation="sensorLandscape">
android:name=".runapp.activities.AboutActivity"
android:screenOrientation="sensorLandscape" />

</activity>
<activity
android:name=".runapp.activities.DataStructureActivity"
android:screenOrientation="sensorLandscape">
android:screenOrientation="sensorLandscape" />

</activity>
<activity
android:name=".datastructures.trees.avl.AVLActivity"
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
android:name=".runapp.activities.AlgorithmActivity"
android:screenOrientation="sensorLandscape" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".runapp.activities.SortingActivity"
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
android:screenOrientation="sensorLandscape"/>

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".datastructures.trees.bst.BSTActivity"
android:screenOrientation="sensorLandscape">

<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->


<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity>
<activity
android:name=".algorithms.sorting.merge.MergeSortActivity"
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>

<activity
android:name=".algorithms.sorting.quick.QuickSortActivity"
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>

<activity
android:name=".runapp.activities.SplashActivity"
android:name=".datastructures.trees.bst.BSTActivity"
android:screenOrientation="sensorLandscape">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>

<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->


<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
<activity
android:name=".datastructures.trees.avl.AVLActivity"
android:screenOrientation="sensorLandscape">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>

</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.Timer;
import java.util.TimerTask;


public class MergeSortActivity extends AppCompatActivity {

Context context;
Expand Down Expand Up @@ -281,7 +280,7 @@ public void onClick(View v) {
btn_info.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
View view = getLayoutInflater().inflate(R.layout.layout_info, null);
View view = getLayoutInflater().inflate(R.layout.layout_sorting_info, null);
TextView tv_name = view.findViewById(R.id.tv_name);
TextView tv_avg = view.findViewById(R.id.tv_avg);
TextView tv_worst = view.findViewById(R.id.tv_worst);
Expand Down Expand Up @@ -622,7 +621,8 @@ public void run() {
public void onBackPressed() {
if (dl_main.isDrawerOpen(Gravity.RIGHT)){
dl_main.closeDrawer(Gravity.RIGHT);
} else {
}
else {
btn_back.performClick();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@
import androidx.drawerlayout.widget.DrawerLayout;

import com.iiitd.dsavisualizer.R;
import com.iiitd.dsavisualizer.algorithms.sorting.merge.MergeSort;
import com.iiitd.dsavisualizer.constants.AppSettings;
import com.iiitd.dsavisualizer.utility.UtilUI;

import java.util.Timer;
import java.util.TimerTask;


public class QuickSortActivity extends AppCompatActivity {

Context context;
Expand Down Expand Up @@ -286,7 +284,7 @@ public void onClick(View v) {
btn_info.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
View view = getLayoutInflater().inflate(R.layout.layout_info, null);
View view = getLayoutInflater().inflate(R.layout.layout_sorting_info, null);
TextView tv_name = view.findViewById(R.id.tv_name);
TextView tv_avg = view.findViewById(R.id.tv_avg);
TextView tv_worst = view.findViewById(R.id.tv_worst);
Expand Down Expand Up @@ -660,7 +658,8 @@ public void run() {
public void onBackPressed() {
if (dl_main.isDrawerOpen(Gravity.RIGHT)){
dl_main.closeDrawer(Gravity.RIGHT);
} else {
}
else {
btn_back.performClick();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class AppSettings {

public static final int SPLASH_TIME = 1000;
public static final int DEFAULT_ANIM_SPEED = 1500; // Range 500ms to 2500ms
public static final int DEFAULT_ANIM_DURATION = 750; // Range 500ms to 2500ms
public static final int DEFAULT_ANIM_DURATION = 750; // Half of DEFAULT_ANIM_SPEED
public static final int TEXT_SMALL = 12;
public static final int TEXT_MEDIUM = 14;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import static com.iiitd.dsavisualizer.datastructures.trees.NodeType.*;

import static com.iiitd.dsavisualizer.datastructures.trees.NodeType.ARROW;
import static com.iiitd.dsavisualizer.datastructures.trees.NodeType.ELEMENT;
import static com.iiitd.dsavisualizer.datastructures.trees.NodeType.EMPTY;

//HARDCODED INFORMATION, Handle with care
public class TreeLayout {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.iiitd.dsavisualizer.datastructures.trees.TreeElementAnimationData;
import com.iiitd.dsavisualizer.datastructures.trees.TreeLayout;
import com.iiitd.dsavisualizer.datastructures.trees.TreeSequence;
import com.iiitd.dsavisualizer.datastructures.trees.bst.BSTNode;

import java.util.ArrayList;
import java.util.LinkedList;
Expand All @@ -25,15 +24,15 @@ public AVL() {
treeSequence = new TreeSequence();
}

int height(AVLNode avlNode) {
private int height(AVLNode avlNode) {
if (avlNode == null) {
return 0;
}

return avlNode.height;
}

int max(int a, int b) {
private int max(int a, int b) {
return (a > b) ? a : b;
}

Expand Down Expand Up @@ -75,47 +74,14 @@ else if (key > avlNode.key) {

}

// public int largest_SmallerEqual(int key) {
// if (root != null) {
// return largest_SmallerEqual(root, key);
// }
//
// return -1;
// }
//
// private int largest_SmallerEqual(AVLNode avlNode, int key) {
// // Base cases
// if (avlNode == null) {
// return -1;
// }
// if (avlNode.key == key) {
// return key;
// }
// // If avlNode's value is smaller, try in right
// // subtree
// else if (avlNode.key < key) {
// int k = largest_SmallerEqual(avlNode.right, key);
// if (k == -1) {
// return avlNode.key;
// } else {
// return k;
// }
// } // If avlNode's key is greater, return value
// // from left subtree.
// else if (avlNode.key > key) {
// return largest_SmallerEqual(avlNode.left, key);
// }
// return -1;
// }

public ArrayList<TreeAnimationState> insert(int key) {
treeAnimationStates = new ArrayList<>();
root = insert(root, key, baseIndex, baseLevel);
root = _insert(root, key, baseIndex, baseLevel);
treeSequence = new TreeSequence(treeAnimationStates);
return treeAnimationStates;
}

private AVLNode insert(AVLNode avlNode, int key, int index, int level) {
private AVLNode _insert(AVLNode avlNode, int key, int index, int level) {
if (avlNode == null) {
TreeAnimationState treeAnimationState = new TreeAnimationState("I");
treeAnimationState.add(new TreeElementAnimationData(key, 1, index));
Expand Down Expand Up @@ -144,10 +110,10 @@ private AVLNode insert(AVLNode avlNode, int key, int index, int level) {
treeAnimationStates.add(treeAnimationState);

if (key < avlNode.key) {
avlNode.left = insert(avlNode.left, key, index - level, level / 2);
avlNode.left = _insert(avlNode.left, key, index - level, level / 2);
}
else if (key > avlNode.key) {
avlNode.right = insert(avlNode.right, key, index + level, level / 2);
avlNode.right = _insert(avlNode.right, key, index + level, level / 2);
}

avlNode.height = 1 + max(height(avlNode.left), height(avlNode.right));
Expand Down Expand Up @@ -351,10 +317,10 @@ else if(avlNode.left != null && avlNode.right != null){
int diff;
diff = height(ret.left) - height(ret.right);

return rotateDel(ret, key, diff, index, level);
return rotateDel(ret, diff, index, level);
}

AVLNode rotateDel(AVLNode avlNode, int key, int diff, int index, int level) {
private AVLNode rotateDel(AVLNode avlNode, int diff, int index, int level) {
System.out.println("in = " + index + " | lev = " + level);

// Node deleted from Right Subtree, diff = +2
Expand Down Expand Up @@ -401,18 +367,14 @@ else if(bf == 0){
return avlNode;
}

AVLNode rotate(AVLNode avlNode, int key, int diff, int index, int level) {
private AVLNode rotate(AVLNode avlNode, int key, int diff, int index, int level) {
System.out.println("in = " + index + " | lev = " + level);

if(diff >= -1 && diff <= 1){
System.out.println("no rotation needed :p");
return avlNode;
}

// TreeAnimationState treeAnimationState = new TreeAnimationState("R");
// treeAnimationState.add(new TreeElementAnimationData(avlNode.key, avlNode.count, index));
// treeAnimationStates.add(treeAnimationState);

//LL
if (diff > 1 && key < avlNode.left.key) {
System.out.println("Left Left");
Expand Down Expand Up @@ -443,7 +405,7 @@ AVLNode rotate(AVLNode avlNode, int key, int diff, int index, int level) {
return avlNode;
}

AVLNode rightRotate(AVLNode avlNode, int index, int level) {
private AVLNode rightRotate(AVLNode avlNode, int index, int level) {

TreeAnimationState treeAnimationState = new TreeAnimationState("R");
treeAnimationState.add(new TreeElementAnimationData(avlNode.key, avlNode.count, index));
Expand Down Expand Up @@ -600,8 +562,6 @@ AVLNode rightRotate(AVLNode avlNode, int index, int level) {
treeAnimationStates.add(step2);
treeAnimationStates.add(step3);



// Perform rotation
left.right = avlNode;
avlNode.left = temp;
Expand All @@ -613,7 +573,7 @@ AVLNode rightRotate(AVLNode avlNode, int index, int level) {
return left;
}

AVLNode leftRotate(AVLNode avlNode, int index, int level) {
private AVLNode leftRotate(AVLNode avlNode, int index, int level) {

TreeAnimationState treeAnimationState = new TreeAnimationState("R");
treeAnimationState.add(new TreeElementAnimationData(avlNode.key, avlNode.count, index));
Expand Down Expand Up @@ -771,7 +731,6 @@ AVLNode leftRotate(AVLNode avlNode, int index, int level) {
treeAnimationStates.add(step2);
treeAnimationStates.add(step3);


// Perform rotation
right.left = avlNode;
avlNode.right = temp;
Expand All @@ -783,16 +742,6 @@ AVLNode leftRotate(AVLNode avlNode, int index, int level) {
return right;
}

AVLNode minimum(AVLNode avlNode) {
AVLNode iterate = avlNode;

while (iterate.left != null) {
iterate = iterate.left;
}

return iterate;
}

public void inorder(){
treeAnimationStates = new ArrayList<>();
_inorder(root, baseIndex, baseLevel);
Expand Down
Loading

0 comments on commit 67e86e2

Please sign in to comment.