Android Open Source - eyebrows-sync Edit Job






From Project

Back to project page eyebrows-sync.

License

The source code is released under:

Copyright (c) 2014 Jon Petraglia of Qweex All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "...

If you think the Android project eyebrows-sync listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.qweex.eyebrowssync;
//  w w  w  .  ja v a2 s. co  m
import android.app.Activity;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import com.qweex.eyebrowssync.JobList.v11;
import com.qweex.utils.DirectoryChooserDialog;

public class EditJob extends Activity implements DirectoryChooserDialog.OnDirectoryChosen {

    String nameWas;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.edit_activity);

        if(getIntent().getExtras()!=null) {
            nameWas = getIntent().getExtras().getString("name");
            if(nameWas!=null) {
                Bundle b = SavedJobs.get(this, nameWas);
                ((EditText)findViewById(R.id.name)).setText(nameWas);
                ((EditText)findViewById(R.id.host)).setText(b.getString("host"));
                ((EditText)findViewById(R.id.port)).setText(Integer.toString(b.getInt("port")));
                ((CheckBox)findViewById(R.id.ssl)).setChecked(b.getBoolean("ssl"));
                //auth (username, password)

                String[] auth = new String(Base64.decode(b.getString("auth"), Base64.DEFAULT)).split(":");
                String username = auth[0], password = "";
                if(auth.length>1)
                    password = auth[1];
                ((EditText)findViewById(R.id.username)).setText(username);
                ((EditText)findViewById(R.id.password)).setText(password);

                ((EditText)findViewById(R.id.foreign_path)).setText(b.getString("foreign_path"));
                ((Button)findViewById(R.id.local_path)).setText(b.getString("local_path"));
                ((EditText)findViewById(R.id.mask)).setText(b.getString("mask"));
            }
        }

        findViewById(R.id.save).setOnClickListener(save);
        findViewById(R.id.local_path).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DirectoryChooserDialog d = new DirectoryChooserDialog(EditJob.this, EditJob.this);
                d.setNewFolderEnabled(true);
                d.chooseDirectory();
            }
        });
    }

    @Override
    public void onDirectoryChosen(String chosenDir) {
        Log.wtf("EyebrowsSync", chosenDir);
        ((Button)findViewById(R.id.local_path)).setText(chosenDir);
    }


    View.OnClickListener save = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Bundle b = new Bundle();
            String newName = ((EditText)findViewById(R.id.name)).getText().toString();
            b.putString("name", newName);
            b.putString("host", ((EditText)findViewById(R.id.host)).getText().toString());
            b.putInt("port", Integer.parseInt(((EditText)findViewById(R.id.port)).getText().toString()));
            b.putBoolean("ssl", ((CheckBox)findViewById(R.id.ssl)).isChecked());

            String auth = ((EditText)findViewById(R.id.username)).getText().toString() + ":" + ((EditText)findViewById(R.id.password)).getText().toString();
            b.putString("auth", Base64.encodeToString(auth.getBytes(), Base64.DEFAULT));

            //auth (username, password)
            b.putString("foreign_path", ((EditText)findViewById(R.id.foreign_path)).getText().toString());
            b.putString("local_path", ((Button)findViewById(R.id.local_path)).getText().toString());
            b.putString("mask", ((EditText)findViewById(R.id.mask)).getText().toString());

            if(nameWas==null)
                SavedJobs.add(EditJob.this, b);
            else
            {
                if(!nameWas.equals(newName)) {
                    v11.syncers.put(newName, v11.syncers.get(nameWas));
                    v11.syncers.remove(nameWas);
                }
                SavedJobs.update(EditJob.this, nameWas, b);
            }
            finish();
        }
    };
}




Java Source Code List

com.qweex.NumberPickerDialogPreference.java
com.qweex.eyebrows.EyebrowsError.java
com.qweex.eyebrows.did_not_write.JSONDownloader.java
com.qweex.eyebrowssync.AboutActivity.java
com.qweex.eyebrowssync.AsyncCrypt.java
com.qweex.eyebrowssync.AttachedRelativeLayout.java
com.qweex.eyebrowssync.EditJob.java
com.qweex.eyebrowssync.FileModifiedHelper.java
com.qweex.eyebrowssync.NotificationSupervisor.java
com.qweex.eyebrowssync.SavedJobs.java
com.qweex.eyebrowssync.StartActivity.java
com.qweex.eyebrowssync.StatusWindow.java
com.qweex.eyebrowssync.Syncer.java
com.qweex.eyebrowssync.UserConfig.java
com.qweex.eyebrowssync.JobList.Base.java
com.qweex.eyebrowssync.JobList.v11.java
com.qweex.eyebrowssync.JobList.v3.java
com.qweex.utils.Crypt.java
com.qweex.utils.DirectoryChooserDialog.java