Example usage for android.app Dialog setCancelable

List of usage examples for android.app Dialog setCancelable

Introduction

In this page you can find the example usage for android.app Dialog setCancelable.

Prototype

public void setCancelable(boolean flag) 

Source Link

Document

Sets whether this dialog is cancelable with the KeyEvent#KEYCODE_BACK BACK key.

Usage

From source file:org.thoughtland.xlocation.ActivityApp.java

private void optionLegend() {
    // Show help/*  ww w  .  j  a  va 2  s  .c o  m*/
    Dialog dialog = new Dialog(ActivityApp.this);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setTitle(R.string.menu_legend);
    dialog.setContentView(R.layout.legend);
    dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));

    ((ImageView) dialog.findViewById(R.id.imgHelpHalf)).setImageBitmap(getHalfCheckBox());
    ((ImageView) dialog.findViewById(R.id.imgHelpOnDemand)).setImageBitmap(getOnDemandCheckBox());

    for (View child : Util.getViewsByTag((ViewGroup) dialog.findViewById(android.R.id.content), "main"))
        child.setVisibility(View.GONE);

    ((LinearLayout) dialog.findViewById(R.id.llUnsafe))
            .setVisibility(PrivacyManager.cVersion3 ? View.VISIBLE : View.GONE);

    dialog.setCancelable(true);
    dialog.show();
}

From source file:de.bogutzky.psychophysiocollector.app.MainActivity.java

private void showGraph(String bluetoothDeviceAddress, int requestCode, int which) {
    int beginAtField = 0;
    GraphView graphView = null;//from  w w  w.j  a v  a2s .c  o  m
    Dialog dialog = null;
    switch (requestCode) {
    case REQUEST_MAIN_COMMAND_SHIMMER:
        beginAtField = 1;
        switch (which) {
        case 1:
            beginAtField = 4;
            break;
        }

        graphView = new GraphView(this, beginAtField);
        if (this.shimmerImuService != null) {
            if (!isSessionStarted)
                this.startStreamingOfAllShimmerImus(false);
            this.shimmerImuService.startDataVisualization(bluetoothDeviceAddress, graphView);
        }
        dialog = new Dialog(this);
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                if (shimmerImuService != null) {
                    shimmerImuService.stopDataVisualization();
                }
                if (!isSessionStarted) {
                    stopAllStreamingOfAllShimmerImus();
                }
            }
        });
        break;
    case REQUEST_MAIN_COMMAND_BIOHARNESS:
        graphView = new GraphView(this, beginAtField);
        if (this.bioHarnessService != null) {
            this.bioHarnessService.startDataVisualization(graphView);
        }
        dialog = new Dialog(this);
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                if (bioHarnessService != null) {
                    bioHarnessService.stopDataVisualization();
                }
            }
        });
        break;
    }

    assert dialog != null;
    dialog.setContentView(graphView);
    dialog.setTitle(getString(R.string.graph));
    dialog.setCancelable(true);
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    lp.height = WindowManager.LayoutParams.MATCH_PARENT;
    dialog.getWindow().setAttributes(lp);

    dialog.show();
}

From source file:com.zen.androidhtmleditor.AHEActivity.java

