Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Create new dashboard to show on empty outline view.

  • Loading branch information...
commit 7b1da07e108c322c2c60424b29d217fbcc8751e0 1 parent 06cbdfc
@hdweiss hdweiss authored
View
3  lint.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
+ <issue id="HardcodedText">
+ <ignore path="res/layout/outline.xml" />
+ </issue>
<issue id="MissingTranslation" severity="warning">
<ignore path="res/values-de" />
</issue>
View
146 res/layout/outline.xml
@@ -2,11 +2,155 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:gravity="center"
android:orientation="vertical" >
<ListView
android:id="@+id/outline_list"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
android:fastScrollEnabled="true"
+ android:visibility="gone" />
+
+ <RelativeLayout
+ android:id="@+id/outline_list_empty"
android:layout_width="fill_parent"
- android:layout_height="fill_parent"/>
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
+
+ <TextView
+ android:id="@+id/EmptyMainText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
+ android:layout_gravity="center_horizontal"
+ android:layout_margin="5dp"
+ android:text="@string/empty_main"
+ android:textSize="20dp" >
+ </TextView>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"
+ android:layout_gravity="center"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:baselineAligned="false"
+ android:orientation="horizontal" >
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="20dp"
+ android:layout_weight="1"
+ android:onClick="runShowSettings"
+ android:orientation="vertical" >
+
+ <ImageButton
+ android:id="@+id/outline_configure"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:background="@drawable/ic_menu_preferences"
+ android:contentDescription="Configure button" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:text="Settings"
+ android:textStyle="bold" >
+ </TextView>
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="20dp"
+ android:layout_weight="1"
+ android:orientation="vertical" >
+
+ <ImageButton
+ android:id="@+id/outline_synchronize"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:background="@drawable/ic_menu_refresh"
+ android:contentDescription="Configure button"
+ android:duplicateParentState="false"
+ android:onClick="runSynchronize" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:text="Synchronize"
+ android:textStyle="bold" >
+ </TextView>
+ </LinearLayout>
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:baselineAligned="false"
+ android:orientation="horizontal" >
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="20dp"
+ android:layout_weight="1"
+ android:onClick="runEditNewNodeActivity"
+ android:orientation="vertical" >
+
+ <ImageButton
+ android:id="@+id/outline_capture"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:background="@drawable/ic_menu_edit"
+ android:contentDescription="Configure button" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:text="Capture"
+ android:textStyle="bold" >
+ </TextView>
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="20dp"
+ android:layout_weight="1"
+ android:orientation="vertical" >
+
+ <ImageButton
+ android:id="@+id/outline_website"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:background="@drawable/icon"
+ android:contentDescription="Configure button"
+ android:onClick="runHelp" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:text="Website"
+ android:textStyle="bold" >
+ </TextView>
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ </RelativeLayout>
+
</LinearLayout>
View
29 res/layout/outline_unconfigured.xml
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" android:orientation="vertical"><TextView
- android:id="@+id/EmptyMainText"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:gravity="center"
- android:inputType="textMultiLine"
- android:text="@string/empty_main" >
-</TextView>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" android:orientation="horizontal">
- <Button
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:layout_weight="1"
- android:id="@+id/dialog_run_sync"
- android:text="@string/menu_sync"/>
- <Button
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:layout_weight="1"
- android:id="@+id/dialog_show_settings"
- android:text="@string/menu_settings"/>
- </LinearLayout>
-</LinearLayout>
View
2  res/values/strings.xml
@@ -28,7 +28,7 @@
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="ok">OK</string>
- <string name="empty_main">You have not yet\nsynchronized your Org files</string>
+ <string name="empty_main">Welcome to MobileOrg</string>
<string name="error_bad_url">The url %s is not properly formatted</string>
<string name="error_dialog_title">Error</string>
<string name="node_edit_prompt">Are you sure you want to discard changes?</string>
View
152 src/com/matburt/mobileorg/Gui/OutlineActivity.java
@@ -4,7 +4,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.LinkedHashMap;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
@@ -19,15 +18,12 @@
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
+import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
-import android.widget.BaseAdapter;
import android.widget.ListView;
-import android.widget.TextView;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockActivity;
@@ -61,8 +57,6 @@
private OutlineCursorAdapter outlineAdapter;
private SynchServiceReceiver syncReceiver;
- private boolean emptylist = false;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -74,25 +68,26 @@ protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
node_id = intent.getLongExtra("node_id", -1);
+ displayNewUserDialog();
+
if (this.node_id == -1) {
- if (this.appInst.isSyncConfigured() == false) {
+ if (this.appInst.isSyncConfigured() == false)
this.showWizard();
- } else {
- if (!this.checkVersionCode()) {
- this.showUpgradePopup();
- }
- }
- } else {
- if (!this.checkVersionCode()) {
- this.showUpgradePopup();
- }
}
-
+
listView = (ListView) this.findViewById(R.id.outline_list);
listView.setOnItemClickListener(outlineClickListener);
listView.setOnItemLongClickListener(outlineLongClickListener);
+ listView.setEmptyView(findViewById(R.id.outline_list_empty));
registerForContextMenu(listView);
+ this.findViewById(R.id.outline_configure).setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ runShowSettings();
+ }
+ });
+
this.syncReceiver = new SynchServiceReceiver();
registerReceiver(this.syncReceiver, new IntentFilter(
Synchronizer.SYNC_UPDATE));
@@ -100,6 +95,25 @@ protected void onCreate(Bundle savedInstanceState) {
refreshDisplay();
}
+ private void displayNewUserDialog() {
+ if (!this.checkVersionCode()) {
+ this.showUpgradePopup();
+ }
+ }
+
+ private OnItemClickListener outlineClickListener = new OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View v, int position,
+ long id) {
+ Long clicked_node_id = listView.getItemIdAtPosition(position);
+ lastSelection = position;
+ if (appInst.getDB().hasNodeChildren(clicked_node_id) || node_id == -1)
+ runExpandSelection(clicked_node_id);
+ else
+ runEditNodeActivity(clicked_node_id);
+ }
+ };
+
@Override
protected void onResume() {
setTitle();
@@ -130,17 +144,7 @@ private void refreshDisplay() {
finish();
}
- if (cursor == null || cursor.getCount() < 1) {
- emptylist = true;
- LinkedHashMap<String, String> lhm = new LinkedHashMap<String, String>();
- lhm.put("Synchronize", "Fetch your org data");
- lhm.put("Settings", "Configure MobileOrg");
- lhm.put("Capture", "Capture a new note");
- lhm.put("Website", "Visit the MobileOrg Wiki");
- listView.setAdapter(new HashMapAdapter(lhm, this));
- }
else {
- emptylist = false;
startManagingCursor(cursor);
this.outlineAdapter = new OutlineCursorAdapter(this, cursor, appInst.getDB());
@@ -180,7 +184,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
case R.id.menu_sync:
- runSync();
+ runSynchronize(null);
return true;
case R.id.menu_settings:
@@ -195,13 +199,14 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
case R.id.menu_capture:
- return runEditNewNodeActivity();
+ runEditNewNodeActivity(null);
+ return true;
case R.id.menu_search:
return runSearch();
case R.id.menu_help:
- runHelp();
+ runHelp(null);
return true;
}
return false;
@@ -239,21 +244,20 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}
- private void runHelp() {
+ public void runHelp(View view) {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://github.com/matburt/mobileorg-android/wiki"));
startActivity(intent);
}
- private void runSync() {
+ public void runSynchronize(View view) {
startService(new Intent(this, SyncService.class));
}
- private boolean runEditNewNodeActivity() {
+ public void runEditNewNodeActivity(View view) {
Intent intent = new Intent(this, EditActivity.class);
intent.putExtra("actionMode", EditActivity.ACTIONMODE_CREATE);
startActivity(intent);
- return true;
}
private void runEditNodeActivity(long nodeId) {
@@ -379,82 +383,4 @@ private boolean checkVersionCode() {
} catch (Exception e) { };
return true;
}
-
-
- private OnItemClickListener outlineClickListener = new OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View v, int position,
- long id) {
- if (emptylist) {
- if (position == SYNC_OPTION) {
- runSync();
- } else if (position == SETTINGS_OPTION) {
- runShowSettings();
- } else if (position == CAPTURE_OPTION) {
- runEditNewNodeActivity();
- } else if (position == WEBSITE_OPTION) {
- String url = "https://github.com/matburt/mobileorg-android/wiki";
- Intent i = new Intent(Intent.ACTION_VIEW);
- i.setData(Uri.parse(url));
- startActivity(i);
- }
- return;
- }
-
- Long clicked_node_id = listView.getItemIdAtPosition(position);
- lastSelection = position;
- if (appInst.getDB().hasNodeChildren(clicked_node_id) || node_id == -1)
- runExpandSelection(clicked_node_id);
- else
- runEditNodeActivity(clicked_node_id);
- }
- };
-
- private static final int SYNC_OPTION = 0;
- private static final int SETTINGS_OPTION = 1;
- private static final int CAPTURE_OPTION = 2;
- private static final int WEBSITE_OPTION = 3;
-
- private class HashMapAdapter extends BaseAdapter {
- private LinkedHashMap<String, String> mData = new LinkedHashMap<String, String>();
- private String[] mKeys;
- private LayoutInflater mInflater;
-
- public HashMapAdapter(LinkedHashMap<String, String> data, OutlineActivity act){
- mData = data;
- mKeys = mData.keySet().toArray(new String[data.size()]);
- mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- }
-
- @Override
- public int getCount() {
- return mData.size();
- }
-
- @Override
- public Object getItem(int position) {
- return mData.get(mKeys[position]);
- }
-
- @Override
- public long getItemId(int arg0) {
- return arg0;
- }
-
- @Override
- public View getView(int pos, View convertView, ViewGroup parent) {
- String key = mKeys[pos];
- String value = getItem(pos).toString();
-
- View row;
-
- row = mInflater.inflate(R.layout.simple_list_item, null);
-
- TextView slitem = (TextView) row.findViewById(R.id.sl_item);
- slitem.setText(key);
- TextView slinfo = (TextView) row.findViewById(R.id.sl_info);
- slinfo.setText(value);
- return row;
- }
- }
}
Please sign in to comment.
Something went wrong with that request. Please try again.