Skip to content

Commit

Permalink
Merge pull request #17 from jonasrottmann/develop
Browse files Browse the repository at this point in the history
Prepared version 0.0.12
  • Loading branch information
jonasrottmann authored May 11, 2017
2 parents 0f3fdba + 9a97f67 commit 850ff06
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ The project is available via [JitPack.io](https://jitpack.io/#jonasrottmann/real
2. **Add the dependency**
```
dependencies {
debugCompile 'com.github.jonasrottmann.realm-browser:realm-browser:0.0.11'
testCompile 'com.github.jonasrottmann.realm-browser:realm-browser-no-op:0.0.11'
releaseCompile 'com.github.jonasrottmann.realm-browser:realm-browser-no-op:0.0.11'
debugCompile 'com.github.jonasrottmann.realm-browser:realm-browser:0.0.12'
testCompile 'com.github.jonasrottmann.realm-browser:realm-browser-no-op:0.0.12'
releaseCompile 'com.github.jonasrottmann.realm-browser:realm-browser-no-op:0.0.12'
}
```
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.

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:
```
depedencies {
debugCompile ('com.github.jonasrottmann.realm-browser:realm-browser:0.0.11') {
debugCompile ('com.github.jonasrottmann.realm-browser:realm-browser:0.0.12') {
exclude group: 'com.android.support';
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {

// plugins
androidGradlePluginVersion = '2.3.1'
realmVersion = '3.1.2'
realmVersion = '3.1.4'
dexcountVersion = '0.6.4'

// dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

import java.util.ArrayList;

import de.jonasrottmann.realmbrowser.R;
import de.jonasrottmann.realmbrowser.basemvp.BasePresenterImpl;
import de.jonasrottmann.realmbrowser.files.model.FilesPojo;
import de.jonasrottmann.realmbrowser.helper.RealmHolder;
import de.jonasrottmann.realmbrowser.models.view.ModelsActivity;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.exceptions.RealmFileException;
import io.realm.exceptions.RealmMigrationNeededException;

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
Expand Down Expand Up @@ -47,12 +49,17 @@ public void onFileSelected(FilesPojo item) {
} catch (RealmMigrationNeededException e) {
if (isViewAttached()) {
//noinspection ConstantConditions
getView().showToast("RealmMigrationNeededException");
getView().showToast(String.format("%s %s", getView().getViewContext().getString(R.string.realm_browser_open_error), getView().getViewContext().getString(R.string.realm_browser_error_migration)));
}
} catch (RealmFileException e) {
if (isViewAttached()) {
//noinspection ConstantConditions
getView().showToast(String.format("%s %s", getView().getViewContext().getString(R.string.realm_browser_open_error), e.getMessage()));
}
} catch (Exception e) {
if (isViewAttached()) {
//noinspection ConstantConditions
getView().showToast("Can't open realm instance. You must close all open realm instances before opening this file.");
getView().showToast(String.format("%s %s", getView().getViewContext().getString(R.string.realm_browser_open_error), getView().getViewContext().getString(R.string.realm_browser_error_openinstances)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import de.jonasrottmann.realmbrowser.basemvp.BaseInteractor;
import de.jonasrottmann.realmbrowser.basemvp.BasePresenter;
import de.jonasrottmann.realmbrowser.basemvp.BaseView;
import de.jonasrottmann.realmbrowser.models.model.InformationPojo;
import de.jonasrottmann.realmbrowser.models.model.ModelPojo;

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

void presentShareDialog(@NonNull String path);

void showInformation(@NonNull InformationPojo informationPojo);
}

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

void onFilterChanged(@NonNull String filter);

void onInformationSelected();

void updateWithModels(@NonNull ArrayList<ModelPojo> modelsList, @SortMode int sortMode);

void presentShareDialog(@NonNull String path);

void showInformation(@NonNull InformationPojo informationPojo);
}

interface Interactor extends BaseInteractor {
Expand All @@ -56,5 +63,7 @@ interface Interactor extends BaseInteractor {
void updateWithSortModeChanged();

void onShareSelected();

void onInformationSelected();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import de.jonasrottmann.realmbrowser.basemvp.BaseInteractorImpl;
import de.jonasrottmann.realmbrowser.helper.RealmHolder;
import de.jonasrottmann.realmbrowser.models.model.InformationPojo;
import de.jonasrottmann.realmbrowser.models.model.ModelPojo;
import io.realm.Realm;
import io.realm.RealmModel;
Expand Down Expand Up @@ -47,6 +49,16 @@ public void updateWithSortModeChanged() {
public void onShareSelected() {
getPresenter().presentShareDialog(RealmHolder.getInstance().getRealmConfiguration().getPath());
}

@Override
public void onInformationSelected() {
File realmFile = new File(RealmHolder.getInstance().getRealmConfiguration().getPath());
long sizeInByte = 0;
if (realmFile.exists() && !realmFile.isDirectory()) {
sizeInByte = realmFile.length();
}
getPresenter().showInformation(new InformationPojo(sizeInByte, realmFile.getPath()));
}
//endregion

//region Helper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import de.jonasrottmann.realmbrowser.basemvp.BasePresenterImpl;
import de.jonasrottmann.realmbrowser.browser.view.RealmBrowserActivity;
import de.jonasrottmann.realmbrowser.models.model.InformationPojo;
import de.jonasrottmann.realmbrowser.models.model.ModelPojo;

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

@Override
public void onInformationSelected() {
interactor.onInformationSelected();
}

@Override
public void onModelSelected(ModelPojo item) {
if (isViewAttached()) {
Expand Down Expand Up @@ -63,5 +69,13 @@ public void presentShareDialog(@NonNull String path) {
getView().presentShareDialog(path);
}
}

@Override
public void showInformation(@NonNull InformationPojo informationPojo) {
if (isViewAttached()) {
//noinspection ConstantConditions
getView().showInformation(informationPojo);
}
}
//endregion
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package de.jonasrottmann.realmbrowser.models.model;

import android.support.annotation.RestrictTo;

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class InformationPojo {
private final long sizeInByte;
private final String path;

public InformationPojo(long sizeInByte, String path) {
this.sizeInByte = sizeInByte;
this.path = path;
}

public long getSizeInByte() {
return sizeInByte;
}

public String getPath() {
return path;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.text.format.Formatter;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;

import java.io.File;
import java.util.ArrayList;
Expand All @@ -26,6 +28,7 @@
import de.jonasrottmann.realmbrowser.helper.RealmHolder;
import de.jonasrottmann.realmbrowser.models.ModelsContract;
import de.jonasrottmann.realmbrowser.models.ModelsPresenter;
import de.jonasrottmann.realmbrowser.models.model.InformationPojo;
import de.jonasrottmann.realmbrowser.models.model.ModelPojo;

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
Expand Down Expand Up @@ -122,6 +125,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
} else if (item.getItemId() == R.id.realm_browser_action_share) {
presenter.onShareSelected();
return true;
} else if (item.getItemId() == R.id.realm_browser_action_info) {
presenter.onInformationSelected();
return true;
} else {
return super.onOptionsItemSelected(item);
}
Expand Down Expand Up @@ -164,6 +170,11 @@ public void presentShareDialog(@NonNull String path) {
startActivity(Intent.createChooser(intentShareFile, "Share Realm File"));
}

@Override
public void showInformation(@NonNull InformationPojo informationPojo) {
Toast.makeText(this, String.format("%s\nSize: %s", informationPojo.getPath(), Formatter.formatShortFileSize(this, informationPojo.getSizeInByte())), Toast.LENGTH_LONG).show();
}

@Override
protected void onDestroy() {
super.onDestroy();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#FFFFFF"
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"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="8dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@
android:icon="@drawable/realm_browser_ic_search_white_24dp"
android:title="@string/realm_browser_action_filter"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="ifRoom"/>
app:showAsAction="always"/>

<item
android:id="@+id/realm_browser_action_sort"
android:icon="@drawable/realm_browser_ic_sort_ascending_white_24dp"
android:title="Sort"
app:showAsAction="always"/>

<item
android:id="@+id/realm_browser_action_info"
android:icon="@drawable/realm_browser_ic_information_outline_white_24dp"
android:title="File Information"
app:showAsAction="ifRoom"/>

<item
android:id="@+id/realm_browser_action_share"
android:icon="@drawable/realm_browser_ic_share_white_24dp"
android:title="Share Realm File"
app:showAsAction="always"/>
android:title="Share File"
app:showAsAction="ifRoom"/>

</menu>
3 changes: 3 additions & 0 deletions realm-browser/src/main/res/values/realm_browser_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<string translatable="true" name="realm_browser_action_filter">Filter</string>
<string translatable="true" name="realm_browser_action_delete">Delete</string>
<string translatable="true" name="realm_browser_action_save">Save</string>
<string translatable="true" name="realm_browser_open_error">Can\'t open realm instance.</string>
<string translatable="true" name="realm_browser_error_openinstances">Make sure to close all open realm instances before opening this file.</string>
<string translatable="true" name="realm_browser_error_migration">Migration needed.</string>

<string-array name="realm_browser_boolean">
<item>true</item>
Expand Down

0 comments on commit 850ff06

Please sign in to comment.