Permalink
Browse files

Refactored wizard into its own package. Removed WizardPreferences.

  • Loading branch information...
1 parent 4a2ba65 commit 0ef0453ea4103e1f722fe68046b04e4242197bf8 @hdweiss hdweiss committed Dec 8, 2012
View
@@ -120,8 +120,13 @@
android:label="MobileOrg Settings" >
</activity>
<activity
- android:name=".Settings.WizardActivity"
+ android:name=".Gui.Wizard.WizardActivity"
android:label="MobileOrg Wizard" >
+ <intent-filter>
+ <action android:name="com.matburt.mobileorg.Settings.SETUP_WIZARD" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
</activity>
<activity
android:name=".Gui.CertificateConflictActivity"
@@ -161,21 +166,28 @@
android:name=".Services.TimeclockDialog"
android:theme="@android:style/Theme.Dialog" >
</activity>
- <activity android:name=".Gui.Agenda.AgendaSettings"></activity>
- <activity android:name=".Gui.Agenda.AgendaEntrySetting"></activity>
+ <activity android:name=".Gui.Agenda.AgendaSettings" >
+ </activity>
+ <activity android:name=".Gui.Agenda.AgendaEntrySetting" >
+ </activity>
<activity
android:name="com.dropbox.client2.android.AuthActivity"
- android:launchMode="singleTask"
- android:configChanges="orientation|keyboard">
- <intent-filter>
- <!-- Change this to be db- followed by your app key -->
- <data android:scheme="db-et6v9bbqd4pu0ak" />
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.BROWSABLE"/>
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
- <service android:name=".Services.CalendarSyncService"></service>
+ android:configChanges="orientation|keyboard"
+ android:launchMode="singleTask" >
+ <intent-filter>
+
+ <!-- Change this to be db- followed by your app key -->
+ <data android:scheme="db-2y6mph4a6httm78" />
@matburt
matburt Jan 8, 2013 Owner

Hey @hdweiss it looks like this is the culprit for issue #344, you changed my dropbox release id.

@hdweiss
hdweiss Jan 8, 2013 Collaborator

Yeah, thats what I figured from issue #344. Sorry about that.

