Skip to content

Commit 08a75f0

Browse files
committed
Initial commit
0 parents  commit 08a75f0

39 files changed

Lines changed: 1097 additions & 0 deletions

.gitignore

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
*.iml
2+
local.properties
3+
.idea
4+
.gradle
5+
#/.idea/workspace.xml
6+
#/.idea/libraries
7+
.DS_Store
8+
build
9+
captures
10+
app/mirror
11+
ShortcutBadger/
12+
projectFilesBackup/
13+
.externalNativeBuild
14+
instapk.log*
15+
app/release
16+
app/debug
17+
18+
### Windows template
19+
# Windows thumbnail cache files
20+
Thumbs.db
21+
ehthumbs.db
22+
ehthumbs_vista.db
23+
24+
# Folder config file
25+
Desktop.ini
26+
27+
# Recycle Bin used on file shares
28+
$RECYCLE.BIN/
29+
30+
# Windows Installer files
31+
*.cab
32+
*.msi
33+
*.msm
34+
*.msp
35+
36+
# Windows shortcuts
37+
*.lnk
38+
### Android template
39+
# Built application files
40+
# Files for the ART/Dalvik VM
41+
# Java class files
42+
# Generated files
43+
bin/
44+
gen/
45+
out/
46+
47+
# Local configuration file (sdk path, etc)
48+
49+
# Proguard folder generated by Eclipse
50+
# Log Files
51+
# Android Studio Navigation editor temp files
52+
.navigation/
53+
54+
# Android Studio captures folder
55+
captures/
56+
57+
# Intellij
58+
.idea/tasks.xml
59+
# Keystore files
60+
# *.jks
61+
62+
# External native build folder generated in Android Studio 2.2 and later
63+
64+
# Google Services (e.g. APIs or Firebase)
65+
# google-services.json
66+
67+
# Freeline
68+
freeline.py
69+
freeline/
70+
freeline_project_description.json
71+
### macOS template
72+
.AppleDouble
73+
.LSOverride
74+
75+
# Icon must end with two \r
76+
Icon
77+
78+
79+
# Thumbnails
80+
._*
81+
82+
# Files that might appear in the root of a volume
83+
.DocumentRevisions-V100
84+
.fseventsd
85+
.Spotlight-V100
86+
.TemporaryItems
87+
.Trashes
88+
.VolumeIcon.icns
89+
.com.apple.timemachine.donotpresent
90+
91+
# Directories potentially created on remote AFP share
92+
.AppleDB
93+
.AppleDesktop
94+
Network Trash Folder
95+
Temporary Items
96+
.apdisk
97+
### Java template
98+
# Compiled class file
99+
100+
# Log file
101+
102+
# BlueJ files
103+
*.ctxt
104+
105+
# Mobile Tools for Java (J2ME)
106+
.mtj.tmp/
107+
108+
# Package Files #
109+
#*.jar
110+
*.war
111+
*.ear
112+
*.zip
113+
*.tar.gz
114+
*.rar
115+
116+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
117+
hs_err_pid*
118+
### Linux template
119+
*~
120+
121+
# temporary files which can be created if a process still has a handle open of a deleted file
122+
.fuse_hidden*
123+
124+
# KDE directory preferences
125+
.directory
126+
127+
# Linux trash folder which might appear on any partition or disk
128+
.Trash-*
129+
130+
# .nfs files are created when an open file is removed but is still being accessed
131+
.nfs*
132+
### JetBrains template
133+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
134+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
135+
136+
# User-specific stuff:
137+
.idea/**/tasks.xml
138+
139+
# Sensitive or high-churn files:
140+
.idea/**/dataSources/
141+
.idea/**/dataSources.ids
142+
.idea/**/dataSources.xml
143+
.idea/**/dataSources.local.xml
144+
.idea/**/sqlDataSources.xml
145+
.idea/**/dynamic.xml
146+
.idea/**/uiDesigner.xml
147+
148+
# Gradle:
149+
# Mongo Explorer plugin:
150+
.idea/**/mongoSettings.xml
151+
152+
## File-based project format:
153+
*.iws
154+
155+
## Plugin-specific files:
156+
157+
# IntelliJ
158+
/out/
159+
160+
# mpeltonen/sbt-idea plugin
161+
.idea_modules/
162+
163+
# JIRA plugin
164+
atlassian-ide-plugin.xml
165+
166+
# Crashlytics plugin (for Android Studio and IntelliJ)
167+
com_crashlytics_export_strings.xml
168+
crashlytics.properties
169+
fabric.properties
170+
171+
# Instapk
172+
instapk.properties
173+
.idea/instapk.xml

.hgignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
.idea/instapk.xml
3+
instapk.log*

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 27
5+
defaultConfig {
6+
applicationId "hendrawd.storageutil"
7+
minSdkVersion 15
8+
targetSdkVersion 27
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
implementation fileTree(dir: 'libs', include: ['*.jar'])
23+
implementation project(path: ':library')
24+
implementation 'com.android.support:appcompat-v7:27.1.1'
25+
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
26+
testImplementation 'junit:junit:4.12'
27+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
28+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
29+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package hendrawd.storageutil;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("hendrawd.storageutil", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="hendrawd.storageutil">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
<activity android:name=".MainActivity">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN"/>
15+
16+
<category android:name="android.intent.category.LAUNCHER"/>
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package hendrawd.storageutil;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.text.Html;
6+
import android.text.Spanned;
7+
import android.util.TypedValue;
8+
import android.widget.TextView;
9+
10+
import hendrawd.storageutil.library.StorageUtil;
11+
12+
public class MainActivity extends AppCompatActivity {
13+
14+
private static final float TEXT_SIZE_IN_SP = 25;
15+
private static final float PADDING_IN_DP = 16;
16+
private static final float LINE_SPACING_EXTRA_IN_DP = 8;
17+
private static final float LINE_SPACING_MULTIPLIER = 1;
18+
19+
@Override
20+
protected void onCreate(Bundle savedInstanceState) {
21+
super.onCreate(savedInstanceState);
22+
final String[] availableExternalStorages = StorageUtil.getStorageDirectories(this);
23+
final TextView tvContent = new TextView(this);
24+
tvContent.setTextSize(TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE_IN_SP);
25+
tvContent.setLineSpacing(getLineSpacingExtra(), LINE_SPACING_MULTIPLIER);
26+
final int paddingInPixel = (int) getPadding();
27+
tvContent.setPadding(paddingInPixel, paddingInPixel, paddingInPixel, paddingInPixel);
28+
29+
final StringBuilder sbContent = new StringBuilder(getBoldHtmlString("Available external storages:"));
30+
for (String availableExternalStorage : availableExternalStorages) {
31+
sbContent.append("<br/>").append(availableExternalStorage);
32+
}
33+
tvContent.setText(fromHtml(sbContent.toString()));
34+
setContentView(tvContent);
35+
}
36+
37+
private float getPadding() {
38+
return dp2px(PADDING_IN_DP);
39+
}
40+
41+
private float getLineSpacingExtra() {
42+
return dp2px(LINE_SPACING_EXTRA_IN_DP);
43+
}
44+
45+
private float dp2px(float dp) {
46+
return TypedValue.applyDimension(
47+
TypedValue.COMPLEX_UNIT_DIP,
48+
dp,
49+
getResources().getDisplayMetrics()
50+
);
51+
}
52+
53+
private String getBoldHtmlString(String string) {
54+
return "<b>" + string + "</b>";
55+
}
56+
57+
@SuppressWarnings("deprecation")
58+
public static Spanned fromHtml(String htmlString) {
59+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
60+
return Html.fromHtml(htmlString, Html.FROM_HTML_MODE_LEGACY);
61+
} else {
62+
return Html.fromHtml(htmlString);
63+
}
64+
}
65+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportHeight="108"
6+
android:viewportWidth="108">
7+
<path
8+
android:fillType="evenOdd"
9+
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
10+
android:strokeColor="#00000000"
11+
android:strokeWidth="1">
12+
<aapt:attr name="android:fillColor">
13+
<gradient
14+
android:endX="78.5885"
15+
android:endY="90.9159"
16+
android:startX="48.7653"
17+
android:startY="61.0927"
18+
android:type="linear">
19+
<item
20+
android:color="#44000000"
21+
android:offset="0.0"/>
22+
<item
23+
android:color="#00000000"
24+
android:offset="1.0"/>
25+
</gradient>
26+
</aapt:attr>
27+
</path>
28+
<path
29+
android:fillColor="#FFFFFF"
30+
android:fillType="nonZero"
31+
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
32+
android:strokeColor="#00000000"
33+
android:strokeWidth="1"/>
34+
</vector>

0 commit comments

Comments
 (0)