Skip to content

Commit 850ff06

Browse files
Merge pull request #17 from jonasrottmann/develop
Prepared version 0.0.12
2 parents 0f3fdba + 9a97f67 commit 850ff06

12 files changed

+104
-11
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ The project is available via [JitPack.io](https://jitpack.io/#jonasrottmann/real
2727
2. **Add the dependency**
2828
```
2929
dependencies {
30-
debugCompile 'com.github.jonasrottmann.realm-browser:realm-browser:0.0.11'
31-
testCompile 'com.github.jonasrottmann.realm-browser:realm-browser-no-op:0.0.11'
32-
releaseCompile 'com.github.jonasrottmann.realm-browser:realm-browser-no-op:0.0.11'
30+
debugCompile 'com.github.jonasrottmann.realm-browser:realm-browser:0.0.12'
31+
testCompile 'com.github.jonasrottmann.realm-browser:realm-browser-no-op:0.0.12'
32+
releaseCompile 'com.github.jonasrottmann.realm-browser:realm-browser-no-op:0.0.12'
3333
}
3434
```
3535
The no-op version of Realm Browser has empty functions which do nothing. It is not necessary to include this, but you may if you do not want to access Realm Browser in release mode. If you want to use a build of the newest development use `compile "com.github.jonasrottmann.realm-browser:realm-browser:develop-SNAPSHOT"` instead.
3636

3737
3. Exclude support libraries (maybe optional): Realm Browser depends on Android support libraries, so you might want to exclude them from your project if they conflict with the ones you include:
3838
```
3939
depedencies {
40-
debugCompile ('com.github.jonasrottmann.realm-browser:realm-browser:0.0.11') {
40+
debugCompile ('com.github.jonasrottmann.realm-browser:realm-browser:0.0.12') {
4141
exclude group: 'com.android.support';
4242
}
4343
}

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ buildscript {
1111

1212
// plugins
1313
androidGradlePluginVersion = '2.3.1'
14-
realmVersion = '3.1.2'
14+
realmVersion = '3.1.4'
1515
dexcountVersion = '0.6.4'
1616

1717
// dependencies

realm-browser/src/main/java/de/jonasrottmann/realmbrowser/files/FilesPresenter.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
import java.util.ArrayList;
88

9+
import de.jonasrottmann.realmbrowser.R;
910
import de.jonasrottmann.realmbrowser.basemvp.BasePresenterImpl;
1011
import de.jonasrottmann.realmbrowser.files.model.FilesPojo;
1112
import de.jonasrottmann.realmbrowser.helper.RealmHolder;
1213
import de.jonasrottmann.realmbrowser.models.view.ModelsActivity;
1314
import io.realm.Realm;
1415
import io.realm.RealmConfiguration;
16+
import io.realm.exceptions.RealmFileException;
1517
import io.realm.exceptions.RealmMigrationNeededException;
1618

1719
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@@ -47,12 +49,17 @@ public void onFileSelected(FilesPojo item) {
4749
} catch (RealmMigrationNeededException e) {
4850
if (isViewAttached()) {
4951
//noinspection ConstantConditions
50-
getView().showToast("RealmMigrationNeededException");
52+
getView().showToast(String.format("%s %s", getView().getViewContext().getString(R.string.realm_browser_open_error), getView().getViewContext().getString(R.string.realm_browser_error_migration)));
53+
}
54+
} catch (RealmFileException e) {
55+
if (isViewAttached()) {
56+
//noinspection ConstantConditions
57+
getView().showToast(String.format("%s %s", getView().getViewContext().getString(R.string.realm_browser_open_error), e.getMessage()));
5158
}
5259
} catch (Exception e) {
5360
if (isViewAttached()) {
5461
//noinspection ConstantConditions
55-
getView().showToast("Can't open realm instance. You must close all open realm instances before opening this file.");
62+
getView().showToast(String.format("%s %s", getView().getViewContext().getString(R.string.realm_browser_open_error), getView().getViewContext().getString(R.string.realm_browser_error_openinstances)));
5663
}
5764
}
5865
}

realm-browser/src/main/java/de/jonasrottmann/realmbrowser/models/ModelsContract.java

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import de.jonasrottmann.realmbrowser.basemvp.BaseInteractor;
1212
import de.jonasrottmann.realmbrowser.basemvp.BasePresenter;
1313
import de.jonasrottmann.realmbrowser.basemvp.BaseView;
14+
import de.jonasrottmann.realmbrowser.models.model.InformationPojo;
1415
import de.jonasrottmann.realmbrowser.models.model.ModelPojo;
1516

1617
import static java.lang.annotation.RetentionPolicy.SOURCE;
@@ -30,6 +31,8 @@ interface View extends BaseView<Presenter> {
3031
Context getViewContext();
3132

3233
void presentShareDialog(@NonNull String path);
34+
35+
void showInformation(@NonNull InformationPojo informationPojo);
3336
}
3437

3538
interface Presenter extends BasePresenter<View> {
@@ -43,9 +46,13 @@ interface Presenter extends BasePresenter<View> {
4346

4447
void onFilterChanged(@NonNull String filter);
4548

49+
void onInformationSelected();
50+
4651
void updateWithModels(@NonNull ArrayList<ModelPojo> modelsList, @SortMode int sortMode);
4752

4853
void presentShareDialog(@NonNull String path);
54+
55+
void showInformation(@NonNull InformationPojo informationPojo);
4956
}
5057

5158
interface Interactor extends BaseInteractor {
@@ -56,5 +63,7 @@ interface Interactor extends BaseInteractor {
5663
void updateWithSortModeChanged();
5764

5865
void onShareSelected();
66+
67+
void onInformationSelected();
5968
}
6069
}

realm-browser/src/main/java/de/jonasrottmann/realmbrowser/models/ModelsInteractor.java

+12
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
import android.support.annotation.Nullable;
55
import android.support.annotation.RestrictTo;
66

7+
import java.io.File;
78
import java.util.ArrayList;
89
import java.util.Collections;
910
import java.util.Comparator;
1011

1112
import de.jonasrottmann.realmbrowser.basemvp.BaseInteractorImpl;
1213
import de.jonasrottmann.realmbrowser.helper.RealmHolder;
14+
import de.jonasrottmann.realmbrowser.models.model.InformationPojo;
1315
import de.jonasrottmann.realmbrowser.models.model.ModelPojo;
1416
import io.realm.Realm;
1517
import io.realm.RealmModel;
@@ -47,6 +49,16 @@ public void updateWithSortModeChanged() {
4749
public void onShareSelected() {
4850
getPresenter().presentShareDialog(RealmHolder.getInstance().getRealmConfiguration().getPath());
4951
}
52+
53+
@Override
54+
public void onInformationSelected() {
55+
File realmFile = new File(RealmHolder.getInstance().getRealmConfiguration().getPath());
56+
long sizeInByte = 0;
57+
if (realmFile.exists() && !realmFile.isDirectory()) {
58+
sizeInByte = realmFile.length();
59+
}
60+
getPresenter().showInformation(new InformationPojo(sizeInByte, realmFile.getPath()));
61+
}
5062
//endregion
5163

5264
//region Helper

realm-browser/src/main/java/de/jonasrottmann/realmbrowser/models/ModelsPresenter.java

+14
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import de.jonasrottmann.realmbrowser.basemvp.BasePresenterImpl;
99
import de.jonasrottmann.realmbrowser.browser.view.RealmBrowserActivity;
10+
import de.jonasrottmann.realmbrowser.models.model.InformationPojo;
1011
import de.jonasrottmann.realmbrowser.models.model.ModelPojo;
1112

1213
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@@ -33,6 +34,11 @@ public void onFilterChanged(@NonNull String filter) {
3334
interactor.updateWithFilter(filter);
3435
}
3536

37+
@Override
38+
public void onInformationSelected() {
39+
interactor.onInformationSelected();
40+
}
41+
3642
@Override
3743
public void onModelSelected(ModelPojo item) {
3844
if (isViewAttached()) {
@@ -63,5 +69,13 @@ public void presentShareDialog(@NonNull String path) {
6369
getView().presentShareDialog(path);
6470
}
6571
}
72+
73+
@Override
74+
public void showInformation(@NonNull InformationPojo informationPojo) {
75+
if (isViewAttached()) {
76+
//noinspection ConstantConditions
77+
getView().showInformation(informationPojo);
78+
}
79+
}
6680
//endregion
6781
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package de.jonasrottmann.realmbrowser.models.model;
2+
3+
import android.support.annotation.RestrictTo;
4+
5+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
6+
public class InformationPojo {
7+
private final long sizeInByte;
8+
private final String path;
9+
10+
public InformationPojo(long sizeInByte, String path) {
11+
this.sizeInByte = sizeInByte;
12+
this.path = path;
13+
}
14+
15+
public long getSizeInByte() {
16+
return sizeInByte;
17+
}
18+
19+
public String getPath() {
20+
return path;
21+
}
22+
}

realm-browser/src/main/java/de/jonasrottmann/realmbrowser/models/view/ModelsActivity.java

+11
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
import android.support.v7.widget.RecyclerView;
1616
import android.support.v7.widget.SearchView;
1717
import android.support.v7.widget.Toolbar;
18+
import android.text.format.Formatter;
1819
import android.view.Menu;
1920
import android.view.MenuInflater;
2021
import android.view.MenuItem;
22+
import android.widget.Toast;
2123

2224
import java.io.File;
2325
import java.util.ArrayList;
@@ -26,6 +28,7 @@
2628
import de.jonasrottmann.realmbrowser.helper.RealmHolder;
2729
import de.jonasrottmann.realmbrowser.models.ModelsContract;
2830
import de.jonasrottmann.realmbrowser.models.ModelsPresenter;
31+
import de.jonasrottmann.realmbrowser.models.model.InformationPojo;
2932
import de.jonasrottmann.realmbrowser.models.model.ModelPojo;
3033

3134
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@@ -122,6 +125,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
122125
} else if (item.getItemId() == R.id.realm_browser_action_share) {
123126
presenter.onShareSelected();
124127
return true;
128+
} else if (item.getItemId() == R.id.realm_browser_action_info) {
129+
presenter.onInformationSelected();
130+
return true;
125131
} else {
126132
return super.onOptionsItemSelected(item);
127133
}
@@ -164,6 +170,11 @@ public void presentShareDialog(@NonNull String path) {
164170
startActivity(Intent.createChooser(intentShareFile, "Share Realm File"));
165171
}
166172

173+
@Override
174+
public void showInformation(@NonNull InformationPojo informationPojo) {
175+
Toast.makeText(this, String.format("%s\nSize: %s", informationPojo.getPath(), Formatter.formatShortFileSize(this, informationPojo.getSizeInByte())), Toast.LENGTH_LONG).show();
176+
}
177+
167178
@Override
168179
protected void onDestroy() {
169180
super.onDestroy();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportHeight="24"
5+
android:viewportWidth="24">
6+
<path
7+
android:fillColor="#FFFFFF"
8+
android:pathData="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z"/>
9+
</vector>

realm-browser/src/main/res/layout/realm_browser_toolbar.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
android:layout_height="?attr/actionBarSize"
77
android:background="?attr/colorPrimary"
88
android:elevation="8dp"
9-
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
9+
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
1010
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

realm-browser/src/main/res/menu/realm_browser_menu_modelsactivity.xml

+9-3
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@
77
android:icon="@drawable/realm_browser_ic_search_white_24dp"
88
android:title="@string/realm_browser_action_filter"
99
app:actionViewClass="android.support.v7.widget.SearchView"
10-
app:showAsAction="ifRoom"/>
10+
app:showAsAction="always"/>
1111

1212
<item
1313
android:id="@+id/realm_browser_action_sort"
1414
android:icon="@drawable/realm_browser_ic_sort_ascending_white_24dp"
1515
android:title="Sort"
1616
app:showAsAction="always"/>
1717

18+
<item
19+
android:id="@+id/realm_browser_action_info"
20+
android:icon="@drawable/realm_browser_ic_information_outline_white_24dp"
21+
android:title="File Information"
22+
app:showAsAction="ifRoom"/>
23+
1824
<item
1925
android:id="@+id/realm_browser_action_share"
2026
android:icon="@drawable/realm_browser_ic_share_white_24dp"
21-
android:title="Share Realm File"
22-
app:showAsAction="always"/>
27+
android:title="Share File"
28+
app:showAsAction="ifRoom"/>
2329

2430
</menu>

realm-browser/src/main/res/values/realm_browser_strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<string translatable="true" name="realm_browser_action_filter">Filter</string>
88
<string translatable="true" name="realm_browser_action_delete">Delete</string>
99
<string translatable="true" name="realm_browser_action_save">Save</string>
10+
<string translatable="true" name="realm_browser_open_error">Can\'t open realm instance.</string>
11+
<string translatable="true" name="realm_browser_error_openinstances">Make sure to close all open realm instances before opening this file.</string>
12+
<string translatable="true" name="realm_browser_error_migration">Migration needed.</string>
1013

1114
<string-array name="realm_browser_boolean">
1215
<item>true</item>

0 commit comments

Comments
 (0)