remove retrolambda and upgrade support library

This commit is contained in:
Mohamed Zenadi 2015-06-09 23:52:46 +02:00
parent a118a196be
commit 83281a1d91
3 changed files with 93 additions and 64 deletions

View file

@ -14,8 +14,8 @@ android {
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_7
} }
// avoid Travis failures // avoid Travis failures
@ -25,8 +25,8 @@ android {
} }
dependencies { dependencies {
compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.0.0' compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'org.sufficientlysecure:openpgp-api:7.0' compile 'org.sufficientlysecure:openpgp-api:7.0'
compile 'org.eclipse.jgit:org.eclipse.jgit:3.7.0.201502260915-r' compile 'org.eclipse.jgit:org.eclipse.jgit:3.7.0.201502260915-r'
compile 'com.jcraft:jsch:0.1.52' compile 'com.jcraft:jsch:0.1.52'
@ -40,7 +40,4 @@ tasks.findAll { // make all tasks whose name starts with 'assemble'...
it.name.startsWith 'assemble' it.name.startsWith 'assemble'
}.each { // ... depending on 'copyDependenciesIntoLibs' task from 'copyLibs.gradle' script plugin }.each { // ... depending on 'copyDependenciesIntoLibs' task from 'copyLibs.gradle' script plugin
it.dependsOn copyDependenciesIntoLibs it.dependsOn copyDependenciesIntoLibs
} }
apply plugin: 'com.android.application' //or apply plugin: 'java'
apply plugin: 'me.tatarka.retrolambda'

View file

@ -1,6 +1,7 @@
package com.zeapo.pwdstore; package com.zeapo.pwdstore;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
@ -12,6 +13,7 @@ import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.Toast; import android.widget.Toast;
import com.google.common.base.Function;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -54,35 +56,52 @@ public class UserPreference extends AppCompatActivity {
} else { } else {
keyPref.setSummary( keyPref.setSummary(
Joiner.on(',') Joiner.on(',')
.join(Iterables.transform(Arrays.asList(selectedKeys.split(",")), input -> OpenPgpUtils.convertKeyIdToHex(Long.valueOf(input)))) .join(Iterables.transform(Arrays.asList(selectedKeys.split(",")), new Function<String, Object>() {
@Override
public Object apply(String input) {
return OpenPgpUtils.convertKeyIdToHex(Long.valueOf(input));
}
}))
); );
} }
keyPref.setOnPreferenceClickListener((Preference pref) -> { keyPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
Intent intent = new Intent(callingActivity, PgpHandler.class); @Override
intent.putExtra("Operation", "GET_KEY_ID"); public boolean onPreferenceClick(Preference preference) {
startActivityForResult(intent, IMPORT_PGP_KEY); Intent intent = new Intent(callingActivity, PgpHandler.class);
return true; intent.putExtra("Operation", "GET_KEY_ID");
startActivityForResult(intent, IMPORT_PGP_KEY);
return true;
}
}); });
findPreference("ssh_key").setOnPreferenceClickListener((Preference pref) -> { findPreference("ssh_key").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
callingActivity.getSshKey(); @Override
return true; public boolean onPreferenceClick(Preference preference) {
callingActivity.getSshKey();
return true;
}
}); });
findPreference("git_server_info").setOnPreferenceClickListener((Preference pref) -> { findPreference("git_server_info").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
Intent intent = new Intent(callingActivity, GitActivity.class); @Override
intent.putExtra("Operation", GitActivity.EDIT_SERVER); public boolean onPreferenceClick(Preference preference) {
startActivityForResult(intent, EDIT_GIT_INFO); Intent intent = new Intent(callingActivity, GitActivity.class);
return true; intent.putExtra("Operation", GitActivity.EDIT_SERVER);
startActivityForResult(intent, EDIT_GIT_INFO);
return true;
}
}); });
findPreference("git_delete_repo").setOnPreferenceClickListener((Preference pref) -> { findPreference("git_delete_repo").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
new AlertDialog.Builder(callingActivity). @Override
setTitle(R.string.pref_dialog_delete_title). public boolean onPreferenceClick(Preference preference) {
setMessage(R.string.pref_dialog_delete_msg). new AlertDialog.Builder(callingActivity).
setCancelable(false). setTitle(R.string.pref_dialog_delete_title).
setPositiveButton(R.string.dialog_delete, setMessage(R.string.pref_dialog_delete_msg).
(dialog, id) -> { setCancelable(false).
setPositiveButton(R.string.dialog_delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
try { try {
FileUtils.cleanDirectory(PasswordRepository.getWorkTree()); FileUtils.cleanDirectory(PasswordRepository.getWorkTree());
} catch (Exception e) { } catch (Exception e) {
@ -90,39 +109,55 @@ public class UserPreference extends AppCompatActivity {
} }
sharedPreferences.edit().putBoolean("repository_initialized", false).commit(); sharedPreferences.edit().putBoolean("repository_initialized", false).commit();
dialog.cancel(); dialogInterface.cancel();
callingActivity.finish(); callingActivity.finish();
} }
). }).
setNegativeButton(R.string.dialog_do_not_delete, setNegativeButton(R.string.dialog_do_not_delete,
(dialog, id) -> { new DialogInterface.OnClickListener() {
dialog.cancel(); @Override
} public void onClick(DialogInterface dialogInterface, int i) {
). {
show(); dialogInterface.cancel();
return true; }
}
}).show();
return true;
}
}); });
callingActivity.mKey = (OpenPgpKeyPreference) findPreference("openpgp_key"); callingActivity.mKey = (OpenPgpKeyPreference) findPreference("openpgp_key");
if (sharedPreferences.getString("openpgp_provider_list", null) != null)
((UserPreference) getActivity()).mKey.setOpenPgpProvider(sharedPreferences.getString("openpgp_provider_list", ""));
findPreference("openpgp_provider_list").setOnPreferenceChangeListener((preference, o) -> { if (sharedPreferences.getString("openpgp_provider_list", null) != null) {
callingActivity.mKey.setOpenPgpProvider((String) o); ((UserPreference) getActivity()).mKey.setOpenPgpProvider(sharedPreferences.getString("openpgp_provider_list", ""));
return true; }
findPreference("openpgp_provider_list").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
callingActivity.mKey.setOpenPgpProvider((String) o);
return true;
}
}); });
final Preference externalRepo = findPreference("pref_select_external"); final Preference externalRepo = findPreference("pref_select_external");
externalRepo.setSummary(getPreferenceManager().getSharedPreferences().getString("git_external_repo", "No external repository selected")); externalRepo.setSummary(getPreferenceManager().getSharedPreferences().getString("git_external_repo", "No external repository selected"));
externalRepo.setOnPreferenceClickListener((Preference pref) -> { externalRepo.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
callingActivity.selectExternalGitRepository(); @Override
return true; public boolean onPreferenceClick(Preference preference) {
callingActivity.selectExternalGitRepository();
return true;
}
}); });
Preference.OnPreferenceChangeListener resetRepo = (preference, o) -> { Preference.OnPreferenceChangeListener resetRepo = new Preference.OnPreferenceChangeListener() {
PasswordRepository.closeRepository(); @Override
getPreferenceManager().getSharedPreferences().edit().putBoolean("repo_changed", true).apply(); public boolean onPreferenceChange(Preference preference, Object o) {
return true; PasswordRepository.closeRepository();
getPreferenceManager().getSharedPreferences().edit().putBoolean("repo_changed", true).apply();
return true;
}
}; };
findPreference("pref_select_external").setOnPreferenceChangeListener(resetRepo); findPreference("pref_select_external").setOnPreferenceChangeListener(resetRepo);
@ -194,10 +229,8 @@ public class UserPreference extends AppCompatActivity {
protected void onActivityResult(int requestCode, int resultCode, protected void onActivityResult(int requestCode, int resultCode,
Intent data) { Intent data) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
switch (requestCode) switch (requestCode) {
{ case IMPORT_SSH_KEY: {
case IMPORT_SSH_KEY:
{
try { try {
if (data.getData() == null) { if (data.getData() == null) {
throw new IOException("Unable to open file"); throw new IOException("Unable to open file");
@ -206,24 +239,24 @@ public class UserPreference extends AppCompatActivity {
Toast.makeText(this, this.getResources().getString(R.string.ssh_key_success_dialog_title), Toast.LENGTH_LONG).show(); Toast.makeText(this, this.getResources().getString(R.string.ssh_key_success_dialog_title), Toast.LENGTH_LONG).show();
setResult(RESULT_OK); setResult(RESULT_OK);
finish(); finish();
} catch (IOException e) } catch (IOException e) {
{
new AlertDialog.Builder(this). new AlertDialog.Builder(this).
setTitle(this.getResources().getString(R.string.ssh_key_error_dialog_title)). setTitle(this.getResources().getString(R.string.ssh_key_error_dialog_title)).
setMessage(this.getResources().getString(R.string.ssh_key_error_dialog_text) + e.getMessage()). setMessage(this.getResources().getString(R.string.ssh_key_error_dialog_text) + e.getMessage()).
setPositiveButton(this.getResources().getString(R.string.dialog_ok), (dialogInterface, i) -> { setPositiveButton(this.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
//pass @Override
public void onClick(DialogInterface dialogInterface, int i) {
// pass
}
}).show(); }).show();
} }
} }
break; break;
case EDIT_GIT_INFO: case EDIT_GIT_INFO: {
{
} }
break; break;
case OpenPgpKeyPreference.REQUEST_CODE_KEY_PREFERENCE: case OpenPgpKeyPreference.REQUEST_CODE_KEY_PREFERENCE: {
{
if (mKey.handleOnActivityResult(requestCode, resultCode, data)) { if (mKey.handleOnActivityResult(requestCode, resultCode, data)) {
// handled by OpenPgpKeyPreference // handled by OpenPgpKeyPreference
PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()).edit().putLong("openpgp_sign_key", mKey.getValue()).apply(); PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()).edit().putLong("openpgp_sign_key", mKey.getValue()).apply();
@ -232,7 +265,7 @@ public class UserPreference extends AppCompatActivity {
} }
break; break;
default: default:
break; break;
} }
} }

View file

@ -7,7 +7,6 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'me.tatarka:gradle-retrolambda:3.1.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files