Search in sources :

Example 26 with Dialog

use of android.app.Dialog in project MusicDNA by harjot-oberai.

the class HomeActivity method renamePlaylistDialog.

public void renamePlaylistDialog(String oldName) {
    final Dialog dialog = new Dialog(ctx);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.save_image_dialog);
    TextView titleText = (TextView) dialog.findViewById(R.id.dialog_title);
    titleText.setText("Rename");
    if (SplashActivity.tf4 != null)
        titleText.setTypeface(SplashActivity.tf4);
    Button btn = (Button) dialog.findViewById(R.id.save_image_btn);
    final EditText newName = (EditText) dialog.findViewById(R.id.save_image_filename_text);
    CheckBox cb = (CheckBox) dialog.findViewById(R.id.text_checkbox);
    cb.setVisibility(GONE);
    newName.setText(oldName);
    btn.setBackgroundColor(themeColor);
    btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean isNameRepeat = false;
            if (newName.getText().toString().trim().equals("")) {
                newName.setError("Enter Playlist Name!");
            } else {
                for (int i = 0; i < allPlaylists.getPlaylists().size(); i++) {
                    if (newName.getText().toString().equals(allPlaylists.getPlaylists().get(i).getPlaylistName())) {
                        isNameRepeat = true;
                        newName.setError("Playlist with same name exists!");
                        break;
                    }
                }
                if (!isNameRepeat) {
                    allPlaylists.getPlaylists().get(renamePlaylistNumber).setPlaylistName(newName.getText().toString());
                    if (pAdapter != null) {
                        pAdapter.notifyItemChanged(renamePlaylistNumber);
                    }
                    AllPlaylistsFragment plFrag = (AllPlaylistsFragment) fragMan.findFragmentByTag("allPlaylists");
                    if (plFrag != null) {
                        plFrag.itemChanged(renamePlaylistNumber);
                    }
                    if (isPlaylistVisible) {
                        ViewPlaylistFragment vplFragment = (ViewPlaylistFragment) fragMan.findFragmentByTag("playlist");
                        vplFragment.updateViewPlaylistFragment();
                    }
                    new SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    dialog.dismiss();
                }
            }
        }
    });
    dialog.show();
}
Also used : EditText(android.widget.EditText) Button(android.widget.Button) Dialog(android.app.Dialog) CustomLocalBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog) CustomGeneralBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog) CheckBox(android.widget.CheckBox) ViewPlaylistFragment(com.sdsmdg.harjot.MusicDNA.fragments.ViewPlaylistFragment.ViewPlaylistFragment) TextView(android.widget.TextView) AllPlaylistsFragment(com.sdsmdg.harjot.MusicDNA.fragments.AllPlaylistsFragment.AllPlaylistsFragment) ImageView(android.widget.ImageView) VisualizerView(com.sdsmdg.harjot.MusicDNA.visualizers.VisualizerView) RecyclerView(android.support.v7.widget.RecyclerView) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) WheelView(com.lantouzi.wheelview.WheelView) ListView(android.widget.ListView)

Example 27 with Dialog

use of android.app.Dialog in project MusicDNA by harjot-oberai.

