From 74d51dcaa72cc2417cfaee459bed38330e449738 Mon Sep 17 00:00:00 2001 From: Schoumi Date: Wed, 24 Feb 2016 00:45:26 +0100 Subject: [PATCH] Material design History is the launch activity FloatingButton for ask upload in historyActivity --- app/build.gradle | 16 ++- app/src/main/AndroidManifest.xml | 21 ++- .../goblim/activity/HistoryActivity.java | 18 ++- .../mobdev/goblim/activity/LinkActivity.java | 7 +- .../goblim/activity/ServersActivity.java | 8 +- ...{MainActivity.java => UploadActivity.java} | 27 ++-- app/src/main/res/layout-land/main.xml | 84 ------------ app/src/main/res/layout-land/upload.xml | 122 +++++++++++++++++ app/src/main/res/layout/history.xml | 61 +++++++-- app/src/main/res/layout/link.xml | 124 +++++++++++------- app/src/main/res/layout/main.xml | 77 ----------- app/src/main/res/layout/servers.xml | 68 +++++++--- app/src/main/res/layout/upload.xml | 104 +++++++++++++++ .../menu/{menu_main.xml => menu_upload.xml} | 5 - app/src/main/res/values-v21/styles.xml | 8 ++ app/src/main/res/values-v23/styles.xml | 9 ++ app/src/main/res/values/colors.xml | 6 + app/src/main/res/values/styles.xml | 11 ++ build.gradle | 6 +- 19 files changed, 505 insertions(+), 277 deletions(-) rename app/src/main/java/fr/mobdev/goblim/activity/{MainActivity.java => UploadActivity.java} (94%) delete mode 100644 app/src/main/res/layout-land/main.xml create mode 100644 app/src/main/res/layout-land/upload.xml delete mode 100644 app/src/main/res/layout/main.xml create mode 100644 app/src/main/res/layout/upload.xml rename app/src/main/res/menu/{menu_main.xml => menu_upload.xml} (66%) create mode 100644 app/src/main/res/values-v21/styles.xml create mode 100644 app/src/main/res/values-v23/styles.xml create mode 100644 app/src/main/res/values/colors.xml diff --git a/app/build.gradle b/app/build.gradle index 5b92a8e..b3b8184 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,16 +1,17 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 22 - buildToolsVersion "21.1.2" + compileSdkVersion 23 + buildToolsVersion "23.0.2" defaultConfig { applicationId "fr.mobdev.goblim" - minSdkVersion 11 - targetSdkVersion 22 - versionCode 2 - versionName "1.0" + minSdkVersion 15 + targetSdkVersion 23 + versionCode 3 + versionName "2.0" } + buildTypes { release { minifyEnabled false @@ -21,5 +22,6 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:22.0.0' + compile 'com.android.support:appcompat-v7:23.1.1' + compile 'com.android.support:design:23.1.1' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 63b44fe..547869a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,14 +12,13 @@ android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:supportsRtl="true" android:theme="@style/AppTheme"> - - - - + android:name="fr.mobdev.goblim.activity.UploadActivity" + android:label="@string/app_name" + android:theme="@style/AppTheme.NoActionBar" + > @@ -28,16 +27,24 @@ + android:label="@string/app_name" + android:theme="@style/AppTheme.NoActionBar" + > + + + + diff --git a/app/src/main/java/fr/mobdev/goblim/activity/HistoryActivity.java b/app/src/main/java/fr/mobdev/goblim/activity/HistoryActivity.java index 9bb50e7..2320ff7 100644 --- a/app/src/main/java/fr/mobdev/goblim/activity/HistoryActivity.java +++ b/app/src/main/java/fr/mobdev/goblim/activity/HistoryActivity.java @@ -20,8 +20,10 @@ package fr.mobdev.goblim.activity; import android.content.Context; import android.content.Intent; -import android.support.v7.app.ActionBarActivity; import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -45,7 +47,7 @@ import fr.mobdev.goblim.R; /* * This Activity help user to find old shared pictures and re-share it if he wanted to */ -public class HistoryActivity extends ActionBarActivity { +public class HistoryActivity extends AppCompatActivity { private List images; @@ -54,6 +56,18 @@ public class HistoryActivity extends ActionBarActivity { super.onCreate(savedInstanceState); setContentView(R.layout.history); + Toolbar toolbar = (Toolbar) findViewById(R.id.history_toolbar); + setSupportActionBar(toolbar); + + FloatingActionButton new_image_button = (FloatingActionButton) findViewById(R.id.new_image_button); + new_image_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent newIntent = new Intent(HistoryActivity.this,UploadActivity.class); + startActivity(newIntent); + } + }); + ListView historyList = (ListView) findViewById(R.id.history_list); updateHistory(); diff --git a/app/src/main/java/fr/mobdev/goblim/activity/LinkActivity.java b/app/src/main/java/fr/mobdev/goblim/activity/LinkActivity.java index 29db5ed..3d08885 100644 --- a/app/src/main/java/fr/mobdev/goblim/activity/LinkActivity.java +++ b/app/src/main/java/fr/mobdev/goblim/activity/LinkActivity.java @@ -23,6 +23,8 @@ import android.content.DialogInterface; import android.content.Intent; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.ImageButton; import android.widget.ImageView; @@ -45,13 +47,16 @@ import fr.mobdev.goblim.objects.Img; * Activity display the link of the uploaded picture and allow user to share it with other app * or copy it to cleapboard */ -public class LinkActivity extends ActionBarActivity { +public class LinkActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.link); + Toolbar toolbar = (Toolbar) findViewById(R.id.link_toolbar); + setSupportActionBar(toolbar); + //get url information Intent receiveIntent = getIntent(); Long imageId = receiveIntent.getLongExtra("imageId", -1); diff --git a/app/src/main/java/fr/mobdev/goblim/activity/ServersActivity.java b/app/src/main/java/fr/mobdev/goblim/activity/ServersActivity.java index 3926ad0..660d416 100644 --- a/app/src/main/java/fr/mobdev/goblim/activity/ServersActivity.java +++ b/app/src/main/java/fr/mobdev/goblim/activity/ServersActivity.java @@ -22,8 +22,9 @@ import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.graphics.Typeface; -import android.support.v7.app.ActionBarActivity; import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -47,7 +48,7 @@ import fr.mobdev.goblim.R; /* * 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 ActionBarActivity { +public class ServersActivity extends AppCompatActivity { private List dbServers; private View.OnClickListener listener; @@ -57,6 +58,9 @@ public class ServersActivity extends ActionBarActivity { super.onCreate(savedInstanceState); setContentView(R.layout.servers); + Toolbar toolbar = (Toolbar) findViewById(R.id.servers_toolbar); + setSupportActionBar(toolbar); + ListView serverList = (ListView) findViewById(R.id.servers_list); serverList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override diff --git a/app/src/main/java/fr/mobdev/goblim/activity/MainActivity.java b/app/src/main/java/fr/mobdev/goblim/activity/UploadActivity.java similarity index 94% rename from app/src/main/java/fr/mobdev/goblim/activity/MainActivity.java rename to app/src/main/java/fr/mobdev/goblim/activity/UploadActivity.java index b2e43e0..a13464e 100644 --- a/app/src/main/java/fr/mobdev/goblim/activity/MainActivity.java +++ b/app/src/main/java/fr/mobdev/goblim/activity/UploadActivity.java @@ -25,8 +25,9 @@ import android.content.pm.ActivityInfo; import android.graphics.Bitmap; import android.net.Uri; import android.provider.MediaStore; -import android.support.v7.app.ActionBarActivity; import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -56,7 +57,7 @@ import fr.mobdev.goblim.R; * This Activity let user access to the others activities in order to manage history, servers and after an upload * the shared options of the given link */ -public class MainActivity extends ActionBarActivity { +public class UploadActivity extends AppCompatActivity { private NetworkAdapter listener; private Uri imageUri; @@ -74,7 +75,12 @@ public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.main); + setContentView(R.layout.upload); + + Toolbar toolbar = (Toolbar) findViewById(R.id.upload_toolbar); + setSupportActionBar(toolbar); + + setTitle(R.string.upload_pict); //prepare data used for upload imageUri = null; @@ -120,7 +126,7 @@ public class MainActivity extends ActionBarActivity { progressDialog.dismiss(); resetImage(); //launch LinkActivity - Intent linkIntent = new Intent(MainActivity.this,LinkActivity.class); + Intent linkIntent = new Intent(UploadActivity.this,LinkActivity.class); linkIntent.putExtra("imageId", id); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); startActivity(linkIntent); @@ -134,7 +140,7 @@ public class MainActivity extends ActionBarActivity { @Override public void run() { //display toast error - Toast.makeText(MainActivity.this, error, Toast.LENGTH_SHORT).show(); + Toast.makeText(UploadActivity.this, error, Toast.LENGTH_SHORT).show(); if(progressDialog != null) { progressDialog.dismiss(); progressDialog = null; @@ -247,7 +253,7 @@ public class MainActivity extends ActionBarActivity { runOnUiThread(new Runnable() { @Override public void run() { - Toast.makeText(MainActivity.this, getString(R.string.server_list_error), Toast.LENGTH_LONG).show(); + Toast.makeText(UploadActivity.this, getString(R.string.server_list_error), Toast.LENGTH_LONG).show(); } }); return; @@ -293,7 +299,7 @@ public class MainActivity extends ActionBarActivity { runOnUiThread(new Runnable() { @Override public void run() { - progressDialog = new ProgressDialog(MainActivity.this); + progressDialog = new ProgressDialog(UploadActivity.this); progressDialog.setMessage(getString(R.string.upload_progress)); progressDialog.setCancelable(false); progressDialog.show(); @@ -346,7 +352,7 @@ public class MainActivity extends ActionBarActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.menu_main, menu); + getMenuInflater().inflate(R.menu.menu_upload, menu); return true; } @@ -357,9 +363,6 @@ public class MainActivity extends ActionBarActivity { if (id == R.id.action_manage_server) { newIntent = new Intent(this,ServersActivity.class); } - else if (id == R.id.action_show_history){ - newIntent = new Intent(this,HistoryActivity.class); - } if(newIntent != null) { startActivity(newIntent); @@ -368,4 +371,4 @@ public class MainActivity extends ActionBarActivity { return super.onOptionsItemSelected(item); } -} \ No newline at end of file +} diff --git a/app/src/main/res/layout-land/main.xml b/app/src/main/res/layout-land/main.xml deleted file mode 100644 index 303adcc..0000000 --- a/app/src/main/res/layout-land/main.xml +++ /dev/null @@ -1,84 +0,0 @@ - - -