@SuppressLint("NewApi")
@Override//w ww . ja v  a2s  .c  o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    setContentView(R.layout.main);
    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    // enable status bar tint
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setTintColor(Color.parseColor("#4acab4"));

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
    Settings.init(settings);
    //Uncomment this for non Market installs. This will allow version checking.
    //new Version(this,getVersionName(this,DeveloperToolsActivity.class),"http://androidhtmleditor.com/version.php").execute();
    deviceId = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
    getOverflowMenu();
    getActionBar().setIcon(R.drawable.icon_white);

    tabactivity = (TabActivity) this;
    tabHost = tabactivity.getTabHost();
    hsv = (HorizontalScrollView) tabactivity.findViewById(R.id.topmenu);

    mLicenseCheckerCallback = new MyLicenseCheckerCallback();
    mChecker = new LicenseChecker(this,
            new ServerManagedPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId)),
            BASE64_PUBLIC_KEY // Your public licensing key.
    );

    mHandler = new Handler();
    // doCheck();

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (LinearLayout) findViewById(R.id.l1);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle("File(s)");
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle("Server");
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    Button button1 = (Button) findViewById(R.id.button1);

    button1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onButtonClickEvent(v);
        }
    });
    Button disconnect_button = (Button) findViewById(R.id.disconnect_button);

    disconnect_button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            disconnect();
        }
    });

    /* Button button2 = (Button)findViewById(R.id.button2);
     button2.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
               
       hsv.setVisibility(View.GONE);
       v.setVisibility(View.GONE);
       RelativeLayout rl = (RelativeLayout)v.getParent();
       Button button1 = (Button)findViewById(R.id.button1);
       button1.setVisibility(View.VISIBLE);
       Button button3 = (Button)findViewById(R.id.button3);
       button3.setVisibility(View.VISIBLE);
               
       ImageView logo = (ImageView)findViewById(R.id.logo);
       logo.setVisibility(View.VISIBLE);
               
       TextView slogan = (TextView)findViewById(R.id.appSlogan);
       slogan.setVisibility(View.VISIBLE);
               
       ScrollView frontLayout = (ScrollView)findViewById(R.id.front);
       frontLayout.setVisibility(View.VISIBLE);
               
       TextView appTitle = (TextView)findViewById(R.id.appTitle);
       appTitle.setVisibility(View.VISIBLE);
               
       Button backButton = (Button)rl.findViewById(R.id.backButton);
       backButton.setVisibility(View.GONE);
       arrayAdapter.clear();
       arrayAdapter.notifyDataSetChanged();
       TextView pathInfo = (TextView)rl.findViewById(R.id.path);
        pathInfo.setText("");
        folderPath = "";
       //new MyFetchTask("zenstudio.com.au", "zenstudi", ".-x$%Wmd5b#C","folder",folderPath).execute();
        connectedTo = -1;
                
                
                
                
        Toast.makeText(AHEActivity.this, "Disconnected", Toast.LENGTH_SHORT).show();
    }
     });*/

    Button button3 = (Button) findViewById(R.id.button3);
    button3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent SettingsIntent = new Intent(AHEActivity.this, Settings.class);
            startActivity(SettingsIntent);
        }
    });

    /*Button backButton = (Button)findViewById(R.id.backButton);
    backButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
       String[] pathBits = folderPath.split("/");
       folderPath = "";
       for(int i=0;i<pathBits.length-1;i++){
          folderPath += pathBits[i]+"/";
       }
       arrayAdapter.clear();
               
       //connectedTo
       SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        String currentServers = settings.getString("Accounts", "");
        if(currentServers.equals("")){}else{
       Gson gson = new Gson();
        SearchResponse response = gson.fromJson(currentServers, SearchResponse.class);
        List<Result> results = response.data;
        Result l = results.get(connectedTo);
                
       if(l.serverName!="" && l.userName!="" && l.port.trim()!=""){
               
          if(l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")){
             new MyFetchTask(l.serverName, l.userName, l.passWord,"folder",folderPath,l.sftp,l.port).execute();
          }else if(l.sftp.equals("3")){
             new FetchSSLTask(l.serverName, l.userName, l.passWord,"folder",folderPath,l.sftp,l.port).execute();
          }
               
       }
                
        }
    }
    });*/

    TextView pathInfo = (TextView) findViewById(R.id.path);
    pathInfo.setText(folderPath);

    lstTest = (ListView) findViewById(R.id.list);
    // lstTest.setDividerHeight(10);
    lstTest.setPadding(0, 5, 0, 5);
    alrts = new ArrayList<String[]>();
    arrayAdapter = new FetchAdapter(AHEActivity.this, R.layout.listitems, alrts);
    lstTest.setAdapter(arrayAdapter);

    lstTest.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
            final View d = v;
            final CharSequence[] items = { "Delete", "Rename", "Chmod", "Download" };

            TextView t = (TextView) v.findViewById(R.id.fileFolderName);
            final String oldName = t.getText().toString();

            final int position = pos;

            AlertDialog.Builder builder = new AlertDialog.Builder(AHEActivity.this);
            builder.setTitle("Choose Action");
            builder.setItems(items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {

                    if (item == 0) {
                        AlertDialog.Builder dbuilder = new AlertDialog.Builder(AHEActivity.this);
                        dbuilder.setMessage("Delete this file?").setCancelable(false)
                                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {

                                        deleteFile(d);
                                        dialog.cancel();
                                    }
                                }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        dialog.cancel();

                                    }
                                });
                        AlertDialog dalert = dbuilder.create();
                        dalert.show();

                    } else if (item == 1) {

                        final Dialog renameDialog = new Dialog(AHEActivity.this);
                        renameDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        renameDialog.setContentView(R.layout.renamediag);

                        renameDialog.setCancelable(true);

                        Button closeServer = (Button) renameDialog.findViewById(R.id.closeServer);
                        closeServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                renameDialog.cancel();
                            }
                        });

                        Button saveServer = (Button) renameDialog.findViewById(R.id.saveServer);
                        saveServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                EditText themeUrl = (EditText) renameDialog.findViewById(R.id.themeLink);
                                String newName = themeUrl.getText().toString();
                                //connectedTo
                                SharedPreferences settings = getSharedPreferences(PREFS_NAME,
                                        Context.MODE_PRIVATE);
                                String currentServers = settings.getString("Accounts", "");
                                if (currentServers.equals("")) {
                                } else {
                                    Gson gson = new Gson();
                                    SearchResponse response = gson.fromJson(currentServers,
                                            SearchResponse.class);
                                    List<Result> results = response.data;
                                    Result l = results.get(connectedTo);

                                    if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {

                                        new RenameTask(l.serverName, l.userName, l.passWord, oldName, newName,
                                                folderPath, l.sftp, l.port, position).execute();

                                        renameDialog.cancel();
                                    }
                                }
                            }
                        });
                        renameDialog.show();
                    } else if (item == 2) {

                        final Dialog chmodDialog = new Dialog(AHEActivity.this);
                        chmodDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        chmodDialog.setContentView(R.layout.chmoddiag);

                        chmodDialog.setCancelable(true);

                        Button closeServer = (Button) chmodDialog.findViewById(R.id.closeServer);
                        closeServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                chmodDialog.cancel();
                            }
                        });

                        Button saveServer = (Button) chmodDialog.findViewById(R.id.saveServer);
                        saveServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                EditText themeUrl = (EditText) chmodDialog.findViewById(R.id.themeLink);
                                String perms = themeUrl.getText().toString();
                                //connectedTo
                                SharedPreferences settings = getSharedPreferences(PREFS_NAME,
                                        Context.MODE_PRIVATE);
                                String currentServers = settings.getString("Accounts", "");
                                if (currentServers.equals("")) {
                                } else {
                                    Gson gson = new Gson();
                                    SearchResponse response = gson.fromJson(currentServers,
                                            SearchResponse.class);
                                    List<Result> results = response.data;
                                    Result l = results.get(connectedTo);

                                    if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {

                                        if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) {
                                            new ChmodTask(l.serverName, l.userName, l.passWord, oldName, perms,
                                                    folderPath, l.sftp, l.port, position).execute();
                                        } else {
                                            Toast.makeText(AHEActivity.this,
                                                    "CHMOD could not be performed on your server via sftp",
                                                    Toast.LENGTH_SHORT).show();
                                        }
                                        chmodDialog.cancel();
                                    }
                                }
                            }
                        });
                        chmodDialog.show();

                    } else if (item == 3) {

                        //Make new class to download a file
                        SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
                        String currentServers = settings.getString("Accounts", "");
                        if (currentServers.equals("")) {
                        } else {
                            Gson gson = new Gson();
                            SearchResponse response = gson.fromJson(currentServers, SearchResponse.class);
                            List<Result> results = response.data;
                            Result l = results.get(connectedTo);

                            if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {

                                if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) {
                                    new DlTask(l.serverName, l.userName, l.passWord, oldName, l.sftp, l.port)
                                            .execute();

                                }
                            }
                        }
                    }

                    //Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();

                }
            });
            AlertDialog alert = builder.create();
            alert.show();
            return true;

        }
    });

    lstTest.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> av, View v, int pos, long id) {

            loadFileFolder(v);

        }
    });

}