the class HomeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    screen_width = display.getWidth();
    screen_height = display.getHeight();
    ratio = (float) screen_height / (float) 1920;
    ratio2 = (float) screen_width / (float) 1080;
    ratio = Math.min(ratio, ratio2);
    setContentView(R.layout.activity_home);
    headSetReceiver = new HeadSetReceiver();
    IntentFilter filter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
    registerReceiver(headSetReceiver, filter);
    PackageInfo pInfo;
    try {
        pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        versionName = pInfo.versionName;
        versionCode = pInfo.versionCode;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    mEndButton = new Button(this);
    mEndButton.setBackgroundColor(themeColor);
    mEndButton.setTextColor(Color.WHITE);
    tp = new TextPaint();
    tp.setColor(themeColor);
    tp.setTextSize(65 * ratio);
    tp.setFakeBoldText(true);
    recentsViewAll = (TextView) findViewById(R.id.recents_view_all);
    recentsViewAll.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showFragment("recent");
        }
    });
    playlistsViewAll = (TextView) findViewById(R.id.playlists_view_all);
    playlistsViewAll.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showFragment("allPlaylists");
        }
    });
    copyrightText = (TextView) findViewById(R.id.copyright_text);
    copyrightText.setText("Music DNA v" + versionName);
    if (SplashActivity.tf4 != null) {
        try {
            copyrightText.setTypeface(SplashActivity.tf4);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    imgLoader = new ImageLoader(this);
    ctx = this;
    initializeHeaderImages();
    hasSoftNavbar = CommonUtils.hasNavBar(this);
    statusBarHeightinDp = CommonUtils.getStatusBarHeight(this);
    navBarHeightSizeinDp = hasSoftNavbar ? CommonUtils.getNavBarHeight(this) : 0;
    serviceConnection = new ServiceConnection() {

        @Override
        public void onServiceConnected(ComponentName className, IBinder service) {
            // cast the IBinder and get MyService instance
            MediaPlayerService.LocalBinder binder = (MediaPlayerService.LocalBinder) service;
            myService = binder.getService();
            bound = true;
            // register
            myService.setCallbacks(HomeActivity.this);
        }

        @Override
        public void onServiceDisconnected(ComponentName arg0) {
            bound = false;
        }
    };
    minuteList = new ArrayList<>();
    for (int i = 1; i < 25; i++) {
        minuteList.add(String.valueOf(i * 5));
    }
    sleepHandler = new Handler();
    lps = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    int margin = ((Number) (getResources().getDisplayMetrics().density * 12)).intValue();
    lps.setMargins(margin, margin, margin, navBarHeightSizeinDp + ((Number) (getResources().getDisplayMetrics().density * 5)).intValue());
    fragMan = getSupportFragmentManager();
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    if (SplashActivity.tf4 != null) {
        collapsingToolbar.setCollapsedTitleTypeface(SplashActivity.tf4);
        collapsingToolbar.setExpandedTitleTypeface(SplashActivity.tf4);
    }
    customLinearGradient = (CustomLinearGradient) findViewById(R.id.custom_linear_gradient);
    customLinearGradient.setAlpha(170);
    customLinearGradient.invalidate();
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        navigationView.setNavigationItemSelectedListener(this);
    }
    navigationView.setCheckedItem(R.id.nav_home);
    View header = navigationView.getHeaderView(0);
    navImageView = (ImageView) header.findViewById(R.id.nav_image_view);
    if (navImageView != null) {
        navImageView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                PlayerFragment pFrag = getPlayerFragment();
                if (pFrag != null) {
                    if (pFrag.mMediaPlayer != null && pFrag.mMediaPlayer.isPlaying()) {
                        onBackPressed();
                        isPlayerVisible = true;
                        //                            hideTabs();
                        showPlayer();
                    }
                }
            }
        });
    }
    connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    phoneStateListener = new PhoneStateListener() {

        @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            PlayerFragment pFrag = playerFragment;
            if (playerFragment != null) {
                if (state == TelephonyManager.CALL_STATE_RINGING) {
                    //Incoming call: Pause music
                    if (pFrag.mMediaPlayer != null && pFrag.mMediaPlayer.isPlaying()) {
                        wasMediaPlayerPlaying = true;
                        pFrag.togglePlayPause();
                    } else {
                        wasMediaPlayerPlaying = false;
                    }
                } else if (state == TelephonyManager.CALL_STATE_IDLE) {
                    //Not in call: Play music
                    if (pFrag.mMediaPlayer != null && !pFrag.mMediaPlayer.isPlaying() && wasMediaPlayerPlaying) {
                        pFrag.togglePlayPause();
                    }
                } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
                    //A call is dialing, active or on hold
                    if (playerFragment.mMediaPlayer != null && pFrag.mMediaPlayer.isPlaying()) {
                        wasMediaPlayerPlaying = true;
                        pFrag.togglePlayPause();
                    } else {
                        wasMediaPlayerPlaying = false;
                    }
                }
            }
            super.onCallStateChanged(state, incomingNumber);
        }
    };
    TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    if (mgr != null) {
        mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
    }
    mPrefs = getPreferences(MODE_PRIVATE);
    prefsEditor = mPrefs.edit();
    gson = new Gson();
    main = this;
    localBanner = (RelativeLayout) findViewById(R.id.localBanner);
    favBanner = (ImageView) findViewById(R.id.favBanner);
    recentBanner = (ImageView) findViewById(R.id.recentBanner);
    folderBanner = (ImageView) findViewById(R.id.folderBanner);
    savedDNABanner = (ImageView) findViewById(R.id.savedDNABanner);
    localBannerPlayAll = (ImageView) findViewById(R.id.local_banner_play_all);
    localBanner.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showFragment("local");
        }
    });
    favBanner.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showFragment("favourite");
        }
    });
    recentBanner.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showFragment("recent");
        }
    });
    folderBanner.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showFragment("allFolders");
        }
    });
    savedDNABanner.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showFragment("allSavedDNAs");
        }
    });
    localBannerPlayAll.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            queue.getQueue().clear();
            for (int i = 0; i < localTrackList.size(); i++) {
                UnifiedTrack ut = new UnifiedTrack(true, localTrackList.get(i), null);
                queue.getQueue().add(ut);
            }
            if (queue.getQueue().size() > 0) {
                Random r = new Random();
                int tmp = r.nextInt(queue.getQueue().size());
                queueCurrentIndex = tmp;
                LocalTrack track = localTrackList.get(tmp);
                localSelectedTrack = track;
                streamSelected = false;
                localSelected = true;
                queueCall = false;
                isReloaded = false;
                onLocalTrackSelected(-1);
            }
        }
    });
    bottomToolbar = (FrameLayout) findViewById(R.id.bottomMargin);
    spHome = (Toolbar) findViewById(R.id.smallPlayer_home);
    playerControllerHome = (ImageView) findViewById(R.id.player_control_sp_home);
    spImgHome = (CircleImageView) findViewById(R.id.selected_track_image_sp_home);
    spTitleHome = (TextView) findViewById(R.id.selected_track_title_sp_home);
    playerControllerHome.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (queue != null && queue.getQueue().size() > 0) {
                onQueueItemClicked(queueCurrentIndex);
                bottomToolbar.setVisibility(View.INVISIBLE);
            }
        }
    });
    playerControllerHome.setImageResource(R.drawable.ic_play_arrow_white_48dp);
    spHome.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (queue != null && queue.getQueue().size() > 0) {
                onQueueItemClicked(queueCurrentIndex);
                bottomToolbar.setVisibility(View.INVISIBLE);
            }
        }
    });
    localRecyclerContainer = (RelativeLayout) findViewById(R.id.localRecyclerContainer);
    recentsRecyclerContainer = (RelativeLayout) findViewById(R.id.recentsRecyclerContainer);
    streamRecyclerContainer = (RelativeLayout) findViewById(R.id.streamRecyclerContainer);
    playlistRecyclerContainer = (RelativeLayout) findViewById(R.id.playlistRecyclerContainer);
    if (SplashActivity.tf4 != null) {
        try {
            ((TextView) findViewById(R.id.playListRecyclerLabel)).setTypeface(SplashActivity.tf4);
            ((TextView) findViewById(R.id.recentsRecyclerLabel)).setTypeface(SplashActivity.tf4);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    localNothingText = (TextView) findViewById(R.id.localNothingText);
    streamNothingText = (TextView) findViewById(R.id.streamNothingText);
    recentsNothingText = (TextView) findViewById(R.id.recentsNothingText);
    playlistNothingText = (TextView) findViewById(R.id.playlistNothingText);
    localViewAll = (TextView) findViewById(R.id.localViewAll);
    localViewAll.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showFragment("local");
        }
    });
    streamViewAll = (TextView) findViewById(R.id.streamViewAll);
    streamViewAll.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showFragment("stream");
        }
    });
    progress = new Dialog(ctx);
    progress.setCancelable(false);
    progress.requestWindowFeature(Window.FEATURE_NO_TITLE);
    progress.setContentView(R.layout.custom_progress_dialog);
    progress.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    progress.show();
    showCase = new ShowcaseView.Builder(this).blockAllTouches().singleShot(0).setStyle(R.style.CustomShowcaseTheme).useDecorViewAsParent().replaceEndButton(mEndButton).setContentTitlePaint(tp).setTarget(new ViewTarget(R.id.recentsRecyclerLabel, this)).setContentTitle("Recents and Playlists").setContentText("Here all you recent songs and playlists will be listed." + "Long press the cards or playlists for more options \n" + "\n" + "(Press Next to continue / Press back to Hide)").build();
    showCase.setButtonText("Next");
    showCase.setButtonPosition(lps);
    showCase.overrideButtonClick(new View.OnClickListener() {

        int count1 = 0;

        @Override
        public void onClick(View v) {
            count1++;
            switch(count1) {
                case 1:
                    showCase.setTarget(new ViewTarget(R.id.local_banner_alt_showcase, (Activity) ctx));
                    showCase.setContentTitle("Local Songs");
                    showCase.setContentText("See all songs available locally, classified on basis of Artist and Album");
                    showCase.setButtonPosition(lps);
                    showCase.setButtonText("Next");
                    break;
                case 2:
                    showCase.setTarget(new ViewTarget(searchView.getId(), (Activity) ctx));
                    showCase.setContentTitle("Search");
                    showCase.setContentText("Search for songs from local library and SoundCloud™");
                    showCase.setButtonPosition(lps);
                    showCase.setButtonText("Done");
                    break;
                case 3:
                    showCase.hide();
                    break;
            }
        }
    });
    new loadSavedData().execute();
}
Also used : ServiceConnection(android.content.ServiceConnection) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Gson(com.google.gson.Gson) ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) WindowManager(android.view.WindowManager) IBinder(android.os.IBinder) PackageManager(android.content.pm.PackageManager) Random(java.util.Random) Button(android.widget.Button) TelephonyManager(android.telephony.TelephonyManager) Dialog(android.app.Dialog) CustomLocalBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog) CustomGeneralBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog) PhoneStateListener(android.telephony.PhoneStateListener) HeadSetReceiver(com.sdsmdg.harjot.MusicDNA.headsethandler.HeadSetReceiver) ComponentName(android.content.ComponentName) TextView(android.widget.TextView) MediaPlayerService(com.sdsmdg.harjot.MusicDNA.notificationmanager.MediaPlayerService) PlayerFragment(com.sdsmdg.harjot.MusicDNA.fragments.PlayerFragment.PlayerFragment) IntentFilter(android.content.IntentFilter) PackageInfo(android.content.pm.PackageInfo) Handler(android.os.Handler) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) ImageView(android.widget.ImageView) VisualizerView(com.sdsmdg.harjot.MusicDNA.visualizers.VisualizerView) RecyclerView(android.support.v7.widget.RecyclerView) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) WheelView(com.lantouzi.wheelview.WheelView) ListView(android.widget.ListView) FileNotFoundException(java.io.FileNotFoundException) TextPaint(android.text.TextPaint) TextPaint(android.text.TextPaint) ColorDrawable(android.graphics.drawable.ColorDrawable) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) RelativeLayout(android.widget.RelativeLayout) ImageLoader(com.sdsmdg.harjot.MusicDNA.imageloader.ImageLoader) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) Display(android.view.Display)

