Search in sources :

Example 36 with Dialog

use of android.app.Dialog in project platform_frameworks_base by android.

the class PreferenceScreen method showDialog.

private void showDialog(Bundle state) {
    Context context = getContext();
    if (mListView != null) {
        mListView.setAdapter(null);
    }
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View childPrefScreen = inflater.inflate(mLayoutResId, null);
    View titleView = childPrefScreen.findViewById(android.R.id.title);
    mListView = (ListView) childPrefScreen.findViewById(android.R.id.list);
    if (mDividerSpecified) {
        mListView.setDivider(mDividerDrawable);
    }
    bind(mListView);
    // Set the title bar if title is available, else no title bar
    final CharSequence title = getTitle();
    Dialog dialog = mDialog = new Dialog(context, context.getThemeResId());
    if (TextUtils.isEmpty(title)) {
        if (titleView != null) {
            titleView.setVisibility(View.GONE);
        }
        dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    } else {
        if (titleView instanceof TextView) {
            ((TextView) titleView).setText(title);
            titleView.setVisibility(View.VISIBLE);
        } else {
            dialog.setTitle(title);
        }
    }
    dialog.setContentView(childPrefScreen);
    dialog.setOnDismissListener(this);
    if (state != null) {
        dialog.onRestoreInstanceState(state);
    }
    // Add the screen to the list of preferences screens opened as dialogs
    getPreferenceManager().addPreferencesScreen(dialog);
    dialog.show();
}
Also used : Context(android.content.Context) Dialog(android.app.Dialog) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 37 with Dialog

use of android.app.Dialog in project JamsMusicPlayer by psaravan.

the class AsyncGoogleMusicAuthenticationTask method onPostExecute.

@Override
protected void onPostExecute(String result) {
    super.onPostExecute(result);
    if (mFirstRun) {
        pd.dismiss();
    }
    //Perform an action based on the operation's result code.
    if (result.equals("GOOGLE_PLAY_SERVICES_AVAILABILITY_EXCEPTION")) {
        Dialog d = GooglePlayServicesUtil.getErrorDialog(availabilityExceptionStatusCode, mActivity, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR);
        d.show();
    } else if (result.equals("USER_RECOVERABLE_AUTH_EXCEPTION")) {
        //45 is an arbitrary value that identifies this activity's result.
        LauncherActivity.mAccountName = mAccountName;
        SettingsActivity____.mAccountName = mAccountName;
        if (mActivity != null) {
            mActivity.startActivityForResult(userRecoverableExceptionIntent, 45);
        }
    } else if (result.equals("GOOGLE_AUTH_EXCEPTION") || result.equals("GENERIC_EXCEPTION")) {
        Toast.makeText(mContext, R.string.unknown_error_google_music, Toast.LENGTH_LONG).show();
    } else if (result.equals("AUTHENTICATED")) {
        if (mFirstRun) {
            String text = mContext.getResources().getString(R.string.signed_in_as) + " " + mAccountName;
            Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
        } else if (mFirstRunFromSettings) {
            //Start scanning the library to add GMusic songs.
            String text = mContext.getResources().getString(R.string.signed_in_as) + " " + mAccountName;
            Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
            //Seting the "REBUILD_LIBRARY" flag to true will force MainActivity to rescan the folders.
            mApp.getSharedPreferences().edit().putBoolean("REBUILD_LIBRARY", true).commit();
            //Restart the app.
            final Intent i = mActivity.getBaseContext().getPackageManager().getLaunchIntentForPackage(mActivity.getBaseContext().getPackageName());
            i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            mActivity.finish();
            mActivity.startActivity(i);
        }
        mApp.getSharedPreferences().edit().putBoolean("GOOGLE_PLAY_MUSIC_ENABLED", true).commit();
    } else {
        Toast.makeText(mContext, R.string.unknown_error_google_music, Toast.LENGTH_LONG).show();
    }
}
Also used : ProgressDialog(android.app.ProgressDialog) Dialog(android.app.Dialog) Intent(android.content.Intent)

Example 38 with Dialog

use of android.app.Dialog in project JamsMusicPlayer by psaravan.

the class LicensesDialog method create.

public Dialog create() {
    //Get resources
    final WebView webView = new WebView(mContext);
    webView.loadDataWithBaseURL(null, mLicensesText, "text/html", "utf-8", null);
    final AlertDialog.Builder builder = new AlertDialog.Builder(mContext).setTitle(mTitleText).setView(webView).setPositiveButton(mCloseText, new Dialog.OnClickListener() {

        public void onClick(final DialogInterface dialogInterface, final int i) {
            dialogInterface.dismiss();
        }
    });
    final AlertDialog dialog = builder.create();
    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(final DialogInterface dialog) {
            if (mOnDismissListener != null) {
                mOnDismissListener.onDismiss(dialog);
            }
        }
    });
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) AlertDialog(android.app.AlertDialog) Dialog(android.app.Dialog) WebView(android.webkit.WebView)

Example 39 with Dialog

use of android.app.Dialog in project weiciyuan by qii.

the class UserAvatarDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    String path = getArguments().getString("path");
    final Rect ori = getArguments().getParcelable("rect");
    Bitmap bitmap = BitmapFactory.decodeFile(path);
    final View content = getActivity().getLayoutInflater().inflate(R.layout.useravatardialog_layout, null);
    final ImageView avatar = ((ImageView) content.findViewById(R.id.imageview));
    avatar.setImageBitmap(bitmap);
    avatar.setClickable(true);
    content.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            animateClose(avatar, ori);
        }
    });
    Dialog dialog = new Dialog(getActivity(), R.style.UserAvatarDialog) {

        @Override
        public boolean onKeyDown(int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
                animateClose(avatar, ori);
                return true;
            }
            return super.onKeyDown(keyCode, event);
        }
    };
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(content);
    content.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            content.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            if (ori == null) {
                return;
            }
            int[] avatarLocation = new int[2];
            avatar.getLocationOnScreen(avatarLocation);
            final int transX = ori.left - avatarLocation[0];
            final int transY = ori.top - avatarLocation[1];
            final float scaleX = (float) ori.width() / (float) avatar.getWidth();
            final float scaleY = (float) ori.height() / (float) avatar.getHeight();
            avatar.setTranslationX(transX);
            avatar.setTranslationY(transY);
            avatar.setPivotX(0);
            avatar.setPivotY(0);
            avatar.setScaleX(scaleX);
            avatar.setScaleY(scaleY);
            avatar.animate().translationX(0).translationY(0).scaleY(1).scaleX(1).alpha(1.0f).setDuration(300).withEndAction(new Runnable() {

                @Override
                public void run() {
                }
            });
        }
    });
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    return dialog;
}
Also used : KeyEvent(android.view.KeyEvent) Rect(android.graphics.Rect) Bitmap(android.graphics.Bitmap) Dialog(android.app.Dialog) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) ViewTreeObserver(android.view.ViewTreeObserver)

Example 40 with Dialog

use of android.app.Dialog in project weiciyuan by qii.

the class AboutFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(false);
    addPreferencesFromResource(R.xml.about_pref);
    findPreference(SettingActivity.SUGGEST).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent(getActivity(), WriteWeiboActivity.class);
            intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
            intent.putExtra("account", GlobalContext.getInstance().getAccountBean());
            intent.putExtra("content", buildContent());
            startActivity(intent);
            return true;
        }
    });
    findPreference(SettingActivity.VERSION).setSummary(buildVersionInfo());
    findPreference(SettingActivity.VERSION).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            ChangeLogDialog changeLogDialog = new ChangeLogDialog(getActivity());
            changeLogDialog.show();
            return true;
        }
    });
    findPreference(SettingActivity.DONATE).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            Dialog dialog = new Dialog(getActivity(), R.style.UserAvatarDialog);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            ImageView imageView = new ImageView(getActivity());
            imageView.setImageResource(R.drawable.alipay);
            dialog.setContentView(imageView);
            dialog.show();
            return true;
        }
    });
    detectDebugPreference();
    findPreference(SettingActivity.AUTHOR).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            blackMagicCount++;
            if (blackMagicCount > 3) {
                SettingUtility.setBlackMagicEnabled();
            }
            if (mp != null && mp.isPlaying()) {
                mp.stop();
                playing = false;
                return true;
            }
            if (mp == null || !playing) {
                mp = MediaPlayer.create(getActivity(), R.raw.star);
            }
            mp.start();
            playing = true;
            Toast.makeText(getActivity(), "♩♪♫♬♭", Toast.LENGTH_SHORT).show();
            return true;
        }
    });
    buildCacheSummary();
    buildLogSummary();
    findPreference(SettingActivity.SAVED_PIC_PATH).setSummary(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath());
}
Also used : Preference(android.preference.Preference) Dialog(android.app.Dialog) ChangeLogDialog(org.qii.weiciyuan.support.lib.changelogdialog.ChangeLogDialog) Intent(android.content.Intent) WriteWeiboActivity(org.qii.weiciyuan.ui.send.WriteWeiboActivity) ImageView(android.widget.ImageView) ChangeLogDialog(org.qii.weiciyuan.support.lib.changelogdialog.ChangeLogDialog)

Aggregations

Dialog (android.app.Dialog)385 View (android.view.View)122 AlertDialog (android.app.AlertDialog)115 DialogInterface (android.content.DialogInterface)98 TextView (android.widget.TextView)87 AlertDialog (android.support.v7.app.AlertDialog)49 Intent (android.content.Intent)44 LayoutInflater (android.view.LayoutInflater)39 EditText (android.widget.EditText)39 ListView (android.widget.ListView)36 ProgressDialog (android.app.ProgressDialog)35 Context (android.content.Context)33 AdapterView (android.widget.AdapterView)31 ImageView (android.widget.ImageView)30 LinearLayout (android.widget.LinearLayout)29 WindowManager (android.view.WindowManager)28 Test (org.junit.Test)25 Button (android.widget.Button)24 BrowserDialog (acr.browser.lightning.dialog.BrowserDialog)23 NonNull (android.support.annotation.NonNull)23