Merge remote-tracking branch 'origin/develop'

This commit is contained in:
ChronosX88 2019-02-16 19:44:03 +04:00
commit aed3cfb794
No known key found for this signature in database
GPG Key ID: 8F92E090A87804AA
21 changed files with 209 additions and 17 deletions

View File

@ -3,6 +3,135 @@
<component name="WizardSettings"> <component name="WizardSettings">
<option name="children"> <option name="children">
<map> <map>
<entry key="imageWizard">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="imageAssetPanel">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="actionbar">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipArt">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="image">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="assetType" value="IMAGE" />
<entry key="imageAsset" value="$PROJECT_DIR$/app/src/main/res/drawable/no-images.png" />
<entry key="outputName" value="img_no_images" />
<entry key="theme" value="HOLO_DARK" />
<entry key="themeColor" value="ffffff" />
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="launcher">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="foregroundImage">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="launcherLegacy">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipArt">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="notification">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipArt">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="outputIconType" value="ACTIONBAR" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="vectorWizard"> <entry key="vectorWizard">
<value> <value>
<PersistentState> <PersistentState>

Binary file not shown.

View File

@ -6,8 +6,8 @@ android {
applicationId "ru.volgorobot.vrcatalog" applicationId "ru.volgorobot.vrcatalog"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 27 targetSdkVersion 27
versionCode 4 versionCode 5
versionName "0.3" versionName "0.3.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
compileOptions { compileOptions {

View File

@ -41,6 +41,8 @@
<action android:name="android.intent.action.SEARCH" /> <action android:name="android.intent.action.SEARCH" />
</intent-filter> </intent-filter>
</activity> </activity>
<provider android:name=".additional.RecentSuggestionProvider"
android:authorities="ru.volgorobot.vrcatalog.additional.RecentSuggestionProvider" />
</application> </application>
</manifest> </manifest>

View File

@ -15,9 +15,11 @@ import com.squareup.picasso.Picasso;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import ru.volgorobot.vrcatalog.R;
public class ImagePagerAdapter extends PagerAdapter { public class ImagePagerAdapter extends PagerAdapter {
/** /**
* This class is designed to control the ViewPager (images of item) in the activity of viewing details of items. * This class is designed to control the ViewPager (images of item) in the activity of viewing details of items (DetailActivity).
*/ */
private Context context; private Context context;
@ -26,6 +28,10 @@ public class ImagePagerAdapter extends PagerAdapter {
public ImagePagerAdapter(Context context, String[] imageUris) { public ImagePagerAdapter(Context context, String[] imageUris) {
this.context = context; this.context = context;
this.imageUris = imageUris; this.imageUris = imageUris;
if(this.imageUris.length == 0) {
this.imageUris = new String[1];
this.imageUris[0] = Uri.parse("android.resource://ru.volgorobot.vrcatalog/" + R.drawable.no_images).toString();
}
} }
@Override @Override

View File

@ -0,0 +1,12 @@
package ru.volgorobot.vrcatalog.additional;
import android.content.SearchRecentSuggestionsProvider;
public class RecentSuggestionProvider extends SearchRecentSuggestionsProvider {
public final static String AUTHORITY = "ru.volgorobot.vrcatalog.additional.RecentSuggestionProvider";
public final static int MODE = DATABASE_MODE_QUERIES;
public RecentSuggestionProvider() {
setupSuggestions(AUTHORITY, MODE);
}
}

View File

@ -9,7 +9,7 @@ import me.texy.treeview.TreeNode;
import me.texy.treeview.base.BaseNodeViewBinder; import me.texy.treeview.base.BaseNodeViewBinder;
import ru.volgorobot.vrcatalog.MainContract; import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;
import ru.volgorobot.vrcatalog.ViewBinderPresenter; import ru.volgorobot.vrcatalog.presenters.ViewBinderPresenter;
import ru.volgorobot.vrcatalog.model.FirstLevelModel; import ru.volgorobot.vrcatalog.model.FirstLevelModel;
public class FirstLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder { public class FirstLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {

View File

@ -9,7 +9,7 @@ import me.texy.treeview.TreeNode;
import me.texy.treeview.base.BaseNodeViewBinder; import me.texy.treeview.base.BaseNodeViewBinder;
import ru.volgorobot.vrcatalog.MainContract; import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;
import ru.volgorobot.vrcatalog.ViewBinderPresenter; import ru.volgorobot.vrcatalog.presenters.ViewBinderPresenter;
import ru.volgorobot.vrcatalog.model.SecondLevelModel; import ru.volgorobot.vrcatalog.model.SecondLevelModel;
public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder { public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {

View File

@ -8,7 +8,7 @@ import me.texy.treeview.TreeNode;
import me.texy.treeview.base.BaseNodeViewBinder; import me.texy.treeview.base.BaseNodeViewBinder;
import ru.volgorobot.vrcatalog.MainContract; import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;
import ru.volgorobot.vrcatalog.ViewBinderPresenter; import ru.volgorobot.vrcatalog.presenters.ViewBinderPresenter;
import ru.volgorobot.vrcatalog.model.ThirdLevelModel; import ru.volgorobot.vrcatalog.model.ThirdLevelModel;
public class ThirdLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder { public class ThirdLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {

View File

@ -1,4 +1,4 @@
package ru.volgorobot.vrcatalog; package ru.volgorobot.vrcatalog.presenters;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
@ -15,6 +15,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.additional.NetworkErrorException; import ru.volgorobot.vrcatalog.additional.NetworkErrorException;
import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode; import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode;
import ru.volgorobot.vrcatalog.model.CoreModel; import ru.volgorobot.vrcatalog.model.CoreModel;

View File

@ -1,10 +1,11 @@
package ru.volgorobot.vrcatalog; package ru.volgorobot.vrcatalog.presenters;
import android.content.Context; import android.content.Context;
import android.os.AsyncTask; import android.os.AsyncTask;
import java.util.ArrayList; import java.util.ArrayList;
import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.additional.NetworkErrorException; import ru.volgorobot.vrcatalog.additional.NetworkErrorException;
import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode; import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode;
import ru.volgorobot.vrcatalog.model.CoreModel; import ru.volgorobot.vrcatalog.model.CoreModel;

View File

@ -1,4 +1,4 @@
package ru.volgorobot.vrcatalog; package ru.volgorobot.vrcatalog.presenters;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
@ -7,6 +7,7 @@ import android.os.AsyncTask;
import java.util.ArrayList; import java.util.ArrayList;
import me.texy.treeview.TreeNode; import me.texy.treeview.TreeNode;
import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.additional.NetworkErrorException; import ru.volgorobot.vrcatalog.additional.NetworkErrorException;
import ru.volgorobot.vrcatalog.model.CoreModel; import ru.volgorobot.vrcatalog.model.CoreModel;
import ru.volgorobot.vrcatalog.model.FirstLevelModel; import ru.volgorobot.vrcatalog.model.FirstLevelModel;

View File

@ -1,4 +1,4 @@
package ru.volgorobot.vrcatalog; package ru.volgorobot.vrcatalog.presenters;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -7,6 +7,7 @@ import android.os.AsyncTask;
import java.util.ArrayList; import java.util.ArrayList;
import me.texy.treeview.TreeNode; import me.texy.treeview.TreeNode;
import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.additional.NetworkErrorException; import ru.volgorobot.vrcatalog.additional.NetworkErrorException;
import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode; import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode;
import ru.volgorobot.vrcatalog.model.CoreModel; import ru.volgorobot.vrcatalog.model.CoreModel;

View File

@ -7,8 +7,6 @@ import android.os.Bundle;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.MenuItem; import android.view.MenuItem;
@ -21,7 +19,7 @@ import android.widget.Toast;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import ru.volgorobot.vrcatalog.ItemPresenter; import ru.volgorobot.vrcatalog.presenters.ItemPresenter;
import ru.volgorobot.vrcatalog.MainContract; import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;
import ru.volgorobot.vrcatalog.additional.ImagePagerAdapter; import ru.volgorobot.vrcatalog.additional.ImagePagerAdapter;

View File

@ -30,7 +30,7 @@ import java.util.ArrayList;
import me.texy.treeview.TreeNode; import me.texy.treeview.TreeNode;
import me.texy.treeview.TreeView; import me.texy.treeview.TreeView;
import ru.volgorobot.vrcatalog.MainContract; import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.MainPresenter; import ru.volgorobot.vrcatalog.presenters.MainPresenter;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;
import ru.volgorobot.vrcatalog.additional.NodeViewFactory; import ru.volgorobot.vrcatalog.additional.NodeViewFactory;
import ru.volgorobot.vrcatalog.model.FirstLevelModel; import ru.volgorobot.vrcatalog.model.FirstLevelModel;

View File

@ -3,6 +3,7 @@ package ru.volgorobot.vrcatalog.view;
import android.app.SearchManager; import android.app.SearchManager;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.provider.SearchRecentSuggestions;
import android.support.v4.widget.NestedScrollView; import android.support.v4.widget.NestedScrollView;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
@ -20,7 +21,8 @@ import me.texy.treeview.TreeNode;
import me.texy.treeview.TreeView; import me.texy.treeview.TreeView;
import ru.volgorobot.vrcatalog.MainContract; import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;
import ru.volgorobot.vrcatalog.SearchablePresenter; import ru.volgorobot.vrcatalog.presenters.SearchablePresenter;
import ru.volgorobot.vrcatalog.additional.RecentSuggestionProvider;
import ru.volgorobot.vrcatalog.additional.SearchableNodeViewFactory; import ru.volgorobot.vrcatalog.additional.SearchableNodeViewFactory;
import ru.volgorobot.vrcatalog.model.FirstLevelModel; import ru.volgorobot.vrcatalog.model.FirstLevelModel;
@ -59,6 +61,9 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
detailName = intent.getStringExtra(SearchManager.QUERY); detailName = intent.getStringExtra(SearchManager.QUERY);
getSupportActionBar().setTitle("Поиск: " + detailName); getSupportActionBar().setTitle("Поиск: " + detailName);
searchablePresenter.fetchDetailsTreeByName(detailName); searchablePresenter.fetchDetailsTreeByName(detailName);
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
RecentSuggestionProvider.AUTHORITY, RecentSuggestionProvider.MODE);
suggestions.saveRecentQuery(detailName, null);
} }
} }

View File

@ -1,10 +1,15 @@
package ru.volgorobot.vrcatalog.view; package ru.volgorobot.vrcatalog.view;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference;
import android.provider.SearchRecentSuggestions;
import android.view.MenuItem; import android.view.MenuItem;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;
import ru.volgorobot.vrcatalog.additional.AppCompatPreferenceActivity; import ru.volgorobot.vrcatalog.additional.AppCompatPreferenceActivity;
import ru.volgorobot.vrcatalog.additional.RecentSuggestionProvider;
public class SettingsActivity extends AppCompatPreferenceActivity { public class SettingsActivity extends AppCompatPreferenceActivity {
@ -15,6 +20,32 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setHomeButtonEnabled(true);
Preference clearSearchHistoryButton = findPreference("clearSearchHistoryButton");
clearSearchHistoryButton.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this)
.setTitle("Подтвердите действие")
.setMessage("Вы уверены, что хотите очистить историю вашего поиска?")
.setPositiveButton("ОК", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(SettingsActivity.this,
RecentSuggestionProvider.AUTHORITY, RecentSuggestionProvider.MODE);
suggestions.clearHistory();
}
})
.setNegativeButton("Отмена", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// Nothing to do
}
});
dialogBuilder.show();
return true;
}
});
} }
@Override @Override

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:background="?android:selectableItemBackground"> android:background="?android:selectableItemBackground">

View File

@ -5,4 +5,7 @@
android:title="Адрес API-сервера" android:title="Адрес API-сервера"
android:summary="API-сервер необходим для доступа к БД деталей" android:summary="API-сервер необходим для доступа к БД деталей"
android:defaultValue="http://example.com"/> android:defaultValue="http://example.com"/>
<Preference
android:title="Очистить историю поиска"
android:key="clearSearchHistoryButton"/>
</PreferenceScreen> </PreferenceScreen>

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android" <searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name" android:label="@string/app_name"
android:hint="Поиск деталей по имени" > android:hint="Поиск деталей по имени"
android:searchSuggestAuthority="ru.volgorobot.vrcatalog.additional.RecentSuggestionProvider"
android:searchSuggestSelection=" ?" >
</searchable> </searchable>