From source file:biz.bokhorst.xprivacy.ActivityMain.java

private void optionLegend() {
    // Show help/*  w ww .ja v  a  2  s  . c  o m*/
    Dialog dialog = new Dialog(ActivityMain.this);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setTitle(R.string.menu_legend);
    dialog.setContentView(R.layout.legend);
    dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));

    ((ImageView) dialog.findViewById(R.id.imgHelpHalf)).setImageBitmap(getHalfCheckBox());
    ((ImageView) dialog.findViewById(R.id.imgHelpOnDemand)).setImageBitmap(getOnDemandCheckBox());

    for (View child : Util.getViewsByTag((ViewGroup) dialog.findViewById(android.R.id.content), "details"))
        child.setVisibility(View.GONE);

    ((LinearLayout) dialog.findViewById(R.id.llUnsafe))
            .setVisibility(PrivacyManager.cVersion3 ? View.VISIBLE : View.GONE);

    dialog.setCancelable(true);
    dialog.show();
}

From source file:org.anurag.file.quest.TaskerActivity.java

/**
 * FUNCTION MAKE 3d LIST VIEW VISIBLE OR GONE AS PER REQUIREMENT
 * @param mode/*from w w w  . ja  v a 2  s . c om*/
 * @param con
 */
public static void load_FIle_Gallery(final int mode) {
    final Dialog pDialog = new Dialog(mContext, R.style.custom_dialog_theme);
    final Handler handle = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case 0:
                try {
                    pDialog.setContentView(R.layout.p_dialog);
                    pDialog.setCancelable(false);
                    pDialog.getWindow().getAttributes().width = size.x * 4 / 5;
                    WebView web = (WebView) pDialog.findViewById(R.id.p_Web_View);
                    web.loadUrl("file:///android_asset/Progress_Bar_HTML/index.html");
                    web.setEnabled(false);
                    pDialog.show();
                } catch (InflateException e) {
                    error = true;
                    Toast.makeText(mContext,
                            "An exception encountered please wait while loading" + " file list",
                            Toast.LENGTH_SHORT).show();
                }
                break;
            case 1:
                if (pDialog != null)
                    if (pDialog.isShowing())
                        pDialog.dismiss();

                if (mediaFileList.size() > 0) {
                    FILE_GALLEY.setVisibility(View.GONE);
                    LIST_VIEW_3D.setVisibility(View.VISIBLE);
                    element = new MediaElementAdapter(mContext, R.layout.row_list_1, mediaFileList);
                    //AT THE PLACE OF ELEMENT YOU CAN USE MUSIC ADAPTER....
                    // AND SEE WHAT HAPPENS
                    if (mediaFileList.size() > 0) {
                        LIST_VIEW_3D.setAdapter(element);
                        LIST_VIEW_3D.setEnabled(true);
                    } else if (mediaFileList.size() == 0) {
                        LIST_VIEW_3D.setAdapter(new EmptyAdapter(mContext, R.layout.row_list_3, EMPTY));
                        LIST_VIEW_3D.setEnabled(false);
                    }
                    LIST_VIEW_3D.setDynamics(new SimpleDynamics(0.7f, 0.6f));
                    if (!elementInFocus) {
                        mFlipperBottom.showPrevious();
                        mFlipperBottom.setAnimation(prevAnim());
                        elementInFocus = true;
                    }
                    if (SEARCH_FLAG) {
                        mVFlipper.showPrevious();
                        mVFlipper.setAnimation(nextAnim());
                    }
                } else {
                    LIST_VIEW_3D.setVisibility(View.GONE);
                    FILE_GALLEY.setVisibility(View.VISIBLE);
                    Toast.makeText(mContext, R.string.empty, Toast.LENGTH_SHORT).show();
                    if (elementInFocus) {
                        mFlipperBottom.showNext();
                        mFlipperBottom.setAnimation(nextAnim());
                    }
                    elementInFocus = false;
                }
                break;
            }
        }
    };
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            // TODO Auto-generated method stub
            handle.sendEmptyMessage(0);
            while (!Utils.loaded) {
                //STOPPING HERE WHILE FILES ARE BEING LOADED IN BACKGROUND....
            }
            if (mode == 0)
                mediaFileList = Utils.music;
            else if (mode == 1)
                mediaFileList = Utils.apps;
            else if (mode == 2)
                mediaFileList = Utils.doc;
            else if (mode == 3)
                mediaFileList = Utils.img;
            else if (mode == 4)
                mediaFileList = Utils.vids;
            else if (mode == 5)
                mediaFileList = Utils.zip;
            else if (mode == 6)
                mediaFileList = Utils.mis;
            handle.sendEmptyMessage(1);
        }
    });
    thread.start();
}

From source file:com.orange.datavenue.DatasourceListFragment.java

