mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Merge pull request #515 from nivl4/chore-add-build-properties
chore: add Habitica connection properties to gradle build
This commit is contained in:
commit
c41e6f02ed
10 changed files with 56 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -52,3 +52,4 @@ fabric.properties
|
|||
.DS_Store
|
||||
*.iml
|
||||
Habitica/res/values/secret_strings.xml
|
||||
habitica.properties
|
||||
|
|
@ -27,5 +27,6 @@ android:
|
|||
#- sys-img-armeabi-v7a-android-19
|
||||
#- sys-img-x86-android-17
|
||||
script:
|
||||
- cp habitica.properties.example habitica.properties
|
||||
- ./gradlew assembleDebug
|
||||
- ./gradlew testDebugUnitTest
|
||||
|
|
|
|||
|
|
@ -188,6 +188,25 @@ if (propFile.canRead()) {
|
|||
android.buildTypes.release.signingConfig = null
|
||||
}
|
||||
|
||||
// Add Habitica Properties to buildConfigField
|
||||
final File HRPG_PROPS_FILE = new File('habitica.properties')
|
||||
if (HRPG_PROPS_FILE.canRead()) {
|
||||
def Properties HRPG_PROPS = new Properties()
|
||||
HRPG_PROPS.load(new FileInputStream(HRPG_PROPS_FILE))
|
||||
|
||||
if (HRPG_PROPS != null) {
|
||||
android.buildTypes.all { buildType ->
|
||||
HRPG_PROPS.any { property ->
|
||||
buildType.buildConfigField "String", property.key, "\"${property.value}\""
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new InvalidUserDataException('habitica.properties found but some entries are missing')
|
||||
}
|
||||
} else {
|
||||
throw new MissingResourceException('habitica.properties not found')
|
||||
}
|
||||
|
||||
apply plugin: 'com.getkeepsafe.dexcount'
|
||||
apply plugin: 'com.android.application' //or apply plugin: 'java'
|
||||
apply plugin: 'me.tatarka.retrolambda'
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
<resources>
|
||||
<!-- Prefs -->
|
||||
<string name="SP_address" translatable="false">ServerAddress</string>
|
||||
<string name="SP_address_default" translatable="false">https://habitica.com/</string>
|
||||
<string name="SP_userID" translatable="false">UserID</string>
|
||||
<string name="SP_APIToken" translatable="false">APIToken</string>
|
||||
<string name="SP_username" translatable="false">Username</string>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import android.widget.EditText;
|
|||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.habitrpg.android.habitica.BuildConfig;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -66,7 +67,7 @@ public class CustomListPreference extends ListPreference {
|
|||
}
|
||||
if (value == null || !value.startsWith("http")) {
|
||||
Log.v("Commiting", "changing values to default");
|
||||
value = mContext.getString(R.string.SP_address_default);
|
||||
value = BuildConfig.BASE_URL;
|
||||
}
|
||||
|
||||
Log.d("Commiting", "putting string: " + value);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import com.facebook.FacebookException;
|
|||
import com.facebook.login.LoginResult;
|
||||
import com.facebook.login.widget.LoginButton;
|
||||
import com.habitrpg.android.habitica.APIHelper;
|
||||
import com.habitrpg.android.habitica.BuildConfig;
|
||||
import com.habitrpg.android.habitica.HostConfig;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.callbacks.HabitRPGUserCallback;
|
||||
|
|
@ -63,12 +64,6 @@ public class LoginActivity extends AppCompatActivity
|
|||
public Boolean isRegistering;
|
||||
private Menu menu;
|
||||
|
||||
@BindString(R.string.SP_address_default)
|
||||
String apiAddress;
|
||||
|
||||
//private String apiAddress;
|
||||
//private String apiAddress = "http://192.168.2.155:8080/"; // local testing
|
||||
|
||||
private CallbackManager callbackManager;
|
||||
|
||||
@Bind(R.id.login_btn)
|
||||
|
|
@ -141,7 +136,7 @@ public class LoginActivity extends AppCompatActivity
|
|||
|
||||
HostConfig hc= PrefsActivity.fromContext(this);
|
||||
if(hc ==null) {
|
||||
hc = new HostConfig(apiAddress, "80", "", "");
|
||||
hc = new HostConfig(BuildConfig.BASE_URL, BuildConfig.PORT, "", "");
|
||||
}
|
||||
mApiHelper = new APIHelper(hc);
|
||||
|
||||
|
|
@ -205,7 +200,7 @@ public class LoginActivity extends AppCompatActivity
|
|||
};
|
||||
|
||||
private View.OnClickListener mForgotPWClick = v -> {
|
||||
String url = getString(R.string.SP_address_default);
|
||||
String url = BuildConfig.BASE_URL;
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse(url));
|
||||
startActivity(i);
|
||||
|
|
@ -352,7 +347,7 @@ startActivity(i);
|
|||
SharedPreferences.Editor editor = prefs.edit();
|
||||
boolean ans = editor.putString(getString(R.string.SP_APIToken), api)
|
||||
.putString(getString(R.string.SP_userID), user)
|
||||
.putString(getString(R.string.SP_address),getString(R.string.SP_address_default))
|
||||
.putString(getString(R.string.SP_address),BuildConfig.BASE_URL)
|
||||
.commit();
|
||||
if(!ans) {
|
||||
throw new Exception("PB_string_commit");
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import android.support.v7.preference.PreferenceFragmentCompat;
|
|||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
||||
import com.habitrpg.android.habitica.BuildConfig;
|
||||
import com.habitrpg.android.habitica.HostConfig;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.ui.fragments.AccountDetailsFragment;
|
||||
|
|
@ -76,8 +77,8 @@ public class PrefsActivity extends BaseActivity implements
|
|||
public static HostConfig fromContext(Context ctx) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||
HostConfig config;
|
||||
String httpPort = "80";
|
||||
String address = prefs.getString(ctx.getString(R.string.SP_address), ctx.getString(R.string.SP_address_default));
|
||||
String httpPort = BuildConfig.PORT;
|
||||
String address = prefs.getString(ctx.getString(R.string.SP_address), BuildConfig.BASE_URL);
|
||||
String api = prefs.getString(ctx.getString(R.string.SP_APIToken), null);
|
||||
String userID = prefs.getString(ctx.getString(R.string.SP_userID), null);
|
||||
config = new HostConfig(address, httpPort, api, userID);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.habitrpg.android.habitica.BuildConfig;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
|
||||
import butterknife.Bind;
|
||||
|
|
@ -26,7 +27,7 @@ public class NewsFragment extends BaseMainFragment {
|
|||
|
||||
ButterKnife.bind(this, view);
|
||||
|
||||
newsWebview.loadUrl("https://habitica.com/static/new-stuff");
|
||||
newsWebview.loadUrl(BuildConfig.BASE_URL + "/static/new-stuff");
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
|
|||
10
README.md
10
README.md
|
|
@ -39,3 +39,13 @@ Thank you very much [to all contributors](https://github.com/HabitRPG/habitrpg-a
|
|||
5. Create new Pull Request
|
||||
* Don't forget to include your Habitica User ID, so that we can count your contributrion towards your contributor tier
|
||||
|
||||
## Build Instructions
|
||||
|
||||
### Config File
|
||||
|
||||
Setup Habitica build config file by simply copying the example habitica properties file.
|
||||
|
||||
$ cp habitica.properties.example habitica.properties
|
||||
|
||||
Note: this is the default production `habitica.properties` file for habitica.com. If you
|
||||
want to use a local habitica server, please modify the values in the properties file accordingly.
|
||||
14
habitica.properties.example
Normal file
14
habitica.properties.example
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Habitica Server Port
|
||||
# local instance
|
||||
# PORT=3000
|
||||
PORT=80
|
||||
|
||||
# Genymotion
|
||||
# BASE_URL=http://10.0.3.2:3000
|
||||
|
||||
# Android Emulator
|
||||
# see: http://developer.android.com/tools/help/emulator.html#networkaddresses
|
||||
# BASE_URL=http://10.0.2.2:3000
|
||||
|
||||
# Production
|
||||
BASE_URL=https://habitica.com
|
||||
Loading…
Reference in a new issue