+
+ <action android:name="android.intent.action.VIEW" />
+
+ <category android:name="android.intent.category.BROWSABLE" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
+ <service android:name=".Services.CalendarSyncService" >
+ </service>
</application>
-</manifest>
+</manifest>
View
@@ -1,37 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
-<com.matburt.mobileorg.Views.PageFlipView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/wizard_parent"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:fillViewport="true"
- android:layout_alignParentTop="true">
- <com.matburt.mobileorg.Views.WideLinearLayout
- android:id="@+id/wizard_container"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:orientation="horizontal">
- <!-- page 1 -->
- <ScrollView
- android:id="@+id/wizard_page1_container"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:fillViewport="true">
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
- <include
- android:layout_marginTop="10dp"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1.0"
- android:id="@+id/wizard_page1"
- layout="@layout/wizard_page1" />
- <include
- layout="@layout/wizard_navbar_first" />
- </LinearLayout>
- </ScrollView>
- </com.matburt.mobileorg.Views.WideLinearLayout>
-</com.matburt.mobileorg.Views.PageFlipView>
+<com.matburt.mobileorg.Gui.Wizard.PageFlipView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/wizard_parent"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_alignParentTop="true"
+ android:fillViewport="true" >
+ <com.matburt.mobileorg.Gui.Wizard.WideLinearLayout
+ android:id="@+id/wizard_container"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal" >
+
+ <!-- page 1 -->
+
+ <ScrollView
+ android:id="@+id/wizard_page1_container"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:fillViewport="true" >
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
+
+ <include
+ android:id="@+id/wizard_page1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:layout_weight="1.0"
+ layout="@layout/wizard_page1" />
+
+ <include layout="@layout/wizard_navbar_first" />
+ </LinearLayout>
+ </ScrollView>
+ </com.matburt.mobileorg.Gui.Wizard.WideLinearLayout>
+
+</com.matburt.mobileorg.Gui.Wizard.PageFlipView>
@@ -2,9 +2,10 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="@string/preference_synchronization" >
- <com.matburt.mobileorg.Settings.WizardPreferences
- android:key="wizardPref"
- android:title="Wizard Preference" />
+ <Preference
+ android:title="@string/rerun_setup_wizard" >
+ <intent android:action="com.matburt.mobileorg.Settings.SETUP_WIZARD" />
+ </Preference>
<ListPreference
android:defaultValue="webdav"
@@ -17,10 +17,10 @@
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
import com.matburt.mobileorg.R;
+import com.matburt.mobileorg.Gui.Wizard.WizardActivity;
import com.matburt.mobileorg.OrgData.OrgProviderUtils;
import com.matburt.mobileorg.Services.SyncService;
import com.matburt.mobileorg.Settings.SettingsActivity;
-import com.matburt.mobileorg.Settings.WizardActivity;
import com.matburt.mobileorg.Synchronizers.Synchronizer;
import com.matburt.mobileorg.util.OrgUtils;
@@ -0,0 +1,216 @@
+package com.matburt.mobileorg.Gui.Wizard;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import android.content.Context;
+import android.util.Log;
+
+import com.dropbox.client2.DropboxAPI;
+import com.dropbox.client2.DropboxAPI.Entry;
+import com.dropbox.client2.android.AndroidAuthSession;
+import com.dropbox.client2.exception.DropboxException;
+import com.matburt.mobileorg.R;
+import com.matburt.mobileorg.Synchronizers.UbuntuOneSynchronizer;
+
+public interface DirectoryBrowser {
+
+ public void browseTo(String directory);
+
+ public void browseTo(int position);
+
+ public String get(int position);
+
+ public String getAbsolutePath(int position);
+
+ public boolean isCurrentDirectoryRoot();
+
+ public ArrayList<String> list();
+
+ //Class for browsing local file system
+
+ public class LocalDirectoryBrowser implements DirectoryBrowser {
+ ArrayList<String> directoryNames = new ArrayList<String>();
+ ArrayList<File> directoryListing = new ArrayList<File>();
+ File curDirectory;
+ Context context;
+ String upOneLevel = "Up one level";
+
+ LocalDirectoryBrowser() {
+ browseTo(File.separator);
+ }
+
+ LocalDirectoryBrowser(Context context) {
+ setContext(context);
+ setLocale();
+ browseTo(File.separator);
+ }
+
+ public void setContext(Context context) { this.context = context; }
+
+ public void setLocale() {
+ upOneLevel = context.getString(R.string.up_one_level);
+ }
+
+ public ArrayList<String> list() { return directoryNames; }
+
+ public String get(int position) { return directoryNames.get(position); }
+
+ public File getDirectory(int position) { return directoryListing.get(position); }
+
+ public String getAbsolutePath(int position) {
+ return getDirectory(position).getAbsolutePath(); }
+
+ public boolean isCurrentDirectoryRoot() { return curDirectory.getParent() == null; }
+
+ public void browseTo(int position) {
+ File newdir = getDirectory(position);
+ browseTo( newdir.getAbsolutePath() );
+ }
+
+ public void browseTo(String directory) {
+ curDirectory = new File(directory);
+ directoryNames.clear();
+ directoryListing.clear();
+ if ( curDirectory.getParent() != null ) {
+ directoryNames.add( upOneLevel );
+ directoryListing.add( curDirectory.getParentFile() );
+ }
+ File[] tmpListing = curDirectory.listFiles();
+ //default list order doesn't seem to be alpha
+ Arrays.sort(tmpListing);
+ for(File dir:tmpListing) {
+ if ( dir.isDirectory()
+ && dir.canWrite() ) {
+ directoryNames.add( dir.getName() );
+ directoryListing.add( dir );
+ }
+ }
+ }
+ }
+
+ public class UbuntuOneDirectoryBrowser implements DirectoryBrowser {
+ UbuntuOneSynchronizer onesync;
+
+ ArrayList<String> directoryNames = new ArrayList<String>();
+ ArrayList<String> directoryListing = new ArrayList<String>();
+ String curDirectory;
+ Context context;
+ String upOneLevel = "Up one level";
+
+ UbuntuOneDirectoryBrowser(Context context, UbuntuOneSynchronizer uos) {
+ onesync = uos;
+ setContext(context);
+ setLocale();
+ browseTo("/");
+ }
+
+ public void setContext(Context context) { this.context = context; }
+
+ public void setLocale() {
+ upOneLevel = context.getString(R.string.up_one_level);
+ }
+
+ public ArrayList<String> list() { return directoryNames; }
+
+ public String get(int position) { return directoryNames.get(position); }
+
+ public String getDirectory(int position) { return directoryListing.get(position); }
+
+ public String getAbsolutePath(int position) { return directoryListing.get(position); }
+
+ public boolean isCurrentDirectoryRoot() { return curDirectory.equals("/"); }
+
+ static public String getParentPath(String path) {
+ if (path.charAt(path.length()-1) == '/') {
+ path = path.substring(0, path.length()-1);
+ }
+ int ind = path.lastIndexOf('/');
+ return path.substring(0, ind+1);
+ }
+
+ public void browseTo(int position) { browseTo( getDirectory(position) ); }
+
+ public void browseTo(String directory) {
+ curDirectory = directory;
+ directoryNames.clear();
+ directoryListing.clear();
+ if ( !isCurrentDirectoryRoot() ) {
+ directoryNames.add( upOneLevel );
+ directoryListing.add( getParentPath(curDirectory) );
+ Log.d("MobileOrg", "Current directory: " + curDirectory);
+ Log.d("MobileOrg", "Parent path: " + getParentPath(curDirectory));
+ }
+ for (String item : onesync.getDirectoryList(directory)) {
+ directoryNames.add(item);
+ directoryListing.add(item);
+ }
+ }
+ }
+
+ public class DropboxDirectoryBrowser implements DirectoryBrowser {
+ DropboxAPI<AndroidAuthSession> dropbox;
+ //array list for adapter
+ ArrayList<String> directoryNames = new ArrayList<String>();
+ //array list containing full path names
+ ArrayList<String> directoryListing = new ArrayList<String>();
+ String curDirectory;
+ Context context;
+ String upOneLevel = "Up one level";
+
+ DropboxDirectoryBrowser(Context context, DropboxAPI dropboxApi) {
+ this.dropbox = dropboxApi;
+ setContext(context);
+ setLocale();
+ browseTo("/");
+ }
+
+ public void setContext(Context context) { this.context = context; }
+
+ public void setLocale() {
+ upOneLevel = context.getString(R.string.up_one_level);
+ }
+
+ public ArrayList<String> list() { return directoryNames; }
+
+ public String get(int position) { return directoryNames.get(position); }
+
+ public String getDirectory(int position) { return directoryListing.get(position); }
+
+ public String getAbsolutePath(int position) { return directoryListing.get(position); }
+
+ public boolean isCurrentDirectoryRoot() { return curDirectory.equals("/"); }
+
+ static public String getParentPath(String path) {
+ int ind = path.lastIndexOf('/');
+ return path.substring(0, ind+1);
+ }
+
+ public void browseTo(int position) { browseTo( getDirectory(position) ); }
+
+ public void browseTo(String directory) {
+ curDirectory = directory;
+ directoryNames.clear();
+ directoryListing.clear();
+ if ( !isCurrentDirectoryRoot() ) {
+ directoryNames.add( upOneLevel );
+ directoryListing.add( getParentPath(curDirectory) );
+ }
+
+ try {
+ Entry entries = dropbox.metadata(directory, 1000, null, true, null);
+
+ for (Entry e : entries.contents) {
+ if (e.isDir) {
+ directoryNames.add(e.fileName());
+ directoryListing.add(e.path);
+ }
+ }
+ } catch (DropboxException e) {
+ Log.d("MobileOrg", "Failed to list directory for dropbox: " + e.toString());
+ }
+ }
+ }
+}
+
@@ -1,4 +1,4 @@
-package com.matburt.mobileorg.Views;
+package com.matburt.mobileorg.Gui.Wizard;
import android.app.Activity;
import android.content.Context;
@@ -1,4 +1,4 @@
-package com.matburt.mobileorg.Views;
+package com.matburt.mobileorg.Gui.Wizard;
import android.content.Context;
import android.util.AttributeSet;
@@ -1,4 +1,4 @@
-package com.matburt.mobileorg.Views;
+package com.matburt.mobileorg.Gui.Wizard;
import android.content.Context;
import android.util.AttributeSet;
Oops, something went wrong.

0 comments on commit 0ef0453

Please sign in to comment.