Skip to content

Commit c7a6cc9

Browse files
committed
added splash and handled android marshmellow permissions
1 parent 32bd548 commit c7a6cc9

File tree

23 files changed

+96
-30
lines changed

23 files changed

+96
-30
lines changed

.idea/misc.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.filebrowser.amit_gupta.filebrowser">
4+
45
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
6+
57
<application
68
android:allowBackup="true"
79
android:icon="@mipmap/file_browser2"
@@ -12,6 +14,11 @@
1214
android:name=".FileBrowser"
1315
android:label="@string/app_name"
1416
android:theme="@style/AppTheme.NoActionBar">
17+
</activity>
18+
<activity android:name=".SplashActivity"
19+
android:screenOrientation="portrait"
20+
android:theme="@android:style/Theme.Black.NoTitleBar"
21+
>
1522
<intent-filter>
1623
<action android:name="android.intent.action.MAIN" />
1724

app/src/main/java/com/filebrowser/amit_gupta/filebrowser/FileBrowser.java

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import android.net.Uri;
77
import android.os.Bundle;
88
import android.os.Environment;
9-
import android.support.design.widget.FloatingActionButton;
109
import android.support.design.widget.NavigationView;
11-
import android.support.design.widget.Snackbar;
1210
import android.support.v4.view.GravityCompat;
1311
import android.support.v4.widget.DrawerLayout;
1412
import android.support.v7.app.ActionBarDrawerToggle;
@@ -47,15 +45,6 @@ protected void onCreate(Bundle savedInstanceState) {
4745
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
4846
setSupportActionBar(toolbar);
4947

50-
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
51-
fab.setOnClickListener(new View.OnClickListener() {
52-
@Override
53-
public void onClick(View view) {
54-
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
55-
.setAction("Action", null).show();
56-
}
57-
});
58-
5948
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
6049
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
6150
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
@@ -75,8 +64,10 @@ public void onClick(View view) {
7564
file = new File(root_sd);
7665
File list[] = file.listFiles();
7766

78-
for (int i = 0; i < list.length; i++) {
79-
myList.add(list[i].getName());
67+
if(list != null && list.length > 0) {
68+
for (int i = 0; i < list.length; i++) {
69+
myList.add(list[i].getName());
70+
}
8071
}
8172

8273
listView.setAdapter(new ArrayAdapter(this,
@@ -94,16 +85,17 @@ public void onBackPressed() {
9485
if(parent != null) {
9586
file = new File(parent);
9687
File list[] = file.listFiles();
97-
98-
myList.clear();
99-
100-
for (int i = 0; i < list.length; i++) {
101-
myList.add(list[i].getName());
88+
if(list != null && list.length > 0) {
89+
myList.clear();
90+
91+
for (int i = 0; i < list.length; i++) {
92+
myList.add(list[i].getName());
93+
}
94+
//Toast.makeText(getApplicationContext(), parent, Toast.LENGTH_SHORT).show();
95+
textView.setText(parent);
96+
listView.setAdapter(new ArrayAdapter(this,
97+
android.R.layout.simple_list_item_1, myList));
10298
}
103-
//Toast.makeText(getApplicationContext(), parent, Toast.LENGTH_SHORT).show();
104-
textView.setText(parent);
105-
listView.setAdapter(new ArrayAdapter(this,
106-
android.R.layout.simple_list_item_1, myList));
10799
}else {
108100
Toast.makeText(getApplicationContext(),"AT THE ROOT Folder, press one more back to Exit App", Toast.LENGTH_SHORT).show();
109101
if(System.currentTimeMillis() - timeStamp < 200){
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.filebrowser.amit_gupta.filebrowser;
2+
3+
import android.app.Activity;
4+
import android.content.Intent;
5+
import android.os.Bundle;
6+
import android.os.Handler;
7+
8+
public class SplashActivity extends Activity {
9+
10+
/** Duration of wait **/
11+
private final int SPLASH_DISPLAY_LENGTH = 1000;
12+
13+
/** Called when the activity is first created. */
14+
@Override
15+
public void onCreate(Bundle icicle) {
16+
super.onCreate(icicle);
17+
setContentView(R.layout.activity_splash);
18+
19+
/* New Handler to start the Menu-Activity
20+
* and close this Splash-Screen after some seconds.*/
21+
new Handler().postDelayed(new Runnable() {
22+
@Override
23+
public void run() {
24+
/* Create an Intent that will start the Menu-Activity. */
25+
Intent mainIntent = new Intent(SplashActivity.this, FileBrowser.class);
26+
SplashActivity.this.startActivity(mainIntent);
27+
SplashActivity.this.finish();
28+
}
29+
}, SPLASH_DISPLAY_LENGTH);
30+
}
31+
}
5.34 KB
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:background="@android:color/white" >
6+
7+
<ImageView
8+
android:id="@+id/imgLogo"
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content"
11+
android:layout_centerInParent="true"
12+
android:src="@drawable/splash" />
13+
14+
<TextView
15+
android:layout_width="fill_parent"
16+
android:layout_height="wrap_content"
17+
android:layout_marginTop="10dp"
18+
android:textSize="20dp"
19+
android:textColor="#454545"
20+
android:gravity="center_horizontal"
21+
android:layout_below="@+id/imgLogo"
22+
android:text="File Explorer" />
23+
24+
</RelativeLayout>

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323

2424
<include layout="@layout/content_file_browser" />
2525

26-
<android.support.design.widget.FloatingActionButton
27-
android:id="@+id/fab"
28-
android:layout_width="wrap_content"
29-
android:layout_height="wrap_content"
30-
android:layout_gravity="bottom|end"
31-
android:layout_margin="@dimen/fab_margin"
32-
android:src="@android:drawable/ic_dialog_email" />
26+
<!--<android.support.design.widget.FloatingActionButton-->
27+
<!--android:id="@+id/fab"-->
28+
<!--android:layout_width="wrap_content"-->
29+
<!--android:layout_height="wrap_content"-->
30+
<!--android:layout_gravity="bottom|end"-->
31+
<!--android:layout_margin="@dimen/fab_margin"-->
32+
<!--android:src="@android:drawable/ic_dialog_email" />-->
3333

3434
</android.support.design.widget.CoordinatorLayout>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
tools:showIn="@layout/app_bar_file_browser">
1414

1515
<TextView
16-
android:layout_width="wrap_content"
16+
android:layout_width="fill_parent"
1717
android:layout_height="wrap_content"
18+
android:padding="5dp"
19+
android:textStyle="bold"
20+
android:background="@color/colorGrey"
21+
android:textColor="@color/colorPrimaryDark"
1822
android:id="@+id/text1"
1923
android:text="Hello World!" />
2024
<ListView xmlns:android="http://schemas.android.com/apk/res/android"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
<color name="colorPrimary">#3F51B5</color>
44
<color name="colorPrimaryDark">#303F9F</color>
55
<color name="colorAccent">#FF4081</color>
6+
<color name="colorGrey">#D3D3D3</color>
67
</resources>

raw/1.png

105 KB
Loading

0 commit comments

Comments
 (0)