--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
--- /dev/null
+package com.koushikdutta.widgets;
+
+import com.koushikdutta.widgets.ActivityBaseFragment.ActivityBaseFragmentListener;
+
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.view.View;
+
+
+
+public class ActivityBase extends FragmentActivity implements ActivityBaseFragmentListener {
+ Class<? extends ActivityBaseFragment> clazz;
+ public ActivityBase(Class<? extends ActivityBaseFragment> clazz) {
+ super();
+ this.clazz = clazz;
+ }
+
+ public ActivityBase() {
+ super();
+ this.clazz = ActivityBaseFragment.class;
+ }
+
+ public ActivityBaseFragment getFragment() {
+ return fragment;
+ }
+
+ public View getView() {
+ return fragment.getView();
+ }
+
+ ActivityBaseFragment fragment;
+ protected final void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ try {
+ fragment = (ActivityBaseFragment)clazz.getConstructors()[0].newInstance();
+ fragment.setArguments(getIntent().getExtras());
+ fragment.setListener(this);
+ getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState, View view) {
+ }
+
+
+ protected ListItem addItem(int sectionName, ListItem item) {
+ return getFragment().addItem(getString(sectionName), item);
+ }
+
+ protected ListItem addItem(int sectionName, ListItem item, int index) {
+ return getFragment().addItem(getString(sectionName), item, index);
+ }
+
+ protected ListItem addItem(String sectionName, ListItem item) {
+ return getFragment().addItem(sectionName, item, -1);
+ }
+
+ public void setEmpty(int res) {
+ getFragment().setEmpty(res);
+ }
+}
return null;
}
+ private ActivityBaseFragmentListener mListener;
+ public ActivityBaseFragmentListener getListener() {
+ return mListener;
+ }
+
+ public void setListener(ActivityBaseFragmentListener listener) {
+ mListener = listener;
+ }
+
+ public static interface ActivityBaseFragmentListener {
+ void onCreate(Bundle savedInstanceState, View view);
+ }
+
protected void onCreate(Bundle savedInstanceState, View view) {
+ if (mListener != null)
+ mListener.onCreate(savedInstanceState, view);
}
TextView mEmpty;
public int Icon;
- public void setEnabled(boolean enabled) {
+ public ListItem setEnabled(boolean enabled) {
Enabled = enabled;
Context.mAdapter.notifyDataSetChanged();
+ return this;
}
public boolean getEnabled() {
return Enabled;
}
- public void setTitle(int title) {
+ public ListItem setTitle(int title) {
if (title == 0)
- setTitle(null);
+ return setTitle(null);
else
- setTitle(Context.getString(title));
+ return setTitle(Context.getString(title));
}
public String getTitle() {
return Title;
}
- public void setTitle(String title) {
+ public ListItem setTitle(String title) {
Title = title;
Context.mAdapter.notifyDataSetChanged();
+ return this;
}
- public void setSummary(int summary) {
+ public ListItem setSummary(int summary) {
if (summary == 0)
- setSummary(null);
+ return setSummary(null);
else
- setSummary(Context.getString(summary));
+ return setSummary(Context.getString(summary));
}
- public void setSummary(String summary) {
+ public ListItem setSummary(String summary) {
Summary = summary;
Context.mAdapter.notifyDataSetChanged();
+ return this;
}
public ListItem(ActivityBaseFragment context, int title, int summary) {
private boolean CheckboxVisible = false;
private boolean checked = false;
- public void setCheckboxVisible(boolean visible) {
+ public ListItem setCheckboxVisible(boolean visible) {
CheckboxVisible = visible;
Context.mAdapter.notifyDataSetChanged();
+ return this;
}
public boolean getCheckboxVisible() {
return checked;
}
- public void setChecked(boolean isChecked) {
+ public ListItem setChecked(boolean isChecked) {
checked = isChecked;
CheckboxVisible = true;
Context.mAdapter.notifyDataSetChanged();
+ return this;
}
//
// boolean mUseOnOff = false;
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>WidgetsSample</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.koushikdutta.widgets.sample"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="16" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.DeviceDefault.Light" >
+ <activity
+ android:name="com.koushikdutta.widgets.sample.MainActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity
+ android:name=".MainActivityDark"
+ android:theme="@android:style/Theme.DeviceDefault"
+ />
+ </application>
+
+</manifest>
\ No newline at end of file
--- /dev/null
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+package com.koushikdutta.widgets;
+
+public final class R {
+ public static final class id {
+ public static final int summary = 0x7f060007;
+ public static final int title = 0x7f060006;
+ public static final int title_container = 0x7f060000;
+ public static final int list_header_title = 0x7f060004;
+ public static final int checkbox = 0x7f060008;
+ public static final int empty = 0x7f060002;
+ public static final int image = 0x7f060005;
+ public static final int footer_container = 0x7f060003;
+ public static final int listview = 0x7f060001;
+ }
+ public static final class color {
+ public static final int holo_blue_light = 0x7f040000;
+ public static final int holo_blue_bright = 0x7f040002;
+ public static final int holo_blue_dark = 0x7f040001;
+ }
+ public static final class layout {
+ public static final int list_header = 0x7f030001;
+ public static final int list_item_small = 0x7f030003;
+ public static final int list_item = 0x7f030002;
+ public static final int activity_base_fragment = 0x7f030000;
+ }
+}
--- /dev/null
+/** Automatically generated file. DO NOT MODIFY */
+package com.koushikdutta.widgets.sample;
+
+public final class BuildConfig {
+ public final static boolean DEBUG = true;
+}
\ No newline at end of file
--- /dev/null
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.koushikdutta.widgets.sample;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class color {
+ public static final int holo_blue_bright=0x7f040002;
+ public static final int holo_blue_dark=0x7f040001;
+ public static final int holo_blue_light=0x7f040000;
+ }
+ public static final class drawable {
+ public static final int box=0x7f020000;
+ public static final int drive=0x7f020001;
+ public static final int dropbox=0x7f020002;
+ public static final int ic_launcher=0x7f020003;
+ public static final int nexusone=0x7f020004;
+ }
+ public static final class id {
+ public static final int checkbox=0x7f060008;
+ public static final int empty=0x7f060002;
+ public static final int footer_container=0x7f060003;
+ public static final int image=0x7f060005;
+ public static final int list_header_title=0x7f060004;
+ public static final int listview=0x7f060001;
+ public static final int summary=0x7f060007;
+ public static final int title=0x7f060006;
+ public static final int title_container=0x7f060000;
+ }
+ public static final class layout {
+ public static final int activity_base_fragment=0x7f030000;
+ public static final int list_header=0x7f030001;
+ public static final int list_item=0x7f030002;
+ public static final int list_item_small=0x7f030003;
+ }
+ public static final class string {
+ public static final int app_name=0x7f050000;
+ public static final int box=0x7f050005;
+ public static final int cloud=0x7f050001;
+ public static final int devices=0x7f050006;
+ public static final int dropbox=0x7f050004;
+ public static final int googledrive=0x7f050002;
+ public static final int googledrive_summary=0x7f050003;
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+ <issue id="NewApi" severity="ignore" />
+</lint>
\ No newline at end of file
--- /dev/null
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
--- /dev/null
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-17
+android.library.reference.1=../Widgets
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">WidgetsSample</string>
+
+ <string name="cloud">Cloud</string>
+ <string name="googledrive">Google Drive</string>
+ <string name="googledrive_summary">By the power of Google!</string>
+ <string name="dropbox">Dropbox</string>
+ <string name="box">Box</string>
+
+ <string name="devices">Devices</string>
+</resources>
\ No newline at end of file
--- /dev/null
+package com.koushikdutta.widgets.sample;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Toast;
+
+import com.koushikdutta.widgets.ActivityBase;
+import com.koushikdutta.widgets.ListItem;
+
+
+public class MainActivity extends ActivityBase {
+ @Override
+ public void onCreate(Bundle savedInstanceState, View view) {
+ super.onCreate(savedInstanceState, view);
+
+ addItem("Theme", new ListItem(getFragment(), "Dark Theme", null, R.drawable.ic_launcher) {
+ @Override
+ public void onClick(View view) {
+ super.onClick(view);
+ startActivity(new Intent(MainActivity.this, MainActivityDark.class));
+ }
+ });
+
+ addItem(R.string.cloud, new ListItem(getFragment(), R.string.googledrive, R.string.googledrive_summary, R.drawable.drive) {
+ @Override
+ public void onClick(View view) {
+ super.onClick(view);
+ Toast.makeText(MainActivity.this, "You clicked Google Drive!", Toast.LENGTH_SHORT).show();
+ }
+ });
+ addItem(R.string.cloud, new ListItem(getFragment(), R.string.dropbox, 0, R.drawable.dropbox));
+ addItem(R.string.cloud, new ListItem(getFragment(), R.string.box, 0, R.drawable.box));
+
+ addItem(R.string.devices, new ListItem(getFragment(), "Nexus S", null, R.drawable.nexusone)).setCheckboxVisible(true).setChecked(true);
+ addItem(R.string.devices, new ListItem(getFragment(), "Nexus One", null, R.drawable.nexusone)).setCheckboxVisible(true);
+ addItem(R.string.devices, new ListItem(getFragment(), "Nexus 4", null, R.drawable.nexusone)).setCheckboxVisible(true);
+ addItem(R.string.devices, new ListItem(getFragment(), "Nexus 7", null, R.drawable.nexusone)).setCheckboxVisible(true).setChecked(true);;
+ addItem(R.string.devices, new ListItem(getFragment(), "Nexus 10", null, R.drawable.nexusone)).setCheckboxVisible(true);
+ }
+}
--- /dev/null
+package com.koushikdutta.widgets.sample;
+
+
+
+public class MainActivityDark extends MainActivity {
+}
+++ /dev/null
-package com.koushikdutta.widgets;
-
-import android.support.v4.app.FragmentActivity;
-import android.view.View;
-
-
-
-public class ActivityBase extends FragmentActivity {
- Class<? extends ActivityBaseFragment> clazz;
- public ActivityBase(Class<? extends ActivityBaseFragment> clazz) {
- super();
- this.clazz = clazz;
- }
-
- public ActivityBaseFragment getFragment() {
- return fragment;
- }
-
- public View getView() {
- return fragment.getView();
- }
-
- ActivityBaseFragment fragment;
- protected void onCreate(android.os.Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- try {
- fragment = (ActivityBaseFragment)clazz.getConstructors()[0].newInstance();
- fragment.setArguments(getIntent().getExtras());
- getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-}