Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Extend permissions and add initial logic to deal with where we store …

…org files. This won't work on current installations right now, need schema check/upgrade
  • Loading branch information...
commit 472efbc10f84d387c6f03c46048950ca9d9f8b78 1 parent 085e95c
@matburt authored
View
3  AndroidManifest.xml
@@ -3,7 +3,8 @@
package="com.matburt.mobileorg"
android:versionCode="1"
android:versionName="1.0">
- <uses-permission android:name='android.permission.INTERNET' />
+ <uses-permission android:name='android.permission.INTERNET'/>
+ <uses-permission android:name='android.permission.WRITE_EXTERNAL_STORAGE'/>
<application android:name=".MobileOrgApplication"
android:label="MobileOrg"
android:icon="@drawable/icon">
View
8 res/layout/settings.xml
@@ -41,16 +41,16 @@
<RadioGroup android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- id="@+id/group1">
+ android:id="@+id/storegrp">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Storage Location"/>
- <RadioButton android:checked="false"
+ <RadioButton android:checked="true"
android:text="Internal"
- id="@+id/internalopt" />
+ android:id="@+id/internalopt" />
<RadioButton android:checked="false"
android:text="Storage Card"
- id="@+id/sdcardopt" />
+ android:id="@+id/sdcardopt"/>
</RadioGroup>
</TableRow>
<TableRow>
View
3  src/com/matburt/mobileorg/MobileOrgActivity.java
@@ -34,7 +34,8 @@
public ArrayList<Integer> nodeSelection;
private LayoutInflater lInflator;
- public OrgViewAdapter(Context context, Node ndx, ArrayList<Integer> selection) {
+ public OrgViewAdapter(Context context, Node ndx,
+ ArrayList<Integer> selection) {
this.topNode = ndx;
this.thisNode = ndx;
this.lInflator = LayoutInflater.from(context);
View
29 src/com/matburt/mobileorg/SettingsActivity.java
@@ -10,6 +10,8 @@
import android.view.View;
import android.view.View.OnClickListener;
import android.database.Cursor;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
@@ -20,6 +22,9 @@
private EditText webUser;
private EditText webPass;
private Button saveButton;
+ RadioGroup storegrp;
+ RadioButton sdcard;
+ RadioButton internal;
private SQLiteDatabase appdb;
@@ -32,6 +37,9 @@ public void onCreate(Bundle savedInstanceState) {
this.webUser = (EditText)this.findViewById(R.id.webUser);
this.webPass = (EditText)this.findViewById(R.id.webPass);
this.saveButton = (Button)this.findViewById(R.id.settingsSave);
+ this.storegrp = (RadioGroup) findViewById(R.id.storegrp);
+ this.internal = (RadioButton) findViewById(R.id.internalopt);
+ this.sdcard = (RadioButton) findViewById(R.id.sdcardopt);
this.saveButton.setOnClickListener(this);
this.initializeSettings();
}
@@ -56,9 +64,11 @@ public void initializeSettings() {
this.appdb.execSQL("INSERT INTO settings (key, val)" +
" VALUES ('webUrl', '')");
this.appdb.execSQL("INSERT INTO settings (key, val)" +
- " VALUES ('webUser', '')");
+ " VALUES ('webUser', '')");
this.appdb.execSQL("INSERT INTO settings (key, val)" +
- " VALUES ('webPass', '')");
+ " VALUES ('webPass', '')");
+ this.appdb.execSQL("INSERT INTO settings (key, val)" +
+ " VALUES ('storage', '')");
}
}
result.close();
@@ -69,6 +79,12 @@ public void populateDisplay() {
this.webUrl.setText(this.settings.get("webUrl"));
this.webUser.setText(this.settings.get("webUser"));
this.webPass.setText(this.settings.get("webPass"));
+ if (this.settings.get("storage") == "internal") {
+ this.storegrp.check(this.internal.getId());
+ }
+ else if (this.settings.get("storage") == "sdcard") {
+ this.storegrp.check(this.sdcard.getId());
+ }
}
public void onClick(View v) {
@@ -81,6 +97,15 @@ public void onSave() {
this.appdb.execSQL("UPDATE settings set val = '" + this.webUrl.getText() + "' where key = 'webUrl'");
this.appdb.execSQL("UPDATE settings set val = '" + this.webUser.getText() + "' where key = 'webUser'");
this.appdb.execSQL("UPDATE settings set val = '" + this.webPass.getText() + "' where key = 'webPass'");
+ int opId = this.storegrp.getCheckedRadioButtonId();
+ if (opId == this.internal.getId()) {
+ this.appdb.execSQL("UPDATE settings set val = 'internal' " +
+ "where key = 'storage'");
+ }
+ else if (opId == this.sdcard.getId()) {
+ this.appdb.execSQL("UPDATE settings set val = 'sdcard' " +
+ "where key = 'storage'");
+ }
this.appdb.close();
this.finish();
}
View
7 src/com/matburt/mobileorg/Synchronizer.java
@@ -50,6 +50,7 @@ public boolean pull() {
return false;
}
+ //Get the index org file
String masterStr = this.fetchOrgFile(this.appSettings.get("webUrl"));
if (masterStr == "") {
Log.e(LT, "Failure getting main org file");
@@ -57,8 +58,12 @@ public boolean pull() {
}
HashMap<String, String> masterList;
masterList = this.getOrgFilesFromMaster(masterStr);
-
String urlActual = this.getRootUrl();
+
+ //Get checksums file
+ masterStr = this.fetchOrgFile(urlActual + "checksums.dat");
+
+ //Get other org files
for (String key : masterList.keySet()) {
Log.d(LT, "Fetching: " +
key + ": " + urlActual + masterList.get(key));
Please sign in to comment.
Something went wrong with that request. Please try again.