mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 06:11:19 +00:00
Added graphical repo folder picker (closes #40).
This commit is contained in:
parent
35644c355b
commit
ca0020b176
18 changed files with 322 additions and 36 deletions
|
@ -6,27 +6,28 @@
|
||||||
android:versionName="0.3.10"
|
android:versionName="0.3.10"
|
||||||
tools:ignore="GradleOverrides" >
|
tools:ignore="GradleOverrides" >
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
|
<uses-sdk
|
||||||
|
android:minSdkVersion="8"
|
||||||
|
android:targetSdkVersion="19" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="false"
|
android:allowBackup="false"
|
||||||
android:label="@string/app_name"
|
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
|
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".gui.MainActivity"
|
android:name=".gui.MainActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:launchMode="singleTop" >
|
android:launchMode="singleTop" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".gui.WebGuiActivity"
|
android:name=".gui.WebGuiActivity"
|
||||||
android:label="@string/web_gui_title" >
|
android:label="@string/web_gui_title" >
|
||||||
|
@ -34,7 +35,6 @@
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".gui.MainActivity" />
|
android:value=".gui.MainActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".gui.SettingsActivity"
|
android:name=".gui.SettingsActivity"
|
||||||
android:label="@string/settings_title" >
|
android:label="@string/settings_title" >
|
||||||
|
@ -47,19 +47,28 @@
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".gui.RepoSettingsActivity"
|
android:name=".gui.RepoSettingsActivity"
|
||||||
android:theme="@style/DialogWhenLargeCompat" >
|
android:theme="@style/DialogWhenLarge" >
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".gui.MainActivity" />
|
android:value=".gui.MainActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".gui.NodeSettingsActivity"
|
android:name=".gui.NodeSettingsActivity"
|
||||||
android:theme="@style/DialogWhenLargeCompat" >
|
android:theme="@style/DialogWhenLarge" >
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".gui.MainActivity" />
|
android:value=".gui.MainActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".gui.FolderPickerActivity"
|
||||||
|
android:label="@string/title_activity_folder_picker" >
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".gui.RepoSettingsActivity" />
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.UI_OPTIONS"
|
||||||
|
android:value="splitActionBarWhenNarrow" />
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -0,0 +1,207 @@
|
||||||
|
package com.nutomic.syncthingandroid.gui;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.ServiceConnection;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.nutomic.syncthingandroid.R;
|
||||||
|
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
|
||||||
|
import com.nutomic.syncthingandroid.syncthing.SyncthingServiceBinder;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileFilter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activity that allows selecting a directory in the local file system.
|
||||||
|
*/
|
||||||
|
public class FolderPickerActivity extends ActionBarActivity
|
||||||
|
implements AdapterView.OnItemClickListener, SyncthingService.OnApiChangeListener {
|
||||||
|
|
||||||
|
private static final String TAG = "FolderPickerActivity";
|
||||||
|
|
||||||
|
public static final String EXTRA_INITIAL_DIRECTORY = "initial_directory";
|
||||||
|
|
||||||
|
public static final String EXTRA_RESULT_DIRECTORY = "result_directory";
|
||||||
|
|
||||||
|
private ListView mListView;
|
||||||
|
|
||||||
|
private FileAdapter mAdapter;
|
||||||
|
|
||||||
|
private File mLocation;
|
||||||
|
|
||||||
|
private SyncthingService mSyncthingService;
|
||||||
|
|
||||||
|
private final ServiceConnection mSyncthingServiceConnection = new ServiceConnection() {
|
||||||
|
|
||||||
|
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||||
|
SyncthingServiceBinder binder = (SyncthingServiceBinder) service;
|
||||||
|
mSyncthingService = binder.getService();
|
||||||
|
mSyncthingService.registerOnApiChangeListener(FolderPickerActivity.this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onServiceDisconnected(ComponentName className) {
|
||||||
|
mSyncthingService = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setContentView(R.layout.folder_picker_activity);
|
||||||
|
mListView = (ListView) findViewById(android.R.id.list);
|
||||||
|
mListView.setOnItemClickListener(this);
|
||||||
|
mListView.setEmptyView(findViewById(android.R.id.empty));
|
||||||
|
mAdapter = new FileAdapter(this);
|
||||||
|
mListView.setAdapter(mAdapter);
|
||||||
|
|
||||||
|
mLocation = new File(getIntent().getStringExtra(EXTRA_INITIAL_DIRECTORY));
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
bindService(new Intent(this, SyncthingService.class),
|
||||||
|
mSyncthingServiceConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
|
getMenuInflater().inflate(R.menu.folder_picker, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.create_folder:
|
||||||
|
final EditText et = new EditText(this);
|
||||||
|
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||||
|
.setTitle(R.string.create_folder)
|
||||||
|
.setView(et)
|
||||||
|
.setPositiveButton(android.R.string.ok,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
createFolder(et.getText().toString());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.create();
|
||||||
|
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||||
|
@Override
|
||||||
|
public void onShow(DialogInterface dialogInterface) {
|
||||||
|
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
|
||||||
|
.showSoftInput(et, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
return true;
|
||||||
|
case R.id.select:
|
||||||
|
Intent intent = new Intent()
|
||||||
|
.putExtra(EXTRA_RESULT_DIRECTORY, mLocation.getAbsolutePath());
|
||||||
|
setResult(Activity.RESULT_OK, intent);
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new folder with the given name and enters it.
|
||||||
|
*/
|
||||||
|
private void createFolder(String name) {
|
||||||
|
File newFolder = new File(mLocation, name);
|
||||||
|
newFolder.mkdir();
|
||||||
|
mLocation = newFolder;
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refreshes the ListView to show the contents of the folder in {@code }mLocation.peek()}.
|
||||||
|
*/
|
||||||
|
private void refresh() {
|
||||||
|
mAdapter.clear();
|
||||||
|
File[] contents = mLocation.listFiles(new FileFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(File file) {
|
||||||
|
return file.isDirectory();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Arrays.sort(contents);
|
||||||
|
for (File f : contents) {
|
||||||
|
mAdapter.add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
|
mLocation = mAdapter.getItem(i);
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class FileAdapter extends ArrayAdapter<File> {
|
||||||
|
|
||||||
|
public FileAdapter(Context context) {
|
||||||
|
super(context, android.R.layout.simple_list_item_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
if (convertView == null) {
|
||||||
|
LayoutInflater inflater = (LayoutInflater) getContext()
|
||||||
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
convertView = inflater.inflate(android.R.layout.simple_list_item_1, parent, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextView title = (TextView) convertView.findViewById(android.R.id.text1);
|
||||||
|
title.setText(getItem(position).getName());
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (!mLocation.equals(Environment.getExternalStorageDirectory())) {
|
||||||
|
mLocation = mLocation.getParentFile();
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setResult(Activity.RESULT_CANCELED);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onApiChange(boolean isAvailable) {
|
||||||
|
if (!isAvailable) {
|
||||||
|
setResult(Activity.RESULT_CANCELED);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -16,7 +16,6 @@ import android.support.v4.app.ActionBarDrawerToggle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentPagerAdapter;
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
|
@ -24,14 +23,10 @@ import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.ActionBar.Tab;
|
import android.support.v7.app.ActionBar.Tab;
|
||||||
import android.support.v7.app.ActionBar.TabListener;
|
import android.support.v7.app.ActionBar.TabListener;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.OrientationEventListener;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.nutomic.syncthingandroid.R;
|
import com.nutomic.syncthingandroid.R;
|
||||||
|
@ -243,7 +238,7 @@ public class MainActivity extends ActionBarActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.main_menu, menu);
|
getMenuInflater().inflate(R.menu.main, menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class NodeSettingsActivity extends PreferenceActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.node_settings_menu, menu);
|
getMenuInflater().inflate(R.menu.node_settings, menu);
|
||||||
return super.onCreateOptionsMenu(menu);
|
return super.onCreateOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nutomic.syncthingandroid.gui;
|
package com.nutomic.syncthingandroid.gui;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -7,6 +8,7 @@ import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
|
@ -33,6 +35,8 @@ public class RepoSettingsActivity extends PreferenceActivity
|
||||||
implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener,
|
implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener,
|
||||||
SyncthingService.OnApiChangeListener {
|
SyncthingService.OnApiChangeListener {
|
||||||
|
|
||||||
|
private static final int DIRECTORY_REQUEST_CODE = 234;
|
||||||
|
|
||||||
public static final String ACTION_CREATE = "create";
|
public static final String ACTION_CREATE = "create";
|
||||||
|
|
||||||
public static final String ACTION_EDIT = "edit";
|
public static final String ACTION_EDIT = "edit";
|
||||||
|
@ -60,7 +64,7 @@ public class RepoSettingsActivity extends PreferenceActivity
|
||||||
|
|
||||||
private EditTextPreference mRepoId;
|
private EditTextPreference mRepoId;
|
||||||
|
|
||||||
private EditTextPreference mDirectory;
|
private Preference mDirectory;
|
||||||
|
|
||||||
private CheckBoxPreference mRepoMaster;
|
private CheckBoxPreference mRepoMaster;
|
||||||
|
|
||||||
|
@ -85,8 +89,8 @@ public class RepoSettingsActivity extends PreferenceActivity
|
||||||
|
|
||||||
mRepoId = (EditTextPreference) findPreference("repo_id");
|
mRepoId = (EditTextPreference) findPreference("repo_id");
|
||||||
mRepoId.setOnPreferenceChangeListener(this);
|
mRepoId.setOnPreferenceChangeListener(this);
|
||||||
mDirectory = (EditTextPreference) findPreference("directory");
|
mDirectory = findPreference("directory");
|
||||||
mDirectory.setOnPreferenceChangeListener(this);
|
mDirectory.setOnPreferenceClickListener(this);
|
||||||
mRepoMaster = (CheckBoxPreference) findPreference("repo_master");
|
mRepoMaster = (CheckBoxPreference) findPreference("repo_master");
|
||||||
mRepoMaster.setOnPreferenceChangeListener(this);
|
mRepoMaster.setOnPreferenceChangeListener(this);
|
||||||
mNodes = (PreferenceScreen) findPreference("nodes");
|
mNodes = (PreferenceScreen) findPreference("nodes");
|
||||||
|
@ -131,7 +135,6 @@ public class RepoSettingsActivity extends PreferenceActivity
|
||||||
|
|
||||||
mRepoId.setText(mRepo.ID);
|
mRepoId.setText(mRepo.ID);
|
||||||
mRepoId.setSummary(mRepo.ID);
|
mRepoId.setSummary(mRepo.ID);
|
||||||
mDirectory.setText(mRepo.Directory);
|
|
||||||
mDirectory.setSummary(mRepo.Directory);
|
mDirectory.setSummary(mRepo.Directory);
|
||||||
mRepoMaster.setChecked(mRepo.ReadOnly);
|
mRepoMaster.setChecked(mRepo.ReadOnly);
|
||||||
List<RestApi.Node> nodesList = mSyncthingService.getApi().getNodes();
|
List<RestApi.Node> nodesList = mSyncthingService.getApi().getNodes();
|
||||||
|
@ -162,7 +165,7 @@ public class RepoSettingsActivity extends PreferenceActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.repo_settings_menu, menu);
|
getMenuInflater().inflate(R.menu.repo_settings, menu);
|
||||||
return super.onCreateOptionsMenu(menu);
|
return super.onCreateOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +265,15 @@ public class RepoSettingsActivity extends PreferenceActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
if (preference.equals(mDelete)) {
|
if (preference.equals(mDirectory)) {
|
||||||
|
Intent intent = new Intent(this, FolderPickerActivity.class)
|
||||||
|
.putExtra(FolderPickerActivity.EXTRA_INITIAL_DIRECTORY,
|
||||||
|
(mRepo.Directory.length() != 0)
|
||||||
|
? mRepo.Directory
|
||||||
|
: Environment.getExternalStorageDirectory().getAbsolutePath());
|
||||||
|
startActivityForResult(intent, DIRECTORY_REQUEST_CODE);
|
||||||
|
}
|
||||||
|
else if (preference.equals(mDelete)) {
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setMessage(R.string.delete_repo_confirm)
|
.setMessage(R.string.delete_repo_confirm)
|
||||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
@ -279,6 +290,15 @@ public class RepoSettingsActivity extends PreferenceActivity
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
if (resultCode == Activity.RESULT_OK && requestCode == DIRECTORY_REQUEST_CODE) {
|
||||||
|
mRepo.Directory = data.getStringExtra(FolderPickerActivity.EXTRA_RESULT_DIRECTORY);
|
||||||
|
mDirectory.setSummary(mRepo.Directory);
|
||||||
|
repoUpdated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void repoUpdated() {
|
private void repoUpdated() {
|
||||||
if (getIntent().getAction().equals(ACTION_EDIT)) {
|
if (getIntent().getAction().equals(ACTION_EDIT)) {
|
||||||
mSyncthingService.getApi().editRepo(mRepo, false);
|
mSyncthingService.getApi().editRepo(mRepo, false);
|
||||||
|
|
|
@ -96,16 +96,25 @@ public class ConfigXml {
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set ignorePerms attribute.
|
|
||||||
NodeList repos = mConfig.getDocumentElement().getElementsByTagName("repository");
|
NodeList repos = mConfig.getDocumentElement().getElementsByTagName("repository");
|
||||||
for (int i = 0; i < repos.getLength(); i++) {
|
for (int i = 0; i < repos.getLength(); i++) {
|
||||||
Element r = (Element) repos.item(i);
|
Element r = (Element) repos.item(i);
|
||||||
|
// Set ignorePerms attribute.
|
||||||
if (!r.hasAttribute("ignorePerms") ||
|
if (!r.hasAttribute("ignorePerms") ||
|
||||||
!Boolean.parseBoolean(r.getAttribute("ignorePerms"))) {
|
!Boolean.parseBoolean(r.getAttribute("ignorePerms"))) {
|
||||||
Log.i(TAG, "Set 'ignorePerms' on repository " + r.getAttribute("id"));
|
Log.i(TAG, "Set 'ignorePerms' on repository " + r.getAttribute("id"));
|
||||||
r.setAttribute("ignorePerms", Boolean.toString(true));
|
r.setAttribute("ignorePerms", Boolean.toString(true));
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replace /sdcard/ in repository path with proper path.
|
||||||
|
String dir = r.getAttribute("directory");
|
||||||
|
if (dir.startsWith("/sdcard")) {
|
||||||
|
String newDir = dir.replace("/sdcard",
|
||||||
|
Environment.getExternalStorageDirectory().getAbsolutePath());
|
||||||
|
r.setAttribute("directory", newDir);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class ReposAdapter extends ArrayAdapter<RestApi.Repo>
|
||||||
private HashMap<String, RestApi.Model> mModels = new HashMap<String, RestApi.Model>();
|
private HashMap<String, RestApi.Model> mModels = new HashMap<String, RestApi.Model>();
|
||||||
|
|
||||||
public ReposAdapter(Context context) {
|
public ReposAdapter(Context context) {
|
||||||
super(context, R.layout.node_list_item);
|
super(context, R.layout.repo_list_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
17
src/main/res/layout/folder_picker_activity.xml
Normal file
17
src/main/res/layout/folder_picker_activity.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@android:id/list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/empty"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/directory_empty"
|
||||||
|
android:layout_centerInParent="true"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
13
src/main/res/menu/folder_picker.xml
Normal file
13
src/main/res/menu/folder_picker.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/create_folder"
|
||||||
|
android:title="Create Folder" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/select"
|
||||||
|
android:title="Select" />
|
||||||
|
|
||||||
|
</menu>
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<style name="DialogWhenLargeCompat" parent="android:Theme.Holo.DialogWhenLarge" />
|
<style name="DialogWhenLarge" parent="android:Theme.Holo.DialogWhenLarge" />
|
||||||
</resources>
|
</resources>
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
<!-- MainActivity -->
|
<!-- MainActivity -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Title of the "add repo" menu action -->
|
<!-- Title of the "add repo" menu action -->
|
||||||
<string name="add_repo">Add Repository</string>
|
<string name="add_repo">Add Repository</string>
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@
|
||||||
|
|
||||||
<!-- LocalNodeInfoFragment -->
|
<!-- LocalNodeInfoFragment -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Same as download_title with a colon and space appended -->
|
<!-- Same as download_title with a colon and space appended -->
|
||||||
<string name="download_title_colon">Download:\u0020</string>
|
<string name="download_title_colon">Download:\u0020</string>
|
||||||
|
|
||||||
|
@ -80,6 +82,7 @@
|
||||||
|
|
||||||
<!-- RepoSettingsActivity -->
|
<!-- RepoSettingsActivity -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Setting title -->
|
<!-- Setting title -->
|
||||||
<string name="repo_id">Repository ID</string>
|
<string name="repo_id">Repository ID</string>
|
||||||
|
|
||||||
|
@ -97,7 +100,6 @@
|
||||||
|
|
||||||
<!-- Setting title -->
|
<!-- Setting title -->
|
||||||
<string name="keep_versions">Keep Versions</string>
|
<string name="keep_versions">Keep Versions</string>
|
||||||
|
|
||||||
<string name="delete_repo">Delete Repository</string>
|
<string name="delete_repo">Delete Repository</string>
|
||||||
|
|
||||||
<!-- Title for RepoSettingsActivity in create mode -->
|
<!-- Title for RepoSettingsActivity in create mode -->
|
||||||
|
@ -120,6 +122,7 @@
|
||||||
|
|
||||||
<!-- NodeSettingsActivity -->
|
<!-- NodeSettingsActivity -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Setting title -->
|
<!-- Setting title -->
|
||||||
<string name="node_id">Node ID</string>
|
<string name="node_id">Node ID</string>
|
||||||
|
|
||||||
|
@ -152,6 +155,7 @@
|
||||||
|
|
||||||
<!-- WebGuiActivity -->
|
<!-- WebGuiActivity -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Title of the web gui activity -->
|
<!-- Title of the web gui activity -->
|
||||||
<string name="web_gui_title">Web GUI</string>
|
<string name="web_gui_title">Web GUI</string>
|
||||||
|
|
||||||
|
@ -171,11 +175,11 @@
|
||||||
<string name="welcome_text">Welcome to Syncthing for Android!\n\n\
|
<string name="welcome_text">Welcome to Syncthing for Android!\n\n\
|
||||||
This app is currently in Alpha state, and you may experience bugs, performance problems or data loss.\n\n\
|
This app is currently in Alpha state, and you may experience bugs, performance problems or data loss.\n\n\
|
||||||
There is currently no special handling for mobile data, so it may use up your data volume if active.\n\n\
|
There is currently no special handling for mobile data, so it may use up your data volume if active.\n\n\
|
||||||
Please report any problems you encounter.
|
Please report any problems you encounter.</string>
|
||||||
</string>
|
|
||||||
|
|
||||||
<!-- SettingsActivity -->
|
<!-- SettingsActivity -->
|
||||||
|
|
||||||
|
|
||||||
<string name="settings_title">Settings</string>
|
<string name="settings_title">Settings</string>
|
||||||
|
|
||||||
<!-- Settings item that opens issue tracker -->
|
<!-- Settings item that opens issue tracker -->
|
||||||
|
@ -190,8 +194,16 @@ Please report any problems you encounter.
|
||||||
<!-- Title of the preference showing upstream version name -->
|
<!-- Title of the preference showing upstream version name -->
|
||||||
<string name="syncthing_version_title">Syncthing Version</string>
|
<string name="syncthing_version_title">Syncthing Version</string>
|
||||||
|
|
||||||
|
<!-- FolderPickerAcitivity -->
|
||||||
|
|
||||||
|
|
||||||
|
<string name="directory_empty">Directory is Empty</string>
|
||||||
|
|
||||||
|
<string name="create_folder">Create new Folder</string>
|
||||||
|
|
||||||
<!-- RestApi -->
|
<!-- RestApi -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Strings representing units for file sizes, from smallest to largest -->
|
<!-- Strings representing units for file sizes, from smallest to largest -->
|
||||||
<string-array name="file_size_units">
|
<string-array name="file_size_units">
|
||||||
<item>B</item>
|
<item>B</item>
|
||||||
|
@ -210,4 +222,8 @@ Please report any problems you encounter.
|
||||||
<item>Tb/s</item>
|
<item>Tb/s</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string name="title_activity_folder_picker">FolderPickerActivity</string>
|
||||||
|
<string name="hello_world">Hello world!</string>
|
||||||
|
<string name="action_settings">Settings</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<style name="MyAppCompatDialogTheme" parent="DialogWhenLargeCompat">
|
<style name="DialogWhenLargeCompat" parent="DialogWhenLarge">
|
||||||
<item name="android:windowIsFloating">false</item>
|
<item name="android:windowIsFloating">false</item>
|
||||||
<item name="android:windowContentOverlay">@null</item>
|
<item name="android:windowContentOverlay">@null</item>
|
||||||
<item name="android:windowSoftInputMode">stateAlwaysHidden</item>
|
<item name="android:windowSoftInputMode">stateAlwaysHidden</item>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
android:key="repo_id"
|
android:key="repo_id"
|
||||||
android:title="@string/repo_id" />
|
android:title="@string/repo_id" />
|
||||||
|
|
||||||
<EditTextPreference
|
<Preference
|
||||||
android:key="directory"
|
android:key="directory"
|
||||||
android:title="@string/directory" />
|
android:title="@string/directory" />
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
style="?android:preferenceInformationStyle" />
|
style="?android:preferenceInformationStyle" />
|
||||||
|
|
||||||
<EditTextPreference
|
<Preference
|
||||||
android:key="directory"
|
android:key="directory"
|
||||||
android:title="@string/directory" />
|
android:title="@string/directory" />
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue