Search in sources :

Example 6 with Dialog

use of android.app.Dialog in project Shuttle by timusus.

the class DialogUtils method showColorPickerDialog.

public static void showColorPickerDialog(SettingsFragment fragment, int selectedColor, int[] mainColors, int[][] subColors, ColorSelectionListener listener) {
    View customView = LayoutInflater.from(fragment.getActivity()).inflate(R.layout.dialog_color_picker, null);
    RecyclerView recyclerView = (RecyclerView) customView.findViewById(R.id.recyclerView);
    GridLayoutManager gridLayoutManager = new GridLayoutManager(fragment.getActivity(), 5);
    recyclerView.setLayoutManager(gridLayoutManager);
    ThemeUtils.themeRecyclerView(recyclerView);
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            ThemeUtils.themeRecyclerView(recyclerView);
            super.onScrollStateChanged(recyclerView, newState);
        }
    });
    ColorAdapter colorAdapter = new ColorAdapter();
    List<AdaptableItem> colorViews = new ArrayList<>();
    for (int i = 0, length = mainColors.length; i < length; i++) {
        ColorView colorView = new ColorView(mainColors[i]);
        boolean selected = false;
        //If the sub colors array contains our selected color, then we set this colorView to selected.
        for (int j = 0, jLength = subColors[i].length; j < jLength; j++) {
            if (subColors[i][j] == selectedColor) {
                selected = true;
            }
        }
        colorView.selected = selected;
        colorViews.add(colorView);
    }
    colorAdapter.setItems(colorViews);
    recyclerView.setAdapter(colorAdapter);
    colorAdapter.setColorListener((position, color, isSubColor) -> {
        if (isSubColor) {
            colorAdapter.setSelectedPosition(position);
        } else {
            List<AdaptableItem> subColorViews = new ArrayList<>();
            for (int i = 0, length = subColors[position].length; i < length; i++) {
                ColorView colorView = new ColorView(subColors[position][i]);
                colorView.selected = colorView.color == selectedColor;
                subColorViews.add(colorView);
                colorAdapter.isSubColor = true;
            }
            colorAdapter.setItems(subColorViews);
        }
    });
    int neutralTextResId;
    TextView textView = (TextView) customView.findViewById(R.id.text1);
    if (ShuttleUtils.isUpgraded()) {
        textView.setVisibility(View.GONE);
        neutralTextResId = R.string.dialog_custom;
    } else {
        textView.setVisibility(View.VISIBLE);
        if (ShuttleUtils.isAmazonBuild()) {
            neutralTextResId = R.string.get_pro_button_amazon;
        } else {
            neutralTextResId = R.string.btn_upgrade;
        }
    }
    getBuilder(fragment.getActivity()).title(fragment.getActivity().getString(R.string.color_pick)).negativeText(R.string.cancel).onNegative((dialog, which) -> dialog.dismiss()).positiveText(R.string.button_done).onPositive((dialog, which) -> {
        int color = selectedColor;
        for (AdaptableItem item : colorAdapter.items) {
            if (((ColorView) item).selected) {
                color = ((ColorView) item).color;
                break;
            }
        }
        listener.colorSelected(color);
        dialog.dismiss();
    }).neutralText(neutralTextResId).autoDismiss(false).onNeutral((dialog, which) -> {
        if (ShuttleUtils.isUpgraded()) {
            showCustomColorPickerDialog(fragment.getActivity(), selectedColor, listener);
            dialog.dismiss();
        } else {
            showUpgradeDialog(fragment.getActivity(), (upgradeDialog, which1) -> {
                if (ShuttleUtils.isAmazonBuild()) {
                    ShuttleUtils.openShuttleLink(fragment.getActivity(), "com.simplecity.amp_pro");
                } else {
                    AnalyticsManager.logUpgrade(AnalyticsManager.UpgradeType.COLORS);
                    ((SettingsActivity) fragment.getActivity()).purchasePremiumUpgrade();
                }
            });
        }
    }).customView(customView, false).show();
}
Also used : ContentProviderOperation(android.content.ContentProviderOperation) R(com.simplecity.amp_library.R) GridLayoutManager(android.support.v7.widget.GridLayoutManager) ProgressBar(android.widget.ProgressBar) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) PlayCountTable(com.simplecity.amp_library.sql.providers.PlayCountTable) Drawable(android.graphics.drawable.Drawable) FileProvider(android.support.v4.content.FileProvider) Song(com.simplecity.amp_library.model.Song) FileObject(com.simplecity.amp_library.model.FileObject) Schedulers(rx.schedulers.Schedulers) View(android.view.View) BlacklistView(com.simplecity.amp_library.ui.modelviews.BlacklistView) BlacklistAdapter(com.simplecity.amp_library.ui.adapters.BlacklistAdapter) SimpleTarget(com.bumptech.glide.request.target.SimpleTarget) WhitelistAdapter(com.simplecity.amp_library.ui.adapters.WhitelistAdapter) R.id.album(com.simplecity.amp_library.R.id.album) MainActivity(com.simplecity.amp_library.ui.activities.MainActivity) ColorView(com.simplecity.amp_library.ui.modelviews.ColorView) R.id.artist(com.simplecity.amp_library.R.id.artist) WhitelistHelper(com.simplecity.amp_library.sql.databases.WhitelistHelper) FileNotFoundException(java.io.FileNotFoundException) CustomColorPicker(com.simplecity.amp_library.ui.views.CustomColorPicker) List(java.util.List) TextView(android.widget.TextView) ColorAdapter(com.simplecity.amp_library.ui.adapters.ColorAdapter) Html(android.text.Html) LastFmArtist(com.simplecity.amp_library.lastfm.LastFmArtist) ListView(android.widget.ListView) AdaptableItem(com.simplecity.amp_library.model.AdaptableItem) Snackbar(android.support.design.widget.Snackbar) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Call(retrofit2.Call) Subscription(rx.Subscription) NumberPicker(android.widget.NumberPicker) SettingsActivity(com.simplecity.amp_library.ui.activities.SettingsActivity) Context(android.content.Context) LastFmAlbum(com.simplecity.amp_library.lastfm.LastFmAlbum) Stream(com.annimon.stream.Stream) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) HttpClient(com.simplecity.amp_library.http.HttpClient) Dialog(android.app.Dialog) Intent(android.content.Intent) RemoteException(android.os.RemoteException) StringRes(android.support.annotation.StringRes) Response(retrofit2.Response) SettingsFragment(com.simplecity.amp_library.ui.fragments.SettingsFragment) ArrayList(java.util.ArrayList) Observable(rx.Observable) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation) WhitelistView(com.simplecity.amp_library.ui.modelviews.WhitelistView) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) BlacklistedSong(com.simplecity.amp_library.model.BlacklistedSong) SqlBriteUtils(com.simplecity.amp_library.sql.sqlbrite.SqlBriteUtils) Collectors(com.annimon.stream.Collectors) ComponentName(android.content.ComponentName) LayoutInflater(android.view.LayoutInflater) IntentCompat(android.support.v4.content.IntentCompat) FileOutputStream(java.io.FileOutputStream) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) IOException(java.io.IOException) File(java.io.File) OperationApplicationException(android.content.OperationApplicationException) Color(android.graphics.Color) RecyclerView(android.support.v7.widget.RecyclerView) ArrayAdapter(android.widget.ArrayAdapter) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) BlacklistHelper(com.simplecity.amp_library.sql.databases.BlacklistHelper) Glide(com.bumptech.glide.Glide) Callback(retrofit2.Callback) ScrollView(android.widget.ScrollView) Bitmap(android.graphics.Bitmap) Activity(android.app.Activity) ArrayList(java.util.ArrayList) AdaptableItem(com.simplecity.amp_library.model.AdaptableItem) View(android.view.View) BlacklistView(com.simplecity.amp_library.ui.modelviews.BlacklistView) ColorView(com.simplecity.amp_library.ui.modelviews.ColorView) TextView(android.widget.TextView) ListView(android.widget.ListView) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) WhitelistView(com.simplecity.amp_library.ui.modelviews.WhitelistView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) ColorView(com.simplecity.amp_library.ui.modelviews.ColorView) GridLayoutManager(android.support.v7.widget.GridLayoutManager) ColorAdapter(com.simplecity.amp_library.ui.adapters.ColorAdapter) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) SettingsActivity(com.simplecity.amp_library.ui.activities.SettingsActivity)

Example 7 with Dialog

use of android.app.Dialog in project Shuttle by timusus.

the class PlaylistUtils method renamePlaylistDialog.

public static void renamePlaylistDialog(final Context context, final Playlist playlist, final MaterialDialog.SingleButtonCallback listener) {
    View customView = LayoutInflater.from(context).inflate(R.layout.dialog_playlist, null);
    final CustomEditText editText = (CustomEditText) customView.findViewById(R.id.editText);
    editText.setText(playlist.name);
    MaterialDialog.Builder builder = DialogUtils.getBuilder(context).title(R.string.create_playlist_create_text_prompt).customView(customView, false).positiveText(R.string.save).onPositive((materialDialog, dialogAction) -> {
        String name = editText.getText().toString();
        if (name.length() > 0) {
            ContentResolver resolver = context.getContentResolver();
            ContentValues values = new ContentValues(1);
            values.put(MediaStore.Audio.Playlists.NAME, name);
            resolver.update(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, values, MediaStore.Audio.Playlists._ID + "=?", new String[] { Long.valueOf(playlist.id).toString() });
            playlist.name = name;
            Toast.makeText(context, R.string.playlist_renamed_message, Toast.LENGTH_SHORT).show();
        }
        if (listener != null) {
            listener.onClick(materialDialog, dialogAction);
        }
    }).negativeText(R.string.cancel);
    final MaterialDialog dialog = builder.build();
    TextWatcher textWatcher = new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // check if playlist with current name exists already, and warn the user if so.
            setSaveButton(dialog, playlist, editText.getText().toString());
        }

        public void afterTextChanged(Editable s) {
        }
    };
    editText.addTextChangedListener(textWatcher);
    dialog.show();
}
Also used : R(com.simplecity.amp_library.R) Spannable(android.text.Spannable) Uri(android.net.Uri) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) PlayCountTable(com.simplecity.amp_library.sql.providers.PlayCountTable) Song(com.simplecity.amp_library.model.Song) CheckBox(android.widget.CheckBox) ContentResolver(android.content.ContentResolver) MediaStore(android.provider.MediaStore) Schedulers(rx.schedulers.Schedulers) View(android.view.View) Log(android.util.Log) Playlist(com.simplecity.amp_library.model.Playlist) BaseColumns(android.provider.BaseColumns) SubMenu(android.view.SubMenu) Query(com.simplecity.amp_library.model.Query) List(java.util.List) TextView(android.widget.TextView) ContentValues(android.content.ContentValues) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) SqlUtils(com.simplecity.amp_library.sql.SqlUtils) TextWatcher(android.text.TextWatcher) FileType(com.simplecity.amp_library.interfaces.FileType) Context(android.content.Context) Stream(com.annimon.stream.Stream) Environment(android.os.Environment) Dialog(android.app.Dialog) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) Editable(android.text.Editable) Observable(rx.Observable) SpannableStringBuilder(android.text.SpannableStringBuilder) Func1(rx.functions.Func1) Toast(android.widget.Toast) BaseFileObject(com.simplecity.amp_library.model.BaseFileObject) Cursor(android.database.Cursor) SqlBriteUtils(com.simplecity.amp_library.sql.sqlbrite.SqlBriteUtils) Collectors(com.annimon.stream.Collectors) LayoutInflater(android.view.LayoutInflater) StyleSpan(android.text.style.StyleSpan) FileWriter(java.io.FileWriter) ProgressDialog(android.app.ProgressDialog) TextUtils(android.text.TextUtils) DialogAction(com.afollestad.materialdialogs.DialogAction) IOException(java.io.IOException) WorkerThread(android.support.annotation.WorkerThread) File(java.io.File) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) MusicService(com.simplecity.amp_library.playback.MusicService) Crashlytics(com.crashlytics.android.Crashlytics) CustomEditText(com.simplecity.amp_library.ui.views.CustomEditText) EditText(android.widget.EditText) ContentUris(android.content.ContentUris) ContentValues(android.content.ContentValues) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) CustomEditText(com.simplecity.amp_library.ui.views.CustomEditText) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) View(android.view.View) TextView(android.widget.TextView) ContentResolver(android.content.ContentResolver)

Example 8 with Dialog

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

the class FakeApp method onCreate.

@Override
public void onCreate() {
    String processName = ActivityThread.currentProcessName();
    Slog.i("FakeOEMFeatures", "Creating app in process: " + processName);
    if (!getApplicationInfo().packageName.equals(processName)) {
        // our extra overhead stuff.
        return;
    }
    final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    final Display display = wm.getDefaultDisplay();
    // is a user build, WARN!  Do not want!
    if ("user".equals(android.os.Build.TYPE)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Should not be on user build");
        builder.setMessage("The app Fake OEM Features should not be installed on a " + "user build.  Please remove this .apk before shipping this build to " + " your customers!");
        builder.setCancelable(false);
        builder.setPositiveButton("I understand", null);
        Dialog dialog = builder.create();
        dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        dialog.show();
    }
    // Make a fake window that is always around eating graphics resources.
    FakeView view = new FakeView(this);
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    if (ActivityManager.isHighEndGfx()) {
        lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
    }
    lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
    lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
    int maxSize = display.getMaximumSizeDimension();
    maxSize *= 2;
    lp.x = maxSize;
    lp.y = maxSize;
    lp.setTitle(getPackageName());
    wm.addView(view, lp);
    // Bind to a fake service we want to keep running in another process.
    bindService(new Intent(this, FakeCoreService.class), mServiceConnection, Context.BIND_AUTO_CREATE);
    bindService(new Intent(this, FakeCoreService2.class), mServiceConnection2, Context.BIND_AUTO_CREATE);
    bindService(new Intent(this, FakeCoreService3.class), mServiceConnection3, Context.BIND_AUTO_CREATE);
    // Start to a fake service that should run in the background of
    // another process.
    mHandler.sendEmptyMessage(MSG_TICK);
    // Make a fake allocation to consume some RAM.
    mStuffing = new int[STUFFING_SIZE_INTS];
    for (int i = 0; i < STUFFING_SIZE_BYTES / PAGE_SIZE; i++) {
        // Fill each page with a unique value.
        final int VAL = i * 2 + 100;
        final int OFF = (i * PAGE_SIZE) / 4;
        for (int j = 0; j < (PAGE_SIZE / 4); j++) {
            mStuffing[OFF + j] = VAL;
        }
    }
}
Also used : AlertDialog(android.app.AlertDialog) Intent(android.content.Intent) WindowManager(android.view.WindowManager) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) Display(android.view.Display)

