diff options
author | Mohamed Zenadi <mohamed@zenadi.com> | 2015-06-09 23:52:46 +0200 |
---|---|---|
committer | Mohamed Zenadi <mohamed@zenadi.com> | 2015-06-09 23:54:20 +0200 |
commit | 83281a1d914ef7e8d4d55be073607835ad4355d1 (patch) | |
tree | 4ec3c8adb6e701917e83a03f6ee9eb8e6da17fee | |
parent | a118a196be6494ab433349c8bd047c4b3a32b662 (diff) |
remove retrolambda and upgrade support library
-rw-r--r-- | app/build.gradle | 13 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/UserPreference.java | 141 | ||||
-rw-r--r-- | build.gradle | 1 |
3 files changed, 92 insertions, 63 deletions
diff --git a/app/build.gradle b/app/build.gradle index 2868ab12..01a521d3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,8 +14,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 } // avoid Travis failures @@ -25,8 +25,8 @@ android { } dependencies { - compile 'com.android.support:appcompat-v7:22.1.1' - compile 'com.android.support:recyclerview-v7:22.0.0' + compile 'com.android.support:appcompat-v7:22.2.0' + compile 'com.android.support:recyclerview-v7:22.2.0' compile 'org.sufficientlysecure:openpgp-api:7.0' compile 'org.eclipse.jgit:org.eclipse.jgit:3.7.0.201502260915-r' 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' }.each { // ... depending on 'copyDependenciesIntoLibs' task from 'copyLibs.gradle' script plugin it.dependsOn copyDependenciesIntoLibs -} - -apply plugin: 'com.android.application' //or apply plugin: 'java' -apply plugin: 'me.tatarka.retrolambda'
\ No newline at end of file +}
\ No newline at end of file diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java index 80cafad8..e143c57c 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java @@ -1,6 +1,7 @@ package com.zeapo.pwdstore; import android.app.AlertDialog; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; @@ -12,6 +13,7 @@ import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import android.widget.Toast; +import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Strings; import com.google.common.collect.Iterables; @@ -54,35 +56,52 @@ public class UserPreference extends AppCompatActivity { } else { keyPref.setSummary( 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) -> { - Intent intent = new Intent(callingActivity, PgpHandler.class); - intent.putExtra("Operation", "GET_KEY_ID"); - startActivityForResult(intent, IMPORT_PGP_KEY); - return true; + keyPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + Intent intent = new Intent(callingActivity, PgpHandler.class); + intent.putExtra("Operation", "GET_KEY_ID"); + startActivityForResult(intent, IMPORT_PGP_KEY); + return true; + } }); - findPreference("ssh_key").setOnPreferenceClickListener((Preference pref) -> { - callingActivity.getSshKey(); - return true; + findPreference("ssh_key").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + callingActivity.getSshKey(); + return true; + } }); - findPreference("git_server_info").setOnPreferenceClickListener((Preference pref) -> { - Intent intent = new Intent(callingActivity, GitActivity.class); - intent.putExtra("Operation", GitActivity.EDIT_SERVER); - startActivityForResult(intent, EDIT_GIT_INFO); - return true; + findPreference("git_server_info").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + Intent intent = new Intent(callingActivity, GitActivity.class); + intent.putExtra("Operation", GitActivity.EDIT_SERVER); + startActivityForResult(intent, EDIT_GIT_INFO); + return true; + } }); - findPreference("git_delete_repo").setOnPreferenceClickListener((Preference pref) -> { - new AlertDialog.Builder(callingActivity). - setTitle(R.string.pref_dialog_delete_title). - setMessage(R.string.pref_dialog_delete_msg). - setCancelable(false). - setPositiveButton(R.string.dialog_delete, - (dialog, id) -> { + findPreference("git_delete_repo").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + new AlertDialog.Builder(callingActivity). + setTitle(R.string.pref_dialog_delete_title). + setMessage(R.string.pref_dialog_delete_msg). + setCancelable(false). + setPositiveButton(R.string.dialog_delete, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { try { FileUtils.cleanDirectory(PasswordRepository.getWorkTree()); } catch (Exception e) { @@ -90,39 +109,55 @@ public class UserPreference extends AppCompatActivity { } sharedPreferences.edit().putBoolean("repository_initialized", false).commit(); - dialog.cancel(); + dialogInterface.cancel(); callingActivity.finish(); } - ). - setNegativeButton(R.string.dialog_do_not_delete, - (dialog, id) -> { - dialog.cancel(); - } - ). - show(); - return true; + }). + setNegativeButton(R.string.dialog_do_not_delete, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + { + dialogInterface.cancel(); + } + } + }).show(); + + return true; + } }); callingActivity.mKey = (OpenPgpKeyPreference) findPreference("openpgp_key"); - if (sharedPreferences.getString("openpgp_provider_list", null) != null) + + if (sharedPreferences.getString("openpgp_provider_list", null) != null) { ((UserPreference) getActivity()).mKey.setOpenPgpProvider(sharedPreferences.getString("openpgp_provider_list", "")); + } - findPreference("openpgp_provider_list").setOnPreferenceChangeListener((preference, o) -> { - callingActivity.mKey.setOpenPgpProvider((String) o); - 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"); externalRepo.setSummary(getPreferenceManager().getSharedPreferences().getString("git_external_repo", "No external repository selected")); - externalRepo.setOnPreferenceClickListener((Preference pref) -> { - callingActivity.selectExternalGitRepository(); - return true; + externalRepo.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + callingActivity.selectExternalGitRepository(); + return true; + } }); - Preference.OnPreferenceChangeListener resetRepo = (preference, o) -> { - PasswordRepository.closeRepository(); - getPreferenceManager().getSharedPreferences().edit().putBoolean("repo_changed", true).apply(); - return true; + Preference.OnPreferenceChangeListener resetRepo = new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object o) { + PasswordRepository.closeRepository(); + getPreferenceManager().getSharedPreferences().edit().putBoolean("repo_changed", true).apply(); + return true; + } }; findPreference("pref_select_external").setOnPreferenceChangeListener(resetRepo); @@ -194,10 +229,8 @@ public class UserPreference extends AppCompatActivity { protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { - switch (requestCode) - { - case IMPORT_SSH_KEY: - { + switch (requestCode) { + case IMPORT_SSH_KEY: { try { if (data.getData() == null) { 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(); setResult(RESULT_OK); finish(); - } catch (IOException e) - { + } catch (IOException e) { new AlertDialog.Builder(this). setTitle(this.getResources().getString(R.string.ssh_key_error_dialog_title)). setMessage(this.getResources().getString(R.string.ssh_key_error_dialog_text) + e.getMessage()). - setPositiveButton(this.getResources().getString(R.string.dialog_ok), (dialogInterface, i) -> { - //pass + setPositiveButton(this.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + // pass + } }).show(); } } break; - case EDIT_GIT_INFO: - { + case EDIT_GIT_INFO: { } break; - case OpenPgpKeyPreference.REQUEST_CODE_KEY_PREFERENCE: - { + case OpenPgpKeyPreference.REQUEST_CODE_KEY_PREFERENCE: { if (mKey.handleOnActivityResult(requestCode, resultCode, data)) { // handled by OpenPgpKeyPreference PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()).edit().putLong("openpgp_sign_key", mKey.getValue()).apply(); @@ -232,7 +265,7 @@ public class UserPreference extends AppCompatActivity { } break; default: - break; + break; } } diff --git a/build.gradle b/build.gradle index f062d72f..3a4c4c2c 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,6 @@ buildscript { } dependencies { 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 // in the individual module build.gradle files |