private void createDatasource() {
    final android.app.Dialog dialog = new android.app.Dialog(getActivity());

    dialog.setContentView(R.layout.create_datasource_dialog);

    dialog.setTitle(R.string.add_datasource);

    final LinearLayout callbackLayout = (LinearLayout) dialog.findViewById(R.id.callback_layout);
    final EditText name = (EditText) dialog.findViewById(R.id.name);
    final EditText description = (EditText) dialog.findViewById(R.id.description);
    final EditText serial = (EditText) dialog.findViewById(R.id.serial);
    final EditText callback = (EditText) dialog.findViewById(R.id.callback);
    final CheckBox status = (CheckBox) dialog.findViewById(R.id.status);

    status.setChecked(true); // by default status is activated

    Button actionButton = (Button) dialog.findViewById(R.id.add_button);

    actionButton.setOnClickListener(new View.OnClickListener() {
        @Override/*from w ww .  j ava2 s . co m*/
        public void onClick(View view) {
            Log.d(TAG_NAME, "name : " + name.getText().toString());
            Log.d(TAG_NAME, "description : " + description.getText().toString());
            Log.d(TAG_NAME, "serial : " + serial.getText().toString());
            Log.d(TAG_NAME, "status : " + status.isChecked());

            Datasource newDatasource = new Datasource();

            newDatasource.setName(name.getText().toString());
            newDatasource.setDescription(description.getText().toString());
            newDatasource.setSerial(serial.getText().toString());

            String callbackUrl = callback.getText().toString();

            if ("".equals(callbackUrl)) {
                newDatasource.setCallback(null);
            } else {
                try {
                    URL url = new URL(callbackUrl);
                    Callback newCallback = new Callback();
                    newCallback.setUrl(url.toString());
                    newCallback.setStatus("activated");
                    newCallback.setName("Callback");
                    newCallback.setDescription("application callback");
                    newDatasource.setCallback(newCallback);
                } catch (MalformedURLException e) {
                    Log.e(TAG_NAME, e.toString());
                    newDatasource.setCallback(null);
                    callback.setText("");
                }
            }

            if (status.isChecked()) {
                newDatasource.setStatus("activated");
            } else {
                newDatasource.setStatus("deactivated");
            }

            CreateDatasourceOperation createDatasourceOperation = new CreateDatasourceOperation(
                    Model.instance.oapiKey, Model.instance.key, newDatasource, new OperationCallback() {
                        @Override
                        public void process(Object object, Exception exception) {
                            if (exception == null) {
                                getDatasources();
                            } else {
                                Errors.displayError(getActivity(), exception);
                            }
                        }
                    });

            createDatasourceOperation.execute("");

            dialog.dismiss();
        }
    });

    Button cancelButton = (Button) dialog.findViewById(R.id.cancel_button);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });

    dialog.setCancelable(false);
    dialog.show();
}

From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final Dialog dialog;
    ProgressDialog pdialog;//from  ww w  .ja va2 s.c  o m
    AlertDialog.Builder builder;
    LayoutInflater inflater;

    switch (id) {
    case Constants.DIALOG_LOGIN:
        dialog = new LoginDialog(this, mSettings, false) {
            @Override
            public void onLoginChosen(String user, String password) {
                removeDialog(Constants.DIALOG_LOGIN);
                new MyLoginTask(user, password).execute();
            }
        };
        break;

    case Constants.DIALOG_COMMENT_CLICK:
        dialog = new CommentClickDialog(this, mSettings);
        break;

    case Constants.DIALOG_REPLY: {
        dialog = new Dialog(this, mSettings.getDialogTheme());
        dialog.setContentView(R.layout.compose_reply_dialog);
        final EditText replyBody = (EditText) dialog.findViewById(R.id.body);
        final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button);
        final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button);

        replySaveButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mReplyTargetName != null) {
                    new CommentReplyTask(mReplyTargetName).execute(replyBody.getText().toString());
                    dialog.dismiss();
                } else {
                    Common.showErrorToast("Error replying. Please try again.", Toast.LENGTH_SHORT,
                            CommentsListActivity.this);
                }
            }
        });
        replyCancelButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mVoteTargetThing.setReplyDraft(replyBody.getText().toString());
                dialog.cancel();
            }
        });
        dialog.setCancelable(false); // disallow the BACK key
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                replyBody.setText("");
            }
        });
        break;
    }

    case Constants.DIALOG_EDIT: {
        dialog = new Dialog(this, mSettings.getDialogTheme());
        dialog.setContentView(R.layout.compose_reply_dialog);
        final EditText replyBody = (EditText) dialog.findViewById(R.id.body);
        final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button);
        final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button);

        replyBody.setText(mEditTargetBody);

        replySaveButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (mReplyTargetName != null) {
                    new EditTask(mReplyTargetName).execute(replyBody.getText().toString());
                    dialog.dismiss();
                } else {
                    Common.showErrorToast("Error editing. Please try again.", Toast.LENGTH_SHORT,
                            CommentsListActivity.this);
                }
            }
        });
        replyCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.cancel();
            }
        });
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                replyBody.setText("");
            }
        });
        break;
    }

    case Constants.DIALOG_DELETE:
        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        builder.setTitle("Really delete this?");
        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                removeDialog(Constants.DIALOG_DELETE);
                new DeleteTask(mDeleteTargetKind).execute(mReplyTargetName);
            }
        }).setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        dialog = builder.create();
        break;

    case Constants.DIALOG_SORT_BY:
        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        builder.setTitle("Sort by:");
        int selectedSortBy = -1;
        for (int i = 0; i < Constants.CommentsSort.SORT_BY_URL_CHOICES.length; i++) {
            if (Constants.CommentsSort.SORT_BY_URL_CHOICES[i].equals(mSettings.getCommentsSortByUrl())) {
                selectedSortBy = i;
                break;
            }
        }
        builder.setSingleChoiceItems(Constants.CommentsSort.SORT_BY_CHOICES, selectedSortBy,
                sortByOnClickListener);
        dialog = builder.create();
        break;

    case Constants.DIALOG_REPORT:
        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        builder.setTitle("Really report this?");
        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                removeDialog(Constants.DIALOG_REPORT);
                new ReportTask(mReportTargetName.toString()).execute();
            }
        }).setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        dialog = builder.create();
        break;

    // "Please wait"
    case Constants.DIALOG_DELETING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Deleting...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_EDITING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Submitting edit...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_LOGGING_IN:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Logging in...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_REPLYING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Sending reply...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_FIND:
        inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View content = inflater.inflate(R.layout.dialog_find, null);
        final EditText find_box = (EditText) content.findViewById(R.id.input_find_box);
        //          final CheckBox wrap_box = (CheckBox) content.findViewById(R.id.find_wrap_checkbox);

        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        builder.setView(content);
        builder.setTitle(R.string.find).setPositiveButton(R.string.find, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String search_text = find_box.getText().toString().toLowerCase();
                //               findCommentText(search_text, wrap_box.isChecked(), false);
                findCommentText(search_text, true, false);
            }
        }).setNegativeButton("Cancel", null);
        dialog = builder.create();
        break;
    default:
        throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}

From source file:org.anurag.file.quest.TaskerActivity.java

/**
 * /*from w  w  w .j a v  a2  s  .  com*/
 */
