diff options
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/AndroidManifest.xml | 127 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/SshKeyGen.java | 38 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.java | 23 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt | 18 |
4 files changed, 102 insertions, 104 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1bb0b487..16db4cbd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,77 +10,74 @@ tools:ignore="ProtectedPermissions"/> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> - <application android:allowBackup="true" - android:icon="@mipmap/ic_launcher" - android:label="@string/app_name" - android:theme="@style/AppTheme" - android:supportsRtl="true"> - <activity android:name=".PasswordStore" android:label="@string/app_name" - android:configChanges="orientation|screenSize"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> + <application android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme" + android:supportsRtl="true"> + <activity + android:name=".PasswordStore" + android:label="@string/app_name" + android:configChanges="orientation|screenSize"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity + android:name=".git.GitActivity" + android:parentActivityName=".PasswordStore"> + <meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.zeapo.pwdstore.PasswordStore" /> + </activity> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - <activity android:name=".git.GitActivity" - android:parentActivityName=".PasswordStore"> - <meta-data android:name="android.PARENT_ACTIVITY1" - android:value="com.zeapo.pwdstore.PasswordStore" /> - </activity> + <activity + android:name=".UserPreference" + android:parentActivityName=".PasswordStore"> + <meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.zeapo.pwdstore.PasswordStore" /> + </activity> - <activity android:name=".UserPreference" - android:parentActivityName=".PasswordStore"> + <activity + android:name=".SshKeyGen" + android:parentActivityName=".PasswordStore"> + <meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.zeapo.pwdstore.PasswordStore" /> + </activity> - <meta-data android:name="android.support.PARENT_ACTIVITY" - android:value="com.zeapo.pwdstore.PasswordStore" /> - </activity> + <service + android:name=".autofill.AutofillService" + android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"> + <intent-filter> + <action android:name="android.accessibilityservice.AccessibilityService" /> + </intent-filter> + <meta-data android:name="android.accessibilityservice" android:resource="@xml/autofill_config" /> + </service> - <activity android:name=".SshKeyGen" - android:parentActivityName=".PasswordStore"> + <activity + android:name=".autofill.AutofillActivity" + android:parentActivityName=".PasswordStore" + android:documentLaunchMode="intoExisting" + android:excludeFromRecents="true" + tools:ignore="UnusedAttribute"> + <meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.zeapo.pwdstore.PasswordStore" /> + </activity> - <meta-data android:name="android.support.PARENT_ACTIVITY" - android:value="com.zeapo.pwdstore.PasswordStore" /> - </activity> + <activity + android:name=".autofill.AutofillPreferenceActivity" + android:parentActivityName=".PasswordStore"> + <meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.zeapo.pwdstore.PasswordStore" /> + </activity> - <service android:name=".autofill.AutofillService" - android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"> - <intent-filter> - <action android:name="android.accessibilityservice.AccessibilityService" /> - </intent-filter> - <meta-data android:name="android.accessibilityservice" - android:resource="@xml/autofill_config" /> - </service> - - <activity android:name=".autofill.AutofillActivity" - android:parentActivityName=".PasswordStore" - android:documentLaunchMode="intoExisting" - android:excludeFromRecents="true" - tools:ignore="UnusedAttribute"> - - <meta-data android:name="android.support.PARENT_ACTIVITY" - android:value="com.zeapo.pwdstore.PasswordStore" /> - </activity> - - <activity android:name=".autofill.AutofillPreferenceActivity" - android:parentActivityName=".PasswordStore"> - - <meta-data android:name="android.support.PARENT_ACTIVITY" - android:value="com.zeapo.pwdstore.PasswordStore" /> - </activity> - - <activity - android:name="com.nononsenseapps.filepicker.FilePickerActivity" - android:label="@string/app_name" - android:theme="@style/FilePickerTheme"> - <intent-filter> - <action android:name="android.intent.action.GET_CONTENT" /> - <category android:name="android.intent.category.DEFAULT" /> - </intent-filter> - </activity> + <activity + android:name="com.nononsenseapps.filepicker.FilePickerActivity" + android:label="@string/app_name" + android:theme="@style/FilePickerTheme"> + <intent-filter> + <action android:name="android.intent.action.GET_CONTENT" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> <activity android:name=".crypto.PgpActivity" - android:parentActivityName=".PasswordStore"/> - <activity android:name=".SelectFolderActivity" /> - </application> + android:parentActivityName=".PasswordStore"/> + <activity android:name=".SelectFolderActivity" /> + </application> </manifest> diff --git a/app/src/main/java/com/zeapo/pwdstore/SshKeyGen.java b/app/src/main/java/com/zeapo/pwdstore/SshKeyGen.java index 380ef659..72d1c024 100644 --- a/app/src/main/java/com/zeapo/pwdstore/SshKeyGen.java +++ b/app/src/main/java/com/zeapo/pwdstore/SshKeyGen.java @@ -37,6 +37,7 @@ import org.apache.commons.io.FileUtils; import java.io.File; import java.io.FileOutputStream; +import java.lang.ref.WeakReference; public class SshKeyGen extends AppCompatActivity { @@ -51,7 +52,7 @@ public class SshKeyGen extends AppCompatActivity { final View v = inflater.inflate(R.layout.fragment_ssh_keygen, container, false); Typeface monoTypeface = Typeface.createFromAsset(getActivity().getAssets(), "fonts/sourcecodepro.ttf"); - Spinner spinner = (Spinner) v.findViewById(R.id.length); + Spinner spinner = v.findViewById(R.id.length); Integer[] lengths = new Integer[]{2048, 4096}; ArrayAdapter<Integer> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, lengths); @@ -59,11 +60,11 @@ public class SshKeyGen extends AppCompatActivity { ((EditText) v.findViewById(R.id.passphrase)).setTypeface(monoTypeface); - CheckBox checkbox = (CheckBox) v.findViewById(R.id.show_passphrase); + CheckBox checkbox = v.findViewById(R.id.show_passphrase); checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - EditText editText = (EditText) v.findViewById(R.id.passphrase); + EditText editText = v.findViewById(R.id.passphrase); int selection = editText.getSelectionEnd(); if (isChecked) { editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); @@ -90,7 +91,7 @@ public class SshKeyGen extends AppCompatActivity { @SuppressLint("InflateParams") final View v = inflater.inflate(R.layout.fragment_show_ssh_key, null); builder.setView(v); - TextView textView = (TextView) v.findViewById(R.id.public_key); + TextView textView = v.findViewById(R.id.public_key); File file = new File(getActivity().getFilesDir() + "/.ssh_key.pub"); try { textView.setText(FileUtils.readFileToString(file)); @@ -124,7 +125,7 @@ public class SshKeyGen extends AppCompatActivity { b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - TextView textView = (TextView) getDialog().findViewById(R.id.public_key); + TextView textView = getDialog().findViewById(R.id.public_key); ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("public key", textView.getText().toString()); clipboard.setPrimaryClip(clip); @@ -152,13 +153,18 @@ public class SshKeyGen extends AppCompatActivity { } } - private class generateTask extends AsyncTask<String, Void, Exception> { + private static class KeyGenerateTask extends AsyncTask<String, Void, Exception> { private ProgressDialog pd; + private WeakReference<SshKeyGen> weakReference; + + private KeyGenerateTask(final SshKeyGen activity) { + weakReference = new WeakReference<>(activity); + } @Override protected void onPreExecute() { super.onPreExecute(); - pd = ProgressDialog.show(SshKeyGen.this, "", "Generating keys"); + pd = ProgressDialog.show(weakReference.get(), "", "Generating keys"); } protected Exception doInBackground(String... strings) { @@ -170,7 +176,7 @@ public class SshKeyGen extends AppCompatActivity { try { KeyPair kp = KeyPair.genKeyPair(jsch, KeyPair.RSA, length); - File file = new File(getFilesDir() + "/.ssh_key"); + File file = new File(weakReference.get().getFilesDir() + "/.ssh_key"); FileOutputStream out = new FileOutputStream(file, false); if (passphrase.length() > 0) { kp.writePrivateKey(out, passphrase.getBytes()); @@ -178,7 +184,7 @@ public class SshKeyGen extends AppCompatActivity { kp.writePrivateKey(out); } - file = new File(getFilesDir() + "/.ssh_key.pub"); + file = new File(weakReference.get().getFilesDir() + "/.ssh_key.pub"); out = new FileOutputStream(file, false); kp.writePublicKey(out, comment); return null; @@ -194,18 +200,18 @@ public class SshKeyGen extends AppCompatActivity { super.onPostExecute(e); pd.dismiss(); if (e == null) { - Toast.makeText(SshKeyGen.this, "SSH-key generated", Toast.LENGTH_LONG).show(); + Toast.makeText(weakReference.get(), "SSH-key generated", Toast.LENGTH_LONG).show(); DialogFragment df = new ShowSshKeyFragment(); - df.show(getFragmentManager(), "public_key"); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + df.show(weakReference.get().getFragmentManager(), "public_key"); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(weakReference.get()); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("use_generated_key", true); editor.apply(); } else { - new AlertDialog.Builder(SshKeyGen.this) + new AlertDialog.Builder(weakReference.get()) .setTitle("Error while trying to generate the ssh-key") - .setMessage(getResources().getString(R.string.ssh_key_error_dialog_text) + e.getMessage()) - .setPositiveButton(getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { + .setMessage(weakReference.get().getResources().getString(R.string.ssh_key_error_dialog_text) + e.getMessage()) + .setPositiveButton(weakReference.get().getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // pass @@ -223,7 +229,7 @@ public class SshKeyGen extends AppCompatActivity { String length = Integer.toString((Integer) ((Spinner) findViewById(R.id.length)).getSelectedItem()); String passphrase = ((EditText) findViewById(R.id.passphrase)).getText().toString(); String comment = ((EditText) findViewById(R.id.comment)).getText().toString(); - new generateTask().execute(length, passphrase, comment); + new KeyGenerateTask(this).execute(length, passphrase, comment); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); diff --git a/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.java b/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.java deleted file mode 100644 index f5c25687..00000000 --- a/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.zeapo.pwdstore; - -import android.os.Bundle; -import androidx.fragment.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - - -public class ToCloneOrNot extends Fragment { - - public ToCloneOrNot() { - // Required empty public constructor - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_to_clone_or_not, container, false); - } - -} diff --git a/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt b/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt new file mode 100644 index 00000000..3df845f2 --- /dev/null +++ b/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt @@ -0,0 +1,18 @@ +package com.zeapo.pwdstore + +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup + + +class ToCloneOrNot : Fragment() { + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle?): View? { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_to_clone_or_not, container, false) + } + +} |