Example 28 with Dialog

use of android.app.Dialog in project MusicDNA by harjot-oberai.

the class HomeActivity method showAddToPlaylistDialog.

public void showAddToPlaylistDialog(final UnifiedTrack track) {
    final Dialog dialog = new Dialog(ctx);
    dialog.setContentView(R.layout.add_to_playlist_dialog);
    dialog.setTitle("Add to Playlist");
    ListView lv = (ListView) dialog.findViewById(R.id.playlist_list);
    AddToPlaylistAdapter adapter;
    if (allPlaylists.getPlaylists() != null && allPlaylists.getPlaylists().size() != 0) {
        adapter = new AddToPlaylistAdapter(allPlaylists.getPlaylists(), ctx);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Playlist temp = allPlaylists.getPlaylists().get(position);
                boolean isRepeat = false;
                for (UnifiedTrack ut : temp.getSongList()) {
                    if (track.getType() && ut.getType() && track.getLocalTrack().getTitle().equals(ut.getLocalTrack().getTitle())) {
                        isRepeat = true;
                        break;
                    } else if (!track.getType() && !ut.getType() && track.getStreamTrack().getTitle().equals(ut.getStreamTrack().getTitle())) {
                        isRepeat = true;
                        break;
                    }
                }
                if (!isRepeat) {
                    temp.addSong(track);
                    playlistsRecycler.setVisibility(View.VISIBLE);
                    playlistNothingText.setVisibility(View.INVISIBLE);
                    pAdapter.notifyDataSetChanged();
                    Toast.makeText(ctx, "Added to Playlist : " + temp.getPlaylistName(), Toast.LENGTH_SHORT).show();
                    new SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    dialog.dismiss();
                } else {
                    Toast.makeText(ctx, "Song already present in Playlist", Toast.LENGTH_SHORT).show();
                }
            }
        });
    } else {
        lv.setVisibility(GONE);
    }
    // set the custom dialog components - text, image and button
    final EditText text = (EditText) dialog.findViewById(R.id.new_playlist_name);
    ImageView image = (ImageView) dialog.findViewById(R.id.confirm_button);
    // if button is clicked, close the custom dialog
    image.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean isNameRepeat = false;
            if (text.getText().toString().trim().equals("")) {
                text.setError("Enter Playlist Name!");
            } else {
                for (int i = 0; i < allPlaylists.getPlaylists().size(); i++) {
                    if (text.getText().toString().equals(allPlaylists.getPlaylists().get(i).getPlaylistName())) {
                        isNameRepeat = true;
                        text.setError("Playlist with same name exists!");
                        break;
                    }
                }
                if (!isNameRepeat) {
                    List<UnifiedTrack> l = new ArrayList<UnifiedTrack>();
                    l.add(track);
                    Playlist pl = new Playlist(l, text.getText().toString().trim());
                    allPlaylists.addPlaylist(pl);
                    playlistsRecycler.setVisibility(View.VISIBLE);
                    playlistNothingText.setVisibility(View.INVISIBLE);
                    pAdapter.notifyDataSetChanged();
                    dialog.dismiss();
                    new SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                }
            }
        }
    });
    dialog.show();
}
Also used : EditText(android.widget.EditText) AddToPlaylistAdapter(com.sdsmdg.harjot.MusicDNA.adapters.playlistdialogadapter.AddToPlaylistAdapter) ImageView(android.widget.ImageView) VisualizerView(com.sdsmdg.harjot.MusicDNA.visualizers.VisualizerView) RecyclerView(android.support.v7.widget.RecyclerView) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) WheelView(com.lantouzi.wheelview.WheelView) ListView(android.widget.ListView) TextPaint(android.text.TextPaint) Playlist(com.sdsmdg.harjot.MusicDNA.models.Playlist) ListView(android.widget.ListView) Dialog(android.app.Dialog) CustomLocalBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog) CustomGeneralBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) AdapterView(android.widget.AdapterView) ColorStateList(android.content.res.ColorStateList) ArrayList(java.util.ArrayList) List(java.util.List) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView)

Example 29 with Dialog

use of android.app.Dialog in project MusicDNA by harjot-oberai.

the class HomeActivity method showSaveQueueDialog.

public void showSaveQueueDialog() {
    final Dialog dialog = new Dialog(ctx);
    dialog.setContentView(R.layout.add_to_playlist_dialog);
    dialog.setTitle("Save Queue");
    ListView lv = (ListView) dialog.findViewById(R.id.playlist_list);
    lv.setVisibility(GONE);
    // set the custom dialog components - text, image and button
    final EditText text = (EditText) dialog.findViewById(R.id.new_playlist_name);
    ImageView image = (ImageView) dialog.findViewById(R.id.confirm_button);
    // if button is clicked, close the custom dialog
    image.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean isNameRepeat = false;
            if (text.getText().toString().trim().equals("")) {
                text.setError("Enter Playlist Name!");
            } else {
                for (int i = 0; i < allPlaylists.getPlaylists().size(); i++) {
                    if (text.getText().toString().equals(allPlaylists.getPlaylists().get(i).getPlaylistName())) {
                        isNameRepeat = true;
                        text.setError("Playlist with same name exists!");
                        break;
                    }
                }
                if (!isNameRepeat) {
                    Playlist pl = new Playlist(text.getText().toString());
                    for (int i = 0; i < queue.getQueue().size(); i++) {
                        pl.getSongList().add(queue.getQueue().get(i));
                    }
                    allPlaylists.addPlaylist(pl);
                    playlistsRecycler.setVisibility(View.VISIBLE);
                    playlistNothingText.setVisibility(View.INVISIBLE);
                    pAdapter.notifyDataSetChanged();
                    new SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    Toast.makeText(HomeActivity.this, "Queue saved!", Toast.LENGTH_SHORT).show();
                    dialog.dismiss();
                }
            }
        }
    });
    dialog.show();
}
Also used : EditText(android.widget.EditText) Playlist(com.sdsmdg.harjot.MusicDNA.models.Playlist) ListView(android.widget.ListView) Dialog(android.app.Dialog) CustomLocalBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog) CustomGeneralBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) ImageView(android.widget.ImageView) VisualizerView(com.sdsmdg.harjot.MusicDNA.visualizers.VisualizerView) RecyclerView(android.support.v7.widget.RecyclerView) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) WheelView(com.lantouzi.wheelview.WheelView) ListView(android.widget.ListView)

