yettags/release-v1.0
@@ -12,7 +12,7 @@ | |||
android:label="@string/app_name" | |||
android:theme="@style/AppTheme"> | |||
<activity | |||
android:name=".MainActivity" | |||
android:name=".activity.MainActivity" | |||
android:label="@string/app_name" | |||
android:theme="@style/AppTheme.NoActionBar"> | |||
<intent-filter> | |||
@@ -21,7 +21,14 @@ | |||
<category android:name="android.intent.category.LAUNCHER" /> | |||
</intent-filter> | |||
</activity> | |||
<activity android:name=".DeviceActivity"></activity> | |||
<activity | |||
android:label="@string/device_informations" | |||
android:name=".activity.DeviceActivity" | |||
android:theme="@style/AppTheme.NoActionBar" /> | |||
<activity | |||
android:label="@string/server_management" | |||
android:name=".activity.ServersActivity" | |||
android:theme="@style/AppTheme.NoActionBar" /> | |||
</application> | |||
</manifest> |
@@ -1,4 +1,4 @@ | |||
package fr.mobdev.lpcprog; | |||
package fr.mobdev.lpcprog.activity; | |||
import android.support.v7.app.AppCompatActivity; | |||
import android.os.Bundle; | |||
@@ -6,16 +6,21 @@ import android.widget.TextView; | |||
import java.util.List; | |||
import fr.mobdev.lpcprog.managers.IspManager; | |||
import fr.mobdev.lpcprog.R; | |||
import fr.mobdev.lpcprog.objects.USBDevice; | |||
import fr.mobdev.lpcprog.managers.UsbCommManager; | |||
public class DeviceActivity extends AppCompatActivity { | |||
private UsbComm comm; | |||
private UsbCommManager comm; | |||
private USBDevice dev; | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
setContentView(R.layout.device); | |||
comm = UsbComm.getInstance(this); | |||
comm = UsbCommManager.getInstance(this); | |||
List<USBDevice> devices = comm.getDevices(); | |||
int pid = getIntent().getIntExtra("PID",-1); | |||
int vid = getIntent().getIntExtra("VID",-1); |
@@ -1,4 +1,4 @@ | |||
package fr.mobdev.lpcprog; | |||
package fr.mobdev.lpcprog.activity; | |||
import android.content.Intent; | |||
import android.os.Bundle; | |||
@@ -11,13 +11,17 @@ import android.view.Menu; | |||
import android.view.MenuItem; | |||
import android.view.MotionEvent; | |||
import android.view.View; | |||
import android.widget.Toast; | |||
import java.util.List; | |||
import fr.mobdev.lpcprog.adapters.DeviceAdapter; | |||
import fr.mobdev.lpcprog.R; | |||
import fr.mobdev.lpcprog.objects.USBDevice; | |||
import fr.mobdev.lpcprog.managers.UsbCommManager; | |||
public class MainActivity extends AppCompatActivity { | |||
private UsbComm comm; | |||
private UsbCommManager comm; | |||
private List<USBDevice> devices; | |||
private int value = 0; | |||
@@ -28,7 +32,7 @@ public class MainActivity extends AppCompatActivity { | |||
setContentView(R.layout.main_activity); | |||
Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); | |||
setSupportActionBar(toolbar); | |||
comm = UsbComm.getInstance(this); | |||
comm = UsbCommManager.getInstance(this); | |||
final GestureDetector gestureDetector = new GestureDetector(MainActivity.this, new GestureDetector.SimpleOnGestureListener(){ | |||
@Override | |||
@@ -70,6 +74,10 @@ public class MainActivity extends AppCompatActivity { | |||
updateList(); | |||
return true; | |||
} | |||
else if(id == R.id.action_server){ | |||
Intent newIntent = new Intent(this,ServersActivity.class); | |||
startActivity(newIntent); | |||
} | |||
return super.onOptionsItemSelected(item); | |||
} |
@@ -0,0 +1,114 @@ | |||
/* | |||
* Copyright (C) 2015 Anthony Chomienne, anthony@mob-dev.fr | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License | |||
* as published by the Free Software Foundation; either version 3 | |||
* of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package fr.mobdev.lpcprog.activity; | |||
import android.os.Bundle; | |||
import android.support.v7.app.AppCompatActivity; | |||
import android.support.v7.widget.LinearLayoutManager; | |||
import android.support.v7.widget.RecyclerView; | |||
import android.support.v7.widget.Toolbar; | |||
import android.view.Menu; | |||
import android.view.MenuItem; | |||
import android.view.View; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import fr.mobdev.lpcprog.R; | |||
import fr.mobdev.lpcprog.adapters.ServerAdapter; | |||
import fr.mobdev.lpcprog.dialog.ServerDialog; | |||
import fr.mobdev.lpcprog.listener.ServerListener; | |||
import fr.mobdev.lpcprog.managers.DatabaseManager; | |||
import fr.mobdev.lpcprog.objects.Server; | |||
/* | |||
* Activity that allow user to manage the server where he want to upload his images. Server must be lutim instance to work with the app | |||
*/ | |||
public class ServersActivity extends AppCompatActivity { | |||
private List<List<Server>> dbServers; | |||
private ServerListener serverListener; | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
setContentView(R.layout.servers); | |||
Toolbar toolbar = (Toolbar) findViewById(R.id.servers_toolbar); | |||
setSupportActionBar(toolbar); | |||
/* ***** Change status of the repos: active to inactive or reverse ***** | |||
ListView serverList = (ListView) findViewById(R.id.servers_list); | |||
serverList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { | |||
@Override | |||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { | |||
Server clickedServer = dbServers.get(position); | |||
DatabaseManager.getInstance(getApplicationContext()).changeServerStatus(clickedServer.id,!clickedServer.isActive); | |||
updateServers(); | |||
return true; | |||
} | |||
});*/ | |||
serverListener = new ServerListener() { | |||
@Override | |||
public void updateServerList() { | |||
updateServers(); | |||
} | |||
}; | |||
updateServers(); | |||
} | |||
private void updateServers() | |||
{ | |||
// build the view with server list in database | |||
dbServers = DatabaseManager.getInstance(getApplicationContext()).getServers(); | |||
List<String> namesList = new ArrayList<>(); | |||
namesList.add(getString(R.string.active_section)); | |||
namesList.add(getString(R.string.inactive_section)); | |||
namesList.add(getString(R.string.failed_section)); | |||
ServerAdapter adapter = new ServerAdapter(dbServers,namesList,serverListener); | |||
RecyclerView serverList = (RecyclerView) findViewById(R.id.servers_list); | |||
serverList.setLayoutManager(new LinearLayoutManager(this)); | |||
serverList.setAdapter(adapter); | |||
} | |||
@Override | |||
public boolean onCreateOptionsMenu(Menu menu) { | |||
getMenuInflater().inflate(R.menu.menu_servers, menu); | |||
return true; | |||
} | |||
@Override | |||
public boolean onOptionsItemSelected(MenuItem item) { | |||
int id = item.getItemId(); | |||
if (id == R.id.action_add_server) { | |||
ServerDialog serverDialog = new ServerDialog(); | |||
serverDialog.setServerListener(serverListener); | |||
serverDialog.show(getSupportFragmentManager(),"Server Dialog"); | |||
return true; | |||
} | |||
return super.onOptionsItemSelected(item); | |||
} | |||
} |
@@ -1,8 +1,5 @@ | |||
package fr.mobdev.lpcprog; | |||
package fr.mobdev.lpcprog.adapters; | |||
import android.hardware.usb.UsbDevice; | |||
import android.hardware.usb.UsbDeviceConnection; | |||
import android.os.Build; | |||
import android.support.v7.widget.RecyclerView; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
@@ -11,6 +8,9 @@ import android.widget.TextView; | |||
import java.util.List; | |||
import fr.mobdev.lpcprog.R; | |||
import fr.mobdev.lpcprog.objects.USBDevice; | |||
public class DeviceAdapter extends RecyclerView.Adapter<DeviceHolder> { | |||
private List<USBDevice> devices; |
@@ -0,0 +1,173 @@ | |||
package fr.mobdev.lpcprog.adapters; | |||
import android.content.DialogInterface; | |||
import android.support.v7.app.AlertDialog; | |||
import android.support.v7.widget.RecyclerView; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import android.widget.ImageView; | |||
import android.widget.TextView; | |||
import java.util.List; | |||
import fr.mobdev.lpcprog.R; | |||
import fr.mobdev.lpcprog.listener.ServerListener; | |||
import fr.mobdev.lpcprog.managers.DatabaseManager; | |||
import fr.mobdev.lpcprog.objects.Server; | |||
public class ServerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | |||
private static final int SECTION = 0; | |||
private static final int FIELD = 1; | |||
private List<List<Server>> servers; | |||
private List<String> sections; | |||
private ServerListener serverListener; | |||
private int count; | |||
public ServerAdapter(List<List<Server>> servers, List<String> sections, ServerListener listener) { | |||
this.servers = servers; | |||
this.sections = sections; | |||
serverListener = listener; | |||
countElements(); | |||
} | |||
@Override | |||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |||
View view; | |||
if (viewType == SECTION) { | |||
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.server_section, parent, false); | |||
return new SectionHolder(view); | |||
} else { | |||
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.server_item, parent, false); | |||
return new ServerHolder(view,serverListener); | |||
} | |||
} | |||
@Override | |||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | |||
if (holder instanceof SectionHolder) { | |||
SectionHolder sectionHolder = (SectionHolder) holder; | |||
int section = getSection(position); | |||
System.out.println("pos " + position + " section " + section); | |||
String sectionName = sections.get(section); | |||
sectionHolder.setupSection(sectionName); | |||
} else if (holder instanceof ServerHolder) { | |||
ServerHolder serverHolder = (ServerHolder) holder; | |||
int section = getSection(position); | |||
int pos = getRealPosition(position); | |||
Server server = servers.get(section).get(pos); | |||
serverHolder.setupServer(server); | |||
} | |||
} | |||
private void countElements() { | |||
int size = 0; | |||
for (int i = 0; i < sections.size(); i++) { | |||
if (servers.get(i).size() > 0) { | |||
size++; | |||
size += servers.get(i).size(); | |||
} | |||
} | |||
count = size; | |||
} | |||
private int getRealPosition(int fakePosition) { | |||
System.out.println("get real " + fakePosition); | |||
fakePosition -= 1; | |||
for (int i = 0; i < sections.size(); i++) { | |||
int serverSize = servers.get(i).size(); | |||
if (fakePosition - serverSize < 0) | |||
return fakePosition; | |||
if (serverSize > 0) { | |||
fakePosition -= 1; | |||
fakePosition -= serverSize; | |||
} | |||
} | |||
return -1; | |||
} | |||
private int getSection(int fakePosition) { | |||
int prev_size = 1; | |||
for (int i = 0; i < sections.size(); i++) { | |||
int serverSize = servers.get(i).size(); | |||
if (fakePosition < prev_size + serverSize) | |||
return i; | |||
if (servers.get(i).size() > 0) { | |||
prev_size += 1; | |||
prev_size += serverSize; | |||
} | |||
} | |||
return -1;//error | |||
} | |||
@Override | |||
public int getItemCount() { | |||
return count; | |||
} | |||
@Override | |||
public int getItemViewType(int position) { | |||
int nbValues = 0; | |||
for (int i = 0; i < sections.size(); i++) { | |||
if (position == i + nbValues) | |||
return SECTION; | |||
else if (position < i + nbValues) | |||
break; | |||
nbValues += servers.get(i).size(); | |||
} | |||
return FIELD; | |||
} | |||
} | |||
class ServerHolder extends RecyclerView.ViewHolder{ | |||
ServerListener serverListener; | |||
public ServerHolder(View itemView, ServerListener serverListener) { | |||
super(itemView); | |||
this.serverListener = serverListener; | |||
} | |||
public void setupServer(final Server server){ | |||
TextView view = (TextView) itemView.findViewById(R.id.server_name); | |||
view.setText(server.url.toString()); | |||
ImageView deleteView = (ImageView) itemView.findViewById(R.id.server_delete); | |||
deleteView.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View v) { | |||
AlertDialog.Builder builder = new AlertDialog.Builder(itemView.getContext()); | |||
builder.setMessage(itemView.getContext().getString(R.string.delete_server_message)+" "+server.url) | |||
.setCancelable(false) | |||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { | |||
public void onClick(DialogInterface dialog, int id) { | |||
//delete server from database and update the view | |||
DatabaseManager.getInstance(itemView.getContext()).deleteServer(server.id); | |||
serverListener.updateServerList(); | |||
} | |||
}) | |||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { | |||
public void onClick(DialogInterface dialog, int id) { | |||
dialog.cancel(); | |||
} | |||
}); | |||
AlertDialog alert = builder.create(); | |||
alert.show(); | |||
} | |||
}); | |||
} | |||
} | |||
class SectionHolder extends RecyclerView.ViewHolder { | |||
public SectionHolder(View itemView) { | |||
super(itemView); | |||
} | |||
public void setupSection(String sectionName) { | |||
TextView view = (TextView)itemView.findViewById(R.id.section_name); | |||
view.setText(sectionName); | |||
} | |||
} | |||
@@ -0,0 +1,85 @@ | |||
/* | |||
* Copyright (C) 2015 Anthony Chomienne, anthony@mob-dev.fr | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License | |||
* as published by the Free Software Foundation; either version 3 | |||
* of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package fr.mobdev.lpcprog.dialog; | |||
import android.app.AlertDialog; | |||
import android.app.Dialog; | |||
import android.content.DialogInterface; | |||
import android.os.Bundle; | |||
import android.support.v4.app.DialogFragment; | |||
import android.view.View; | |||
import android.widget.EditText; | |||
import android.widget.Spinner; | |||
import android.support.annotation.NonNull; | |||
import fr.mobdev.lpcprog.listener.ServerListener; | |||
import fr.mobdev.lpcprog.R; | |||
import fr.mobdev.lpcprog.managers.DatabaseManager; | |||
/* | |||
* Dialog allow user to add a new Server where he can upload images | |||
*/ | |||
public class ServerDialog extends DialogFragment { | |||
private static final int HTTPS_POSITION = 1; | |||
private ServerListener listener; | |||
public void setServerListener(ServerListener listener) | |||
{ | |||
this.listener = listener; | |||
} | |||
@Override | |||
public @NonNull Dialog onCreateDialog(Bundle savedInstanceState) | |||
{ | |||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | |||
final View view = View.inflate(getActivity(),R.layout.server_dialog, null); | |||
builder.setView(view) | |||
.setTitle(R.string.server_title) | |||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { | |||
@Override | |||
public void onClick(DialogInterface dialog, int which) { | |||
//build the url | |||
String url = "http"; | |||
//is it http or https? | |||
Spinner httpSpinner = (Spinner) view.findViewById(R.id.http_spinner); | |||
if(httpSpinner.getSelectedItemPosition() == HTTPS_POSITION) | |||
url += "s"; | |||
url +="://"; | |||
//get the rest of the url | |||
EditText urlText = (EditText) view.findViewById(R.id.url_text); | |||
if(urlText.getText().length() > 0) | |||
url += urlText.getText(); | |||
//add server to database | |||
DatabaseManager.getInstance(getActivity().getApplicationContext()).addServer(url); | |||
listener.updateServerList(); | |||
dismiss(); | |||
} | |||
}) | |||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { | |||
@Override | |||
public void onClick(DialogInterface dialog, int which) { | |||
dismiss(); | |||
} | |||
}); | |||
return builder.create(); | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
/* | |||
* Copyright (C) 2015 Anthony Chomienne, anthony@mob-dev.fr | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License | |||
* as published by the Free Software Foundation; either version 3 | |||
* of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package fr.mobdev.lpcprog.listener; | |||
import java.util.EventListener; | |||
public interface ServerListener extends EventListener { | |||
void updateServerList(); | |||
} |
@@ -0,0 +1,104 @@ | |||
package fr.mobdev.lpcprog.managers; | |||
import android.content.ContentValues; | |||
import android.content.Context; | |||
import android.database.Cursor; | |||
import android.database.sqlite.SQLiteDatabase; | |||
import android.database.sqlite.SQLiteOpenHelper; | |||
import java.net.URL; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import fr.mobdev.lpcprog.objects.Server; | |||
public class DatabaseManager extends SQLiteOpenHelper { | |||
private static DatabaseManager instance; | |||
public static DatabaseManager getInstance(Context context){ | |||
if(instance == null) | |||
instance = new DatabaseManager(context); | |||
return instance; | |||
} | |||
private DatabaseManager(Context context){ | |||
super(context,"lpcprog.db",null,1); | |||
} | |||
@Override | |||
public void onCreate(SQLiteDatabase db) { | |||
db.execSQL("Create table if not exists binaries (" + | |||
"id integer primary key autoincrement, name varchar(1024), short_hash varchar(1024), real_short_hash varchar(1024), date INTEGER, storage_duration INTEGER ,thumb TEXT, token varchar(1024));"); | |||
db.execSQL("Create table if not exists servers (" + | |||
"id integer primary key autoincrement, url varchar(1024), isActive INTEGER, attempted INTEGER);"); | |||
ContentValues values = new ContentValues(); | |||
values.put("url","https://wiki.mob-dev.fr/files/"); | |||
values.put("isActive",1); | |||
values.put("attempted",0); | |||
db.insert("servers",null,values); | |||
} | |||
@Override | |||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | |||
//Nothing to do right now | |||
} | |||
public void addServer(String url) { | |||
ContentValues values = new ContentValues(); | |||
values.put("url",url); | |||
values.put("isActive",1); | |||
values.put("attempted",0); | |||
getWritableDatabase().insert("servers",null,values); | |||
} | |||
public void changeServerStatus(long id, boolean newStatus) { | |||
ContentValues values = new ContentValues(); | |||
values.put("isActive",newStatus); | |||
String where = "id = ?"; | |||
String whereArgs[] = new String[1]; | |||
whereArgs[0] = String.valueOf(id); | |||
getWritableDatabase().update("servers",values,where,whereArgs); | |||
} | |||
public void deleteServer(long id) | |||
{ | |||
String where = "id = ?"; | |||
String whereArgs[] = new String[1]; | |||
whereArgs[0] = String.valueOf(id); | |||
getWritableDatabase().delete("servers",where,whereArgs); | |||
} | |||
public List<List<Server>> getServers() { | |||
List<List<Server>> list = new ArrayList<>(); | |||
List<Server> active = new ArrayList<>(); | |||
List<Server> inactive = new ArrayList<>(); | |||
List<Server> failed = new ArrayList<>(); | |||
list.add(active); | |||
list.add(failed); | |||
list.add(inactive); | |||
Cursor cursor = getReadableDatabase().query("servers", null, null, null, null, null, null); | |||
while (cursor.moveToNext()) { | |||
int col = 0; | |||
try { | |||
Server server = new Server(); | |||
server.id = cursor.getLong(col++); | |||
server.url = new URL(cursor.getString(col++)); | |||
int isActive = cursor.getInt(col++); | |||
server.isActive = isActive != 0; | |||
server.attempted = cursor.getInt(col); | |||
if (server.isActive && server.attempted == 0) | |||
active.add(server); | |||
else if (server.isActive && server.attempted != 0) | |||
failed.add(server); | |||
else | |||
inactive.add(server); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
cursor.close(); | |||
return list; | |||
} | |||
} |
@@ -1,4 +1,4 @@ | |||
package fr.mobdev.lpcprog; | |||
package fr.mobdev.lpcprog.managers; | |||
import com.ftdi.j2xx.D2xxManager; | |||
import com.ftdi.j2xx.FT_Device; | |||
@@ -6,6 +6,8 @@ import com.ftdi.j2xx.FT_Device; | |||
import java.nio.ByteBuffer; | |||
import java.util.Locale; | |||
import fr.mobdev.lpcprog.objects.USBDevice; | |||
public class IspManager { | |||
//defines |
@@ -0,0 +1,4 @@ | |||
package fr.mobdev.lpcprog.managers; | |||
public class NetworkManager { | |||
} |
@@ -1,4 +1,4 @@ | |||
package fr.mobdev.lpcprog; | |||
package fr.mobdev.lpcprog.managers; | |||
import android.content.Context; | |||
@@ -7,16 +7,18 @@ import com.ftdi.j2xx.D2xxManager; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class UsbComm { | |||
import fr.mobdev.lpcprog.objects.USBDevice; | |||
private static UsbComm instance = null; | |||
public class UsbCommManager { | |||
private static UsbCommManager instance = null; | |||
private D2xxManager manager = null; | |||
private Context context; | |||
List<USBDevice> openedDevices; | |||
private UsbComm(Context context){ | |||
private UsbCommManager(Context context){ | |||
openedDevices = new ArrayList<>(); | |||
try { | |||
manager = D2xxManager.getInstance(context); | |||
@@ -26,9 +28,9 @@ public class UsbComm { | |||
} | |||
} | |||
public static UsbComm getInstance(Context context){ | |||
public static UsbCommManager getInstance(Context context){ | |||
if(instance == null) | |||
instance = new UsbComm(context); | |||
instance = new UsbCommManager(context); | |||
return instance; | |||
} | |||
@@ -0,0 +1,10 @@ | |||
package fr.mobdev.lpcprog.objects; | |||
public class Binary { | |||
public long id; | |||
public String name; | |||
public String filename; | |||
public int version; | |||
public String path; | |||
public String sha1; | |||
} |
@@ -0,0 +1,13 @@ | |||
package fr.mobdev.lpcprog.objects; | |||
import java.net.URL; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class Server { | |||
public long id; | |||
public URL url; | |||
public boolean isActive; | |||
public int attempted; | |||
public List<Binary> binaries = new ArrayList<>(); | |||
} |
@@ -1,4 +1,4 @@ | |||
package fr.mobdev.lpcprog; | |||
package fr.mobdev.lpcprog.objects; | |||
import com.ftdi.j2xx.FT_Device; | |||
@@ -1,55 +1,77 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
<android.support.design.widget.CoordinatorLayout | |||
xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:fitsSystemWindows="true" | |||
android:layout_height="match_parent" | |||
android:layout_width="match_parent" | |||
android:paddingBottom="@dimen/activity_vertical_margin" | |||
android:paddingLeft="@dimen/activity_horizontal_margin" | |||
android:paddingRight="@dimen/activity_horizontal_margin" | |||
android:paddingTop="@dimen/activity_vertical_margin" | |||
tools:context="fr.mobdev.lpcprog.DeviceActivity"> | |||
<LinearLayout | |||
android:id="@+id/device_info" | |||
android:layout_alignParentTop="true" | |||
tools:context=".activity.DeviceActivity" | |||
> | |||
<android.support.design.widget.AppBarLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical"> | |||
<TextView | |||
android:id="@+id/name" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" /> | |||
<TextView | |||
android:id="@+id/vendor_id" | |||
android:theme="@style/AppTheme.PopupOverlay"> | |||
<android.support.v7.widget.Toolbar | |||
android:id="@+id/servers_toolbar" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" /> | |||
<TextView | |||
android:id="@+id/id" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" /> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:id="@+id/lpc_info" | |||
android:layout_below="@id/device_info" | |||
android:orientation="vertical" | |||
android:layout_height="?attr/actionBarSize" | |||
android:background="?attr/colorPrimary" | |||
app:popupTheme="@style/AppTheme.PopupOverlay" | |||
/> | |||
</android.support.design.widget.AppBarLayout> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content"> | |||
<TextView | |||
android:id="@+id/uids" | |||
android:layout_height="match_parent"> | |||
<LinearLayout | |||
android:id="@+id/device_info" | |||
android:layout_alignParentTop="true" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" /> | |||
<TextView | |||
android:id="@+id/part_id" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical"> | |||
<TextView | |||
android:id="@+id/name" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" /> | |||
<TextView | |||
android:id="@+id/vendor_id" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" /> | |||
<TextView | |||
android:id="@+id/id" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" /> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:id="@+id/lpc_info" | |||
android:layout_below="@id/device_info" | |||
android:orientation="vertical" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" /> | |||
<TextView | |||
android:id="@+id/boot_version" | |||
android:layout_height="wrap_content"> | |||
<TextView | |||
android:id="@+id/uids" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" /> | |||
<TextView | |||
android:id="@+id/part_id" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" /> | |||
<TextView | |||
android:id="@+id/boot_version" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" /> | |||
</LinearLayout> | |||
<android.support.v7.widget.RecyclerView | |||
android:id="@+id/bin_list" | |||
android:layout_below="@id/lpc_info" | |||
android:layout_alignParentBottom="true" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" /> | |||
</LinearLayout> | |||
<android.support.v7.widget.RecyclerView | |||
android:id="@+id/bin_list" | |||
android:layout_below="@id/lpc_info" | |||
android:layout_alignParentBottom="true" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content"/> | |||
</RelativeLayout> | |||
android:layout_height="wrap_content"/> | |||
</RelativeLayout> | |||
</android.support.design.widget.CoordinatorLayout> |
@@ -5,7 +5,7 @@ | |||
android:fitsSystemWindows="true" | |||
android:layout_height="match_parent" | |||
android:layout_width="match_parent" | |||
tools:context="fr.mobdev.lpcprog.MainActivity" | |||
tools:context=".activity.MainActivity" | |||
> | |||
<android.support.design.widget.AppBarLayout | |||
@@ -0,0 +1,21 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:orientation="horizontal" android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<Spinner | |||
android:id="@+id/http_spinner" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:entries="@array/https" | |||
/> | |||
<EditText | |||
android:id="@+id/url_text" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:hint="@string/url" | |||
android:inputType="textUri" | |||
/> | |||
</LinearLayout> |
@@ -0,0 +1,20 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<ImageView | |||
android:layout_alignParentRight="true" | |||
android:layout_alignParentTop="true" | |||
android:src="@android:drawable/ic_delete" | |||
android:id="@+id/server_delete" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" /> | |||
<TextView | |||
android:layout_toLeftOf="@+id/server_delete" | |||
android:textAppearance="?android:attr/textAppearanceMedium" | |||
android:id="@+id/server_name" | |||
android:layout_alignParentLeft="true" | |||
android:layout_alignParentTop="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" /> | |||
</RelativeLayout> |
@@ -0,0 +1,16 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:orientation="vertical" android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:id="@+id/section_name" | |||
style="?android:attr/listSeparatorTextViewStyle" | |||
android:layout_width="match_parent" | |||
android:layout_height="48dp" | |||
android:layout_marginLeft="5dp" | |||
android:layout_marginStart="5dp" | |||
android:textAppearance="?android:attr/textAppearanceMedium" | |||
android:textColor="@color/colorPrimary" | |||
android:gravity="center_vertical"/> | |||
</LinearLayout> |
@@ -0,0 +1,41 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<android.support.design.widget.CoordinatorLayout | |||
xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:fitsSystemWindows="true" | |||
android:layout_height="match_parent" | |||
android:layout_width="match_parent" | |||
tools:context=".activity.ServersActivity" | |||
> | |||
<android.support.design.widget.AppBarLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:theme="@style/AppTheme.PopupOverlay"> | |||
<android.support.v7.widget.Toolbar | |||
android:id="@+id/servers_toolbar" | |||
android:layout_width="match_parent" | |||
android:layout_height="?attr/actionBarSize" | |||
android:background="?attr/colorPrimary" | |||
app:popupTheme="@style/AppTheme.PopupOverlay" | |||
/> | |||
</android.support.design.widget.AppBarLayout> | |||
<RelativeLayout app:layout_behavior="@string/appbar_scrolling_view_behavior" | |||
android:paddingLeft="@dimen/activity_horizontal_margin" | |||
android:paddingRight="@dimen/activity_horizontal_margin" | |||
android:paddingTop="@dimen/activity_vertical_margin" | |||
android:paddingBottom="@dimen/activity_vertical_margin" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<android.support.v7.widget.RecyclerView | |||
android:id="@+id/servers_list" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:choiceMode="singleChoice" | |||
/> | |||
</RelativeLayout> | |||
</android.support.design.widget.CoordinatorLayout> |
@@ -1,9 +1,14 @@ | |||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"> | |||
xmlns:tools="http://schemas.android.com/tools" tools:context=".activity.MainActivity"> | |||
<item | |||
android:id="@+id/action_refresh" | |||
android:title="@string/str_refresh" | |||
android:icon="@drawable/ic_refresh" | |||
app:showAsAction="ifRoom" /> | |||
<item | |||
android:id="@+id/action_server" | |||
android:title="@string/str_server" | |||
android:icon="@android:drawable/ic_menu_manage" | |||
app:showAsAction="ifRoom" /> | |||
</menu> |
@@ -0,0 +1,8 @@ | |||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" tools:context="fr.mobdev.goblim.activity.ServersActivity"> | |||
<item android:id="@+id/action_add_server" | |||
android:icon="@android:drawable/ic_menu_add" | |||
android:title="@string/add_server" | |||
app:showAsAction="ifRoom" /> | |||
</menu> |
@@ -1,6 +1,19 @@ | |||
<resources> | |||
<string name="app_name">LPCProg</string> | |||
<string name="hello_world">Hello world!</string> | |||
<string name="str_refresh">Refresh</string> | |||
<string name="server_title">Add new server</string> | |||
<string name="delete_server_message">Delete the server</string> | |||
<string name="url">Site Url</string> | |||
<string name="active_section">Active Servers</string> | |||
<string name="failed_section">Failed Servers</string> | |||
<string name="inactive_section">Inactive Servers</string> | |||
<string name="str_server">Manage Servers</string> | |||
<string name="add_server">Add a Server</string> | |||
<string name="device_informations">Device Informations</string> | |||
<string name="server_management">Manage Servers</string> | |||
<array name="https"> | |||
<item>http://</item> | |||
<item>https://</item> | |||
</array> | |||
</resources> |