Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactored wizard into its own package. Removed WizardPreferences.

  • Loading branch information...
commit 0ef0453ea4103e1f722fe68046b04e4242197bf8 1 parent 4a2ba65
@hdweiss hdweiss authored
View
42 AndroidManifest.xml
@@ -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 Owner
matburt added a note

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

@hdweiss Collaborator
hdweiss added a note

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+ <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
74 res/layout/wizard.xml
@@ -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>
View
7 res/xml/preferences.xml
@@ -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"
View
2  src/com/matburt/mobileorg/Gui/Outline/OutlineActivity.java
@@ -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;
View
216 src/com/matburt/mobileorg/Gui/Wizard/DirectoryBrowser.java
@@ -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());
+ }
+ }
+ }
+}
+
View
2  src/com/matburt/mobileorg/Views/PageFlipView.java → ...om/matburt/mobileorg/Gui/Wizard/PageFlipView.java
@@ -1,4 +1,4 @@
-package com.matburt.mobileorg.Views;
+package com.matburt.mobileorg.Gui.Wizard;
import android.app.Activity;
import android.content.Context;
View
2  src/com/matburt/mobileorg/Views/PageView.java → src/com/matburt/mobileorg/Gui/Wizard/PageView.java
@@ -1,4 +1,4 @@
-package com.matburt.mobileorg.Views;
+package com.matburt.mobileorg.Gui.Wizard;
import android.content.Context;
import android.util.AttributeSet;
View
2  ...com/matburt/mobileorg/Views/WideLinearLayout.java → ...atburt/mobileorg/Gui/Wizard/WideLinearLayout.java
@@ -1,4 +1,4 @@
-package com.matburt.mobileorg.Views;
+package com.matburt.mobileorg.Gui.Wizard;
import android.content.Context;
import android.util.AttributeSet;
View
6 ...om/matburt/mobileorg/Settings/WizardActivity.java → .../matburt/mobileorg/Gui/Wizard/WizardActivity.java
@@ -1,4 +1,4 @@
-package com.matburt.mobileorg.Settings;
+package com.matburt.mobileorg.Gui.Wizard;
import java.util.ArrayList;
@@ -40,10 +40,12 @@
import com.dropbox.client2.session.AppKeyPair;
import com.dropbox.client2.session.Session.AccessType;
import com.matburt.mobileorg.R;
+import com.matburt.mobileorg.Gui.Wizard.DirectoryBrowser.DropboxDirectoryBrowser;
+import com.matburt.mobileorg.Gui.Wizard.DirectoryBrowser.LocalDirectoryBrowser;
+import com.matburt.mobileorg.Gui.Wizard.DirectoryBrowser.UbuntuOneDirectoryBrowser;
import com.matburt.mobileorg.Synchronizers.SSHSynchronizer;
import com.matburt.mobileorg.Synchronizers.UbuntuOneSynchronizer;
import com.matburt.mobileorg.Synchronizers.WebDAVSynchronizer;
-import com.matburt.mobileorg.Views.PageFlipView;
import com.matburt.mobileorg.util.OrgUtils;
public class WizardActivity extends Activity {
View
4 src/com/matburt/mobileorg/Services/CalendarSyncService.java
@@ -71,7 +71,11 @@ public void onDestroy() {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
+ if (intent == null)
+ return 0;
+
refreshPreferences();
+
final String[] fileList = intent.getStringArrayExtra(FILELIST);
final boolean clearDB = intent.getBooleanExtra(CLEARDB, false);
final boolean pull = intent.getBooleanExtra(PULL, false);
View
2  src/com/matburt/mobileorg/Settings/SettingsActivity.java
@@ -17,6 +17,7 @@
import com.actionbarsherlock.app.SherlockPreferenceActivity;
import com.matburt.mobileorg.R;
+import com.matburt.mobileorg.Gui.Wizard.WizardActivity;
import com.matburt.mobileorg.OrgData.OrgProviderUtils;
import com.matburt.mobileorg.Services.CalendarSyncService;
import com.matburt.mobileorg.Services.CalendarWrapper;
@@ -104,7 +105,6 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
}
private Preference.OnPreferenceClickListener onClearDBClick = new Preference.OnPreferenceClickListener() {
-
@Override
public boolean onPreferenceClick(Preference preference) {
new AlertDialog.Builder(SettingsActivity.this)
View
57 src/com/matburt/mobileorg/Settings/WizardPreferences.java
@@ -1,57 +0,0 @@
-package com.matburt.mobileorg.Settings;
-
-import android.content.Context;
-import android.content.Intent;
-import android.preference.Preference;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.matburt.mobileorg.R;
-
-public class WizardPreferences extends Preference {
- public WizardPreferences(Context context) {
- super(context);
- }
-
- public WizardPreferences(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public WizardPreferences(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- protected View onCreateView(ViewGroup parent){
-
- LinearLayout layout = new LinearLayout(getContext());
- LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
- //params1.gravity = Gravity.LEFT;
- params1.weight = 1.0f;
- layout.setPadding(15, 10, 10, 10);
- layout.setOrientation(LinearLayout.HORIZONTAL);
- TextView view = new TextView(getContext());
- view.setText(R.string.rerun_setup_wizard);
- // view.setTextSize(18);
- // view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
- view.setTextAppearance(getContext(), android.R.style.TextAppearance_Large);
- //view.setGravity(Gravity.LEFT);
- view.setLayoutParams(params1);
-
- this.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- public boolean onPreferenceClick(Preference arg0) {
- getContext().startActivity(new Intent(getContext(), WizardActivity.class));
- return true;
- }
- });
-
- layout.addView(view);
- layout.setId(android.R.id.widget_frame);
- return layout;
- }
-}
View
30 src/com/matburt/mobileorg/Synchronizers/DropboxSynchronizer.java
@@ -150,21 +150,21 @@ private void connect() {
}
}
- private void showToast(String msg) {
- final String u_msg = msg;
- final Handler mHandler = new Handler();
- final Runnable mRunPost = new Runnable() {
- public void run() {
- Toast.makeText(context, u_msg, Toast.LENGTH_LONG).show();
- }
- };
-
- new Thread() {
- public void run() {
- mHandler.post(mRunPost);
- }
- }.start();
- }
+ private void showToast(String msg) {
+ final String u_msg = msg;
+ final Handler mHandler = new Handler();
+ final Runnable mRunPost = new Runnable() {
+ public void run() {
+ Toast.makeText(context, u_msg, Toast.LENGTH_LONG).show();
+ }
+ };
+
+ new Thread() {
+ public void run() {
+ mHandler.post(mRunPost);
+ }
+ }.start();
+ }
@Override
@matburt

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

@hdweiss
Collaborator

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

Please sign in to comment.
Something went wrong with that request. Please try again.