Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: hjort/android-toys
base: 51f05866e5
...
head fork: hjort/android-toys
compare: e19e3b799c
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
1  ListaCompras/.classpath
@@ -4,5 +4,6 @@
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="lib" path="lib/marketlicense.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
View
3  ListaCompras/AndroidManifest.xml
@@ -19,4 +19,7 @@
</activity>
</application>
+ <!-- Required permission to check licensing. -->
+<!-- <uses-permission android:name="com.android.vending.CHECK_LICENSE" /> -->
+
</manifest>
View
BIN  ListaCompras/lib/marketlicense.jar
Binary file not shown
View
12 ListaCompras/res/values/strings.xml
@@ -23,5 +23,17 @@
<item>Frutas e Verduras</item>
<item>Outros</item>
</string-array>
+
+ <!-- License checking status messages -->
+ <string name="checking_license">Verificando licença...</string>
+ <string name="dont_allow">Não permite acesso ao usuário</string>
+ <string name="allow">Permite acesso ao usuário</string>
+ <string name="application_error">Erro de Aplicação: %1$s</string>
+ <!-- Unlicensed dialog messages -->
+ <string name="unlicensed_dialog_title">Aplicação não licenciada</string>
+ <string name="unlicensed_dialog_body">Esta aplicação não está licenciada. Por favor adquira-a usando o Android Market.</string>
+ <string name="buy_button">Comprar</string>
+ <string name="quit_button">Sair</string>
+
</resources>
View
109 ListaCompras/src/co/hjort/apps/compras/view/ListaCompras.java
@@ -2,9 +2,20 @@
import java.util.List;
+/*
+import com.android.vending.licensing.AESObfuscator;
+import com.android.vending.licensing.LicenseChecker;
+import com.android.vending.licensing.LicenseCheckerCallback;
+import com.android.vending.licensing.ServerManagedPolicy;
+*/
+
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
+/*
+import android.os.Handler;
+import android.provider.Settings.Secure;
+*/
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -23,6 +34,7 @@
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.Toast;
+
import co.hjort.apps.compras.domain.Produto;
import co.hjort.apps.compras.persistence.ProdutoDAO;
@@ -46,6 +58,18 @@
private int codigoSecao;
private int qtdeProdutos;
+
+ /*
+ private static final String BASE64_PUBLIC_KEY = "...";
+
+ private static final byte[] SALT = new byte[] { -46, 64, 30, -118, -103, -47, 74, -64, 41, 88, -94, -44, 77, -117, -36, -113, -11, 31, -64, 89 };
+
+ private LicenseChecker mChecker;
+ private LicenseCheckerCallback mLicenseCheckerCallback;
+
+ // a handler on the UI thread
+ private Handler mHandler;
+ */
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -59,12 +83,12 @@ protected void onCreate(Bundle savedInstanceState) {
spnSecao.setAdapter(adapter);
spnSecao.setOnItemSelectedListener(new OnItemSelectedListener() {
-// @Override
+ @Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
popularItensSecao(pos + 1);
}
-// @Override
+ @Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
@@ -73,14 +97,14 @@ public void onNothingSelected(AdapterView<?> parent) {
btnIncluir = (Button) findViewById(R.id.incluir);
btnIncluir.setOnClickListener(new OnClickListener() {
-// @Override
+ @Override
public void onClick(View v) {
incluirProduto();
}
});
txtProduto.setOnKeyListener(new OnKeyListener() {
-// @Override
+ @Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN)
&& (keyCode == KeyEvent.KEYCODE_ENTER)) {
@@ -97,8 +121,32 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
checkItemListener = new CheckItemListener();
dao = ProdutoDAO.getInstance(this);
+
+ /*
+ mHandler = new Handler();
+
+ final String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
+
+ // library calls this when it's done
+ mLicenseCheckerCallback = new MyLicenseCheckerCallback();
+
+ // construct the license checker with a policy
+ mChecker = new LicenseChecker(this, new ServerManagedPolicy(this,
+ new AESObfuscator(SALT, getPackageName(), deviceId)), BASE64_PUBLIC_KEY);
+
+ // check the license
+ doCheckLicense();
+ */
}
+ /*
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mChecker.onDestroy();
+ }
+ */
+
private void popularItensSecao(int secao) {
codigoSecao = secao;
qtdeProdutos = 0;
@@ -132,7 +180,7 @@ private void popularItensSecao(int secao) {
private class RemoverItemListener implements OnClickListener {
-// @Override
+ @Override
public void onClick(View view) {
int id = view.getId();
if (dao.excluir(id)) {
@@ -146,7 +194,7 @@ public void onClick(View view) {
private class CheckItemListener implements OnCheckedChangeListener {
-// @Override
+ @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
dao.marcar(buttonView.getId(), isChecked);
}
@@ -184,8 +232,9 @@ private void incluirProduto() {
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
- menu.add(0, MENU_MARCAR_TODOS, 0, R.string.menu_marcar_todos);
- menu.add(0, MENU_DESMARCAR_TODOS, 0, R.string.menu_desmarcar_todos);
+ // FIXME: readicionar esses itens do menu
+// menu.add(0, MENU_MARCAR_TODOS, 0, R.string.menu_marcar_todos);
+// menu.add(0, MENU_DESMARCAR_TODOS, 0, R.string.menu_desmarcar_todos);
menu.add(0, MENU_EXCLUIR_TODOS, 0, R.string.menu_excluir_todos);
return true;
@@ -222,4 +271,48 @@ public boolean onOptionsItemSelected(MenuItem item) {
return false;
}
+ /*
+ private void doCheckLicense() {
+ mChecker.checkAccess(mLicenseCheckerCallback);
+ setProgressBarIndeterminateVisibility(true);
+ Toast.makeText(getApplication(), R.string.checking_license, Toast.LENGTH_LONG);
+ mChecker.checkAccess(mLicenseCheckerCallback);
+ }
+
+ private class MyLicenseCheckerCallback implements LicenseCheckerCallback {
+
+ @Override
+ public void allow() {
+ if (isFinishing()) {
+ return;
+ }
+ displayResult(getString(R.string.allow));
+ }
+
+ @Override
+ public void dontAllow() {
+ if (isFinishing()) {
+ return;
+ }
+ displayResult(getString(R.string.dont_allow));
+ showDialog(0);
+ }
+
+ @Override
+ public void applicationError(ApplicationErrorCode errorCode) {
+ // TODO Auto-generated method stub
+ }
+
+ }
+
+ private void displayResult(final String result) {
+ mHandler.post(new Runnable() {
+ public void run() {
+ Toast.makeText(getApplication(), result, Toast.LENGTH_LONG);
+ setProgressBarIndeterminateVisibility(false);
+ }
+ });
+ }
+ */
+
}

No commit comments for this range

Something went wrong with that request. Please try again.