Skip to content

Commit

Permalink
Add a page to manage urls
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 1, 2023
1 parent 1cde9fb commit e18dfa7
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 47 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ English DoliDroid ChangeLog

***** ChangeLog for 3.0 *****

3.0-b57
- Add a page to manage favorites connections

3.0-b56
- Fix null pointer error on "Copy current URL" feature.
- Reorganize menus to prepare future features
Expand Down
13 changes: 3 additions & 10 deletions app/src/main/java/com/nltechno/dolidroidpro/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@

package com.nltechno.dolidroidpro;

import java.io.FileOutputStream;
import java.util.List;

import com.nltechno.utils.Utils;

import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
Expand All @@ -46,12 +43,8 @@
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import androidx.security.crypto.EncryptedSharedPreferences;
import androidx.security.crypto.MasterKeys;

/**
* About activity class
*
Expand Down Expand Up @@ -99,7 +92,7 @@ public void onCreate(Bundle savedInstanceState) {
// resource. By default these links will appear but not
// respond to user input. To make them active, you need to
// call setMovementMethod() on the TextView object.
TextView t1 = findViewById(R.id.TextAbout01);
TextView t1 = findViewById(R.id.textAboutVersion);
t1.setMovementMethod(LinkMovementMethod.getInstance());

Log.d(LOG_TAG, "Open file " + MainActivity.FILENAME+ " in directory "+getApplicationContext().getFilesDir().toString());
Expand All @@ -120,7 +113,7 @@ public void onStart() {
Intent intent = getIntent();

// Show text section 1
TextView textViewAbout1 = findViewById(R.id.TextAbout01);
TextView textViewAbout1 = findViewById(R.id.textAboutVersion);
String s1="";

PackageManager manager = this.getPackageManager();
Expand Down Expand Up @@ -211,7 +204,7 @@ public void onStart() {
}

// Show text section 3
TextView textViewAbout3 = findViewById(R.id.TextAbout03);
TextView textViewAbout3 = findViewById(R.id.textAboutCurrentUrl);
String s3="";

// Current url
Expand Down
29 changes: 12 additions & 17 deletions app/src/main/java/com/nltechno/dolidroidpro/ManageURLActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,12 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Color;
import android.graphics.Point;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -44,7 +37,6 @@
import android.widget.Button;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import androidx.security.crypto.EncryptedSharedPreferences;
Expand All @@ -55,7 +47,6 @@
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;

/**
* About activity class
Expand All @@ -71,7 +62,6 @@ public class ManageURLActivity extends Activity {

ListView listView;


/**
* Called when activity is created
*/
Expand Down Expand Up @@ -111,10 +101,10 @@ public void onCreate(Bundle savedInstanceState) {
Log.d(LOG_TAG, "Open file " + MainActivity.FILENAME+ " in directory "+getApplicationContext().getFilesDir().toString());

// Fill the list of Urls
ListView listViewOfUrls = (ListView) findViewById(R.id.list_view);
ListView listViewOfUrls = (ListView) findViewById(R.id.listViewConnections);
ArrayAdapter<String> arr = new ArrayAdapter<String>(
this,
android.R.layout.simple_list_item_1,
android.R.layout.simple_list_item_activated_1,
MainActivity.listOfRootUrl);
listViewOfUrls.setAdapter(arr);

Expand Down Expand Up @@ -245,6 +235,7 @@ public void onStart() {
// For api level 24: textViewAbout1.setText(Html.fromHtml(s1, Html.FROM_HTML_MODE_LEGACY));

// Show text title
TextView textListOfCurrentUrl = findViewById(R.id.textListOfCurrentUrl);
TextView textViewAbout2 = findViewById(R.id.TextInstanceURLTitle);
String s2="";

Expand All @@ -257,9 +248,10 @@ public void onStart() {
//findViewById(R.id.imageView02).setVisibility(View.VISIBLE);
//findViewById(R.id.imageView02).setEnabled(true);

s2+="<font color='#440066'><b>"+getString(R.string.savedDolUrlRoot)+":</b></font><br /><br />\n";
s2+=savedDolRootUrl+"\n";
s2=savedDolRootUrl;

textListOfCurrentUrl.setVisibility(View.VISIBLE);
textListOfCurrentUrl.setEnabled(true);
textViewAbout2.setVisibility(View.VISIBLE);
textViewAbout2.setEnabled(true);
textViewAbout2.setText(Html.fromHtml(s2));
Expand All @@ -271,14 +263,17 @@ public void onStart() {
//findViewById(R.id.imageView02).setVisibility(View.INVISIBLE);
//findViewById(R.id.imageView02).setEnabled(false);

textListOfCurrentUrl.setVisibility(View.INVISIBLE);
textListOfCurrentUrl.setEnabled(false);

textViewAbout2.setVisibility(View.INVISIBLE);
textViewAbout2.setEnabled(false);
textViewAbout2.setText("");
}


// Show btn or not
// Check if url is inside predefined URL
// Check if url is inside favorite URL
boolean savedDolRootUrlFoundIntoPredefinedLoginUrl = false;
try
{
Expand Down Expand Up @@ -306,7 +301,7 @@ public void onStart() {
}


// Show text section of login an pass
// Show text section of login and pass
TextView textViewAbout2b = findViewById(R.id.TextSavedLogins);
String s2b="";

Expand Down Expand Up @@ -377,7 +372,7 @@ public void onStart() {
textViewListOfUrl.setVisibility(View.INVISIBLE);
Button btnClearAll = findViewById(R.id.buttonClearAllUrl);
btnClearAll.setVisibility(View.INVISIBLE);
ListView listView = findViewById(R.id.list_view);
ListView listView = findViewById(R.id.listViewConnections);
listView.setVisibility(View.INVISIBLE);
}

Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:textColor="@color/black">

<TextView
android:id="@+id/textAndroidClient"
android:id="@+id/textAboutAndroidClient"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
Expand All @@ -27,7 +27,7 @@
tools:ignore="TextContrastCheck" />

<TextView
android:id="@+id/TextAbout01"
android:id="@+id/textAboutVersion"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/imageView01"
Expand All @@ -42,7 +42,7 @@
tools:context=".AboutActivity" />

<TextView
android:id="@+id/TextAbout03"
android:id="@+id/textAboutCurrentUrl"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/imageView03"
Expand All @@ -60,7 +60,7 @@
android:id="@+id/imageView01"
android:layout_width="48dp"
android:layout_height="42dp"
android:layout_below="@+id/textAndroidClient"
android:layout_below="@+id/textAboutAndroidClient"
android:layout_alignParentStart="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
Expand All @@ -72,7 +72,7 @@
android:id="@+id/imageView03"
android:layout_width="48dp"
android:layout_height="45dp"
android:layout_below="@id/TextAbout01"
android:layout_below="@id/textAboutVersion"
android:layout_alignParentStart="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="55dp"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
android:textColor="@color/black" />

<TextView
android:id="@+id/textAndroidClient"
android:id="@+id/textAboutAndroidClient"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
Expand Down
29 changes: 23 additions & 6 deletions app/src/main/res/layout/activity_manageurl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
android:textColor="@color/black">

<TextView
android:id="@+id/textAndroidClient"
android:id="@+id/textAboutAndroidClient"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
Expand All @@ -34,7 +34,7 @@
android:id="@+id/TextInstanceURLTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/imageTop"
android:layout_below="@id/textListOfCurrentUrl"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="18dp"
Expand All @@ -61,6 +61,22 @@
android:textStyle="bold"
tools:context=".ManageURLActivity" />

<TextView
android:id="@+id/textListOfCurrentUrl"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/imageTop"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="18dp"
android:layout_marginTop="44dp"
android:layout_marginEnd="18dp"
android:maxLines="50"
android:text="@string/currentUrl"
android:textSize="16sp"
android:textStyle="bold"
tools:context=".ManageURLActivity" />

<TextView
android:id="@+id/TextSavedLogins"
android:layout_width="fill_parent"
Expand All @@ -84,7 +100,7 @@
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="14dp"
android:layout_marginTop="10dp"
android:layout_marginTop="14dp"
android:layout_marginEnd="14dp"
android:background="#009688"
android:paddingStart="8dp"
Expand All @@ -100,7 +116,7 @@
android:id="@+id/buttonClearAllUrl"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_below="@id/list_view"
android:layout_below="@id/listViewConnections"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="10dp"
Expand Down Expand Up @@ -131,12 +147,13 @@
tools:visibility="visible" />

<ListView
android:id="@+id/list_view"
android:id="@+id/listViewConnections"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="240dp"
android:layout_below="@id/textListOfUrlsTitle"
android:layout_marginStart="10dp"
android:layout_marginTop="16dp"
android:layout_marginTop="14dp"
android:layout_marginEnd="10dp" />

</RelativeLayout>
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<string name="open">Start</string>
<string name="dolibarr_url">Dolibarr URL</string>
<string name="logo_dolidroid">Logo DoliDroid</string>
<string name="SelectUrl">or select a predefined URL</string>
<string name="SelectUrl">or select a favorite connection</string>
<string name="enterNewUrl">or enter a new URL</string>
<string name="UrlCopied">URL copied into clipboard</string>

Expand Down Expand Up @@ -48,7 +48,7 @@
<string name="DeviceHasODXViewer">Device has OpenOffice viewers</string>
<string name="DeviceSize">Device screen size</string>
<string name="savedDolUrlRoot">Dolibarr instance Url</string>
<string name="currentUrl">Current Url</string>
<string name="currentUrl">Current connection</string>
<string name="UserAgent">User Agent</string>
<string name="SavedLogin">Saved login</string>
<string name="SavedPassword">Saved password</string>
Expand All @@ -59,9 +59,9 @@
<string name="Warning">Warning</string>

<!-- Activity Manage URL -->
<string name="DeletePredefinedUrl">Remove this predefined URL of this instance</string>
<string name="DeleteAllPredefinedUrl">Remove all predefined URLs</string>
<string name="ListOfUrls">List of Urls</string>
<string name="DeletePredefinedUrl">Remove this connection</string>
<string name="DeleteAllPredefinedUrl">Remove all favorites connections</string>
<string name="ListOfUrls">List of connections</string>

<!-- Menu main + web -->
<string name="menu_info">About DoliDroid</string>
Expand All @@ -80,9 +80,9 @@
<string name="menu_utilities">Utilities</string>
<string name="menu_settings">Settings</string>
<string name="menu_add_url">Add predefined URL</string>
<string name="menu_remove_url">Remove a predefined URL</string>
<string name="menu_clear_all_urls">Clear predefined URLs</string>
<string name="menu_manage_all_urls">Manage predefined URLs</string>
<string name="menu_remove_url">Remove a favorite connection</string>
<string name="menu_clear_all_urls">Clear favorites connections</string>
<string name="menu_manage_all_urls">Manage favorites connections</string>
<string name="dolicloud_register" ignore="MissingTranslation"><a href="https://myaccount.dolicloud.com/register.php?origin=dolidroid&amp;utm_source=dolidroid&amp;utm_campaign=none&amp;utm_medium=mobile">I don\'t have a Dolibarr ERP CRM instance yet, create one on DoliCloud.com...</a></string>

<!-- Menu web browser -->
Expand Down

0 comments on commit e18dfa7

Please sign in to comment.