@Override
public void onItemClick(QuickAction source, int pos, int actionId) {
    CURRENT_ITEM = mViewPager.getCurrentItem();
    switch (actionId) {

    case -1:
        // THIS CASE DIAPLAYS AN ACTIVITY SHOWING THE
        // DEVELOPMENT STAGE OF THE APP

        break;

    case 1:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // FIRST OPTION IS CASE 1
        //SEARCH_FLAG = true;
        load_FIle_Gallery(0);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;
    case 2:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // SECOND OPTION IS CASE 2
        //SEARCH_FLAG = true;
        load_FIle_Gallery(1);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;
    case 3:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // THIRT OPTION IS CASE 3
        //SEARCH_FLAG = true;
        load_FIle_Gallery(2);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;

    case 4:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // Fourth OPTION IS CASE 4
        //SEARCH_FLAG = true;
        load_FIle_Gallery(3);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;

    case 5:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // FIFTH OPTION IS CASE 5
        //SEARCH_FLAG = true;
        load_FIle_Gallery(4);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;

    case 6:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // SIXTH OPTION IS CASE 6
        //SEARCH_FLAG = true;
        load_FIle_Gallery(5);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;

    case 7:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // SEVENTH OPTION IS CASE 7
        //SEARCH_FLAG = true;
        load_FIle_Gallery(6);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;

    case 8:

        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // FIRST LOCATION IS CASE 8
        load_FIle_Gallery(0);
        break;

    case 9:
        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // SECOND LOCATION IS CASE 9
        //loadMediaList(pos=1);
        //elementInFocus = true;
        //media.setAdapter(new MediaElementAdapter(getBaseContext(), R.layout.row_list_1, mediaFileList));
        load_FIle_Gallery(1);
        break;

    case 10:
        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // THIRD LOCATION IS CASE 10
        load_FIle_Gallery(2);
        break;

    case 11:
        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // FOURTH LOCATION IS CASE 11
        load_FIle_Gallery(3);
        break;

    case 12:
        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // FIFTH LOCATION IS CASE 12
        load_FIle_Gallery(4);
        break;

    case 13:
        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // SIXTH LOCATION IS CASE 13
        load_FIle_Gallery(5);
        break;

    case 14:
        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // SEVENTH LOCATION IS CASE 14
        load_FIle_Gallery(6);
        break;

    case 80:
        // SHOWING THE OPTIONS AVAILABLE FOR CHANGING APPREANCE
        QuickAction q = new QuickAction(getBaseContext());
        ActionItem q1 = new ActionItem(100, "  Adjust Transparency",
                getResources().getDrawable(R.drawable.ic_launcher_appreance));
        q.addActionItem(q1);
        if (CURRENT_ITEM != 3) {
            q1 = new ActionItem(90, "  Set Folder Icon",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_violet));
            q.addActionItem(q1);
        }
        q.setOnActionItemClickListener(this);
        q.show(indicator);
        break;

    case 90:
        //DIRECTED FROM CASE 80
        // DISPLAYS THE OPTIONS AVAILABLE FOR CHANGING FOLDER ICON TO SHOW
        int FOLDER_TYPE = RootAdapter.FOLDER_TYPE;
        QuickAction ac = new QuickAction(getBaseContext());
        ActionItem it;

        if (FOLDER_TYPE == 0)
            it = new ActionItem(2800, "  Window Style Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(2800, "  Window Style Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        ac.addActionItem(it);

        if (FOLDER_TYPE == 1)
            it = new ActionItem(2900, "  Oxygen Violet Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(2900, "  Oxygen Violet Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_violet));
        ac.addActionItem(it);

        if (FOLDER_TYPE == 2)
            it = new ActionItem(3000, "  Oxygen Orange Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(3000, "  Oxygen Orange Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_oxygen));
        ac.addActionItem(it);

        if (FOLDER_TYPE == 3)
            it = new ActionItem(3100, "  Yellow Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(3100, "  Yellow Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_yellow));
        ac.addActionItem(it);

        if (FOLDER_TYPE == 4)
            it = new ActionItem(3101, "  Ubuntu Orange Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(3101, "  Ubuntu Orange Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_ubuntu));
        ac.addActionItem(it);

        if (FOLDER_TYPE == 5)
            it = new ActionItem(3102, "  Ubuntu Black Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(3102, "  Ubuntu Black Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_ubuntu_black));
        ac.addActionItem(it);

        if (FOLDER_TYPE == 6)
            it = new ActionItem(3103, "  Gnome Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(3103, "  Gnome Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_gnome));
        ac.addActionItem(it);

        ac.setOnActionItemClickListener(this);
        ac.show(indicator);
        break;
    case 100:
        // DIRECTED FROM CASE 80
        // SHOWING ALL THE TRANSPARENCY LEVEL AVAILABLE
        QuickAction d = new QuickAction(getBaseContext());
        ActionItem l;
        if (TRANS_LEVEL == 0.6f)
            l = new ActionItem(1700, "  60% Opaque", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            l = new ActionItem(1700, "  60% Opaque",
                    getResources().getDrawable(R.drawable.ic_launcher_appreance));
        d.addActionItem(l);

        if (TRANS_LEVEL == 0.7f)
            l = new ActionItem(1800, "  70% Opaque", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            l = new ActionItem(1800, "  70% Opaque",
                    getResources().getDrawable(R.drawable.ic_launcher_appreance));
        d.addActionItem(l);

        if (TRANS_LEVEL == 0.8f)
            l = new ActionItem(1900, "  80% Opaque", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            l = new ActionItem(1900, "  80% Opaque",
                    getResources().getDrawable(R.drawable.ic_launcher_appreance));
        d.addActionItem(l);

        if (TRANS_LEVEL == 0.9f)
            l = new ActionItem(2000, "  90% Opaque", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            l = new ActionItem(2000, "  90% Opaque",
                    getResources().getDrawable(R.drawable.ic_launcher_appreance));
        d.addActionItem(l);

        if (TRANS_LEVEL == 1.0f)
            l = new ActionItem(2100, "  100% Opaque", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            l = new ActionItem(2100, "  100% Opaque",
                    getResources().getDrawable(R.drawable.ic_launcher_appreance));
        d.addActionItem(l);
        d.setOnActionItemClickListener(this);
        d.show(indicator);
        break;
    case 200:
        // DISPLAYS OPTIONS AVAILABLE IF USER SELECTS FOLDER OPTIONS
        QuickAction a = new QuickAction(getBaseContext());
        ActionItem i = new ActionItem(800, "Set Panel On Startup",
                getResources().getDrawable(R.drawable.ic_launcher_startup));
        a.addActionItem(i);
        if (mViewPager.getCurrentItem() != 3) {
            i = new ActionItem(900, "Set Directory On Startup",
                    getResources().getDrawable(R.drawable.ic_launcher_startup));
            a.addActionItem(i);
        }
        a.setOnActionItemClickListener(this);
        a.show(indicator);
        break;

    case 300:
        QuickAction b = new QuickAction(getBaseContext());
        ActionItem j;
        if (SHOW_HIDDEN_FOLDERS)
            j = new ActionItem(1000, "Show Hidden Folders",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            j = new ActionItem(1000, "Show Hidden Folders",
                    getResources().getDrawable(R.drawable.ic_launcher_disabled));
        b.addActionItem(j);
        j = new ActionItem(1100, "Sorting", getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        b.addActionItem(j);
        b.setOnActionItemClickListener(this);
        b.show(indicator);
        break;

    case 400:
        // LAUNCHES AN INTERFACE FOR SELECTING A DIRECTORY FOR HOME
        // WITH REQUEST CODE 400
        new GetHomeDirectory(mContext, size.x * 4 / 5, preferences);
        break;
    case 500:
        // RESETS APP SETTINGS TO DEFAULT
        edit.clear();
        edit.putString("INTERNAL_PATH_ONE", INTERNAL_PATH_ONE = PATH);
        edit.putString("INTERNAL_PATH_TWO", INTERNAL_PATH_TWO = PATH);
        edit.putInt("SHOW_APP", SHOW_APP = 1);
        edit.putInt("CURRENT_PREF_ITEM", CURRENT_PREF_ITEM = 2);
        edit.putFloat("TRANS_LEVEL", TRANS_LEVEL = 0.8f);
        edit.putBoolean("SHOW_HIDDEN_FOLDERS", SHOW_HIDDEN_FOLDERS = false);
        edit.putInt("SORT_TYPE", SORT_TYPE = 2);
        edit.putInt("FOLDER_TYPE", FOLDER_TYPE = 3);
        edit.putString("HOME_DIRECTORY", HOME_DIRECTORY = null);
        edit.putBoolean("ENABLE_ON_LAUNCH", ENABLE_ON_LAUNCH = false);
        edit.commit();

        // CLEARING THE DEFAULT SELECTED APPS 
        SharedPreferences pr = getSharedPreferences("DEFAULT_APPS", MODE_PRIVATE);
        SharedPreferences.Editor ed = pr.edit();
        ed.clear();
        ed.commit();
        Toast.makeText(getBaseContext(), "Restored To Default", Toast.LENGTH_SHORT).show();
        break;
    case 600:
        CURRENT_ITEM = mViewPager.getCurrentItem();
        setAdapter(CURRENT_ITEM);
        break;
    case 700: {
        Dialog as = new Dialog(mContext, R.style.custom_dialog_theme);
        as.setContentView(R.layout.info_layout);
        as.getWindow().getAttributes().width = size.x * 5 / 6;
        as.setCancelable(true);
        as.show();
    }
        break;
    case 800:
        // DIRECTED FROM CASE 200 
        // IT IS FIRST OPTION AVAILABLE UNDER STARTUP
        QuickAction e = new QuickAction(getBaseContext());
        ActionItem m;
        if (CURRENT_PREF_ITEM == 0)
            m = new ActionItem(2200, "File Gallery", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            m = new ActionItem(2200, "File Gallery",
                    getResources().getDrawable(R.drawable.ic_launcher_startup));
        e.addActionItem(m);

        if (CURRENT_PREF_ITEM == 1)
            m = new ActionItem(2300, "/", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            m = new ActionItem(2300, "/", getResources().getDrawable(R.drawable.ic_launcher_startup));
        e.addActionItem(m);
        if (CURRENT_PREF_ITEM == 2)
            m = new ActionItem(2400, "SD Card", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            m = new ActionItem(2400, "SD Card", getResources().getDrawable(R.drawable.ic_launcher_startup));
        e.addActionItem(m);

        if (CURRENT_PREF_ITEM == 3)
            m = new ActionItem(2500, "Your App Store",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            m = new ActionItem(2500, "Your App Store",
                    getResources().getDrawable(R.drawable.ic_launcher_startup));
        e.addActionItem(m);
        e.setOnActionItemClickListener(this);
        e.show(indicator);
        break;
    case 900:
        // DIRECTED FROM CASE 200 
        // IT IS SECOND OPTION AVAILABLE UNDER STARTUP
        QuickAction f = new QuickAction(getBaseContext());
        ActionItem n = new ActionItem(2600, "/", getResources().getDrawable(R.drawable.ic_launcher_startup));
        f.addActionItem(n);
        n = new ActionItem(2700, "SD Card", getResources().getDrawable(R.drawable.ic_launcher_startup));
        f.addActionItem(n);

        if (ENABLE_ON_LAUNCH)
            n = new ActionItem(3600, "Enable On Launch",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            n = new ActionItem(3600, "Enable On Launch",
                    getResources().getDrawable(R.drawable.ic_launcher_disabled));
        f.addActionItem(n);

        f.setOnActionItemClickListener(this);
        f.show(indicator);
        break;

    case 1000:
        // CASE 300 DIRECTED QUICKACTION TO CASE 1000 , FIRST OPTION UNDER FOLDER OPTIONS
        // IF HIDDEN FOLDERS ARE VISIBLE HIDE IT OTHER WISE MAKE THEM VISIBLE
        if (SHOW_HIDDEN_FOLDERS) {
            edit.putBoolean("SHOW_HIDDEN_FOLDERS", false);
            SHOW_HIDDEN_FOLDERS = RFileManager.SHOW_HIDDEN_FOLDER = SFileManager.SHOW_HIDDEN_FOLDER = false;
        } else {
            SHOW_HIDDEN_FOLDERS = RFileManager.SHOW_HIDDEN_FOLDER = SFileManager.SHOW_HIDDEN_FOLDER = true;
            edit.putBoolean("SHOW_HIDDEN_FOLDERS", true);
        }
        edit.commit();
        setAdapter(CURRENT_ITEM);
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        break;
    case 1100:
        // DISPLAYS THE AVAILABLE SORTING METHODS AVAILABLE
        QuickAction c = new QuickAction(getBaseContext());
        ActionItem k;
        if (SORT_TYPE == 1)
            k = new ActionItem(1200, "Alphabetical Order",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            k = new ActionItem(1200, "Alphabetical Order",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        c.addActionItem(k);

        if (SORT_TYPE == 2)
            k = new ActionItem(1300, "Folder First Then File",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            k = new ActionItem(1300, "Folder First Then File",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        c.addActionItem(k);

        if (SORT_TYPE == 3)
            k = new ActionItem(1400, "File First Then Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            k = new ActionItem(1400, "File First Then Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        c.addActionItem(k);

        if (SORT_TYPE == 4)
            k = new ActionItem(1500, "Hidedn Item First",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            k = new ActionItem(1500, "Hidden Item First",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        c.addActionItem(k);

        if (SORT_TYPE == 5)
            k = new ActionItem(1600, "Non Hidden Item First",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            k = new ActionItem(1600, "Non Hidden First",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        c.addActionItem(k);
        c.setOnActionItemClickListener(this);
        c.show(indicator);
        break;

    case 1200:
        // DIRECTED FROM CASE 1100
        // SETS SORTING IN ALPHABETICAL ORDER
        SORT_TYPE = RFileManager.SORT_TYPE = SFileManager.SORT_TYPE = 1;
        edit.putInt("SORT_TYPE", 1);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 1300:
        // SETS SORTING IN FOLDER FIRST THEN FILE
        // DIRECTED FROM CASE 1100
        SORT_TYPE = RFileManager.SORT_TYPE = SFileManager.SORT_TYPE = 2;
        edit.putInt("SORT_TYPE", 2);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 1400:
        // SETS DORTING IN FILE FIRST THE FOLDER
        // DIRECTED FROM CASE 1100
        SORT_TYPE = RFileManager.SORT_TYPE = SFileManager.SORT_TYPE = 3;
        edit.putInt("SORT_TYPE", 3);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 1500:
        // SETS SORTING IN SHOW HIDDEN ITEM FIRST
        // DIRECTED FROM CASE 1100
        SORT_TYPE = RFileManager.SORT_TYPE = SFileManager.SORT_TYPE = 4;
        edit.putInt("SORT_TYPE", 4);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 1600:
        // SETS SORTING IN SHOW NON HIDDEN ITEMS FIRST
        // DIRECTED FROM CASE 1100
        SORT_TYPE = RFileManager.SORT_TYPE = SFileManager.SORT_TYPE = 5;
        edit.putInt("SORT_TYPE", 5);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 1700:
        //DIRECTED FROM CASE 100
        //SETS THE TRANSPARENCY TO 60%
        TRANS_LEVEL = 0.6f;
        edit.putFloat("TRANS_LEVEL", 0.6f);
        edit.commit();
        this.getWindow().getAttributes().alpha = TRANS_LEVEL;
        Toast.makeText(getBaseContext(), "Settings saved,restart app to view change", Toast.LENGTH_SHORT)
                .show();
        break;
    case 1800:
        //DIRECTED FROM CASE 100
        //SETS THE TRANSPARENCY TO 70%
        TRANS_LEVEL = 0.7f;
        edit.putFloat("TRANS_LEVEL", 0.7f);
        edit.commit();
        this.getWindow().getAttributes().alpha = TRANS_LEVEL;
        Toast.makeText(getBaseContext(), "Settings saved,restart app to view change", Toast.LENGTH_SHORT)
                .show();
        break;

    case 1900:
        //DIRECTED FROM CASE 100
        //SETS THE TRANSPARENCY TO 80%
        TRANS_LEVEL = 0.8f;
        edit.putFloat("TRANS_LEVEL", 0.8f);
        edit.commit();
        this.getWindow().getAttributes().alpha = TRANS_LEVEL;
        Toast.makeText(getBaseContext(), "Settings saved,restart app to view change", Toast.LENGTH_SHORT)
                .show();
        break;
    case 2000:
        //DIRECTED FROM CASE 100
        //SETS THE TRANSPARENCY TO 90%
        TRANS_LEVEL = 0.9f;
        edit.putFloat("TRANS_LEVEL", 0.9f);
        edit.commit();
        this.getWindow().getAttributes().alpha = TRANS_LEVEL;
        Toast.makeText(getBaseContext(), "Settings saved,restart app to view change", Toast.LENGTH_SHORT)
                .show();
        break;
    case 2100:
        //DIRECTED FROM CASE 100
        //SETS THE TRANSPARENCY TO 100%
        TRANS_LEVEL = 1.0f;
        edit.putFloat("TRANS_LEVEL", 1.0f);
        edit.commit();
        this.getWindow().getAttributes().alpha = TRANS_LEVEL;
        Toast.makeText(getBaseContext(), "Settings saved,restart app to view change", Toast.LENGTH_SHORT)
                .show();
        break;

    case 2200:
        //DIRECTED FROM CASE 800
        //SETS THE SETTING TO LOAD ALL FILE PANEL TO LOAD FIRST
        CURRENT_PREF_ITEM = 0;
        edit.putInt("CURRENT_PREF_ITEM", 0);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Saved", Toast.LENGTH_SHORT).show();
        break;
    case 2300:
        //DIRECTED FROM CASE 800
        //SETS THE SETTING TO LOAD SD CARD PANEL-1 TO LOAD FIRST
        CURRENT_PREF_ITEM = 1;
        edit.putInt("CURRENT_PREF_ITEM", 1);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Saved", Toast.LENGTH_SHORT).show();
        break;
    case 2400:
        //DIRECTED FROM CASE 800
        //SETS THE SETTING TO LOAD SD CARD PANEL-2 TO LOAD FIRST
        CURRENT_PREF_ITEM = 2;
        edit.putInt("CURRENT_PREF_ITEM", 2);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Saved", Toast.LENGTH_SHORT).show();
        break;
    case 2500:
        //DIRECTED FROM CASE 800
        //SETS THE SETTING TO LOAD ALL FILE PANEL TO LOAD FIRST
        //CURRENT_PREF_ITEM = 3;
        edit.putInt("CURRENT_PREF_ITEM", 3);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Saved", Toast.LENGTH_SHORT).show();
        break;

    case 2600:
        // LAUNCHES AN ACTIVITY TO SELECT THE DIRECTORY FOR INTERNAL STORAGE 1
        // DIRECTED FROM CASE 900
        new SetLaunchDir(mContext, size.x * 4 / 5, preferences, 1);
        break;
    case 2700:
        // LAUNCHES AN ACTIVITY TO SELECT THE DIRECTORY FOR INTERNAL STORAGE 2
        // DIRECTED FROM CASE 900
        new SetLaunchDir(mContext, size.x * 4 / 5, preferences, 2);
        break;

    case 2800:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO DEFAULT FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 0;
        edit.putInt("FOLDER_TYPE", 0);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 2900:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO VIOLET FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 1;
        edit.putInt("FOLDER_TYPE", 1);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 3000:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO OXYGEN FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 2;
        edit.putInt("FOLDER_TYPE", 2);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 3100:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO YELLOW FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 3;
        edit.putInt("FOLDER_TYPE", 3);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 3101:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO YELLOW FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 4;
        edit.putInt("FOLDER_TYPE", 4);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 3102:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO YELLOW FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 5;
        edit.putInt("FOLDER_TYPE", 5);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;
    case 3103:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO YELLOW FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 6;
        edit.putInt("FOLDER_TYPE", 6);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;
    case 3200:
        //DIRECTED FROM CASE 400 ONLY FOR APP PANEL
        // DISPLAYS OPTION FOR SETTING TO SHOW USER OR SYSTEM OR BOTH TYPES OF APP
        QuickAction s = new QuickAction(getBaseContext());
        ActionItem ti;
        if (SHOW_APP == 1)
            ti = new ActionItem(3300, "Show Downloaded Apps",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            ti = new ActionItem(3300, "Show Downloaded Apps",
                    getResources().getDrawable(R.drawable.ic_launcher_user));
        s.addActionItem(ti);

        if (SHOW_APP == 2)
            ti = new ActionItem(3400, "Show System Apps",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            ti = new ActionItem(3400, "Show System Apps",
                    getResources().getDrawable(R.drawable.ic_launcher_system));
        s.addActionItem(ti);

        if (SHOW_APP == 3)
            ti = new ActionItem(3500, "Show Both Of Them",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            ti = new ActionItem(3500, "Show Both Of Them",
                    getResources().getDrawable(R.drawable.ic_launcher_both));
        s.addActionItem(ti);
        s.setOnActionItemClickListener(this);
        s.show(indicator);
        break;
    case 3300:
        // SETS THE SETTING TO SHOW DOWNLOADED APPS ONLY
        // DIRECTED FROM CASE 3200
        edit.putInt("SHOW_APP", 1);
        edit.commit();
        SHOW_APP = nManager.SHOW_APP = 1;
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        nList = nManager.giveMeAppList();
        nAppAdapter = new AppAdapter(getBaseContext(), R.layout.row_list_1, nList);
        APP_LIST_VIEW.setAdapter(nAppAdapter);
        break;
    case 3400:
        // SETS THE SETTING TO SHOW SYSTEM APPS ONLY
        // DIRECTED FROM CASE 3200
        edit.putInt("SHOW_APP", 2);
        edit.commit();
        SHOW_APP = nManager.SHOW_APP = 2;
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        nList = nManager.giveMeAppList();
        nAppAdapter = new AppAdapter(getBaseContext(), R.layout.row_list_1, nList);
        APP_LIST_VIEW.setAdapter(nAppAdapter);
        break;

    case 3500:
        // SETS THE SETTING TO SHOW DOWNLOADED AND SYSTEM APPS
        // DIRECTED FROM CASE 3200
        edit.putInt("SHOW_APP", 3);
        edit.commit();
        SHOW_APP = nManager.SHOW_APP = 3;
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        nList = nManager.giveMeAppList();
        nAppAdapter = new AppAdapter(getBaseContext(), R.layout.row_list_1, nList);
        APP_LIST_VIEW.setAdapter(nAppAdapter);
        break;

    case 3600:
        // DIRECTED FROM CASE 900
        // ENABLES OR DISABLES TO SHOW PREFFERED DIRECTORY ON LAUNCH
        if (ENABLE_ON_LAUNCH)
            edit.putBoolean("ENABLE_ON_LAUNCH", ENABLE_ON_LAUNCH = false);
        else
            edit.putBoolean("ENABLE_ON_LAUNCH", ENABLE_ON_LAUNCH = true);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Saved", Toast.LENGTH_SHORT).show();
        break;

    }
}

From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java

private void closeScanRemoteNetworkProgressDlg(final Dialog dialog, final NotifyEvent p_ntfy,
        final ListView lv_ipaddr, final AdapterScanAddressResultList adap, final TextView tvmsg) {
    final LinearLayout ll_addr = (LinearLayout) dialog.findViewById(R.id.scan_remote_ntwk_scan_address);
    final LinearLayout ll_prog = (LinearLayout) dialog.findViewById(R.id.scan_remote_ntwk_progress);
    final Button btn_scan = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_ok);
    final Button btn_cancel = (Button) dialog.findViewById(R.id.scan_remote_ntwk_btn_cancel);
    ll_addr.setVisibility(LinearLayout.VISIBLE);
    ll_prog.setVisibility(LinearLayout.GONE);
    btn_scan.setVisibility(Button.VISIBLE);
    btn_cancel.setVisibility(Button.VISIBLE);
    adap.setButtonEnabled(true);//from  w w  w.  j  av a  2 s .c o  m
    dialog.setOnKeyListener(null);
    dialog.setCancelable(true);
    if (p_ntfy != null)
        p_ntfy.notifyToListener(true, null);

}