Skip to content

Commit 848d89b

Browse files
committed
zoom in and out, show file detail and small preview
1 parent faf40e2 commit 848d89b

File tree

8 files changed

+96
-19
lines changed

8 files changed

+96
-19
lines changed
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
package com.katcom.androidFileVault;
22

3-
public abstract class PreviewMode {
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class PreviewMode {
47
final public static String FILE_DETAIL = "File Detail";
58
final public static String PREVIEW_SMALL = "Preview Small";
69
final public static String PREVIEW_MEDIUM = "Preview Medium";
710
final public static String PREVIEW_BIG = "Preview Big";
11+
private static List<String> modes;
12+
13+
private PreviewMode(){}
14+
15+
static {
16+
modes = new ArrayList<>();
17+
modes.add(FILE_DETAIL);
18+
modes.add(PREVIEW_SMALL);
19+
}
20+
21+
public static List<String> getModeList(){
22+
return modes;
23+
}
24+
public static int getModeCount(){
25+
return modes.size();
26+
}
827

928
}

app/src/main/java/com/katcom/androidFileVault/VaultFragment.java

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import android.view.MenuItem;
1414
import android.view.View;
1515
import android.view.ViewGroup;
16+
import android.widget.Button;
1617
import android.widget.TextView;
1718

1819
import java.io.File;
@@ -23,10 +24,14 @@ public class VaultFragment extends Fragment {
2324
private NavigationView mNavigation;
2425
private RecyclerView mFileRecyclerView;
2526
private RecyclerView.Adapter mAdapter;
26-
private FileAdapterPreviewSmall mAdapterPreviewSmall;
27+
private Button mZoomInButton;
28+
private Button mZoomOutButton;
2729
private FileVault mVault;
2830

2931
private String mPreviewMode;
32+
private List<String> modes = PreviewMode.getModeList();
33+
private int currentModeIndex = 0;
34+
3035
@Override
3136
public void onCreate(Bundle savedInstanceState) {
3237
super.onCreate(savedInstanceState);
@@ -56,10 +61,42 @@ public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
5661
mVault = FileVault.get(this.getContext());
5762
mPreviewMode = PreviewMode.PREVIEW_SMALL;
5863
updateUI();
59-
//updateUI();
64+
65+
mZoomInButton = view.findViewById(R.id.button_zoom_in);
66+
mZoomInButton.setOnClickListener(new View.OnClickListener() {
67+
@Override
68+
public void onClick(View v) {
69+
chooseBiggerItemLayout();
70+
}
71+
});
72+
73+
mZoomInButton = view.findViewById(R.id.button_zoom_out);
74+
mZoomInButton.setOnClickListener(new View.OnClickListener() {
75+
@Override
76+
public void onClick(View v) {
77+
chooseSmallerItemLayout();
78+
}
79+
});
6080
return view;
6181
}
6282

83+
private void chooseSmallerItemLayout() {
84+
if(currentModeIndex > 0){
85+
currentModeIndex --;
86+
mPreviewMode = modes.get(currentModeIndex);
87+
}
88+
updateUI();
89+
}
90+
91+
private void chooseBiggerItemLayout() {
92+
if(currentModeIndex < modes.size()-1){
93+
currentModeIndex ++;
94+
mPreviewMode = modes.get(currentModeIndex);
95+
}
96+
updateUI();
97+
}
98+
99+
63100
private void copySampleFiles() {
64101
File file = new File(this.getContext().getFilesDir() + "/" + FileVault.sVaultDirectory);
65102
if(!file.exists()){
@@ -78,6 +115,8 @@ private void updateUI() {
78115
showSmallPreview(files);
79116
break;
80117
}
118+
currentModeIndex = modes.indexOf(mPreviewMode);
119+
81120
/* original code
82121
List<ProtectedFile> files = mVault.getFiles();
83122
mAdapter = new FileAdapterFileDetail(files);
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3-
4-
</selector>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item
4+
android:top="-2dp"
5+
android:left="-2dp"
6+
android:right="-2dp">
7+
<shape android:shape="rectangle">
8+
<solid android:color="@android:color/transparent" />
9+
<stroke android:color="@android:color/darker_gray"
10+
android:width="1dp"/>
11+
<corners android:radius="4dp"/>
12+
</shape>
13+
</item>
14+
</layer-list>

app/src/main/res/layout/fragment_vault.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@
1818
android:orientation="horizontal">
1919

2020
<Button
21-
android:id="@+id/button"
21+
android:id="@+id/button_sort"
2222
android:layout_width="wrap_content"
2323
android:layout_height="wrap_content"
2424
android:layout_weight="1"
2525
android:text="Sort" />
2626

2727
<Button
28-
android:id="@+id/button2"
28+
android:id="@+id/button_zoom_in"
2929
android:layout_width="wrap_content"
3030
android:layout_height="wrap_content"
3131
android:layout_weight="1"
3232
android:text="Zoom in" />
3333

3434
<Button
35-
android:id="@+id/button3"
35+
android:id="@+id/button_zoom_out"
3636
android:layout_width="wrap_content"
3737
android:layout_height="wrap_content"
3838
android:layout_weight="1"
Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
4-
android:layout_width="wrap_content"
5-
android:layout_height="wrap_content">
6-
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:layout_marginBottom="10dp"
7+
android:background="@drawable/item_file_detail"
8+
android:padding="5dp">
9+
<ImageView
10+
android:layout_width="50dp"
11+
android:layout_height="50dp"
12+
android:layout_marginRight="10dp"
13+
android:src="@drawable/ic_launcher_background"/>
714
<TextView
815
android:id="@+id/file_preview_filename_name_text_view"
916
android:layout_width="wrap_content"
10-
android:layout_height="wrap_content"
11-
android:text="TextView" />
12-
</LinearLayout>
17+
android:layout_height="30dp"
18+
android:textSize="25dp"
19+
android:ellipsize="middle"
20+
android:text="TextView"
21+
/>
22+
</LinearLayout>

app/src/main/res/layout/item_file_preview_small.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
<ImageView
1111
android:id="@+id/file_preview_image_view"
12-
android:layout_width="50dp"
13-
android:layout_height="50dp"
12+
android:layout_width="60dp"
13+
android:layout_height="60dp"
1414
android:src="@drawable/ic_launcher_background"/>
1515
<TextView
1616
android:id="@+id/file_preview_filename_text_view"

app/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
<color name="colorBackgroundBlue">#2196F3</color>
77
<color name="colorButtonWhite">#FFFFFF</color>
88
<color name="colorPasswordInput">#F0F0F0</color>
9+
<color name="colorDarkGray">#1111</color>
910
</resources>

app/src/main/res/values/textSizes.xml

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)