add debug menu to copy git info to clipboard

Makes it easier to find out what the diffs were.
This commit is contained in:
Eric House 2017-09-24 14:32:58 -07:00
parent 096aa3bd0f
commit fd7f564e11
5 changed files with 48 additions and 3 deletions

View file

@ -3,6 +3,7 @@ def VERSION_CODE_BASE = 125
def VERSION_NAME = '4.4.129' def VERSION_NAME = '4.4.129'
def FABRIC_API_KEY = System.getenv("FABRIC_API_KEY") def FABRIC_API_KEY = System.getenv("FABRIC_API_KEY")
def GCM_SENDER_ID = System.getenv("GCM_SENDER_ID") def GCM_SENDER_ID = System.getenv("GCM_SENDER_ID")
def BUILD_INFO_NAME = "build-info.txt"
boolean forFDroid = hasProperty('forFDroid') boolean forFDroid = hasProperty('forFDroid')
@ -57,6 +58,10 @@ android {
flavorDimensions "variant"//, "abi" flavorDimensions "variant"//, "abi"
productFlavors { productFlavors {
all {
buildConfigField "String", "BUILD_INFO_NAME", "\"${BUILD_INFO_NAME}\""
}
xw4 { xw4 {
dimension "variant" dimension "variant"
applicationId "org.eehouse.android.xw4" applicationId "org.eehouse.android.xw4"
@ -254,15 +259,14 @@ afterEvaluate {
task makeBuildAssets() { task makeBuildAssets() {
def assetsDir = android.sourceSets.main.assets.srcDirs.toArray()[0] def assetsDir = android.sourceSets.main.assets.srcDirs.toArray()[0]
String path = new File(assetsDir, 'build-info.txt').getAbsolutePath() String path = new File(assetsDir, BUILD_INFO_NAME).getAbsolutePath()
File file = new File(path);
String out = "git: ${GITREV}\n" String out = "git: ${GITREV}\n"
String diff = "git diff".execute().text.trim() String diff = "git diff".execute().text.trim()
if (diff) { if (diff) {
out += "\n" + diff out += "\n" + diff
} }
file.write(out) new File(path).write(out)
} }
gradle.projectsEvaluated { gradle.projectsEvaluated {

View file

@ -564,6 +564,7 @@ public class GamesListDelegate extends ListDelegateBase
private static final int[] DEBUG_ITEMS = { private static final int[] DEBUG_ITEMS = {
// R.id.games_menu_loaddb, // R.id.games_menu_loaddb,
R.id.games_menu_storedb, R.id.games_menu_storedb,
R.id.games_menu_writegit,
}; };
private static final int[] NOSEL_ITEMS = { private static final int[] NOSEL_ITEMS = {
R.id.games_menu_newgroup, R.id.games_menu_newgroup,
@ -1597,6 +1598,10 @@ public class GamesListDelegate extends ListDelegateBase
Action.STORAGE_CONFIRMED, itemID ); Action.STORAGE_CONFIRMED, itemID );
break; break;
case R.id.games_menu_writegit:
Utils.gitInfoToClip( m_activity );
break;
default: default:
handled = handleSelGamesItem( itemID, selRowIDs ) handled = handleSelGamesItem( itemID, selRowIDs )
|| handleSelGroupsItem( itemID, getSelGroupIDs() ); || handleSelGroupsItem( itemID, getSelGroupIDs() );

View file

@ -32,7 +32,9 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.res.AssetManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.text.ClipboardManager;
import android.database.Cursor; import android.database.Cursor;
import android.media.Ringtone; import android.media.Ringtone;
@ -55,9 +57,12 @@ import android.widget.Toast;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.Serializable; import java.io.Serializable;
@ -187,6 +192,33 @@ public class Utils {
context.startActivity( Intent.createChooser( intent, chooserMsg ) ); context.startActivity( Intent.createChooser( intent, chooserMsg ) );
} }
static void gitInfoToClip( Context context )
{
StringBuilder sb;
try {
InputStream is = context.getAssets().open( BuildConfig.BUILD_INFO_NAME,
AssetManager.ACCESS_BUFFER );
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
sb = new StringBuilder();
for ( ; ; ) {
String line = reader.readLine();
if ( null == line ) {
break;
}
sb.append( line ).append( "\n" );
}
reader.close();
} catch ( Exception ex ) {
sb = null;
}
if ( null != sb ) {
ClipboardManager clipboard = (ClipboardManager)
context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText( sb.toString() );
}
}
public static void postNotification( Context context, Intent intent, public static void postNotification( Context context, Intent intent,
int titleID, int bodyID, int id ) int titleID, int bodyID, int id )
{ {

View file

@ -120,5 +120,8 @@
<item android:id="@+id/games_menu_loaddb" <item android:id="@+id/games_menu_loaddb"
android:title="@string/gamel_menu_loaddb" android:title="@string/gamel_menu_loaddb"
/> />
<item android:id="@+id/games_menu_writegit"
android:title="@string/gamel_menu_writegit"
/>
</menu> </menu>

View file

@ -2491,6 +2491,7 @@
<string name="name_dict_fmt">%1$s/%2$s</string> <string name="name_dict_fmt">%1$s/%2$s</string>
<string name="gamel_menu_storedb">Write games to SD card</string> <string name="gamel_menu_storedb">Write games to SD card</string>
<string name="gamel_menu_loaddb">Load games from SD card</string> <string name="gamel_menu_loaddb">Load games from SD card</string>
<string name="gamel_menu_writegit">Copy git info to clipboard</string>
<string name="enable_dupes_title">Accept duplicate invites</string> <string name="enable_dupes_title">Accept duplicate invites</string>
<string name="xlations_locale">Fake locale for translation</string> <string name="xlations_locale">Fake locale for translation</string>
<string name="enable_dupes_summary">Accept invitations more than once</string> <string name="enable_dupes_summary">Accept invitations more than once</string>