Example 9 with Dialog

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

the class FakeBackgroundService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    mHandler.sendEmptyMessageDelayed(MSG_TICK, TICK_DELAY);
    final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    final Display display = wm.getDefaultDisplay();
    // Make a fake window that is always around eating graphics resources.
    FakeView view = new FakeView(this);
    Dialog dialog = new Dialog(this, android.R.style.Theme_Holo_Dialog);
    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED | WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    dialog.getWindow().setDimAmount(0);
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
    int maxSize = display.getMaximumSizeDimension();
    maxSize *= 2;
    lp.x = maxSize;
    lp.y = maxSize;
    lp.setTitle(getPackageName() + ":background");
    dialog.getWindow().setAttributes(lp);
    dialog.getWindow().setContentView(view);
    dialog.show();
}
Also used : Dialog(android.app.Dialog) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 10 with Dialog

use of android.app.Dialog in project simplefacebook by androidquery.

the class FeedFragment method askYesNo.

protected void askYesNo(Activity context, String title, String question, String yes, String no) {
    Dialog dialog = new AlertDialog.Builder(context).setTitle(title).setMessage(question).setPositiveButton(yes, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            refresh();
        }
    }).setNegativeButton(no, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
        }
    }).create();
    dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) OnClickListener(android.view.View.OnClickListener)

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