Example 30 with Dialog

use of android.app.Dialog in project MusicDNA by harjot-oberai.

the class ViewSavedDNA method showDialog.

public void showDialog(int type) {
    if (type == 0) {
        final Dialog dialog = new Dialog(getContext());
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.save_image_dialog);
        TextView titleText = (TextView) dialog.findViewById(R.id.dialog_title);
        titleText.setText("Save as Image");
        if (SplashActivity.tf4 != null)
            titleText.setTypeface(SplashActivity.tf4);
        // set the custom dialog components - text, image and button
        final EditText text = (EditText) dialog.findViewById(R.id.save_image_filename_text);
        text.setText(HomeActivity.tempSavedDNA.getName());
        text.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
        Button btn = (Button) dialog.findViewById(R.id.save_image_btn);
        btn.setBackgroundColor(HomeActivity.themeColor);
        CheckBox cb = (CheckBox) dialog.findViewById(R.id.text_checkbox);
        cb.setChecked(addTextToImage);
        cb.setButtonTintList(ColorStateList.valueOf(HomeActivity.themeColor));
        cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                addTextToImage = isChecked;
            }
        });
        // if button is clicked, close the custom dialog
        btn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (text.getText().toString().trim().equals("")) {
                    text.setError("Enter Filename");
                } else {
                    mVisualizerView2.drawText(text.getText().toString(), addTextToImage);
                    mVisualizerView2.setDrawingCacheEnabled(true);
                    FileUtils.saveBitmapAsImage(mVisualizerView2.getDrawingCache(), text.getText().toString());
                    mVisualizerView2.dropText();
                    mVisualizerView2.setDrawingCacheEnabled(false);
                    dialog.dismiss();
                }
            }
        });
        dialog.show();
    } else if (type == 1) {
        final Dialog dialog = new Dialog(getContext());
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.save_image_dialog);
        TextView titleText = (TextView) dialog.findViewById(R.id.dialog_title);
        titleText.setText("Share as Image");
        if (SplashActivity.tf4 != null)
            titleText.setTypeface(SplashActivity.tf4);
        // set the custom dialog components - text, image and button
        final EditText text = (EditText) dialog.findViewById(R.id.save_image_filename_text);
        text.setText(HomeActivity.tempSavedDNA.getName());
        text.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
        Button btn = (Button) dialog.findViewById(R.id.save_image_btn);
        btn.setBackgroundColor(HomeActivity.themeColor);
        btn.setText("SHARE");
        CheckBox cb = (CheckBox) dialog.findViewById(R.id.text_checkbox);
        cb.setChecked(addTextToImage);
        cb.setButtonTintList(ColorStateList.valueOf(HomeActivity.themeColor));
        cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                addTextToImage = isChecked;
            }
        });
        // if button is clicked, close the custom dialog
        btn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (text.getText().toString().trim().equals("")) {
                    text.setError("Enter Text");
                } else {
                    mVisualizerView2.drawText(text.getText().toString(), addTextToImage);
                    mVisualizerView2.setDrawingCacheEnabled(true);
                    FileUtils.shareBitmapAsImage(mVisualizerView2.getDrawingCache(), text.getText().toString(), getContext());
                    mVisualizerView2.dropText();
                    mVisualizerView2.setDrawingCacheEnabled(false);
                    dialog.dismiss();
                }
            }
        });
        dialog.show();
    }
}
Also used : EditText(android.widget.EditText) ImageView(android.widget.ImageView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) Dialog(android.app.Dialog) CheckBox(android.widget.CheckBox) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton)

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