Skip to content

Commit

Permalink
V1.0.1 Fixes a permissions related crash that can occur if Juicessh i…
Browse files Browse the repository at this point in the history
…s installed after Fwknop2
  • Loading branch information
jp-bennett committed Jun 18, 2015
1 parent dfc3449 commit 75c4016
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ android {
applicationId "org.cipherdyne.fwknop2"
minSdkVersion 15
targetSdkVersion 19
versionCode 4
versionName "1.0"
versionCode 5
versionName "1.0.1"
ndk {
moduleName 'libfwknop'
ldLibs 'log'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
Expand Down Expand Up @@ -375,26 +376,39 @@ public void onItemSelected(AdapterView<?> parent, View view,
lay_sshcmd.setVisibility(View.VISIBLE);
spn_juice.setVisibility(View.GONE);
} else if (parent.getItemAtPosition(pos).toString().equalsIgnoreCase("Juicessh")) {
lay_sshcmd.setVisibility(View.GONE);

if (connectionListLoader == null) {
connectionListLoader = new ConnectionListLoader(getActivity(), juice_adapt);
connectionListLoader.setOnLoadedListener(new ConnectionListLoader.OnLoadedListener() {
@Override
public void onLoaded() { // This is so ugly...
spn_juice.setVisibility(View.VISIBLE);
if (config.SSH_CMD.contains("juice:") && spn_juice.getCount() > 0 ) {
for (int n = 0; n < spn_juice.getCount(); n++) {
if (config.SSH_CMD.contains(juice_adapt.getConnectionName(n))) {
spn_juice.setSelection(n);
if(getActivity().checkCallingOrSelfPermission("com.sonelli.juicessh.api.v1.permission.READ_CONNECTIONS") == PackageManager.PERMISSION_GRANTED) {

lay_sshcmd.setVisibility(View.GONE);

if (connectionListLoader == null) {
connectionListLoader = new ConnectionListLoader(getActivity(), juice_adapt);
connectionListLoader.setOnLoadedListener(new ConnectionListLoader.OnLoadedListener() {
@Override
public void onLoaded() { // This is so ugly...
spn_juice.setVisibility(View.VISIBLE);
if (config.SSH_CMD.contains("juice:") && spn_juice.getCount() > 0) {
for (int n = 0; n < spn_juice.getCount(); n++) {
if (config.SSH_CMD.contains(juice_adapt.getConnectionName(n))) {
spn_juice.setSelection(n);
}
}
}
}
}
});
getActivity().getSupportLoaderManager().initLoader(0, null, connectionListLoader);
});
getActivity().getSupportLoaderManager().initLoader(0, null, connectionListLoader);
} else {
getActivity().getSupportLoaderManager().restartLoader(0, null, connectionListLoader);
}
} else {
getActivity().getSupportLoaderManager().restartLoader(0, null, connectionListLoader);
Context context = getActivity();
CharSequence text = "Fwknop2 does not have permission to access Juicessh connection list. Please reinstall Fwknop2.";
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.setGravity(Gravity.CENTER, 0, 0);
LinearLayout toastLayout = (LinearLayout) toast.getView();
TextView toastTV = (TextView) toastLayout.getChildAt(0);
toastTV.setTextSize(30);
toast.show();
}
}
}
Expand Down

0 comments on commit 75c4016

Please sign in to comment.