diff --git a/app/app-release.apk b/app/app-release.apk index 88e9e003a7b3..157e35c667ce 100644 Binary files a/app/app-release.apk and b/app/app-release.apk differ diff --git a/app/build.gradle b/app/build.gradle index 984e84c48e6a..76159c1538cb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "openfoodfacts.github.scrachx.openfood" minSdkVersion 15 targetSdkVersion 23 - versionCode 19 - versionName "0.2.1" + versionCode 20 + versionName "0.2.2" } dexOptions { @@ -56,10 +56,10 @@ apply plugin: 'com.neenbedankt.android-apt' dependencies { - compile 'com.android.support:appcompat-v7:23.3.0' - compile 'com.android.support:support-v4:23.3.0' + compile 'com.android.support:appcompat-v7:23.4.0' + compile 'com.android.support:support-v4:23.4.0' compile 'com.android.support:multidex:1.0.1' - compile 'com.android.support:recyclerview-v7:23.3.0' + compile 'com.android.support:recyclerview-v7:23.4.0' compile 'com.jakewharton:butterknife:7.0.1' diff --git a/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/MainActivity.java b/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/MainActivity.java index 56deedc85f76..b07e222b0b6c 100644 --- a/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/MainActivity.java +++ b/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/MainActivity.java @@ -7,8 +7,12 @@ import android.support.v4.app.FragmentManager; import android.support.v7.widget.Toolbar; import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.widget.CompoundButton; + +import com.afollestad.materialdialogs.MaterialDialog; import com.mikepenz.fastadapter.utils.RecyclerViewCacheUtil; import com.mikepenz.fontawesome_typeface_library.FontAwesome; import com.mikepenz.materialdrawer.AccountHeader; @@ -184,4 +188,25 @@ public void onBackPressed() { } } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + switch (item.getItemId()) { + case R.id.action_about: + new MaterialDialog.Builder(this) + .title(R.string.action_about) + .content(R.string.txtAbout) + .negativeText(R.string.txtOk) + .show(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } } diff --git a/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/ProductActivity.java b/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/ProductActivity.java index 35671d047803..13be1e756250 100644 --- a/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/ProductActivity.java +++ b/app/src/main/java/openfoodfacts/github/scrachx/openfood/views/ProductActivity.java @@ -1,6 +1,7 @@ package openfoodfacts.github.scrachx.openfood.views; import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import android.support.v4.app.NavUtils; import android.support.v4.view.MenuItemCompat; @@ -25,6 +26,7 @@ public class ProductActivity extends BaseActivity { private ShareActionProvider mShareActionProvider; private ProductPagerAdapter adapterResult; private List mAllergens; + private State mState; @Bind(R.id.pager) ViewPager viewPager; @Bind(R.id.toolbar) Toolbar toolbar; @@ -44,10 +46,10 @@ protected void onCreate(Bundle savedInstanceState) { viewPager.setAdapter(adapterResult); Intent intent = getIntent(); - State state = (State) intent.getExtras().getSerializable("state"); + mState = (State) intent.getExtras().getSerializable("state"); - List all = (List) state.getProduct().getAllergensHierarchy(); - List traces = (List) state.getProduct().getTracesTags(); + List all = (List) mState.getProduct().getAllergensHierarchy(); + List traces = (List) mState.getProduct().getTracesTags(); all.addAll(traces); List matchAll = new ArrayList(); for (int a = 0; a < mAllergens.size(); a++) { @@ -77,24 +79,29 @@ public boolean onOptionsItemSelected(MenuItem item) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; + case R.id.action_edit_product: + String url = Utils.getUriProductByCurrentLanguage() + mState.getProduct().getCode(); + if (mState.getProduct().getUrl() != null) { + url = " " + mState.getProduct().getUrl(); + } + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + startActivity(browserIntent); + default: + return super.onOptionsItemSelected(item); } - return super.onOptionsItemSelected(item); } @Override public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.menu_product_share, menu); + getMenuInflater().inflate(R.menu.menu_product, menu); MenuItem item = menu.findItem(R.id.menu_item_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); - Intent intent = getIntent(); - State state = (State) intent.getExtras().getSerializable("state"); - Intent shareIntent = new Intent(Intent.ACTION_SEND); - String url = " " + Utils.getUriProductByCurrentLanguage() + state.getProduct().getCode(); - if (state.getProduct().getUrl() != null) { - url = " " + state.getProduct().getUrl(); + String url = " " + Utils.getUriProductByCurrentLanguage() + mState.getProduct().getCode(); + if (mState.getProduct().getUrl() != null) { + url = " " + mState.getProduct().getUrl(); } shareIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.msg_share) + url); shareIntent.setType("text/plain"); diff --git a/app/src/main/res/menu/menu_product_share.xml b/app/src/main/res/menu/menu_product.xml similarity index 63% rename from app/src/main/res/menu/menu_product_share.xml rename to app/src/main/res/menu/menu_product.xml index 51180cc2c8ff..37edf9e0322a 100644 --- a/app/src/main/res/menu/menu_product_share.xml +++ b/app/src/main/res/menu/menu_product.xml @@ -7,4 +7,9 @@ android:title="@string/share" app:actionProviderClass="android.support.v7.widget.ShareActionProvider" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 467d0d1a95a8..0dd31dfc89a7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -144,6 +144,7 @@ Data may not be accurate, be careful, please check by yourself! From gallery Product sent! + Edit product