From 209737511276cde108a12e18013d7eda2e2259b1 Mon Sep 17 00:00:00 2001 From: Andrew Comminos Date: Tue, 28 Feb 2017 01:09:38 -0800 Subject: Remove unused setup wizard code. --- .../mumbleclient/wizard/WizardActivity.java | 172 --------------------- .../mumbleclient/wizard/WizardAudioFragment.java | 98 ------------ .../wizard/WizardCertificateFragment.java | 80 ---------- .../mumbleclient/wizard/WizardNavigation.java | 26 ---- .../mumbleclient/wizard/WizardWelcomeFragment.java | 37 ----- 5 files changed, 413 deletions(-) delete mode 100644 app/src/main/java/com/morlunk/mumbleclient/wizard/WizardActivity.java delete mode 100644 app/src/main/java/com/morlunk/mumbleclient/wizard/WizardAudioFragment.java delete mode 100644 app/src/main/java/com/morlunk/mumbleclient/wizard/WizardCertificateFragment.java delete mode 100644 app/src/main/java/com/morlunk/mumbleclient/wizard/WizardNavigation.java delete mode 100644 app/src/main/java/com/morlunk/mumbleclient/wizard/WizardWelcomeFragment.java diff --git a/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardActivity.java b/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardActivity.java deleted file mode 100644 index 00188b0..0000000 --- a/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardActivity.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2014 Andrew Comminos - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.morlunk.mumbleclient.wizard; - -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.ActionBarActivity; -import android.view.View; -import android.widget.Button; - -import com.morlunk.mumbleclient.R; -import com.morlunk.mumbleclient.Settings; - -/** - * A simple activity_wizard providing an easy to use interface for configuring useful settings. - * Created by andrew on 01/11/13. - */ -public class WizardActivity extends ActionBarActivity implements WizardNavigation { - private Settings mSettings; - private ViewPager mViewPager; - private WizardPagerAdapter mPagerAdapter; - private ViewPager.OnPageChangeListener mPageListener = new ViewPager.OnPageChangeListener() { - @Override - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - - } - - @Override - public void onPageScrollStateChanged(int state) { - - } - - @Override - public void onPageSelected(int position) { - updateNavigationButtons(position); - setTitle(mPagerAdapter.getPageTitle(position)); - } - }; - private Button mBackButton; - private Button mNextButton; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_wizard); - - getSupportActionBar().setDisplayShowHomeEnabled(false); - - mSettings = Settings.getInstance(this); - mViewPager = (ViewPager) findViewById(R.id.wizard_pager); - mPagerAdapter = new WizardPagerAdapter(getSupportFragmentManager()); - mViewPager.setAdapter(mPagerAdapter); - mViewPager.setOnPageChangeListener(mPageListener); - mBackButton = (Button) findViewById(R.id.wizard_back_button); - mNextButton = (Button) findViewById(R.id.wizard_next_button); - - mBackButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - back(); - } - }); - mNextButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - next(); - } - }); - - updateNavigationButtons(0); - setTitle(mPagerAdapter.getPageTitle(0)); - } - - @Override - public void onBackPressed() { - back(); - } - - private void updateNavigationButtons(int pagerPosition) { - mBackButton.setText(pagerPosition == 0 ? R.string.wizard_cancel : R.string.wizard_back); - mNextButton.setText(pagerPosition == mPagerAdapter.getCount() - 1 ? R.string.wizard_finish : R.string.wizard_next); - } - - private void showConfirmQuitDialog() { - new AlertDialog.Builder(this) - .setMessage(R.string.wizard_confirm_close) - .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - mSettings.setFirstRun(false); // Mark in settings never to run this wizard again - finish(); - } - }).setNegativeButton(android.R.string.cancel, null) - .show(); - } - - @Override - public void next() { - if (mViewPager.getCurrentItem() == (mPagerAdapter.getCount() - 1)) { - mSettings.setFirstRun(false); // Mark in settings never to run this wizard again - finish(); - } else - mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, true); - } - - @Override - public void back() { - if(mViewPager.getCurrentItem() == 0) - showConfirmQuitDialog(); // If cancel is pressed at the beginning of the pager, prompt the user to quit. - else - mViewPager.setCurrentItem(mViewPager.getCurrentItem()-1, true); - } - - private class WizardPagerAdapter extends FragmentPagerAdapter { - - private final Class WIZARD_FRAGMENTS[] = new Class[] { - WizardWelcomeFragment.class, - WizardCertificateFragment.class, - WizardAudioFragment.class, - WizardCertificateFragment.class - }; - - public WizardPagerAdapter(FragmentManager fm) { - super(fm); - } - - @Override - public Fragment getItem(int i) { - return Fragment.instantiate(WizardActivity.this, WIZARD_FRAGMENTS[i].getName()); - } - - @Override - public CharSequence getPageTitle(int position) { - switch (position) { - case 0: - return getString(R.string.wizard_welcome_title); - case 1: - return getString(R.string.wizard_certificate_title); - case 2: - return getString(R.string.wizard_audio_title); - case 3: - return getString(R.string.wizard_general_title); - } - return null; - } - - @Override - public int getCount() { - return WIZARD_FRAGMENTS.length; - } - } -} diff --git a/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardAudioFragment.java b/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardAudioFragment.java deleted file mode 100644 index 1150da4..0000000 --- a/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardAudioFragment.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2014 Andrew Comminos - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.morlunk.mumbleclient.wizard; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.Spinner; -import android.widget.SpinnerAdapter; -import android.widget.TextView; - -import com.morlunk.mumbleclient.R; - -/** - * Created by andrew on 04/11/13. - */ -public class WizardAudioFragment extends Fragment { - - private Spinner mInputSpinner; - private AudioInputSpinnerAdapter mSpinnerAdapter; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_wizard_audio, container, false); - mSpinnerAdapter = new AudioInputSpinnerAdapter(); - mInputSpinner = (Spinner) view.findViewById(R.id.wizard_audio_input_spinner); - mInputSpinner.setAdapter(mSpinnerAdapter); - return view; - } - - private class AudioInputSpinnerAdapter extends BaseAdapter implements SpinnerAdapter { - - @Override - public int getCount() { - return 3; - } - - @Override - public Object getItem(int position) { - switch (position) { - case 0: - return "Voice Activity"; - case 1: - return "Push to Talk"; - case 2: - return "Continuous"; - } - return null; - } - - @Override - public long getItemId(int position) { - return position; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - View view = convertView; - if(view == null) { - LayoutInflater inflater = getActivity().getLayoutInflater(); - view = inflater.inflate(android.R.layout.simple_spinner_item, parent, false); - } - TextView textView = (TextView) view.findViewById(android.R.id.text1); - textView.setText((CharSequence) getItem(position)); - return view; - } - - @Override - public View getDropDownView(int position, View convertView, ViewGroup parent) { - View view = convertView; - if(view == null) { - LayoutInflater inflater = getActivity().getLayoutInflater(); - view = inflater.inflate(android.R.layout.simple_spinner_dropdown_item, parent, false); - } - TextView textView = (TextView) view.findViewById(android.R.id.text1); - textView.setText((CharSequence) getItem(position)); - return view; - } - } -} diff --git a/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardCertificateFragment.java b/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardCertificateFragment.java deleted file mode 100644 index 48a6f83..0000000 --- a/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardCertificateFragment.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2014 Andrew Comminos - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.morlunk.mumbleclient.wizard; - -import android.app.Activity; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; - -import com.morlunk.mumbleclient.R; -import com.morlunk.mumbleclient.Settings; -import com.morlunk.mumbleclient.db.DatabaseCertificate; -import com.morlunk.mumbleclient.preference.PlumbleCertificateGenerateTask; - -import java.io.File; - -/** - * Created by andrew on 02/11/13. - */ -public class WizardCertificateFragment extends Fragment { - - private Button mGenerateButton; - private WizardNavigation mNavigation; - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - try { - mNavigation = (WizardNavigation) activity; - } catch (ClassCastException e) { - throw new RuntimeException(activity.getClass().getName()+" must implement WizardNavigation!"); - } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_wizard_certificate, container, false); - mGenerateButton = (Button) view.findViewById(R.id.wizard_certificate_generate); - mGenerateButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - generateCertificate(); - } - }); - return view; - } - - private void generateCertificate() { - final Settings settings = Settings.getInstance(getActivity()); - PlumbleCertificateGenerateTask task = new PlumbleCertificateGenerateTask(getActivity()) { - @Override - protected void onPostExecute(DatabaseCertificate result) { - super.onPostExecute(result); - // FIXME(acomminos) -// settings.setCertificatePath(result.getAbsolutePath()); - mGenerateButton.setEnabled(false); - mNavigation.next(); - } - }; - task.execute(); - } -} diff --git a/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardNavigation.java b/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardNavigation.java deleted file mode 100644 index eeb4b29..0000000 --- a/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardNavigation.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2014 Andrew Comminos - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.morlunk.mumbleclient.wizard; - -/** - * Created by andrew on 04/11/13. - */ -public interface WizardNavigation { - public void back(); - public void next(); -} diff --git a/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardWelcomeFragment.java b/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardWelcomeFragment.java deleted file mode 100644 index a86e0f6..0000000 --- a/app/src/main/java/com/morlunk/mumbleclient/wizard/WizardWelcomeFragment.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2014 Andrew Comminos - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.morlunk.mumbleclient.wizard; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import com.morlunk.mumbleclient.R; - -/** - * Created by andrew on 03/11/13. - */ -public class WizardWelcomeFragment extends Fragment { - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_wizard_welcome, container, false); - } -} -- cgit v1.2.3