add sugestions of mmarif

* delete OpenWebRepoActivity (function is handled in RepoDetailActivity )
 * add&handle case "openWebRepo" in RepoDetailActivity
 * add new Value "instanceUrlWithProtocol" to tinyDb
This commit is contained in:
6543 2019-09-10 19:48:44 +02:00
parent 83e3564c13
commit 20f687e30e
3 changed files with 16 additions and 29 deletions

View File

@ -194,16 +194,20 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
instanceHost = instanceUrl;
}
String instanceUrlWithProtocol;
if(protocol.toLowerCase().equals("https")) {
instanceUrl = "https://" + instanceHost + "/api/v1/";
instanceUrlWithProtocol = "https://" + instanceHost;
}
else {
instanceUrl = "http://" + instanceHost + "/api/v1/";
instanceUrlWithProtocol = "https://" + instanceHost;
}
tinyDb.putString("instanceUrlRaw", instanceHost);
tinyDb.putString("loginUid", loginUid);
tinyDb.putString("instanceUrl", instanceUrl);
tinyDb.putString("instanceUrlWithProtocol", instanceUrlWithProtocol);
if(connToInternet) {

View File

@ -1,29 +0,0 @@
package org.mian.gitnex.activities;
import androidx.appcompat.app.AppCompatActivity;
/**
* Author 6543
*/
import android.view.View;
import org.mian.gitnex.util.TinyDB;
import android.content.Intent;
import android.net.Uri;
public class OpenWebRepoActivity extends AppCompatActivity implements View.OnClickListener {
@Override
public void onClick(View v) {
TinyDB tinyDb = new TinyDB(getApplicationContext());
String repoFullName = tinyDb.getString("repoFullName");
String instanceUrl = tinyDb.getString("instanceUrl");
String url = instanceUrl + "/" + repoFullName;
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
}

View File

@ -35,6 +35,7 @@ import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.util.AppUtil;
import org.mian.gitnex.util.TinyDB;
import java.util.Objects;
import android.net.Uri;
/**
* Author M M Arif
@ -153,6 +154,17 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
case "createRelease":
startActivity(new Intent(RepoDetailActivity.this, CreateReleaseActivity.class));
break;
case "openWebRepo":
TinyDB tinyDb = new TinyDB(getApplicationContext());
String repoFullName = tinyDb.getString("repoFullName");
String instanceUrlWithProtocol = "https://" + tinyDb.getString("instanceUrlRaw");
if(!tinyDb.getString("instanceUrlWithProtocol").isEmpty()) {
instanceUrlWithProtocol = tinyDb.getString("instanceUrlWithProtocol");
}
Uri url = Uri.parse(instanceUrlWithProtocol + "/" + repoFullName);
Intent i = new Intent(Intent.ACTION_VIEW, url);
startActivity(i);
break;
}
}